|
|
Rank: Member Groups: Member
Joined: 4/8/2011 Posts: 16 Location: Denmark
|
Hi all
Is it possible to multipli/substract the last 5 values and use this in a formula?
If it is - how do you do it?
|
|
|
|
|
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: Advanced Member
 Groups: Member
Joined: 4/7/2011 Posts: 137 Location: KZN, South Africa
|
hi mogwai
It all depends in what environment you want to do this. In Excel you can do Compressed Data 5 data points backwards in time and do some simple excel stuff. In VBA you can use the x.data.recordedvaluesbycount(StartTime,count,dreverse,btinside) and write the values into an array and do what ever you want from here
|
|
|
Rank: Member Groups: Member
Joined: 4/8/2011 Posts: 16 Location: Denmark
|
Hi  It is Process book I want to do this - I would prefer to use the process book formula  I would like to use last value, the 5th last value, the 10th last value and so on. By the way do you know where you can find the VBA code you wrote? Are there a manual for this?
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 4/7/2011 Posts: 137 Location: KZN, South Africa
|
OK so you want to do this using a dataset is that correct, good luck. I would recommend using the vba
You can get the sdk help files by going to your start menu->programs->pi system->about pi-sdk When the sdk opens just go to the help section and select pi-sdk help
|
|
|
Rank: Member Groups: Member
Joined: 4/8/2011 Posts: 16 Location: Denmark
|
If it is not possible the way that I want can you then be more specific (with a example) how to make the VBA solution `? I am a bit confused if its the VBA in processbook or Excel - maybe it is the same in both cases 
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 4/7/2011 Posts: 137 Location: KZN, South Africa
|
Private Sub test()
'***********DECLARE VARIABLES*********** Dim srv As PISDK.Server Dim pt1 As PIPoint Dim pv1 As PIValue Dim pvs As PIValues '***********SET MISSERVER TO DEFAULT*********** Set srv = PISDK.Servers.DefaultServer '***********GET DATA*********** Set pt1 = srv.PIPoints("sinusoid") Set pv1 = pt1.Data.Snapshot Set pvs = pt1.Data.RecordedValuesByCount(Now(), 10, dReverse, btInside) For Each pv1 In pvs Debug.Print pv1.Value Next
End Sub
Just make sure that you have the all the correct references in VBA,PI-SDK 1.3,PI-SDK Dialogs,PI-SDK Common and PITimeServer. Although you will not be using all of them in this example, I always add them anyway.
|
|
|
|
Guest
|