Timer for a tag

Hi,

My client wants a timer/counter beside his multi state indicator to show how long the tag in question has been down for. eg if there is a comms failure and it is alarming he wants to be able to go to that alarm on the mimic page and see how long the comms have been failed for and then when they come back it just reses to 0. so they will be able to see at a quick glance if an item has failed for long or short time.

First, add a dynamic property to the multi-state indicator called counter that is an integer datatype. That will hold the number of seconds while the indicator is down. Next, drag a Timer component from the Misc tab of the palette into the window. Set the Delay (ms) to 1000 for every second. Bind the Running? property to the tag in question that drives the multi-state indicator. Lastly, put the following script on the propertyChange event of the Timer component:if event.propertyName == "running": if event.newValue == 0: event.source.parent.getComponent('Multi-State Indicator').counter = 0 elif event.propertyName == "value": event.source.parent.getComponent('Multi-State Indicator').counter = event.source.parent.getComponent('Multi-State Indicator').counter + 1You can display the counter dynamic property on a label next to the multi-state indicator.

I am having some problems with my Timer as it is starting to count only when i have looged onto the client viewer ie. if i log on and the multi state indicator is showing as failed it will only start from 0 once i hve logged in therefore i do not know if the item has been failing for long before i looged on to the system.

That is correct. It will only start counting when the client is open and that window is open. If you want to count when the client is closed you need to create DB expression tags where you can do the same type of logic. The DB tag will get evaluated when the client is closed. You can just bind your counter to the DB tag.

Yeah I also think the timer is the wrong approach. You really want a timestamp somewhere that shows the time that the quality went poor, so that your “timer” is really just doing a date difference between that time and the current time.

A sql-bridge group triggered on the tag quality might be a good way to go…