mike72 Posted December 3, 2012 Share Posted December 3, 2012 sorry to bother you again guru been studying the help guide again and came across the mix/max function in an expression, is there a way to have the time associated with that too? say if i want a varable text with the max amps displaying, how can i put the time next to it when it happened? i would also need to be able to re-set that, if i re-set the channel, would it clear? mike Link to comment Share on other sites More sharing options...
AzeoTech Posted December 3, 2012 Share Posted December 3, 2012 Not a bother. Its my job. getTime(max(x)) returns the time of the max of x. Its typically better to do: private mx = max(x) and then use mx and mx.time, or getTime(mx) so that you aren't calcing the max twice. But that only matters if you are doing the max of a lot of values (say a million). As for resetting, you can clear the history, or you can just subset the value first: getTime(max(x[systime(), systime() - 3600])) gives the time of the max of the x over the last hour. Or, use a global variable to set the starttime: getTime(max(x[starttime, systime()])) then just set starttime = systime() to reset the max. Link to comment Share on other sites More sharing options...
mike72 Posted December 3, 2012 Author Share Posted December 3, 2012 hi guru tried the first option a while ago already, but it gives me daq time. where would i squeeze in, formatdatetime;"%c" to make it understandable? is it possible to have 2 expressions on one component? mike Link to comment Share on other sites More sharing options...
AzeoTech Posted December 3, 2012 Share Posted December 3, 2012 You would just wrap the whole thing: formatDateTime("%c", getTime(max(x))) You can only have one expression for a component display, but you can convert everything to a string and concat it. So: format("%.3f", max(x)) + ", " + formatDateTime("%c",getTime(max(x))) You can put whatever other text you want in there too using the same pattern. Link to comment Share on other sites More sharing options...
mike72 Posted December 3, 2012 Author Share Posted December 3, 2012 yip, you did it again. thanks again for your help guru. mike Link to comment Share on other sites More sharing options...
ledbelly2142 Posted February 1, 2013 Share Posted February 1, 2013 I like this thread, I would like to do something similar. What if I wanted to get the max and min values for a day (24 hr period) and log it in a test channel? Would it be the following for max if I ran the sequence at 00:00 every day? private mx = max(tempchannel) getTime(max(tempchannel[systime(), systime() - 86400])) testchannelmax.addvalue(mx) or should the mx be a global variable globel mx = max(tempchannel) getTime(max(tempchannel)[systime(), systime()-86400])) testchannelmax.addvalue(mx) Could I make a test channel and put the sequence in the Event of the "tempchannel" channel? How could I look at the min and max values for each day historically with existing "tempchannel" data? I hope I'm making sense. I would like to take an existing temperature channel, and look at (graph) historical min and max for each day, as well as month. Thanks in advance! Link to comment Share on other sites More sharing options...
AzeoTech Posted February 1, 2013 Share Posted February 1, 2013 First, your sequence is slightly wrong. Doing just max(tempchannel) gives you the max over all time, while your gettime() version returns the time of the max over the last 24 hours. Also, the gettime call does nothing because you don't do anything with the result. There truthfully is no reason for this line at all. What you want is something like this in the event for tempChannel (assuming testchannelmax is created): if (formatdatetime("%d", tempchannel.time[0]) != formatdatetime("%d",tempchannel.time[1])) private sod = floor(tempchannel.time[1] / 86400) * 86400 private mx = max(tempchannel[sod, sod + 86399.999]) private mn = min(tempchannel[sod, sod + 86399.999]) testchannelmax.addvalue(mx) testchannelmin.addvalue(mn)endif[/CODE]Once you do that you can plot testchannelmax just like any other channel, however it will only have one data point a day.The first line just checks for the day turning over. "sod" is start of day and is the start time of yesterday. Then I'm subsetting from that point through the day by adding 86399.999 to it (86400 secs in a day). Link to comment Share on other sites More sharing options...
ledbelly2142 Posted February 1, 2013 Share Posted February 1, 2013 I must be doing something wrong, my test channels are not adding any values. test channels are device type: Test, I/O type A to D, Timing = 0, no conversions. No errors on the sequence. Link to comment Share on other sites More sharing options...
ledbelly2142 Posted February 1, 2013 Share Posted February 1, 2013 It works, I found an error in my typing, missing a ")" in the first line, so the "if" argument was never true. The "testchannelmax" and "testchannelmin" does not have historical data from "tempchannel". Is it possible to plot historical min/max with "tempchannel"? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 4, 2013 Share Posted February 4, 2013 testChannelMax / min will build historical, one data point per day. You can plot it with tempchannel by simply adding a separate Trace on the same graph. Consider using a different axis so you can change the trace type to point instead of line. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.