Time When Button Pressed


Recommended Posts

hi guru

guru, been hunting around again but cant find any help or examples of my following question:

i would like a variable value compenent to show when last a button was pressed. let me explain, i got a pay-as-you-go kilowatt meter counter on my clt, and whenever some one gives a new value to the kwh channel, i would like to display whenever that date was. if i put FormatDateTime ("%c", kwh.Time(0)) in the variable value component, all i get is the local time.

mike

Link to comment
Share on other sites

Is kwh being constantly updated, or just when someone clicks the button. If when someone clicks the button, then your expression should work, though you need to replace the () surrounding the 0 with []:

formatDateTime("%c", kwh.time[0])

If its changing constantly, you'll need another variable to hold the time of button click. In the quick sequence action of the button (add a second action if needed) put:

global kwhChangeTime = systime()

then change your expression in your component to:

formatDateTime("%c", kwhChangeTime)

Link to comment
Share on other sites

hi guru

just to let you know, the square brackets didnt work either. the button is only pressed once or twice a month. had to go the 2nd option and make another test channel, KwhChangeTime and works perfect, thank you.

another quick question, mix/max values, are they stored in the history or in persistance?

mike

Link to comment
Share on other sites

() vs [] is more for forward compatability. It works now, but no guarantees it will work in the future. (Actually, I can pretty much guarantee it won't work for much longer...)

min / max values? What min / max values? You mean if you do:

max(kwh)

? That is calced on the fly.

Link to comment
Share on other sites

i got channels recording temps, and have min/max values assiociated with them, but they dont hold their values for very long. on the temp channels, ive got the history lengh set at 9000 and persistance for 1000000. if i push up the history length, it starts to interfere with the machines processor.

so just out of interest, wanted to find out where the min/max values i get, get their values from. ie, the history or persistance. if i want to read the min or max value of the outside temp from 9 months ago, its going to be a whole load of data that its going to have to hold in memory.

mike

Link to comment
Share on other sites

As I said, the max / min are calced on the fly. If it wasn't, you wouldn't be able to do max / min on arbitrary time ranges. Note that you can't access the persistance with just the channel name. You have to subset. So given your settings (for myChannel):

max(myChannel)

will give the max of the last 9000 points, but:

max(myChannel[0, 1000000])

will give the max of the entire persist file (bringing it temporarily into memory). Or, for the last 9 months:

max(myChannel[systime(), systime() - 86400 * 9 * 30])

(assuming a 30 day month).

Link to comment
Share on other sites

Archived

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