You like to create a tag that reports the running hours e.g. of a motor. The running hours are supposed to update each time the motor changes from ON to OFF or vice versa. Is my understanding correct?
Tag 1 - OFF - 14:09:35
Tag 1 - ON - 14:15:00
Tag 1 - OFF - 14:20:00
Tag 2 - 5 min
I roughly understand what you are looking for but some details are still not clear.
With PI you can set up calculated tags. There exist several calculation engines like PI Performance Equation Scheduler, PI Totalizer Subsystem, PI Advanced Calculation Engine (PI ACE) and last but not least PI Asset Based Analytics. Please refer to the PI Server Applications user guide for information about PI Totalizer Subsystem and PI Performance Equation Scheduler. PI ACE User Guide is the manual for PI Advanced Calculation Engine. Asset based Analytics has recently been released. I highly recommend you looking into the related learning videos at OSIsoft youtube learning channel.
I suggest going with either Asset Based Analytics or PI Performance Equation Scheduler. For both you are using PI Performance Equation Syntax. PI Performance Equation Reference can usually be found as %PIHOME%\Help\PEReference.chm on each PI Data Archive or PI Client node. The function you need to evaluate how long a particular tag had a specific value is TimeEQ. The function excepts the source tag name, the periods starttime and endtime plus the value as parameter.
To be able to provide you with an example, I would need to know some more details.
- What calculation engine do you like to go with?
- Is Tag 2 supposed to update scan based e.g. every 5 seconds or when Tag 1 receives a new value?
- Are you interested in the total time since e.g. the beginning of the year or just for the latest period Tag 1 was reporting "ON"?
- What's Tag 2 supposed to report when Tag 1 is in "ON" state, the latest result (no update) or 0?
- Will Tag 1 switch between "ON" and "OFF" or are there other states involved?
- Will "ON" always be followed by "OFF" and vice versa or is there a chance the snapshot of Tag 1 becomes updated with "OFF" while it is reporting "OFF" already?