AnsweredAssumed Answered

Get TOTAL minutes a Tag was at value X

Question asked by DanielPesch on Oct 10, 2019
Latest reply on Oct 10, 2019 by TimCarmichael

I have a tag that is a 0 or a 1. I'm using Process book and code behind with VB (as required by the boss).


I need to write code that returns the TOTAL number of minutes a Tag-X was a value of 1.


Given a Start date-time and a End date-time. I'd like to know how many minutes the value was a 1 for the date time range. 


Dim srv As PISDK.server
Dim ipiCalc As IPICalculation
Dim vals As PIValues
Set srv = PISDK.Servers.DefaultServer
Set ipiCalc = PISDK.Servers.DefaultServer

Dim exp As String
exp = "'PumpRunning'=1"

'SummaryDuration , << shown below ..not sure what to use here. Also not sure if format below is correct..

Set vals = ipiCalc.ExpressionSummaries("t", "*", SummaryDuration, exp, PISDK.ArchiveSummariesTypeConstants.asTotal, CalculationBasisConstants.cbTimeWeighted, SampleTypeConstants.stRecordedValues, SampleInerval = "1m", Null)



Any help here would be appreciated.