What is the easy way to capture the duration of machine states in a transaction group?
Instead of calculating the duration in the query, I want to have duration as a column I think.
( I might miss some edges cases, not worried about them )
Do I script some tags as counters that reset on state change for each machine?
Must be a better way I think.
update: hours meter function in the transaction group item put the duration of the previous state into the group for me, and I added a tag to capture the previous state as well, thanks for the help
Does it have to be in a transaction group? Assuming you have a tag that keeps track of the machine state, a tag change event on the tag would give you the opportunity to log what the new value is and when it changes.
In tag event scripts, you have previousValue and currentValue available and are fully qualified values. You can access the previous timestamp by doing previousValue.timestamp and the same with the currentValue.
Just a word of warning. This timestamp may not be what you think it is. For instance perhaps the tag value is updated due to a quality change, this time stamp may no longer reflect the time which the value last changed.
IMHO, you're better off tracking the time of the last value change in a memory tag.
The hour meter puts the duration of the previous state into the transaction group.
So it is kind of useful.
Is there an easy way to put the previous state into another item in the same transaction group?
Then I would have the current state, previous state, and the duration of previous state so my queries will be very organized.
I can make a tag if not.
In the opc item path, can I designate the previous value?
Looks like I need to make a tag that holds the previous value and then I should be set.