From: Dave B. <db...@th...> - 2007-09-18 15:02:50
|
First, thanks to all who have helped with suggestions on this particular issue, and in getting me up to at least a crawl, in general! I'm still thinking in sequential programming logic, rather then MH looping structure, so I realize I'm not doing things "right"... My simple test to try to drive the PowerHorn is a clear example of (one) wrong way to write my code: my $once = 0; my $tic; if($once == 0) { set $HORN ON; $tic = time; while($tic == time){ print_log("Beep!"); } set $HORN OFF; $once=1; } This causes the system to hang briefly on startup, then display a long string of "Beep!"s in the log, then fall into do-nothing on subsequent loops. I'm sure a better implementation would be to set a device ON, start a timer object for 1 or 2 seconds, then set the device OFF in some later execution loop. There are some examples, for sure, but at my stage of development, they're bewilderingly complicated and intertwined with voice commands, etc. I would really appreciate it if some kind soul would show me how to restructure a simple program like the above! Or, for this particular task, maybe a for loop, to 'flash' the device ON and OFF say 10 times, with short, unequal delays (ON..OFF......ON..OFF......). I also see in the docs, under Generic_Item: You can also stack a series of set_with_timer calls with one set call like this: set('s1~t1~s2~t2...sn'); where s1, s2, ... sn are various states, and t1, t2 ... tn are the times to wait between states. See example below. This looks like I could implement the for loop in a single line (after declarations, etc.), like: set('ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'~0.5~'ON'~0.2~'OFF'); Unfortunately, I couldn't parse a relevant example out of the text below that, as most of the following example lines appeared to be related to tieing items. I can see the t's as delay times, but the s's must be more than 'ON' and 'OFF'. Docs like this assume too much knowledge and experience with MH and/or Perl, for beginners, I think! Thanks for any help! Dave |