|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
So once again following on from the reusable function "ConnectToPI": http://www.rjksolutionsl...nect-to-PI-routine.aspx
We will take a look at retrieving the last 10 PIValues for the PI Point "SINUSOID" and looking at the quality, timestamp and value of each PIValue retrieved.
What we need to do is the following: - Create a PI Point variable and assign the point "SINUSOID" - Create variables for the retrieved PIValues and for a single PIValue - Make a call to the PI SDK "PIPoint.Data.RecordedValuesByCount" method - Cycle through each value and output the timestamp/value
As we will be retrieving the timestamp associated with values, we will need to add a reference to the PI TimeServer Type Library.
Your code may look something like the following:
Quote: Sub ReadSinusoid_Last10Values()
If ConnectToPI Then Dim PITag As PISDK.PIPoint Set PITag = PIServer.PIPoints("SINUSOID") ' Create variables for the collection of PIValues to be enumerated Dim PITagVal As PISDK.PIValue Dim PITagVals As PISDK.PIValues ' Retrieve the last 10 values starting from the current time backwards Set PITagVals = PITag.Data.RecordedValuesByCount("*", 10, dReverse) For Each PITagVal In PITagVals ' If the value is good then display it, notify if value is Bad If PITagVal.IsGood Then Debug.Print PITagVal.TimeStamp.LocalDate & " " & PITagVal.Value Else Debug.Print "Bad value found at " & PITagVal.TimeStamp.LocalDate End If Next PITagVal Set PITagVals = Nothing Set PITagVal = Nothing Set PITag = Nothing Else ' Handle bad connection... End If
End Sub
Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
|
|
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.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Following on from our C# conversions, here is the method for retrieving the last 10 values from Sinusoid.
Code: private void ReadSinusoid_Last10Values() { if (ConnectToPI()) { PISDK.PIPoint PITag = PIServer.PIPoints["SINUSOID"];
PISDK.PIValues PITagVals = PITag.Data.RecordedValuesByCount("*", 10, PISDK.DirectionConstants.dReverse, PISDK.BoundaryTypeConstants.btAuto, null, PISDK.FilteredViewConstants.fvShowFilteredState, null); foreach (PISDK.PIValue PITagVal in PITagVals) { if (PITagVal.IsGood()) { // GOOD VALUE } else { // BAD VALUE } } } else {
} } Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 11/11/2008 Posts: 4
|
I need help with writing code in VB.Net to display values of a point starting from when another value equals zero until that value equals zero again. In other words, I am trying to view "batch data" without setting up PIBatch. We have a cycle time counter so when the counter goes to zero, that is the end of the batch. I'd then like to view data such as max, min, etc for various points. If anyone can help, I'd be extremely thankful.
|
|
|
|
Guest
|