alexzhornyak/SCXML-tutorial

delay attribute not working in commons-scxml2-2.0-SNAPSHOT version

seenivasanmca opened this issue · 5 comments

Unable to evaluate the expression from the .json from src tag.It is treating like string
{
"dp1":'10 < 25',
}

Delay attribute is not working properly. Here i have configured 5s delay but its is executing only once.

<datamodel>
<!--<data id="sensordata" src="http://loaclhost:8080/retrive/sensor/data?hk200300,hk1720"-->

<data id="sensorData" src="http://localhost:8080/sensordata.json"/>
    <data id="detectionparam" src="http://localhost:8080/sample.json" />
    <data id="dp1"/>
    <data id="dp2" />
	 <data id="dp3" expr="true"/>
	 <data id="dp4" />


</datamodel>



<state id="No_Fault">



    <!-- <transition cond="true" target="Fault"/> -->
    <onentry>




                
         <assign location="dp1" expr="sensorData.HK_200300 &lt; 25" />
        <assign location="dp2" expr="true" />
		<assign location="dp4" expr="true"/>



        <log label="DP1 Value On Entry" expr="dp1" />
		            <log label="DP3 Value On Entry" expr="dp3" />

		<send  event="ec1"/>
		

    </onentry>


    <transition event="'ec1'" cond="dp1 or dp2 or dp3" target="Fault">
	
        <log label="DP1" expr="dp1" />
        <log label="DP2" expr="dp2" />
        <log label="DP3" expr="dp3" />
    </transition>

    <onexit>
        <log label="DP1 Value On Exit" expr="dp1" />
    </onexit>




</state>



<state id="Fault" initial="Root_Cause">



    <datamodel>
        <data id="rc1" />
        <data id="rc2"/>
        <data id="rc3"/>
		<data id="fm1"/>
    </datamodel>



    <parallel id="Root_Cause">
        <state id="RC1" initial="RC1_Initial">



            <state id="RC1_Initial">
                <transition cond="rc1" target="rc1" />
            </state>



            <final id="rc1">
            <onentry>
            <log label="Fault RC1" expr="rc1" />
            </onentry>
            </final>




        </state>





        <state id="RC2" initial="RC2_Initial">



            <state id="RC2_Initial">
                <transition cond="rc2" target="rc2" />
            </state>



            <final id="rc2">
            <onentry>
            <log label="Fault RC2" expr="rc2" />
            </onentry>
            </final>
            
        </state>



        <state id="RC3" initial="RC3_Initial">



            <state id="RC3_Initial">
                <transition cond="rc3" target="rc3" />
            </state>



            <final id="rc3">
            <onentry>
            <log label="Fault RC3" expr="rc3" />
            </onentry>
            </final>



        </state>



        <transition target="Fault_Mode" />
    </parallel>





    <parallel id="Fault_Mode">
        <state id="FM1" initial="FM1_Check">
            <state id="FM1_Check">
            <transition cond="fm1" target="fm1"/>
            </state>
            
            <final id="fm1">
            <onentry>
            <log label="Fault Mode FM1" expr="fm1" />
            </onentry>
            </final>
        </state>



        <state id="FM2">
            <onentry>
                <log label="FM2" />
            </onentry>
        </state>
    </parallel>



</state>

I do not see any <send> elements with attribute 'delay' or 'delayexpr' in your SCXML source code! If you mean another subject then explain detaily, please.

image

I offer you to use Visual SCXML Editor that supports local debugging and test locally the behaviour of your statemachine.
You may open Issue_5.zip with the editor.

Recommended SCXML Code Standard

  1. It is not recommended to use same names for states and data fields
    image

  2. It is not recommended to use names for states that differ only by case
    image

<datamodel>
<!--<data id="sensordata" src="http://loaclhost:8080/retrive/sensor/data?hk200300,hk1720"-->

<data id="sensorData" src="http://localhost:8080/sensordata.json"/>
    <data id="detectionparam" src="http://localhost:8080/sample.json" />
    <data id="dp1"/>
    <data id="dp2" />
	 <data id="dp3" expr="true"/>
	 <data id="dp4" />


</datamodel>



