I was able to use PLEG to create a “Number of Starts” counter for a binary device. I am also able to reset the counter to zero using a virtual switch and nested Condition Expressions. The status report is attached as code. The Action for Condition cResetCounter toggles the Counter-Reset switch to off after 5 seconds so that counting resumes. Are others using nested Condition Expressions within PLEG? If so, how many levels of nesting does PLEG support?
[code]PLEG-Test
Device ID: 4212013-11-14 21:23:13.081 PLC Version: 5.3
Device Properties
Name Device Name Device Variable Last Change Value
p1 AnyBinaryDevice Status 2013-11-14 21:22:59.608 1
p2 Counter-Reset Status 2013-11-14 21:23:10.194 0
Conditions
Name Expression Last True State
_cDeviceOn p1 == 1 2013-11-14 21:22:59.610 true
cResetCounter p2 == 1 2013-11-14 21:23:05.686 false
_cNoOfStarts cResetCounter ? 0 : (_cDeviceOn ? _cNoOfStarts + 1 : _cNoOfStarts) 2013-11-14 21:23:10.198 1
Actions
Actions for Condition: cResetCounter
Delay 05
Device Action Arguments
Counter-Reset SetTarget newTargetValue=0[/code]