Menu

Force execution of a rule...

netsrac69
2011-11-04
2012-12-14
  • netsrac69

    netsrac69 - 2011-11-04

    Hey Guys,

    this is something that has happened to me a thousand times and I try to understand it.

    I do have a rule which is running fine - just as an example:

      <rule id="DummyTest">
        <condition type="object" id="DummySwitch" value="on" trigger="true" />
        <actionlist>
          <action type="set-value" id="DummyLamp" value="on"  />
        </actionlist>
      </rule>

    This works fine for the first "on" I got on the bus. But if I press "on" a second time, all I got in the log is the following:

    1320393107 INFO Object : New value on for object DummySwitch (type: 1.001)
    1320393107 INFO Rule : Evaluate rule DummyTest
    1320393107 INFO ObjectValue : SwitchingObjectValue: Compare value_m='1' to value='1'
    1320393107 INFO Condition : ObjectCondition (id='DummySwitch') evaluated as '1'
    1320393107 INFO Rule : Rule DummyTest evaluated as 1, prev value was 1
    1320393107 INFO FilePersistentStorage : Writing log'on' for object 'DummySwitch'

    Because of the of "evaluated as 1, previous value was 1", the rule behind here is not executed.

    I understand the problem, because this could create infinite loops, but is there a was to for the execution of the Rule "DummyTest" whenever I receive a "on" signal?

    For several reasons I can not set the DummySwitch to off after the evaluation of the rule.

    Thanks….Netsrac

     
  • Anthony

    Anthony - 2011-11-04

    hi,

    there is 2 type of <actionlist>
    1) the default <actionlist type="if-true">
    2) and <actionlist type="on-true">

    the first is execute when the condition change in false to true
    the second is execute when the condition is true (don't look the previous value)

    i think for you, you have to use :

    <rule id="DummyTest">
     <condition type="object" id="DummySwitch" value="on" trigger="true" />
     <actionlist type="on-true" >
      <action type="set-value" id="DummyLamp" value="on" />
     </actionlist>
     </rule>
    

    Anthony

     
  • Anthony

    Anthony - 2011-11-04

    hi,
    following analysis I made a mistake it's the opposite:
    1) <actionlist type="if-true"> =>  is execute when the condition is true (don't look the previous value)
    2) the default  <actionlist type="on-true"> => is execute when the condition change in false to true the second

    you have to use <actionlist type="if-true">

    sorry ;-)
    bye,
    Anthony.

     
  • netsrac69

    netsrac69 - 2011-11-04

    Perfect…thanks, this works fine…

     
  • netsrac69

    netsrac69 - 2011-11-04

    I love all those undocumented features…I should better read the code itself :-)

     
  • Damago

    Damago - 2012-04-12

    I have added this to documentation. Also re-arranged the section regarding rules for this and other things to be more explanatory.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.