<state id="No_Fault">



    <!-- <transition cond="true" target="Fault"/> -->
    <onentry>




                
         <assign location="dp1" expr="sensorData.HK_200300 &lt; 25" />
        <assign location="dp2" expr="true" />
		<assign location="dp4" expr="true"/>



        <log label="DP1 Value On Entry" expr="dp1" />
		            <log label="DP3 Value On Entry" expr="dp3" />

		<send  event="ec1" delay="5s"/>
		

    </onentry>


    <transition event="'ec1'" cond="dp1 or dp2 or dp3" target="Fault">
	
        <log label="DP1" expr="dp1" />
        <log label="DP2" expr="dp2" />
        <log label="DP3" expr="dp3" />
    </transition>

    <onexit>
        <log label="DP1 Value On Exit" expr="dp1" />
    </onexit>




</state>



<state id="Fault" initial="Root_Cause">



    <datamodel>
        <data id="rc1" />
        <data id="rc2"/>
        <data id="rc3"/>
		<data id="fm1"/>
    </datamodel>



    <parallel id="Root_Cause">
        <state id="RC1" initial="RC1_Initial">



            <state id="RC1_Initial">
                <transition cond="rc1" target="rc1" />
            </state>



            <final id="rc1">
            <onentry>
            <log label="Fault RC1" expr="rc1" />
            </onentry>
            </final>




        </state>





        <state id="RC2" initial="RC2_Initial">



            <state id="RC2_Initial">
                <transition cond="rc2" target="rc2" />
            </state>



            <final id="rc2">
            <onentry>
            <log label="Fault RC2" expr="rc2" />
            </onentry>
            </final>
            
        </state>



        <state id="RC3" initial="RC3_Initial">



            <state id="RC3_Initial">
                <transition cond="rc3" target="rc3" />
            </state>



            <final id="rc3">
            <onentry>
            <log label="Fault RC3" expr="rc3" />
            </onentry>
            </final>



        </state>



        <transition target="Fault_Mode" />
    </parallel>





    <parallel id="Fault_Mode">
        <state id="FM1" initial="FM1_Check">
            <state id="FM1_Check">
            <transition cond="fm1" target="fm1"/>
            </state>
            
            <final id="fm1">
            <onentry>
            <log label="Fault Mode FM1" expr="fm1" />
            </onentry>
            </final>
        </state>



        <state id="FM2">
            <onentry>
                <log label="FM2" />
            </onentry>
        </state>
    </parallel>



</state>

update scxml with delay attribute

<datamodel>
<!--<data id="sensordata" src="http://loaclhost:8080/retrive/sensor/data?hk200300,hk1720"-->

<data id="sensorData" src="http://localhost:8080/sensordata.json"/>
    <data id="detectionparam" src="http://localhost:8080/sample.json" />
    <data id="dp1"/>
    <data id="dp2" />
	 <data id="dp3" expr="true"/>
	 <data id="dp4" />


</datamodel>



<state id="No_Fault">



    <!-- <transition cond="true" target="Fault"/> -->
    <onentry>




                
         <assign location="dp1" expr="sensorData.HK_200300 &lt; 25" />
        <assign location="dp2" expr="true" />
		<assign location="dp4" expr="true"/>



        <log label="DP1 Value On Entry" expr="dp1" />
		            <log label="DP3 Value On Entry" expr="dp3" />

		<send  event="ec1" delay="5s"/>
		

    </onentry>


    <transition event="'ec1'" cond="dp1 or dp2 or dp3" target="Fault">
	
        <log label="DP1" expr="dp1" />
        <log label="DP2" expr="dp2" />
        <log label="DP3" expr="dp3" />
    </transition>

    <onexit>
        <log label="DP1 Value On Exit" expr="dp1" />
    </onexit>




</state>



<state id="Fault" initial="Root_Cause">



    <datamodel>
        <data id="rc1" />
        <data id="rc2"/>
        <data id="rc3"/>
		<data id="fm1"/>
    </datamodel>



    <parallel id="Root_Cause">
        <state id="RC1" initial="RC1_Initial">



            <state id="RC1_Initial">
                <transition cond="rc1" target="rc1" />
            </state>



            <final id="rc1">
            <onentry>
            <log label="Fault RC1" expr="rc1" />
            </onentry>
            </final>




        </state>





        <state id="RC2" initial="RC2_Initial">



            <state id="RC2_Initial">
                <transition cond="rc2" target="rc2" />
            </state>



            <final id="rc2">
            <onentry>
            <log label="Fault RC2" expr="rc2" />
            </onentry>
            </final>
            
        </state>



        <state id="RC3" initial="RC3_Initial">



            <state id="RC3_Initial">
                <transition cond="rc3" target="rc3" />
            </state>



            <final id="rc3">
            <onentry>
            <log label="Fault RC3" expr="rc3" />
            </onentry>
            </final>



        </state>



        <transition target="Fault_Mode" />
    </parallel>





    <parallel id="Fault_Mode">
        <state id="FM1" initial="FM1_Check">
            <state id="FM1_Check">
            <transition cond="fm1" target="fm1"/>
            </state>
            
            <final id="fm1">
            <onentry>
            <log label="Fault Mode FM1" expr="fm1" />
            </onentry>
            </final>
        </state>



        <state id="FM2">
            <onentry>
                <log label="FM2" />
            </onentry>
        </state>
    </parallel>



