Hourmeter


Technidyne

Recommended Posts

In our process we have some UV lamps we want to keep track of the accumulated "on-time" of an (hourmeter)

I want to create a digital panel meter meter that accumulates the On-time of the "UVlamp" channel.

Not sure how to keep it accumulating?

Link to comment
Share on other sites

I'm assuming you have a channel that stores its on/off state. I'll assume its called "OnOff". You'll probably want to use a registry variable so it persists across DF restarts, but not it won't count when DF isn't running. Anyhow, in the Event for the OnOff channel put:



if (isEmpty(registry.strHourMeter))
registry.strHourMeter = "0"
endif
if (numrows(onOff) > 1)
if (onOff[0])
registry.strHourMeter = doubleToStr(strToDouble(registry.strHourMeter) + (onOff.time[0] - onOff.time[1]) / 3600)
endif
endif

[/CODE]

Numeric registry variables are limited to integers (by Windows), so I use a string one instead. I check to make sure it exists and if not initialize to "0". Use that single line to reset the counter at any time. Then in the script, whenever it onOff reads non-zero, it adds the difference in time between the last two readings to the registry variable.

You can then reference the registry variable anywhere like I did. If you are doing display only, you don't need strToDouble().

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.