Specific time to trigger a channel
kenlok16
Junior Member
Dear,
Could anyone tell me how to do the following or any keyword that I can search in the forum?
I have tried time, clock or trigger, but fail, thanks all!
1. From monday to friday, it trigger morning function at 9am, lunch function at 1pm and night function at 6
2. Sat and sunday it only trigger morning and lunch function
does it mean i need to get time and date from master? in channel event or in define program?
Could anyone tell me how to do the following or any keyword that I can search in the forum?
I have tried time, clock or trigger, but fail, thanks all!
1. From monday to friday, it trigger morning function at 9am, lunch function at 1pm and night function at 6
2. Sat and sunday it only trigger morning and lunch function
does it mean i need to get time and date from master? in channel event or in define program?
Comments
-
The way I do it ( I'm sure there will be other wiser replies)
you can use the TIME command in Define Program to do something at a specific time:DEFINE_PROGRAM if(TIME='09:00:00') { //do somthing here }
note that you will want to put some other qualifyer in the if statement as the condition 09:00:00 will occur many times in define program depending on how fast teh define_program section is running.
There is the DAY command as well that will return the day of the week , but a better use would be the DAY_OF_WEEK command. That returns a numberDEFINE_PROGRAM stack_var sinteger sDay sDay = DAY_OF_WEEK (DATE) //do time 9:00 //do time 1:00 if( sDay = 1 || sDay=7) { //do time 6:00 } -
Make sure you put a wait 10 before the statement so that it only executes once. Otherwise during single second where if(TIME='09:00:00') will evaluates as true you could firesd off that code a couple hundred of times.
if(TIME='09:00:00') { wait 10 //do somthing here }
I would also add a local var in the code below to keep that statement from executing more than onceDEFINE_PROGRAM stack_var sinteger sDay local_var integer nRunOnce ; sDay = DAY_OF_WEEK (DATE) //do time 9:00 //do time 1:00 if(sDay = 1 || sDay=7) { if(nRunOnce != sDay) { nRunOnce = sDay ; //do time 6:00 } } -
I had an idea about this also. I think it's better (and probably more efficient) to do a timeline to run every second. In the timeline, check if it's 09:00:00 and if true, do the thing you want.
-
JohnMichnr wrote: »
DEFINE_PROGRAM if(TIME='09:00:00') { //do somthing here }
I don't think that will work. I think you have to use compare_string.
Paul -
I don't think that will work. I think you have to use compare_string.
Paul
I've used that since the dos days with no problem. The string handling will equat that to a true statement for as long as the clock is at 09:00:00. but you could use a compare as well. Never tried it.
Timeline - overall is it really that much more effecient. I thought timelines added a bt of overhead. -
JohnMichnr wrote: »I've used that since the dos days with no problem. The string handling will equat that to a true statement for as long as the clock is at 09:00:00. but you could use a compare as well. Never tried it.
Timeline - overall is it really that much more effecient. I thought timelines added a bt of overhead.
I also think there's a relatively small limiit to the number of timelines you can run simultaneiously. I think it's something like 15.
And also also, I think a simple comparison is easiest.
Here's what I'd do.DEFINE_VARIABLE volatile integer nflag DEFINE_PROGRAM if(!nflag and TIME='09:00:00') { nflag=1 begin_world_takeover(minions_count) wait 15 { nflag=0 // reset for next time } } -
ericmedley wrote: »I also think there's a relatively small limiit to the number of timelines you can run simultaneiously. I think it's something like 15.
Really - I had not heard that before - is that documented somewhere that I have never read? -
Or you could do...
define_program sDay = DAY_OF_WEEK (DATE) wait 10 'oneSecWT' { if ((time = '18:00:00') and ((sDay <> 1) or (sDay <> 7))) { //do the event } if (time = '09:00:00') { //do the event } if (time = '13:00:00') { //do the event } }
It should only trigger once. -
JohnMichnr wrote: »Really - I had not heard that before - is that documented somewhere that I have never read?
I think I heard it in ProgIII (part deux) last summer. I don't remember for sure. My information is suspect at best. I jsut seem to remember the number thinking at the time, "Boy, I'd better be careful on how many timelines I may be running simultaneiously" and also thinking what would the result be of trying to run over the limit.
Maybe when I get to Prog III (Part tre') this summer I'll make a point to ask.
-
ericmedley wrote:I also think there's a relatively small limiit to the number of timelines you can run simultaneiously. I think it's something like 15.JohnMichnr wrote:Really - I had not heard that before - is that documented somewhere that I have never read?
I never heard or read anything like that before either.ericmedley wrote:My information is suspect at best.
You said it, not me.
I just did a quick test with 100 simultaneous repeating timelines and I had no problems.
If there is a limit it appears to be way more than 15. -
Joe Hebert wrote: »If there is a limit it appears to be way more than 15.
Well, there is definitely a limit of 4,294,967,295. This is because the ID is of type long.
Now, what if I need more that 4.295 billion timelimes????
Jeff
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

