TIME Command
TurnipTruck
Junior Member
Does anyone use the TIME command?
I am using it to send the current time to AXB-TMCs once a day in DEFINE_PROGRAM with a flag so my event only occurs once each time 06:00:00 comes around.
Is this a typical usage for the TIME command?
Does anyone find it otherwise useful?
Thanks!
I am using it to send the current time to AXB-TMCs once a day in DEFINE_PROGRAM with a flag so my event only occurs once each time 06:00:00 comes around.
Is this a typical usage for the TIME command?
Does anyone find it otherwise useful?
Thanks!
Comments
-
I use it in instances where someone may leave a system on and go home for the weekend, thus running up hours on a projector, or burning in a plasma.
IF(TIME='23:00:00')
{
// SHUT SYSTEM DOWN
}
Joe -
Joe wrote:I use it in instances where someone may leave a system on and go home for the weekend, thus running up hours on a projector, or burning in a plasma.
IF(TIME='23:00:00')
{
// SHUT SYSTEM DOWN
}
Joe
Or if you want to use the wildcard(??), valdating the expression for the entire minute:
IF (COMPARE_STRING(TIME,''12:00:??'))
{
// SHUT SYSTEM DOWN
} -
hmm, i like the wild card, had missed that before. thanks for the insight.
i do things with TIME, like downloading tv guides early in the morning for the next day; reseting log files just after midnight; for very remote systems, i ensure they do a reboot at 4am every day (i don't want an inaccessible device that's 300 kilometres away to hang); if the time is equal to sunset, turn on some lights, or open/close blinds
i tend to place repeating, relative time events into a timeline. this is better for example when checking weather or news, every 60 minutes or so.
just my 2 cents worth. -
Joe wrote:I use it in instances where someone may leave a system on and go home for the weekend, thus running up hours on a projector, or burning in a plasma.
IF(TIME='23:00:00')
{
// SHUT SYSTEM DOWN
}
Joe
Also keep in mind that the "If(Time='23:00:00')" will be true for a full second, and will execute multiple times. Make sure if you're doing something that should only be done once that you set a flag or somthing to make sure that it doesn't happen multiple times. I usually use a "Wait 11" for that purpose.
--D -
bano wrote:Or if you want to use the wildcard(??), valdating the expression for the entire minute:
IF (COMPARE_STRING(TIME,''12:00:??'))
{
// SHUT SYSTEM DOWN
}
The '??' wildcard will not work in NetLinx!!!
Some kind of funtion I'd do:DEFINE_VARIABLE VOLATILE INTEGER ZeitFlag DEFINE_FUNCTION CheckForTime() { STACK_VAR SINTEGER Hour, Minute, Secund // get current time Hour = TIME_TO_HOUR(TIME) // get hour of system time as a numeric value Minute = TIME_TO_MINUTE(TIME) Second = TIME_TO_SECOND(TIME) SELECT { ACTIVE((Hour = 12) AND (Minute = 0)): // { IF(NOT(TimeFlag)) // to prevent multiple executions { // Lock time check TimeFlag = 1 // Do what you want } } ACTIVE((Hour = 12) AND (Minute = 1)): // activate timecheck again { TimeFlag = 0 } } } DEFINE_PROGRAM WAIT 200 // check every 20 seconds only { CheckForTime() } -
Marc Scheibein wrote:The '??' wildcard will not work in NetLinx!!!
Some kind of funtion I'd do:DEFINE_VARIABLE VOLATILE INTEGER ZeitFlag DEFINE_FUNCTION CheckForTime() { STACK_VAR SINTEGER Hour, Minute, Secund // get current time Hour = TIME_TO_HOUR(TIME) // get hour of system time as a numeric value Minute = TIME_TO_MINUTE(TIME) Second = TIME_TO_SECOND(TIME) SELECT { ACTIVE((Hour = 12) AND (Minute = 0)): // { IF(NOT(TimeFlag)) // to prevent multiple executions { // Lock time check TimeFlag = 1 // Do what you want } } ACTIVE((Hour = 12) AND (Minute = 1)): // activate timecheck again { TimeFlag = 0 } } } DEFINE_PROGRAM WAIT 200 // check every 20 seconds only { CheckForTime() }
Please read Tech Note Number 555 -
Ups..... thanks Bano :rolleyes:
However... nice to have functions to get the time elements numeric
-
This might be of use as well. JUst replace the 05 and 01 in this line ( if (Mytime.Minute == '05' && Mytime.Seconds == '01') to what ever you want, add the hour if you want, make them varialbes and change it from the keyboard. Then run in define program. Works good in lieu of single event time_line for things you want to happen every x hour, every x minute or x seconds.
Every 15 minuteslocal_var integer nRunOnce If (Mytime.Minute == '00' || Mytime.Minute == '15' || Mytime.Minute == '45' && Mytime.Seconds == '01' ) { if (!nRunOnce) { // do something nRunOnce = 1 wait 15 { nRunOnce = 0 } } }
I use the seconds to allow for a short wait to keep the event from repeating during the duration of the minute. So I wait for 1.5 seconds whichs is 1/2 second longer than the duration of the second of which the event would evaluate as true and keep repeating through every pass if not for the wait and the local variable nSBRunOnce.DEFINE_TYPE structure sTime { char Hour [2] char Minute [2] char Seconds [2] } DEFINE_VARIABLE non_volatile sTime MyTime DEFINE_FUNCTION fnProcessTime(char iMyTime [8]) { if(length_string(iMyTime) == 8) { MyTime.Hour = get_buffer_string(iMyTime,2) cRSSTrash = remove_string(iMyTime,':',1) MyTime.Minute = get_buffer_string(iMyTime,2) cRSSTrash = remove_string(iMyTime,':',1) MyTime.Seconds = get_buffer_string(iMyTime,2) } } DEFINE_PROGRAM { stack_var char cMytime [8] if (cMyTime != TIME) { cMyTime = TIME fnProcessTime(cMyTime) } if (Mytime.Minute == '05' && Mytime.Seconds == '01') { local_var integer nRunOnce if (!nRunOnce) { send_string 0,"'Time ',Time,' - Updating Doing Something!',crlf" Do something nRunOnce = 1 wait 15 { nRunOnce = 0 } } } } -
The wildcard will stay active for a full minute, this is simple but it works!
IF(COMPARE_STRING(TIME,'10:00:??') AND nBLOCK == 0) { nBLOCK = 1; //DO SOMETHING WAIT 700 nBLOCK = 0; //reset } -
String
I use the time string for HVAC setbacks - we have a customer who sometimes turns zones off, but forgets to turn them back on. With Michigan weather - this can become an issue quickly from rapids temperature changes.
As a result in my timeline for feedback I use this:
IF(TIME='02:00:00')
{
//TO SAVE SPACE I WONT WRITE OUT THE LOOP,
//BUT IT IS A FOR LOOP THAT TURNS THE ZONES ON.
}
Works well. -
davieo wrote:
As a result in my timeline for feedback I use this: IF(TIME='02:00:00') { //TO SAVE SPACE I WONT WRITE OUT THE LOOP, //BUT IT IS A FOR LOOP THAT TURNS THE ZONES ON. }Just keep in mind that if your feed back timeline repeats @ 200ms your code will run 4 or 5 times before the "if" is no longer true. 9 or 10 times if your feedback timeline is 100ms. If it were in define_program w/o a wait it would probably run 1100 times. -
Correct
vining,
You are absolutely right, which is why this time line is at 1000ms. It is a seperate timeline for the HVAC feedback. You do point out something that is a good detail that less experienced programmers might miss. Also you made me realize that I did not put enough detail in my hastily crafted post. Sorry to all for any confusion.
Dave -
I've been trying to say this from the beginning. I gave up on the discussion, let them loop.:)vining wrote:Just keep in mind that if your feed back timeline repeats @ 200ms your code will run 4 or 5 times before the "if" is no longer true. 9 or 10 times if your feedback timeline is 100ms. If it were in define_program w/o a wait it would probably run 1100 times.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums


