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

[PI SDK] PI Equation: TagAvg without questionable values Options · View
nfcae
#1 Posted : Wednesday, August 25, 2010 6:20:41 PM
Rank: Member
Groups: Member

Joined: 8/23/2010
Posts: 12
Location: Portugal, Lisbon
Sorry to bother again with another question but is there a way to make a PI Equation (TagAvg) excluding the questionable values?

Check if its questionable: Not(IsSet('sinusoid', "q"))
Calculate Average: TagAvg('sinusoid', '24-AUG-2010 00:00:00', '24-AUG-2010 01:00:00')

C# Code:

Code:
IPICalculation ipiCalc = (IPICalculation)g_srvPIServer;
string filterExp = ?;
ipiCalc.Calculate(startTime, endTime, filterExp, SampleTypeConstants.stInterval, "10m", null);


where ? is the expression to calculate the TagAvg without the questionable variables.

This is a very old problem of ours, not even sure if its possible to do it.(might not even be IPICalculation)

Again, thanks for your time Smile
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.
RJK Solutions
#2 Posted : Wednesday, August 25, 2010 7:52:46 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Sure, try "FilteredSummaries" of the PISDK.IPIData2 interface.
Here is a quick example:

Code:

Dim _Point As PISDK.PIPoint = _PISDK.Servers.DefaultServer.PIPoints("sinusoid")
        Dim _Data2 As PISDK.IPIData2 = _Point.Data
        Dim _nvsFilSum As PISDKCommon.NamedValues = _Data2.FilteredSummaries("y", "t", "1d", "Not(IsSet('sinusoid', ""q""))", PISDK.ArchiveSummariesTypeConstants.asAverage)
        Dim _FilSumValues As PISDK.PIValues = _nvsFilSum("Average").Value
        For i As Integer = 1 To _FilSumValues.Count
            MsgBox(_FilSumValues(i).Value)
        Next


Combine this with some asynchronous calls and away you go.

Enjoy!
Principal Consultant
Real-Time Data Management @ Wipro Technologies
nfcae
#3 Posted : Thursday, August 26, 2010 12:07:09 PM
Rank: Member
Groups: Member

Joined: 8/23/2010
Posts: 12
Location: Portugal, Lisbon
Sorry for the delay took me some time to get this converted to C# seems i can't use indexes [] directly to NamedValues. Seems to be giving the expected results at first glance!

Just out of curiosity, any idea why they made this function different? It returns NamedValues instead of PIValues.. i guess they are trying to make future functions that give many results in one call?

Again thanks!
Phil

RJK Solutions
#4 Posted : Thursday, August 26, 2010 1:51:27 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
The reason NamedValues is used is because you can set the ArchiveSummariesTypeConstants enumeration to "asAll" i.e. return for the PI Point all of the summary types. To access the particular summar type, you fetch it from the NamedValues collection.

I plan on upgrading the forum slightly so I can include VB.Net and C# code inline of the posts with a tab for each language. Smile

I did do some testing of FilteredSummaries setting some of the sinusoid values to questionable and they were ignored in the averaging so from what you said this should do what you need.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
nfcae
#5 Posted : Thursday, August 26, 2010 4:28:37 PM
Rank: Member
Groups: Member

Joined: 8/23/2010
Posts: 12
Location: Portugal, Lisbon
Quote:
I plan on upgrading the forum slightly so I can include VB.Net and C# code inline of the posts with a tab for each language. Smile


That's actually good, most examples provided by OSISoft are made in VB.NET which isn't our main language here.. sometimes we face some language specific problems and take awhile to fix. hehe
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.