YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

The simplest possible program with your help Options · View
laniermami
#1 Posted : Thursday, March 04, 2010 7:16:48 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2010
Posts: 4
Location: USA
I am new to PI-SDK programming and am trying to do the simplest possible program with your help. I am missing something. Please help.

Option Explicit On
Public Class Form1

Dim srv As PISDK.Server
Dim piconst As PISDK.PIConstant
Private Sub Command1_Click()

Dim dt As Date, dt2 As Date
dt = CDate(Text2.Text)

Dim pt As PISDK.PIPoint
pt = srv.PIPoints(Text1.Text)

Dim pv As PISDK.PIValue
pv = pt.Data.Snapshot
Text4.Text = CStr(pv.Value)
Text5.Text = CStr(pv.TimeStamp.LocalDate)
' Get the recorded values
Dim pvs As PISDK.PIValues
pvs = pt.Data.RecordedValues(dt, dt2) ' , btType)
For Each pv In pvs
List2.Items.Add(CStr(pv.TimeStamp.LocalDate) + vbTab + CStr(pv.Value))
Next
Label11.Text = CStr(pvs.Count)

End Sub

End Class
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Michael
#2 Posted : Thursday, March 04, 2010 8:30:29 PM
Rank: Advanced Member
Groups: Member

Joined: 12/3/2009
Posts: 71
Location: Germany/Pennsylvania
ok, but where is your problem? Aside from the line

pvs = pt.Data.RecordedValues(dt, dt2) ' , btType)

There should no apostroph and dt2 is not set.

Michael
RJK Solutions
#3 Posted : Thursday, March 04, 2010 8:53:51 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Michael I was thinking the same thing but he never initialises the PISDK.Server variable "srv" nor is there a creation of the PISDK class. So I bet it errors on the "pt = srv.PIPoints...." line.

So the code should be:

Code:

Option Explicit On
Public Class Form1

Dim sdk as PISDK.PISDK = Nothing
Dim srv As PISDK.Server = Nothing
Dim piconst As PISDK.PIConstant

Private Sub Command1_Click()

If sdk Is Nothing Then SDK = New PISDK.PISDK
If srv Is Nothing Then srv = sdk.Servers("localhost")
If Not srv.Connected Then srv.Open

Dim dt As Date, dt2 As Date
dt = CDate(Text2.Text)

Dim pt As PISDK.PIPoint
pt = srv.PIPoints(Text1.Text)

Dim pv As PISDK.PIValue
pv = pt.Data.Snapshot
Text4.Text = CStr(pv.Value)
Text5.Text = CStr(pv.TimeStamp.LocalDate)
' Get the recorded values
Dim pvs As PISDK.PIValues
pvs = pt.Data.RecordedValues(dt, dt2) ' , btType)
For Each pv In pvs
List2.Items.Add(CStr(pv.TimeStamp.LocalDate) + vbTab + CStr(pv.Value))
Next
Label11.Text = CStr(pvs.Count)

End Sub

End Class
Principal Consultant
Real-Time Data Management @ Wipro Technologies
laniermami
#4 Posted : Thursday, March 04, 2010 9:01:50 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2010
Posts: 4
Location: USA
Thank you for your quick response. I need to "chew and digest" before I move on. I'm impressed with your courteous help.
RJK Solutions
#5 Posted : Thursday, March 04, 2010 9:02:47 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Your welcome, we are here to help BigGrin
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Michael
#6 Posted : Thursday, March 04, 2010 9:36:12 PM
Rank: Advanced Member
Groups: Member

Joined: 12/3/2009
Posts: 71
Location: Germany/Pennsylvania
oops... and in addition the apostoph is correct. Shhh

Rhys:
What happend if the endtime is not set? It is replaced with "*" ? Currently I do not have a PI running to test it.

Michael
laniermami2
#7 Posted : Friday, March 05, 2010 2:21:56 PM
Rank: Newbie
Groups: Member

Joined: 3/5/2010
Posts: 1
Location: USA
Hi there again.

This program has compiled, but when I run it, I have not gotten any data. Just waiting until I close again. The reasons mioght be First, I am typing the Time in as 00:00:00 to 00:00:10. Would this make sense? Secondly, the PI server is remote. I feel there should be a place for login. I am not familiar with the way VB speaks to PI. As techs, I know I should be asking direct and precise questions. I am vague due to my lack of familiarity with PI.
Michael
#8 Posted : Friday, March 05, 2010 2:49:08 PM
Rank: Advanced Member
Groups: Member

Joined: 12/3/2009
Posts: 71
Location: Germany/Pennsylvania
You have to enter the complete date if you are passing a date variable. But PI is supporting a lot of settings (PI string formats etc). Check the PISDK help files whats available.

There are different methods to login. Which one is the best depends on your environment. Replace "localhost" with your servername, maybe you have to enter user and password to login (if there is no trust or the default user has a pwd). Check your connection settings , you can access them executing the AboutPI-SDK.exe.

Michael
laniermami
#9 Posted : Friday, March 12, 2010 2:40:50 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2010
Posts: 4
Location: USA
Good Morning Gentlemen:

Here's hoping for a great Friday success!

I was able to send my code to someone who ran it on a local server, and it ran fine. So, as Michael said in the beginning, maybe the code is not the problem. I, however, need to run the code to gather data from a remote system. I am getting the following error. Any help or idea would be great!

Also, I did connect via AboutPI-SDK.exe as per Michael as well.

COMException was unhandled
Failed to retrieve events from server. [-10722] PINET: Timeout on PI RPC or System Call

The line where this happens is:
pvs = pt.Data.RecordedValues(dt, dt2)

Thanks again.
laniermami
#10 Posted : Friday, March 12, 2010 9:03:38 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2010
Posts: 4
Location: USA
I've got it. The web searches have paid off!

In case you are interested..... here's what I had to do..... (for a remote PI Server)

I ran AboutPISDK.exe, Clicked on File, Connection, chose the Server I wanted (-Mike's post, thanks)

Then, in Command Prompt, in folder pipc\adm
pigetmsg -f -remote (-this info came from techsupport.osisoft......Trusts for Interfaces)

It asks for......
1) Node Name
2) Port #
3) User Name
4) Password

Then I can go back into my VB code and run it.

Problem solved.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.