Hi,
I am currently recording the live status of the machine and displaying the status of the machine as below,
Whenever the machine is in Stopped state for more than 10 mins, I would like to start a counter and display as 'hh:mm:ss' in the next column ( for every shift as shift loss)
And when the machine goes from Stopped to any other state, the duration in the loss column must be halted and whenever the machine goes back to stopped state, the cumulated time should be displayed.
Moreover whenever the shift changes, this time should reset and if the machine is already in stopped state, counter should start from one,
Currently i am following the below approach,
Tags used:
- State tag
- Statechange time elapsed (to display the duration )
- Global Shift change tag
Calculation:
- LossFlag (Expression Tag)
if ({[.]../StateChange}="Stopped",true,false)
2.ShiftLossCumulative Tag:
if ( ({[.]ShiftLoss} = true ) && ({[.]../StateChangeTimeElapsed}>600), {[.]ShiftLossCumulative}+1, 0)
Tag change event script:
vShift = system.tag.readBlocking("[~]BASE/Global/ShiftChange")[0].value
if vShift == True:
currentValue.value = 0
elif currentValue.value == 0 and previousValue !=0:
currentValue.value =currentValue.value + previousValue.value
3.ShiftLossMins:
if(
isNull({[.]ShiftLossCumulative}),
"00:00:00",
if ({[.]../StateChange}="Stopped" && {[.]../StateChangeTimeElapsed} > 600 && {[default]BASE/Global/ShiftChange}=FALSE,
stringFormat(
"%02d:%02d:%02d",
toInt(floor(({[.]ShiftLossCumulative}+600)/3600)),
toInt(floor(({[.]ShiftLossCumulative}+600)%3600/60)),
toInt(floor(({[.]ShiftLossCumulative}+600)%60))),
stringFormat(
"%02d:%02d:%02d",
toInt(floor({[.]ShiftLossCumulative}/3600)),
toInt(floor({[.]ShiftLossCumulative}%3600/60)),
toInt(floor({[.]ShiftLossCumulative}%60))
)
)
)
This 'ShiftLossMins' Tag will be displayed in the screen.
Somehow, this is getting failed and occuring issues like, when the machine is in stopped state it is working fine.
When it goes to other state, ShiftLossMins getting reset
Any suggestions to overcome this issue?