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.
Can you access the previous timestamp of a tag in an expression item of the transaction group and say like timestamp - old timestamp?
I am not sure how I can have the old time and the new time available to me to do the calculation.
oh I see it
In tag event scripts, you have
currentValue available and are fully qualified values. You can access the previous timestamp by doing
previousValue.timestamp and the same with the currentValue.
You can also look into event meters in transaction groups
Hour and Event Meters - Transaction Group Items (inductiveuniversity.com)
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.
What about the hour meter feature in the transaction group?
Is that usable?
I wouldn’t see why not, if that’s the functionality that you’re looking for.
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.
Thanks for the help!