Menu

conditional actions - discussion

Damago
2011-03-03
2012-12-14
  • Damago

    Damago - 2011-03-03

    I think it could be good to discuss separately the way of implementing conditional actions.

    As Jean-François did write in one of the topics:
    The only thing I still see in my todo list is a simple way to compare object values without having to use LUA. But I'm still not sure what's the best way to do it, because if I just implement value comparison, one day somebody will ask if he can specify an offset, or want to add a multiplication factor to one of the values, or a combination of 3 values, or…. You know how good people can be at finding new needs. ;-)

    My suggestion is to make it similarly to repeat list. Maybe the "repeat-list" could be abbreviated to "repeat">

     <action type="repeat-list" period="2" count="3">
                        <action type="toggle-value" id="door_light"/>
    </action>
    

    To open discussion I would suggest some solutions:

    1) if the code for conditions can be re-used for condition evaluation, than It would be possible to make it re-using the whole condition syntax excluding the timer, and trigger:

     <action type="conditional">
                        <condition   (whatever here)/> 
                        <actionlist>
                            <action type="toggle-value" id="door_light"/>
                            <action type="toggle-value" id="door_light" delay="200ms"/>
                       <actionlist>
    </action>
    

    2) Another possibility is to add a separate tag <if> with condition attribute

    <actionlist>
              <if id="lamp1" condition="equal" value="on">
                       <action ..../>
              </if>
              <if id="lamp2" condition="equal" object="lamp3">
                       <action type="toggle-value" id="door_light" />
              </if>
    </actionlist>
    

    3) another possiblity is to add specific <ifxxxx> tags:

    <ifequal id1="xxxx" id2="yyyy">
    <ifdifferent id1="xxxx" id2="yyyy">
    <ifvalue id="xxxx" value="yyyy">
    <ifnotvalue id="xxxx" value="yyyy">
    

    Which might be easiest to implement.

    4) fourth solution

    <action type="if-equal" id1="xxx" id2="xxx">
          <action ...>
    </action>
    <action type="if-value" id="xxx" value="xxx">.....</action>
    <action type="if-not-equal" id1="xxx" value="xxx"></action>
    

    Which might be quite similiar.

    This is only an open brainstorming session.

    Yours
    Damago1

     
  • Damago

    Damago - 2011-03-04

    After some thoughts about it I have slightly better idea:

    <actionlist>
        <actionlist type="if-equal" id1="xxx" id2="yyy">
            <action ...... >
            <action ...... >
        </actionlist>
        <actionlist type="if-value" id="xxx" value="on">
            <action ....>
        </actionlist>
        <actionlist type="repeat" count="2" period="200ms">
             <action ....>
        </actionlist>
    </actionlist>
    <actionlist type="if-false">
        <action ....>
        <action ....>
    </action>
    
     

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.