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

Max/Min for just the current day Options · View
TopeU
#1 Posted : Wednesday, June 15, 2011 7:28:13 PM
Rank: Newbie
Groups: Member

Joined: 6/15/2011
Posts: 5
I need to get the maximum and minimum of a tag for just the current day. It needs to be from 12:01 to the current time and not for the past 24 hours. Is there a way to do this; preferrably w/o using a macro?

Thanks.
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.
OlJo69
#2 Posted : Thursday, June 16, 2011 10:12:25 AM
Rank: Newbie
Groups: Member

Joined: 3/4/2011
Posts: 6
Location: France
Get the Max/Min of a tag over le last day (24h) is easy with the PI Calculation of the value object but as far as I know there is no way to get what you what without a VBA macro...

Here is an example of a macro retrieving Max/Min of the SINUSOID tag :
Code:
Private Sub Value_DataUpdate()
Dim myPoint As PIPoint
Dim myServer As Server
Dim myPIValues As PIValues
Dim myPIValue As PIValue

If Application.RunMode Then
    Set myServer = PISDK.Servers.DefaultServer
    Set myPoint = myServer.PIPoints("SINUSOID")
    Set myPIValues = myPoint.Data.RecordedValues("t", "*", btAuto, "", fvRemoveFiltered)
    Set myPIValue = myPIValues.Summary("t", "*", astMaximum, cbEventWeightedIncludeBothEnds)
    MaxText.Contents = CStr(myPIValue.Value)
    Set myPIValue = myPIValues.Summary("t", "*", astMinimum, cbEventWeightedIncludeBothEnds)
    MinText.Contents = CStr(myPIValue.Value)
Else
End If

End Sub

This is asumming you have on your display a Value object named "Value", two Text objects named "MaxText" and "MinText" and PISDK referenced in your VBA project.

Also, did you considered using PEs (Performance Equations) ? I know it's not the best solution as each PE consume a point licence ... but well, will work for sure!

Hope this helps Smile
O.
TopeU
#3 Posted : Monday, June 20, 2011 8:58:35 PM
Rank: Newbie
Groups: Member

Joined: 6/15/2011
Posts: 5
Thanks OlJo69. I really was trying to avoid macros but it looks like I'm unable to. I wanna try two things:

1st. I tried getting the min/max of a tag value over the past 24h but te value is inaccurate. I'm not sure what all the flelds in the Pi calculation form stand for so I would appreciate someone telling me how I would do that.

2nd. I tried using our code in the macro and including the PI SDK as a reference but couldnt get past the first "Dim" statement.

RJK Solutions
#4 Posted : Monday, June 20, 2011 9:21:55 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hello,

Where are you doing this, in ProcessBook/Datalink?
You could for example have a Dataset in ProcessBook with the expression:

TagMax('sinusoid','t','*')

This would give you the maximum for the tag 'sinusoid' starting from midnight of the current day (t = today @ 00:00) to the current time (* = current time).

You could change it to a sliding 24 hour average using:

TagMax('sinusoid','*-24h','*')

Is this what you were after?
Principal Consultant
Real-Time Data Management @ Wipro Technologies
RJK Solutions
#5 Posted : Monday, June 20, 2011 9:21:56 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hello,

Where are you doing this, in ProcessBook/Datalink?
You could for example have a Dataset in ProcessBook with the expression:

TagMax('sinusoid','t','*')

This would give you the maximum for the tag 'sinusoid' starting from midnight of the current day (t = today @ 00:00) to the current time (* = current time).

You could change it to a sliding 24 hour average using:

TagMax('sinusoid','*-24h','*')

Is this what you were after?
Principal Consultant
Real-Time Data Management @ Wipro Technologies
TopeU
#6 Posted : Monday, June 20, 2011 9:44:07 PM
Rank: Newbie
Groups: Member

Joined: 6/15/2011
Posts: 5
I'm using ProcessBook.
This looks like it works. Sweet! Thanks. One problem I'm still having is the Time stamp. I would like the time stamp to show the time of the Max and Min values.

squatty
#7 Posted : Wednesday, June 22, 2011 3:00:08 PM
Rank: Advanced Member

Groups: Member

Joined: 4/7/2011
Posts: 137
Location: KZN, South Africa
FindEq('tag','t','*',TagMax('tag','t','*'))

This should do the trick, let me know if it works
TopeU
#8 Posted : Wednesday, June 22, 2011 5:50:21 PM
Rank: Newbie
Groups: Member

Joined: 6/15/2011
Posts: 5
squatty wrote:
FindEq('tag','t','*',TagMax('tag','t','*'))

This should do the trick, let me know if it works


That also worked! Thanks to all of you!
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.