Playing with elk rules

mikefamig

Senior Member
This post is for the programmers out there that have been working with elk rules and like to tinker with things. I'm just learning elk rules and this is just an exercise to fuel some creative fire.
 
I have often been confused about the order of execution in rules and often wished that I had some procedural control over execution of them so I'm playing with an idea to add some control. My first thought is that it would be nice if I could end execution of the rules at will which would be the equivalent of a goto command to goto the last rule in the llist effectively ending execution. Tell me if you think htat this would work and why or why not.
 
First I would set up a counter and call it the "goto" counter.
 
Then the first rule in the list would be IF goto counter=0 and output1 = off  then set goto counter = 1"
-
-
-
-
-
Then I would add an "and goto counter = 1" to each and every additional rule in the list.
-
-
-
-
so far we have done nothing to affect execution of the rules given that goto counter=1.
 
Then the second to last rule would be whenever goto counter="something that is always true"  then set goto counter=0 and turn output1 on for 2 seconds.
 
Then I would make the last rule in the list "whenever goto counter =2 then set goto counter = 0 and turn output 1 on for 2 seconds.
 
Now at the end of any rule I would be able to end further execution of the list by setting goto counter = 2 causing an event that executes the last rule setting the counter = 0 and setting output1=off. This in turn would cause the rule list to execute one more time but the initial event that started all this should have expired at this point and nothing should be triggered.....no? Or did I design an eternal loop? Do I need to get a new hobby?
 
I know that this is headache stuff but I like to play. What are your thoughts?
 
Mike.
 
I tried to write the above rules and got stuck on the second to last rule that needs to always be true. I want that rule to execute every time an event causes the rules to be read in order to reset the counter but found that there is no "whenever" condition that is always true.
 
The whole thing is academic anyways because I don't dare to send it to my system for fear that I'll end up balling things up and having to re-initialize the system again. It would be fun to have a system on the test bench. just to mess with.
 
Mike.
 
Back
Top