</state>

updated scxml with delay attributes

<datamodel>
<!--<data id="sensordata" src="http://loaclhost:8080/retrive/sensor/data?hk200300,hk1720"-->

<data id="sensorData" src="http://localhost:8080/sensordata.json"/>
    <data id="detectionparam" src="http://localhost:8080/sample.json" />
    <data id="dp1"/>
    <data id="dp2" />
	 <data id="dp3" expr="true"/>
	 <data id="dp4" />


</datamodel>



<state id="No_Fault">



    <!-- <transition cond="true" target="Fault"/> -->
    <onentry>




                
         <assign location="dp1" expr="sensorData.HK_200300 &lt; 25" />
        <assign location="dp2" expr="true" />
		<assign location="dp4" expr="true"/>



        <log label="DP1 Value On Entry" expr="dp1" />
		            <log label="DP3 Value On Entry" expr="dp3" />

		<send  event="ec1" delay="5s"/>
		

    </onentry>


    <transition event="'ec1'" cond="dp1 or dp2 or dp3" target="Fault">
	
        <log label="DP1" expr="dp1" />
        <log label="DP2" expr="dp2" />
        <log label="DP3" expr="dp3" />
    </transition>

    <onexit>
        <log label="DP1 Value On Exit" expr="dp1" />
    </onexit>




</state>



<state id="Fault" initial="Root_Cause">



    <datamodel>
        <data id="rc1" />
        <data id="rc2"/>
        <data id="rc3"/>
		<data id="fm1"/>
    </datamodel>



    <parallel id="Root_Cause">
        <state id="RC1" initial="RC1_Initial">



            <state id="RC1_Initial">
                <transition cond="rc1" target="rc1" />
            </state>



            <final id="rc1">
            <onentry>
            <log label="Fault RC1" expr="rc1" />
            </onentry>
            </final>




        </state>





        <state id="RC2" initial="RC2_Initial">



            <state id="RC2_Initial">
                <transition cond="rc2" target="rc2" />
            </state>



            <final id="rc2">
            <onentry>
            <log label="Fault RC2" expr="rc2" />
            </onentry>
            </final>
            
        </state>



        <state id="RC3" initial="RC3_Initial">



            <state id="RC3_Initial">
                <transition cond="rc3" target="rc3" />
            </state>



            <final id="rc3">
            <onentry>
            <log label="Fault RC3" expr="rc3" />
            </onentry>
            </final>



        </state>



        <transition target="Fault_Mode" />
    </parallel>





    <parallel id="Fault_Mode">
        <state id="FM1" initial="FM1_Check">
            <state id="FM1_Check">
            <transition cond="fm1" target="fm1"/>
            </state>
            
            <final id="fm1">
            <onentry>
            <log label="Fault Mode FM1" expr="fm1" />
            </onentry>
            </final>
        </state>



        <state id="FM2">
            <onentry>
                <log label="FM2" />
            </onentry>
        </state>
    </parallel>



</state>

@seenivasanmca follow the next issue support conditions, please:

  1. attach full scxml file as zip or txt with all necessary xml tags such as <scxml> element
  2. try not to send state chart with syntax or non-standard errors such as <transition event="'ec1'" (must be <transition event="ec1") where event ec1 is enclosed with ' character and there is a lot of time wasted to find such error
  3. check in any visual SCXML editor the behaviour of your statemachine first. Is the behaviour as expected or not!? Because I do not know what is expected from your source code, sorry
  4. read the SCXML standard concerning the element you need. For example, attribute 'delayexpr' in <send> element must return something like return 25*45 + 'ms'

Your present code is working something like that now
Issue_5