You need to be careful with the waits if there is any chance you will need to relays to pulse at the same time. Only the first wait is likely to execute if you are using the same wait statement for all relays.
You could do the timeline thing and have it trigger every .1 seconds and count down to the OFF command if you think you need to change pulse times on the fly for the relays. If you need the pulse time for each relay is constant, then the timeline approach seems like too much work for no real gain (that I can think of ). I would opt for the KISS method
How about setting the pulse time in just one place?
define_function pulseRelay(dev myRelay, integer myChannel, integer myPulse)
{
// Store the old pulse time
stack_var integer oldPulse;
oldPulse = get_pulse_time;
// Set the new pulse time
set_pulse_time(myPulse)
// Pulse your relay
pulse[myRelay,myChannel];
// Restore old pulse time
set_pulse_time(oldPulse);
}
I was about to go the wait route - but realized, if you had 10 REL10s . . . you'd need 100 different cases for a switch I was going to propose (10 for the device, 10 for each relay.) Timelines are terribly inefficient (as far as creating them - you have to code in three different places just to create them), so I wouldn't go that route at all.
for testing I just put this in define program and toggle the nBtnTest var in debug to make it run. Just put the Do_Push_Timed that I have in DEF_PROG where you need it, adjust the vars in it as needed for your various relays and you're good to go.
The problem with the above solution is it requires a constant evaluation in define_program. Take full of advantage of the event driven programming model of NetLinx, and I suggest removing define_program all together.
The problem with the above solution is it requires a constant evaluation in define_program. Take full of advantage of the event driven programming model of NetLinx, and I suggest removing define_program all together.
The code in def program is just for testing and it is not intended to be used at all. As I stated in my post you need to take the do push timed out of def program and put it where you want use it. I would never suggest putting anything in def program except to run some quick tests or as aquick fix.
Comments
It does require a few lines of code, but it should be easy enough to change the "pulse" time on a per device basis.
Jeff
or setup a timeline and all the necessary bits inside a the function... more accurate?
You could do the timeline thing and have it trigger every .1 seconds and count down to the OFF command if you think you need to change pulse times on the fly for the relays. If you need the pulse time for each relay is constant, then the timeline approach seems like too much work for no real gain (that I can think of
Jeff
I was about to go the wait route - but realized, if you had 10 REL10s . . . you'd need 100 different cases for a switch I was going to propose (10 for the device, 10 for each relay.) Timelines are terribly inefficient (as far as creating them - you have to code in three different places just to create them), so I wouldn't go that route at all.
for testing I just put this in define program and toggle the nBtnTest var in debug to make it run. Just put the Do_Push_Timed that I have in DEF_PROG where you need it, adjust the vars in it as needed for your various relays and you're good to go.