Is it possible to request the average of a PI signal that contains On/Off or 0/1 values? I tried the traditional method but PI returns an error because the place contains a string instead of a numeric value.
Is it possible to request the average of a PI signal that contains On/Off or 0/1 values? I tried the traditional method but PI returns an error because the place contains a string instead of a numeric value.
Yes, but it will take a set of steps in an analysis.
This gets the EVENT weighted average:
GetValues RecordedValues('Tag',<start time>,<end time>' // Get the archived values
Length ArrayLength(GetValues) // Get the count of archived values
FindOn FilterData(GetValues,$val = "ON") // Get only the 'ON' values
OnCount ArrayLength(FindOn) // Get the count of values
Percent OnCount/Length*100
To get the TIME weighted average:
TimeON TimeEQ('Tag',<start>,<end>,"ON")
TimeNotOn TimeNE('Tag',<start>,<end>,"ON")
PercentOn TimeON/ Total(TimeOn,TimeNotOn) * 100
These assume there is no bad data.
Yes, but it will take a set of steps in an analysis.
This gets the EVENT weighted average:
GetValues RecordedValues('Tag',<start time>,<end time>' // Get the archived values
Length ArrayLength(GetValues) // Get the count of archived values
FindOn FilterData(GetValues,$val = "ON") // Get only the 'ON' values
OnCount ArrayLength(FindOn) // Get the count of values
Percent OnCount/Length*100
To get the TIME weighted average:
TimeON TimeEQ('Tag',<start>,<end>,"ON")
TimeNotOn TimeNE('Tag',<start>,<end>,"ON")
PercentOn TimeON/ Total(TimeOn,TimeNotOn) * 100
These assume there is no bad data.