Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.

Log in or register to post/reply in the forum.

Value At Time

Clayton Apr 22, 2011 09:42 PM

I'm trying to write an RTMC-Pro project that uses an expression to grab data from a specific time. At 6am our precip gauge resets a cumulative counter to zero and I want to grab that data. I'm trying the ValueAtTime expression, but it seems to be stumbling on the timestamp, which I've entered as 600, and just returns the most recent value. Here's the syntax I've tried:

600 is what 6am looks like in the mixed array timestamp from our CR10X. I figured 6999 would make a good default in the event of an error. Can the default also be text, like "error"?


ChipsNSalsa Apr 25, 2011 06:47 PM

Timestamps in RTMCs working memory (not what's being displayed) are nanaoseconds since the beginning of 1990. You could do

StartRelativeToNewest(nSecPerDay,OrderCollected);ValueAtTime"MMSA_SESAME_DAT:1.cumm_h2o",TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o"),TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o") MOD nSecPerDay - nSecPerHour*6,6999)

That will work but it will be incorrect between midnight and 6 am. What do you want to display during that period, the previous days 6am reading? If so an IIF function will have to be involved like this:

StartRelativeToNewest(2*nSecPerDay,OrderCollected);ValueAtTime("MMSA_SESAME_DAT:1.cumm_h2o",TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o"),IIF(TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o") MOD nSecPerDay<nSecPerHour*6,TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o") MOD nSecPerDay+nSecPerHour*18,TimeStamp("MMSA_SESAME_DAT:1.cumm_h2o") MOD nSecPerDay-nSecPerHour*6),6999)

Note that I fed the expression two days worth of data with the StartRelativeToNewest function because between midnight and 6 am we need to go back more than 24 hours to get to the previous days 6 am reading. You could make the expression a little shorter using the Alias function like this:

Alias(X,"MMSA_SESAME_DAT:1.cumm_h2o");StartRelativeToNewest(2*nSecPerDay,OrderCollected);ValueAtTime(X,TimeStamp(X),IIF(TimeStamp(X) MOD nSecPerDay<nSecPerHour*6,TimeStamp(X) MOD nSecPerDay+nSecPerHour*18,TimeStamp(X) MOD nSecPerDay-nSecPerHour*6),6999)

* Last updated by: ChipsNSalsa on 4/26/2011 @ 4:13 PM *

Makada Nov 14, 2021 06:31 PM

What do i need to change in my similar code to have the report range function in rtmc with one day working?

The below code is increasing by every 10 minutes.

Alias(val, "Server:CR1000.Table1.Windroos");
IIF(IsFinite(ValueAtTime(val,TimeStamp(val),TimeStamp(val) MOD nSecPerDay-nSecPerMin*010,6999)), ValueAtTime(val,TimeStamp(val),TimeStamp(val) MOD nSecPerDay-nSecPerMin*010,6999), $" ")

Alias(val, "Server:CR1000.Table1.Windroos");
IIF(IsFinite(ValueAtTime(val,TimeStamp(val),TimeStamp(val) MOD nSecPerDay-nSecPerMin*020,6999)), ValueAtTime(val,TimeStamp(val),TimeStamp(val) MOD nSecPerDay-nSecPerMin*020,6999), $" ")

With the kindest regards. 

Log in or register to post/reply in the forum.