Guy Lavoie
Active Member
I was posting a suggestion on the Elk M1 dealer site forum and then a question came to mind concerning how the rule engine worked. The following code is intended to dial a different number every 15 seconds as long as the system is still tripped (output 2 is still on) until the last number is dialed. My question is this: will all the rules begionning with "WHENEVER output 201 state is turned off" evaluate as true at the first occurance? If so, will they all be seen in the order the rules are presented below? If this is the case, then I run the risk of having the M1 queue the numbers to dial all at once since the 2nd rule sets the counter to 2, then the following rule looks for the counter being set to 2...then it fires and advances the counter to 3, etc.
WHENEVER output 2 is turned ON
THEN dial 1st number
THEN counter1 = 1
THEN Turn output 201 ON for 15 seconds
WHENEVER output 201 state is turned off
AND counter1 = 1
AND output 2 state is ON
THEN dial 2nd number
THEN counter1 = 2
THEN Turn output 201 ON for 15 seconds
WHENEVER output 201 state is turned off
AND counter1 = 2
AND output 2 state is ON
THEN dial 3rd number
THEN counter1 = 3
...
WHENEVER output 201 state is turned off
AND counter1 = last one
AND output 2 state is ON
THEN dial last number
THEN counter1 = 0
If this were an Ocelot, it would indeed behave this way. To get around it, I would either reverse the order of the rules as shown below, or use a SkipTo statement to skip over the remaining rules that are also looking for output 201 turning off.
WHENEVER output 201 state is turned off
AND counter1 = last one
AND output 2 state is ON
THEN dial last number
THEN counter1 = 0
WHENEVER output 201 state is turned off
AND counter1 = 2
AND output 2 state is ON
THEN dial 3rd number
THEN counter1 = 3
WHENEVER output 201 state is turned off
AND counter1 = 1
AND output 2 state is ON
THEN dial 2nd number
THEN counter1 = 2
THEN Turn output 201 ON for 15 seconds
WHENEVER output 2 is turned ON
THEN dial 1st number
THEN counter1 = 1
THEN Turn output 201 ON for 15 seconds
How does the Elk rule engine work here?
WHENEVER output 2 is turned ON
THEN dial 1st number
THEN counter1 = 1
THEN Turn output 201 ON for 15 seconds
WHENEVER output 201 state is turned off
AND counter1 = 1
AND output 2 state is ON
THEN dial 2nd number
THEN counter1 = 2
THEN Turn output 201 ON for 15 seconds
WHENEVER output 201 state is turned off
AND counter1 = 2
AND output 2 state is ON
THEN dial 3rd number
THEN counter1 = 3
...
WHENEVER output 201 state is turned off
AND counter1 = last one
AND output 2 state is ON
THEN dial last number
THEN counter1 = 0
If this were an Ocelot, it would indeed behave this way. To get around it, I would either reverse the order of the rules as shown below, or use a SkipTo statement to skip over the remaining rules that are also looking for output 201 turning off.
WHENEVER output 201 state is turned off
AND counter1 = last one
AND output 2 state is ON
THEN dial last number
THEN counter1 = 0
WHENEVER output 201 state is turned off
AND counter1 = 2
AND output 2 state is ON
THEN dial 3rd number
THEN counter1 = 3
WHENEVER output 201 state is turned off
AND counter1 = 1
AND output 2 state is ON
THEN dial 2nd number
THEN counter1 = 2
THEN Turn output 201 ON for 15 seconds
WHENEVER output 2 is turned ON
THEN dial 1st number
THEN counter1 = 1
THEN Turn output 201 ON for 15 seconds
How does the Elk rule engine work here?