Hello,
I am trying to formulate a running formulation batch end calculator, which must do all its work in VBA before putting it as a text value in PI. I can do this really easily in Excel and i can get snippets via PI Calcs PE, but now I need to do it all in VBA in PI.
To start, I need to know the start time of the formulation, for this i need to look at the formulation volume when it equals 0. In PI datalink, thats easy, but how to do it in VBA in PI?
Then once i have this time stamp, i then need to get the time stamps of each of the batches as they are passed to the batch volume tag.
Lastly, I then must search between the times of these batch volumes for lab results and add them all up.
I thought I could use PISDK and something like this to start off with to get the formulation volume start time but it just gives me a single large number that keeps on increasing :-(
In PE I can juse use this:
FindEQ('blnd1vol.pv','*','*-2d',1)
But i find i cant use PE in VBA, GRRRRRRRR
So, PISDK I tried this:
Sub Test()
Dim srv As Server
Dim ipiCalc As IPICalculation
Dim vals1 As PIValues
Dim expr1 As String, StartTime As String, endTime As String
Dim testTimes As Variant, cnt As Long, I As Long
Dim bCheck As Boolean, bValCheck As Boolean
StartTime = "*"
endTime = "*-2d"
expr1 = "'Blnd1vol.pv'<1"
Dim data As pisdk.IPICalculation
Set data = pisdk.Servers.DefaultServer
Set ipiCalc = data
Set vals1 = ipiCalc.Calculate(StartTime, endTime, expr1, stRecordedValues, "")
Debug.Print vals1(1).Value
End Sub
But as you can guess, it doesnt work.
Anyone provide any help or a better way of doing this?
An example of data that I get out of excel
Sample Name Sample Date Volume Density
30/11/2014 02:29 0
Blender A 30/11/2014 04:30 1250 0.7426
Batch 1 2132
Blender A 30/11/2014 07:00 3189 0.7604
Batch 2 4296
Sub Batch 1 2132 0.7426
Sub Batch 2 2164 0.7604
Quality 4296 0.7515
Thanks