Persistent timers in PAC Control.
Lets not get any of us long term PAC Control users triggered by talking about how even after all these years PAC Control still does not maintain timer values between downloads or reboots….
But rather let’s talk about why you might want such a feature.
Use case #1.
Maintenance. Let’s say you have a pump house that needs bearings and seals replaced before they fail, so you need to track the total hours any given pump has accumulated.
When you start the pump the first time after replacing all those parts, you want to start counting from zero the days, hours and minutes it’s been running.
When the pump turns off, the timer pauses, when it starts again, the timer resumes from the timer value it paused on…
At midnight, you move the current timer into a different table that keeps track of total running time over the weeks and months, after moving the day’s run time to that table, you reset the daily run timer.
Of course all the timers and tables survive a download or a controller power cycle.
Use case #2.
State timer. You want to know how long a digital (or variable) input or output has been turned on and when it changes state you want the timer to reset back to zero and start timing again.
This way in groov View you can quickly see how long a device has been on or how long it’s been off.
Of course the timers survive a download or a controller power cycle.
As far as making persistent timer code goes, both use cases end up being rather different from each other. The first requires keeping track of each pause and resume with a master save function and the second requires a hard stop/reset/start methodology.
The trick to all this is to not actually use any of the PAC Control timers. Up timers get reset back to zero when they are loaded with a value and down timers don’t keep track of long running processes.
Rather, you need to use actual date/time values and keep track of when different events happened in real time which are then converted to seconds and those seconds are kept track of……
In both cases, heavy use of persistent tables and variables is the only way to keep track of time through a controller reboot or strategy download.
All this was beyond my skill set, so I tossed it over the cubicle wall to @torchard. (As you do).