poll button state in statechart and raise internal events on change

This commit is contained in:
Joeri Exelmans 2025-06-06 10:42:23 +02:00
parent 675efff85c
commit 45c0844fc2
5 changed files with 738 additions and 354 deletions

View file

@ -1,7 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:sgraph="http://www.yakindu.org/sct/sgraph/2.0.0"> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:sgraph="http://www.yakindu.org/sct/sgraph/2.0.0">
<sgraph:Statechart xmi:id="_jCYoMD-lEfCA8aDVRFe8Eg" specification="@EventDriven&#xA;@SuperSteps(no)&#xA;&#xA;import: &quot;./src/data_types.h&quot;&#xA;&#xA;interface:&#xA;&#x9;in event sensor: int32_t&#xA;&#xA;&#x9;in event buttonPressed&#xA;&#x9;in event buttonReleased&#xA;&#x9;&#xA;&#x9;out event setMotorR: int32_t&#xA;&#x9;out event setMotorL: int32_t&#xA;&#xA;&#x9;operation pid(sensor: int32_t, pid_vars: pid_vars_t): int32_t&#xA;&#xA;internal:&#xA;&#x9;var speed: int32_t&#xA;&#x9;var pid_vars: pid_vars_t" name="Statechart" domainID="com.yakindu.domain.c"> <sgraph:Statechart xmi:id="_jCYoMD-lEfCA8aDVRFe8Eg" specification="@EventDriven&#xA;@SuperSteps(no)&#xA;&#xA;import: &quot;./src/data_types.h&quot;&#xA;&#xA;interface:&#xA;&#x9;in event sensor: int32_t&#xA;&#x9;&#xA;&#x9;in event buttonState: bool&#xA;&#x9;&#xA;&#x9;out event setMotorR: int32_t&#xA;&#x9;out event setMotorL: int32_t&#xA;&#xA;&#x9;operation pid(sensor: int32_t, pid_vars: pid_vars_t): int32_t&#xA;&#xA;internal:&#xA;&#x9;event buttonPressed&#xA;&#x9;event buttonReleased&#xA;&#xA;&#x9;var speed: int32_t&#xA;&#x9;var pid_vars: pid_vars_t" name="Statechart" domainID="com.yakindu.domain.c">
<regions xmi:id="_jCcSkz-lEfCA8aDVRFe8Eg" name="main region"> <regions xmi:id="_jCcSkz-lEfCA8aDVRFe8Eg" name="main region">
<vertices xsi:type="sgraph:State" xmi:id="_m3tQgEKxEfCR-J2J55rMGQ" name="everything" incomingTransitions="_4ORTsEKxEfCR-J2J55rMGQ">
<regions xmi:id="_m3vFsEKxEfCR-J2J55rMGQ" name="r1">
<vertices xsi:type="sgraph:State" xmi:id="_Kp4gYD-yEfCA8aDVRFe8Eg" name="off" incomingTransitions="_n4LxNz-zEfCA8aDVRFe8Eg _YGkvAD-yEfCA8aDVRFe8Eg">
<outgoingTransitions xmi:id="_ff2psD-yEfCA8aDVRFe8Eg" specification="buttonPressed" target="_IsdxcD-yEfCA8aDVRFe8Eg"/>
</vertices>
<vertices xsi:type="sgraph:Entry" xmi:id="_XxLt0D-yEfCA8aDVRFe8Eg">
<outgoingTransitions xmi:id="_YGkvAD-yEfCA8aDVRFe8Eg" specification="" target="_Kp4gYD-yEfCA8aDVRFe8Eg"/>
</vertices>
<vertices xsi:type="sgraph:State" xmi:id="_IsdxcD-yEfCA8aDVRFe8Eg" name="on" incomingTransitions="_ff2psD-yEfCA8aDVRFe8Eg"> <vertices xsi:type="sgraph:State" xmi:id="_IsdxcD-yEfCA8aDVRFe8Eg" name="on" incomingTransitions="_ff2psD-yEfCA8aDVRFe8Eg">
<regions xmi:id="_IseYgD-yEfCA8aDVRFe8Eg" name="r1"> <regions xmi:id="_IseYgD-yEfCA8aDVRFe8Eg" name="r1">
<vertices xsi:type="sgraph:State" xmi:id="_jCcSlj-lEfCA8aDVRFe8Eg" specification="entry /&#xA;speed = pid(sensor.value, pid_vars);&#xA;raise setMotorL: speed;&#xA;raise setMotorR: speed" name="responding" incomingTransitions="_jCcSlT-lEfCA8aDVRFe8Eg _numMwD-yEfCA8aDVRFe8Eg"> <vertices xsi:type="sgraph:State" xmi:id="_jCcSlj-lEfCA8aDVRFe8Eg" specification="entry /&#xA;speed = pid(sensor.value, pid_vars);&#xA;raise setMotorL: speed;&#xA;raise setMotorR: speed" name="responding" incomingTransitions="_jCcSlT-lEfCA8aDVRFe8Eg _numMwD-yEfCA8aDVRFe8Eg">
@ -31,11 +39,21 @@
</vertices> </vertices>
</regions> </regions>
</vertices> </vertices>
<vertices xsi:type="sgraph:State" xmi:id="_Kp4gYD-yEfCA8aDVRFe8Eg" name="off" incomingTransitions="_n4LxNz-zEfCA8aDVRFe8Eg _YGkvAD-yEfCA8aDVRFe8Eg"> </regions>
<outgoingTransitions xmi:id="_ff2psD-yEfCA8aDVRFe8Eg" specification="buttonPressed" target="_IsdxcD-yEfCA8aDVRFe8Eg"/> <regions xmi:id="_m3vFsUKxEfCR-J2J55rMGQ" name="pollButton">
<vertices xsi:type="sgraph:State" xmi:id="_o5BoAEKxEfCR-J2J55rMGQ" name="button0" incomingTransitions="_xJ4q8EKxEfCR-J2J55rMGQ _2zxroEKxEfCR-J2J55rMGQ">
<outgoingTransitions xmi:id="_qfvHIEKxEfCR-J2J55rMGQ" specification="buttonState [buttonState.value]&#xA;/ raise buttonPressed" target="_pEw98EKxEfCR-J2J55rMGQ"/>
</vertices> </vertices>
<vertices xsi:type="sgraph:Entry" xmi:id="_XxLt0D-yEfCA8aDVRFe8Eg"> <vertices xsi:type="sgraph:State" xmi:id="_pEw98EKxEfCR-J2J55rMGQ" name="button1" incomingTransitions="_qfvHIEKxEfCR-J2J55rMGQ">
<outgoingTransitions xmi:id="_YGkvAD-yEfCA8aDVRFe8Eg" specification="" target="_Kp4gYD-yEfCA8aDVRFe8Eg"/> <outgoingTransitions xmi:id="_xJ4q8EKxEfCR-J2J55rMGQ" specification="buttonState[!buttonState.value]&#xA;/ raise buttonReleased" target="_o5BoAEKxEfCR-J2J55rMGQ"/>
</vertices>
<vertices xsi:type="sgraph:Entry" xmi:id="_2YsSIEKxEfCR-J2J55rMGQ">
<outgoingTransitions xmi:id="_2zxroEKxEfCR-J2J55rMGQ" specification="" target="_o5BoAEKxEfCR-J2J55rMGQ"/>
</vertices>
</regions>
</vertices>
<vertices xsi:type="sgraph:Entry" xmi:id="_3ou9sEKxEfCR-J2J55rMGQ">
<outgoingTransitions xmi:id="_4ORTsEKxEfCR-J2J55rMGQ" specification="" target="_m3tQgEKxEfCR-J2J55rMGQ"/>
</vertices> </vertices>
</regions> </regions>
</sgraph:Statechart> </sgraph:Statechart>
@ -46,6 +64,52 @@
<layoutConstraint xsi:type="notation:Location" xmi:id="_jCeHxD-lEfCA8aDVRFe8Eg"/> <layoutConstraint xsi:type="notation:Location" xmi:id="_jCeHxD-lEfCA8aDVRFe8Eg"/>
</children> </children>
<children xsi:type="notation:Shape" xmi:id="_jCeHxT-lEfCA8aDVRFe8Eg" type="RegionCompartment" fontName="Verdana" lineColor="4210752"> <children xsi:type="notation:Shape" xmi:id="_jCeHxT-lEfCA8aDVRFe8Eg" type="RegionCompartment" fontName="Verdana" lineColor="4210752">
<children xmi:id="_m3w64EKxEfCR-J2J55rMGQ" type="State" element="_m3tQgEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_m3xh8EKxEfCR-J2J55rMGQ" type="StateName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_m3xh8UKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_m3yJAEKxEfCR-J2J55rMGQ"/>
</children>
<children xsi:type="notation:Compartment" xmi:id="_m3yJAUKxEfCR-J2J55rMGQ" type="StateTextCompartment">
<children xsi:type="notation:Shape" xmi:id="_m3yJAkKxEfCR-J2J55rMGQ" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_m3yJA0KxEfCR-J2J55rMGQ"/>
</children>
</children>
<children xsi:type="notation:Compartment" xmi:id="_m3yJBEKxEfCR-J2J55rMGQ" type="StateFigureCompartment">
<children xmi:id="_m31zYEKxEfCR-J2J55rMGQ" type="Region" element="_m3vFsEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_m32acEKxEfCR-J2J55rMGQ" type="RegionName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_m32acUKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_m32ackKxEfCR-J2J55rMGQ"/>
</children>
<children xsi:type="notation:Shape" xmi:id="_m32ac0KxEfCR-J2J55rMGQ" type="RegionCompartment" fontName="Verdana" lineColor="4210752">
<children xmi:id="_Kp5ugD-yEfCA8aDVRFe8Eg" type="State" element="_Kp4gYD-yEfCA8aDVRFe8Eg">
<children xsi:type="notation:DecorationNode" xmi:id="_Kp68oD-yEfCA8aDVRFe8Eg" type="StateName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_Kp68oT-yEfCA8aDVRFe8Eg"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_Kp68oj-yEfCA8aDVRFe8Eg"/>
</children>
<children xsi:type="notation:Compartment" xmi:id="_Kp68oz-yEfCA8aDVRFe8Eg" type="StateTextCompartment">
<children xsi:type="notation:Shape" xmi:id="_Kp68pD-yEfCA8aDVRFe8Eg" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_Kp68pT-yEfCA8aDVRFe8Eg"/>
</children>
</children>
<children xsi:type="notation:Compartment" xmi:id="_Kp7jsD-yEfCA8aDVRFe8Eg" type="StateFigureCompartment"/>
<styles xsi:type="notation:ShapeStyle" xmi:id="_Kp5ugT-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="15720400" lineColor="12632256"/>
<styles xsi:type="notation:FontStyle" xmi:id="_Kp5ugj-yEfCA8aDVRFe8Eg"/>
<styles xsi:type="notation:BooleanValueStyle" xmi:id="_Kp7jsT-yEfCA8aDVRFe8Eg" name="isHorizontal" booleanValue="true"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_Kp5ugz-yEfCA8aDVRFe8Eg" x="1013" y="340" width="91" height="69"/>
</children>
<children xmi:id="_XxMU4D-yEfCA8aDVRFe8Eg" type="Entry" element="_XxLt0D-yEfCA8aDVRFe8Eg">
<children xmi:id="_XxM78D-yEfCA8aDVRFe8Eg" type="BorderItemLabelContainer">
<children xsi:type="notation:DecorationNode" xmi:id="_XxM78z-yEfCA8aDVRFe8Eg" type="BorderItemLabel">
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxM79D-yEfCA8aDVRFe8Eg"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_XxM79T-yEfCA8aDVRFe8Eg"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxM78T-yEfCA8aDVRFe8Eg" fontName="Verdana" lineColor="4210752"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_XxM78j-yEfCA8aDVRFe8Eg"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxMU4T-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="0" lineColor="16777215"/>
<styles xsi:type="notation:NamedStyle" xmi:id="_XxMU4j-yEfCA8aDVRFe8Eg" name="allowColors"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_XxMU4z-yEfCA8aDVRFe8Eg" x="1061" y="103" width="15" height="15"/>
</children>
<children xmi:id="_IsgNsD-yEfCA8aDVRFe8Eg" type="State" element="_IsdxcD-yEfCA8aDVRFe8Eg"> <children xmi:id="_IsgNsD-yEfCA8aDVRFe8Eg" type="State" element="_IsdxcD-yEfCA8aDVRFe8Eg">
<children xsi:type="notation:DecorationNode" xmi:id="_Isg0wD-yEfCA8aDVRFe8Eg" type="StateName"> <children xsi:type="notation:DecorationNode" xmi:id="_Isg0wD-yEfCA8aDVRFe8Eg" type="StateName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_Isg0wT-yEfCA8aDVRFe8Eg"/> <styles xsi:type="notation:ShapeStyle" xmi:id="_Isg0wT-yEfCA8aDVRFe8Eg"/>
@ -176,41 +240,92 @@
<styles xsi:type="notation:ShapeStyle" xmi:id="_IsgNsT-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="15720400" lineColor="12632256"/> <styles xsi:type="notation:ShapeStyle" xmi:id="_IsgNsT-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="15720400" lineColor="12632256"/>
<styles xsi:type="notation:FontStyle" xmi:id="_IsgNsj-yEfCA8aDVRFe8Eg"/> <styles xsi:type="notation:FontStyle" xmi:id="_IsgNsj-yEfCA8aDVRFe8Eg"/>
<styles xsi:type="notation:BooleanValueStyle" xmi:id="_IsiC4T-yEfCA8aDVRFe8Eg" name="isHorizontal" booleanValue="true"/> <styles xsi:type="notation:BooleanValueStyle" xmi:id="_IsiC4T-yEfCA8aDVRFe8Eg" name="isHorizontal" booleanValue="true"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_IsgNsz-yEfCA8aDVRFe8Eg" x="31" y="76" width="981" height="438"/> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_IsgNsz-yEfCA8aDVRFe8Eg" x="-42" y="47" width="981" height="438"/>
</children> </children>
<children xmi:id="_Kp5ugD-yEfCA8aDVRFe8Eg" type="State" element="_Kp4gYD-yEfCA8aDVRFe8Eg"> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_m32adEKxEfCR-J2J55rMGQ"/>
<children xsi:type="notation:DecorationNode" xmi:id="_Kp68oD-yEfCA8aDVRFe8Eg" type="StateName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_Kp68oT-yEfCA8aDVRFe8Eg"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_Kp68oj-yEfCA8aDVRFe8Eg"/>
</children> </children>
<children xsi:type="notation:Compartment" xmi:id="_Kp68oz-yEfCA8aDVRFe8Eg" type="StateTextCompartment"> <styles xsi:type="notation:ShapeStyle" xmi:id="_m31zYUKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="16448250" lineColor="12632256"/>
<children xsi:type="notation:Shape" xmi:id="_Kp68pD-yEfCA8aDVRFe8Eg" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752"> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_m31zYkKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_Kp68pT-yEfCA8aDVRFe8Eg"/> </children>
<children xmi:id="_m32adUKxEfCR-J2J55rMGQ" type="Region" element="_m3vFsUKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_m32aeEKxEfCR-J2J55rMGQ" type="RegionName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_m32aeUKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_m32aekKxEfCR-J2J55rMGQ"/>
</children>
<children xsi:type="notation:Shape" xmi:id="_m32ae0KxEfCR-J2J55rMGQ" type="RegionCompartment" fontName="Verdana" lineColor="4210752">
<children xmi:id="_o5DdMEKxEfCR-J2J55rMGQ" type="State" element="_o5BoAEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_o5DdNEKxEfCR-J2J55rMGQ" type="StateName">
<styles xsi:type="notation:ShapeStyle" xmi:id="_o5DdNUKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_o5DdNkKxEfCR-J2J55rMGQ"/>
</children>
<children xsi:type="notation:Compartment" xmi:id="_o5DdN0KxEfCR-J2J55rMGQ" type="StateTextCompartment">
<children xsi:type="notation:Shape" xmi:id="_o5EEQEKxEfCR-J2J55rMGQ" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_o5EEQUKxEfCR-J2J55rMGQ"/>
</children> </children>
</children> </children>
<children xsi:type="notation:Compartment" xmi:id="_Kp7jsD-yEfCA8aDVRFe8Eg" type="StateFigureCompartment"/> <children xsi:type="notation:Compartment" xmi:id="_o5EEQkKxEfCR-J2J55rMGQ" type="StateFigureCompartment"/>
<styles xsi:type="notation:ShapeStyle" xmi:id="_Kp5ugT-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="15720400" lineColor="12632256"/> <styles xsi:type="notation:ShapeStyle" xmi:id="_o5DdMUKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="15720400" lineColor="12632256"/>
<styles xsi:type="notation:FontStyle" xmi:id="_Kp5ugj-yEfCA8aDVRFe8Eg"/> <styles xsi:type="notation:FontStyle" xmi:id="_o5DdMkKxEfCR-J2J55rMGQ"/>
<styles xsi:type="notation:BooleanValueStyle" xmi:id="_Kp7jsT-yEfCA8aDVRFe8Eg" name="isHorizontal" booleanValue="true"/> <styles xsi:type="notation:BooleanValueStyle" xmi:id="_o5EEQ0KxEfCR-J2J55rMGQ" name="isHorizontal" booleanValue="true"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_Kp5ugz-yEfCA8aDVRFe8Eg" x="1086" y="369" width="91" height="69"/> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_o5DdM0KxEfCR-J2J55rMGQ" x="76" y="110" width="142" height="53"/>
</children> </children>
<children xmi:id="_XxMU4D-yEfCA8aDVRFe8Eg" type="Entry" element="_XxLt0D-yEfCA8aDVRFe8Eg"> <children xmi:id="_pExlAEKxEfCR-J2J55rMGQ" type="State" element="_pEw98EKxEfCR-J2J55rMGQ">
<children xmi:id="_XxM78D-yEfCA8aDVRFe8Eg" type="BorderItemLabelContainer"> <children xsi:type="notation:DecorationNode" xmi:id="_pEyMEEKxEfCR-J2J55rMGQ" type="StateName">
<children xsi:type="notation:DecorationNode" xmi:id="_XxM78z-yEfCA8aDVRFe8Eg" type="BorderItemLabel"> <styles xsi:type="notation:ShapeStyle" xmi:id="_pEyMEUKxEfCR-J2J55rMGQ"/>
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxM79D-yEfCA8aDVRFe8Eg"/> <layoutConstraint xsi:type="notation:Location" xmi:id="_pEyMEkKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_XxM79T-yEfCA8aDVRFe8Eg"/>
</children> </children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxM78T-yEfCA8aDVRFe8Eg" fontName="Verdana" lineColor="4210752"/> <children xsi:type="notation:Compartment" xmi:id="_pEyzIEKxEfCR-J2J55rMGQ" type="StateTextCompartment">
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_XxM78j-yEfCA8aDVRFe8Eg"/> <children xsi:type="notation:Shape" xmi:id="_pEyzIUKxEfCR-J2J55rMGQ" type="StateTextCompartmentExpression" fontName="Verdana" lineColor="4210752">
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_pEyzIkKxEfCR-J2J55rMGQ"/>
</children> </children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_XxMU4T-yEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="0" lineColor="16777215"/> </children>
<styles xsi:type="notation:NamedStyle" xmi:id="_XxMU4j-yEfCA8aDVRFe8Eg" name="allowColors"/> <children xsi:type="notation:Compartment" xmi:id="_pEyzI0KxEfCR-J2J55rMGQ" type="StateFigureCompartment"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_XxMU4z-yEfCA8aDVRFe8Eg" x="1134" y="132" width="15" height="15"/> <styles xsi:type="notation:ShapeStyle" xmi:id="_pExlAUKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="15720400" lineColor="12632256"/>
<styles xsi:type="notation:FontStyle" xmi:id="_pExlAkKxEfCR-J2J55rMGQ"/>
<styles xsi:type="notation:BooleanValueStyle" xmi:id="_pEyzJEKxEfCR-J2J55rMGQ" name="isHorizontal" booleanValue="true"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_pExlA0KxEfCR-J2J55rMGQ" x="76" y="314" width="138" height="53"/>
</children>
<children xmi:id="_2YtgQEKxEfCR-J2J55rMGQ" type="Entry" element="_2YsSIEKxEfCR-J2J55rMGQ">
<children xmi:id="_2YuHUEKxEfCR-J2J55rMGQ" type="BorderItemLabelContainer">
<children xsi:type="notation:DecorationNode" xmi:id="_2YuHU0KxEfCR-J2J55rMGQ" type="BorderItemLabel">
<styles xsi:type="notation:ShapeStyle" xmi:id="_2YuHVEKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_2YuHVUKxEfCR-J2J55rMGQ"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_2YuHUUKxEfCR-J2J55rMGQ" fontName="Verdana" lineColor="4210752"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_2YuHUkKxEfCR-J2J55rMGQ"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_2YtgQUKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="0" lineColor="16777215"/>
<styles xsi:type="notation:NamedStyle" xmi:id="_2YtgQkKxEfCR-J2J55rMGQ" name="allowColors"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_2YtgQ0KxEfCR-J2J55rMGQ" x="172" y="68"/>
</children>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_m32afEKxEfCR-J2J55rMGQ"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_m32adkKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="16448250" lineColor="12632256"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_m32ad0KxEfCR-J2J55rMGQ"/>
</children>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_m3w64UKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="15720400" lineColor="12632256"/>
<styles xsi:type="notation:FontStyle" xmi:id="_m3w64kKxEfCR-J2J55rMGQ"/>
<styles xsi:type="notation:BooleanValueStyle" xmi:id="_m3yJBUKxEfCR-J2J55rMGQ" name="isHorizontal" booleanValue="true"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_m3w640KxEfCR-J2J55rMGQ" x="78" y="22" width="1586" height="665"/>
</children>
<children xmi:id="_3ovkwEKxEfCR-J2J55rMGQ" type="Entry" element="_3ou9sEKxEfCR-J2J55rMGQ">
<children xmi:id="_3owL0EKxEfCR-J2J55rMGQ" type="BorderItemLabelContainer">
<children xsi:type="notation:DecorationNode" xmi:id="_3owL00KxEfCR-J2J55rMGQ" type="BorderItemLabel">
<styles xsi:type="notation:ShapeStyle" xmi:id="_3owL1EKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_3owL1UKxEfCR-J2J55rMGQ"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_3owL0UKxEfCR-J2J55rMGQ" fontName="Verdana" lineColor="4210752"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_3owL0kKxEfCR-J2J55rMGQ"/>
</children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_3ovkwUKxEfCR-J2J55rMGQ" fontName="Verdana" fillColor="0" lineColor="16777215"/>
<styles xsi:type="notation:NamedStyle" xmi:id="_3ovkwkKxEfCR-J2J55rMGQ" name="allowColors"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_3ovkw0KxEfCR-J2J55rMGQ" x="32" y="46" width="15" height="15"/>
</children> </children>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_jCeH6D-lEfCA8aDVRFe8Eg"/> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_jCeH6D-lEfCA8aDVRFe8Eg"/>
</children> </children>
<styles xsi:type="notation:ShapeStyle" xmi:id="_jCeH6T-lEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="16448250" lineColor="12632256"/> <styles xsi:type="notation:ShapeStyle" xmi:id="_jCeH6T-lEfCA8aDVRFe8Eg" fontName="Verdana" fillColor="16448250" lineColor="12632256"/>
<layoutConstraint xsi:type="notation:Bounds" xmi:id="_jCeH6j-lEfCA8aDVRFe8Eg" x="56" y="87" width="1437" height="632"/> <layoutConstraint xsi:type="notation:Bounds" xmi:id="_jCeH6j-lEfCA8aDVRFe8Eg" x="56" y="87" width="2330" height="752"/>
</children> </children>
<children xsi:type="notation:Shape" xmi:id="_jCeH6z-lEfCA8aDVRFe8Eg" type="StatechartText" fontName="Verdana" lineColor="4210752"> <children xsi:type="notation:Shape" xmi:id="_jCeH6z-lEfCA8aDVRFe8Eg" type="StatechartText" fontName="Verdana" lineColor="4210752">
<children xsi:type="notation:DecorationNode" xmi:id="_jCeH7D-lEfCA8aDVRFe8Eg" type="StatechartName"> <children xsi:type="notation:DecorationNode" xmi:id="_jCeH7D-lEfCA8aDVRFe8Eg" type="StatechartName">
@ -250,7 +365,7 @@
</children> </children>
<styles xsi:type="notation:ConnectorStyle" xmi:id="_n4LxMz-zEfCA8aDVRFe8Eg" routing="Rectilinear" lineColor="4210752"/> <styles xsi:type="notation:ConnectorStyle" xmi:id="_n4LxMz-zEfCA8aDVRFe8Eg" routing="Rectilinear" lineColor="4210752"/>
<styles xsi:type="notation:FontStyle" xmi:id="_n4LxMj-zEfCA8aDVRFe8Eg" fontName="Verdana"/> <styles xsi:type="notation:FontStyle" xmi:id="_n4LxMj-zEfCA8aDVRFe8Eg" fontName="Verdana"/>
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_n4LxMT-zEfCA8aDVRFe8Eg" points="[5, -3, -240, -24]$[200, -3, -45, -24]"/> <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_n4LxMT-zEfCA8aDVRFe8Eg" points="[5, -4, -240, -25]$[200, -4, -45, -25]"/>
<sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_n4LxMD-zEfCA8aDVRFe8Eg" id="(0.9166666666666666,0.4528301886792453)"/> <sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_n4LxMD-zEfCA8aDVRFe8Eg" id="(0.9166666666666666,0.4528301886792453)"/>
</edges> </edges>
<edges xmi:id="_n4MYSD-zEfCA8aDVRFe8Eg" type="Transition" element="_n4MYNT-zEfCA8aDVRFe8Eg" source="_n4LxID-zEfCA8aDVRFe8Eg" target="_n4MYPD-zEfCA8aDVRFe8Eg"> <edges xmi:id="_n4MYSD-zEfCA8aDVRFe8Eg" type="Transition" element="_n4MYNT-zEfCA8aDVRFe8Eg" source="_n4LxID-zEfCA8aDVRFe8Eg" target="_n4MYPD-zEfCA8aDVRFe8Eg">
@ -335,5 +450,48 @@
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_OVc9wj-zEfCA8aDVRFe8Eg" points="[-2, 41, 133, 49]$[-61, 41, 74, 49]$[-61, -8, 74, 0]$[-119, -8, 16, 0]"/> <bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_OVc9wj-zEfCA8aDVRFe8Eg" points="[-2, 41, 133, 49]$[-61, 41, 74, 49]$[-61, -8, 74, 0]$[-119, -8, 16, 0]"/>
<sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_OVfaAD-zEfCA8aDVRFe8Eg" id="(0.013245033112582781,0.4628099173553719)"/> <sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_OVfaAD-zEfCA8aDVRFe8Eg" id="(0.013245033112582781,0.4628099173553719)"/>
</edges> </edges>
<edges xmi:id="_qfw8UEKxEfCR-J2J55rMGQ" type="Transition" element="_qfvHIEKxEfCR-J2J55rMGQ" source="_o5DdMEKxEfCR-J2J55rMGQ" target="_pExlAEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_qfxjY0KxEfCR-J2J55rMGQ" type="TransitionExpression">
<styles xsi:type="notation:ShapeStyle" xmi:id="_qfxjZEKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_qfxjZUKxEfCR-J2J55rMGQ" x="-5" y="-89"/>
</children>
<styles xsi:type="notation:ConnectorStyle" xmi:id="_qfxjYEKxEfCR-J2J55rMGQ" routing="Rectilinear" lineColor="4210752"/>
<styles xsi:type="notation:FontStyle" xmi:id="_qfxjYkKxEfCR-J2J55rMGQ" fontName="Verdana"/>
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_qfxjYUKxEfCR-J2J55rMGQ" points="[18, 3, 17, -166]$[18, 154, 17, -15]"/>
<sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_qfz_oEKxEfCR-J2J55rMGQ" id="(0.7377049180327869,0.9433962264150944)"/>
<targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_qfz_oUKxEfCR-J2J55rMGQ" id="(0.7540983606557377,0.2830188679245283)"/>
</edges>
<edges xmi:id="_xJ6gIEKxEfCR-J2J55rMGQ" type="Transition" element="_xJ4q8EKxEfCR-J2J55rMGQ" source="_pExlAEKxEfCR-J2J55rMGQ" target="_o5DdMEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_xJ6gJEKxEfCR-J2J55rMGQ" type="TransitionExpression">
<styles xsi:type="notation:ShapeStyle" xmi:id="_xJ6gJUKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_xJ6gJkKxEfCR-J2J55rMGQ" x="3"/>
</children>
<styles xsi:type="notation:ConnectorStyle" xmi:id="_xJ6gIUKxEfCR-J2J55rMGQ" routing="Rectilinear" lineColor="4210752"/>
<styles xsi:type="notation:FontStyle" xmi:id="_xJ6gI0KxEfCR-J2J55rMGQ" fontName="Verdana"/>
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_xJ6gIkKxEfCR-J2J55rMGQ" points="[3, -2, -13, 181]$[3, -153, -13, 30]"/>
<sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_xJ8VUEKxEfCR-J2J55rMGQ" id="(0.08196721311475409,0.03773584905660377)"/>
<targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_xJ8VUUKxEfCR-J2J55rMGQ" id="(0.19672131147540983,0.4339622641509434)"/>
</edges>
<edges xmi:id="_2zzg0EKxEfCR-J2J55rMGQ" type="Transition" element="_2zxroEKxEfCR-J2J55rMGQ" source="_2YtgQEKxEfCR-J2J55rMGQ" target="_o5DdMEKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_2zzg1EKxEfCR-J2J55rMGQ" type="TransitionExpression">
<styles xsi:type="notation:ShapeStyle" xmi:id="_2zzg1UKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_2zzg1kKxEfCR-J2J55rMGQ" y="10"/>
</children>
<styles xsi:type="notation:ConnectorStyle" xmi:id="_2zzg0UKxEfCR-J2J55rMGQ" routing="Rectilinear" lineColor="4210752"/>
<styles xsi:type="notation:FontStyle" xmi:id="_2zzg00KxEfCR-J2J55rMGQ" fontName="Verdana"/>
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_2zzg0kKxEfCR-J2J55rMGQ" points="[4, 4, 1, -33]$[4, 30, 1, -7]"/>
<targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_2z19EEKxEfCR-J2J55rMGQ" id="(0.7535211267605634,0.16981132075471697)"/>
</edges>
<edges xmi:id="_4OSh0EKxEfCR-J2J55rMGQ" type="Transition" element="_4ORTsEKxEfCR-J2J55rMGQ" source="_3ovkwEKxEfCR-J2J55rMGQ" target="_m3w64EKxEfCR-J2J55rMGQ">
<children xsi:type="notation:DecorationNode" xmi:id="_4OTI4EKxEfCR-J2J55rMGQ" type="TransitionExpression">
<styles xsi:type="notation:ShapeStyle" xmi:id="_4OTI4UKxEfCR-J2J55rMGQ"/>
<layoutConstraint xsi:type="notation:Location" xmi:id="_4OTI4kKxEfCR-J2J55rMGQ" y="10"/>
</children>
<styles xsi:type="notation:ConnectorStyle" xmi:id="_4OSh0UKxEfCR-J2J55rMGQ" routing="Rectilinear" lineColor="4210752"/>
<styles xsi:type="notation:FontStyle" xmi:id="_4OSh00KxEfCR-J2J55rMGQ" fontName="Verdana"/>
<bendpoints xsi:type="notation:RelativeBendpoints" xmi:id="_4OSh0kKxEfCR-J2J55rMGQ" points="[8, 7, -90, 22]$[40, 7, -58, 22]"/>
<sourceAnchor xsi:type="notation:IdentityAnchor" xmi:id="_4OU-EEKxEfCR-J2J55rMGQ" id="(0.4,0.0)"/>
<targetAnchor xsi:type="notation:IdentityAnchor" xmi:id="_4OU-EUKxEfCR-J2J55rMGQ" id="(0.03656998738965952,0.013533834586466165)"/>
</edges>
</notation:Diagram> </notation:Diagram>
</xmi:XMI> </xmi:XMI>

View file

@ -15,51 +15,68 @@ Implementation of the state machine 'Statechart'
#endif #endif
/* prototypes of all internal functions */ /* prototypes of all internal functions */
static void enact_main_region_on_r1_responding(Statechart* handle); static void enact_main_region_everything_r1_on_r1_responding(Statechart* handle);
static void enact_main_region_on_r1_sensor_error(Statechart* handle); static void enact_main_region_everything_r1_on_r1_sensor_error(Statechart* handle);
static void enact_main_region_on_r2_pressed(Statechart* handle); static void enact_main_region_everything_r1_on_r2_pressed(Statechart* handle);
static void exact_main_region_on_r2_pressed(Statechart* handle); static void exact_main_region_everything_r1_on_r2_pressed(Statechart* handle);
static void enseq_main_region_on_default(Statechart* handle); static void enseq_main_region_everything_default(Statechart* handle);
static void enseq_main_region_on_r1_responding_default(Statechart* handle); static void enseq_main_region_everything_r1_off_default(Statechart* handle);
static void enseq_main_region_on_r1_sensor_error_default(Statechart* handle); static void enseq_main_region_everything_r1_on_default(Statechart* handle);
static void enseq_main_region_on_r2_not_pressed_default(Statechart* handle); static void enseq_main_region_everything_r1_on_r1_responding_default(Statechart* handle);
static void enseq_main_region_on_r2_pressed_default(Statechart* handle); static void enseq_main_region_everything_r1_on_r1_sensor_error_default(Statechart* handle);
static void enseq_main_region_off_default(Statechart* handle); static void enseq_main_region_everything_r1_on_r2_not_pressed_default(Statechart* handle);
static void enseq_main_region_everything_r1_on_r2_pressed_default(Statechart* handle);
static void enseq_main_region_everything_pollButton_button0_default(Statechart* handle);
static void enseq_main_region_everything_pollButton_button1_default(Statechart* handle);
static void enseq_main_region_default(Statechart* handle); static void enseq_main_region_default(Statechart* handle);
static void enseq_main_region_on_r1_default(Statechart* handle); static void enseq_main_region_everything_r1_default(Statechart* handle);
static void enseq_main_region_on_r2_default(Statechart* handle); static void enseq_main_region_everything_r1_on_r1_default(Statechart* handle);
static void exseq_main_region_on(Statechart* handle); static void enseq_main_region_everything_r1_on_r2_default(Statechart* handle);
static void exseq_main_region_on_r1_responding(Statechart* handle); static void enseq_main_region_everything_pollButton_default(Statechart* handle);
static void exseq_main_region_on_r1_sensor_error(Statechart* handle); static void exseq_main_region_everything_r1_off(Statechart* handle);
static void exseq_main_region_on_r2_not_pressed(Statechart* handle); static void exseq_main_region_everything_r1_on(Statechart* handle);
static void exseq_main_region_on_r2_pressed(Statechart* handle); static void exseq_main_region_everything_r1_on_r1_responding(Statechart* handle);
static void exseq_main_region_off(Statechart* handle); static void exseq_main_region_everything_r1_on_r1_sensor_error(Statechart* handle);
static void exseq_main_region_everything_r1_on_r2_not_pressed(Statechart* handle);
static void exseq_main_region_everything_r1_on_r2_pressed(Statechart* handle);
static void exseq_main_region_everything_pollButton_button0(Statechart* handle);
static void exseq_main_region_everything_pollButton_button1(Statechart* handle);
static void exseq_main_region(Statechart* handle); static void exseq_main_region(Statechart* handle);
static void exseq_main_region_on_r1(Statechart* handle); static void exseq_main_region_everything_r1_on_r1(Statechart* handle);
static void exseq_main_region_on_r2(Statechart* handle); static void exseq_main_region_everything_r1_on_r2(Statechart* handle);
static void react_main_region_on_r1__choice_0(Statechart* handle); static void react_main_region_everything_r1_on_r1__choice_0(Statechart* handle);
static void react_main_region_on_r1__entry_Default(Statechart* handle); static void react_main_region_everything_r1__entry_Default(Statechart* handle);
static void react_main_region_on_r2__entry_Default(Statechart* handle); static void react_main_region_everything_r1_on_r1__entry_Default(Statechart* handle);
static void react_main_region_everything_r1_on_r2__entry_Default(Statechart* handle);
static void react_main_region_everything_pollButton__entry_Default(Statechart* handle);
static void react_main_region__entry_Default(Statechart* handle); static void react_main_region__entry_Default(Statechart* handle);
/*! The reactions of state off. */
static sc_integer main_region_everything_r1_off_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state responding. */ /*! The reactions of state responding. */
static sc_integer main_region_on_r1_responding_react(Statechart* handle, const sc_integer transitioned_before); static sc_integer main_region_everything_r1_on_r1_responding_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state sensor_error. */ /*! The reactions of state sensor_error. */
static sc_integer main_region_on_r1_sensor_error_react(Statechart* handle, const sc_integer transitioned_before); static sc_integer main_region_everything_r1_on_r1_sensor_error_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state not_pressed. */ /*! The reactions of state not_pressed. */
static sc_integer main_region_on_r2_not_pressed_react(Statechart* handle, const sc_integer transitioned_before); static sc_integer main_region_everything_r1_on_r2_not_pressed_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state pressed. */ /*! The reactions of state pressed. */
static sc_integer main_region_on_r2_pressed_react(Statechart* handle, const sc_integer transitioned_before); static sc_integer main_region_everything_r1_on_r2_pressed_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state off. */ /*! The reactions of state button0. */
static sc_integer main_region_off_react(Statechart* handle, const sc_integer transitioned_before); static sc_integer main_region_everything_pollButton_button0_react(Statechart* handle, const sc_integer transitioned_before);
/*! The reactions of state button1. */
static sc_integer main_region_everything_pollButton_button1_react(Statechart* handle, const sc_integer transitioned_before);
static void clear_in_events(Statechart* handle); static void clear_in_events(Statechart* handle);
static void clear_internal_events(Statechart* handle);
static void micro_step(Statechart* handle); static void micro_step(Statechart* handle);
/*! Performs a 'run to completion' step. */ /*! Performs a 'run to completion' step. */
@ -99,6 +116,7 @@ void statechart_init(Statechart* handle)
clear_in_events(handle); clear_in_events(handle);
clear_internal_events(handle);
sc_observable_int32_t_init(&handle->iface.setMotorR); sc_observable_int32_t_init(&handle->iface.setMotorR);
sc_observable_int32_t_init(&handle->iface.setMotorL); sc_observable_int32_t_init(&handle->iface.setMotorL);
@ -107,6 +125,7 @@ void statechart_init(Statechart* handle)
statechart_internal_set_speed(handle, 0); statechart_internal_set_speed(handle, 0);
handle->isExecuting = bool_false; handle->isExecuting = bool_false;
statechart_eventqueue_init(&handle->internal_event_queue, handle->internal_buffer, STATECHART_INTERNAL_EVENTQUEUE_BUFFERSIZE);
statechart_eventqueue_init(&handle->in_event_queue, handle->in_buffer, STATECHART_IN_EVENTQUEUE_BUFFERSIZE); statechart_eventqueue_init(&handle->in_event_queue, handle->in_buffer, STATECHART_IN_EVENTQUEUE_BUFFERSIZE);
} }
@ -135,7 +154,8 @@ void statechart_exit(Statechart* handle)
exseq_main_region(handle); exseq_main_region(handle);
handle->stateConfVector[0] = Statechart_last_state; handle->stateConfVector[0] = Statechart_last_state;
handle->stateConfVector[1] = Statechart_last_state; handle->stateConfVector[1] = Statechart_last_state;
handle->stateConfVectorPosition = 1; handle->stateConfVector[2] = Statechart_last_state;
handle->stateConfVectorPosition = 2;
handle->isExecuting = bool_false; handle->isExecuting = bool_false;
} }
@ -184,28 +204,40 @@ sc_boolean statechart_is_state_active(const Statechart* handle, StatechartStates
sc_boolean result = bool_false; sc_boolean result = bool_false;
switch (state) switch (state)
{ {
case Statechart_main_region_on : case Statechart_main_region_everything :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON] >= Statechart_main_region_on result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING] >= Statechart_main_region_everything
&& handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON] <= Statechart_main_region_on_r2_pressed); && handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING] <= Statechart_main_region_everything_pollButton_button1);
break; break;
case Statechart_main_region_on_r1_responding : case Statechart_main_region_everything_r1_off :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON_R1_RESPONDING] == Statechart_main_region_on_r1_responding result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_OFF] == Statechart_main_region_everything_r1_off
); );
break; break;
case Statechart_main_region_on_r1_sensor_error : case Statechart_main_region_everything_r1_on :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON_R1_SENSOR_ERROR] == Statechart_main_region_on_r1_sensor_error result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON] >= Statechart_main_region_everything_r1_on
&& handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON] <= Statechart_main_region_everything_r1_on_r2_pressed);
break;
case Statechart_main_region_everything_r1_on_r1_responding :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R1_RESPONDING] == Statechart_main_region_everything_r1_on_r1_responding
); );
break; break;
case Statechart_main_region_on_r2_not_pressed : case Statechart_main_region_everything_r1_on_r1_sensor_error :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON_R2_NOT_PRESSED] == Statechart_main_region_on_r2_not_pressed result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R1_SENSOR_ERROR] == Statechart_main_region_everything_r1_on_r1_sensor_error
); );
break; break;
case Statechart_main_region_on_r2_pressed : case Statechart_main_region_everything_r1_on_r2_not_pressed :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_ON_R2_PRESSED] == Statechart_main_region_on_r2_pressed result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R2_NOT_PRESSED] == Statechart_main_region_everything_r1_on_r2_not_pressed
); );
break; break;
case Statechart_main_region_off : case Statechart_main_region_everything_r1_on_r2_pressed :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_OFF] == Statechart_main_region_off result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R2_PRESSED] == Statechart_main_region_everything_r1_on_r2_pressed
);
break;
case Statechart_main_region_everything_pollButton_button0 :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_POLLBUTTON_BUTTON0] == Statechart_main_region_everything_pollButton_button0
);
break;
case Statechart_main_region_everything_pollButton_button1 :
result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHART_MAIN_REGION_EVERYTHING_POLLBUTTON_BUTTON1] == Statechart_main_region_everything_pollButton_button1
); );
break; break;
default: default:
@ -218,9 +250,14 @@ sc_boolean statechart_is_state_active(const Statechart* handle, StatechartStates
static void clear_in_events(Statechart* handle) static void clear_in_events(Statechart* handle)
{ {
handle->iface.sensor_raised = bool_false; handle->iface.sensor_raised = bool_false;
handle->iface.buttonPressed_raised = bool_false; handle->iface.buttonState_raised = bool_false;
handle->iface.buttonReleased_raised = bool_false; handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised = bool_false;
handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised = bool_false; }
static void clear_internal_events(Statechart* handle)
{
handle->internal.buttonPressed_raised = bool_false;
handle->internal.buttonReleased_raised = bool_false;
} }
static void micro_step(Statechart* handle) static void micro_step(Statechart* handle)
@ -229,19 +266,19 @@ static void micro_step(Statechart* handle)
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 0;
switch(handle->stateConfVector[ 0 ]) switch(handle->stateConfVector[ 0 ])
{ {
case Statechart_main_region_on_r1_responding : case Statechart_main_region_everything_r1_off :
{ {
transitioned = main_region_on_r1_responding_react(handle,transitioned); transitioned = main_region_everything_r1_off_react(handle,transitioned);
break; break;
} }
case Statechart_main_region_on_r1_sensor_error : case Statechart_main_region_everything_r1_on_r1_responding :
{ {
transitioned = main_region_on_r1_sensor_error_react(handle,transitioned); transitioned = main_region_everything_r1_on_r1_responding_react(handle,transitioned);
break; break;
} }
case Statechart_main_region_off : case Statechart_main_region_everything_r1_on_r1_sensor_error :
{ {
transitioned = main_region_off_react(handle,transitioned); transitioned = main_region_everything_r1_on_r1_sensor_error_react(handle,transitioned);
break; break;
} }
default: default:
@ -252,14 +289,32 @@ static void micro_step(Statechart* handle)
{ {
switch(handle->stateConfVector[ 1 ]) switch(handle->stateConfVector[ 1 ])
{ {
case Statechart_main_region_on_r2_not_pressed : case Statechart_main_region_everything_r1_on_r2_not_pressed :
{ {
main_region_on_r2_not_pressed_react(handle,transitioned); transitioned = main_region_everything_r1_on_r2_not_pressed_react(handle,transitioned);
break; break;
} }
case Statechart_main_region_on_r2_pressed : case Statechart_main_region_everything_r1_on_r2_pressed :
{ {
main_region_on_r2_pressed_react(handle,transitioned); transitioned = main_region_everything_r1_on_r2_pressed_react(handle,transitioned);
break;
}
default:
/* do nothing */
break;
}
} if ((handle->stateConfVectorPosition) < (2))
{
switch(handle->stateConfVector[ 2 ])
{
case Statechart_main_region_everything_pollButton_button0 :
{
main_region_everything_pollButton_button0_react(handle,transitioned);
break;
}
case Statechart_main_region_everything_pollButton_button1 :
{
main_region_everything_pollButton_button1_react(handle,transitioned);
break; break;
} }
default: default:
@ -282,6 +337,7 @@ static void run_cycle(Statechart* handle)
{ {
micro_step(handle); micro_step(handle);
clear_in_events(handle); clear_in_events(handle);
clear_internal_events(handle);
} while (statechart_dispatch_next_event(handle) == bool_true); } while (statechart_dispatch_next_event(handle) == bool_true);
handle->isExecuting = bool_false; handle->isExecuting = bool_false;
} }
@ -293,15 +349,9 @@ void statechart_raise_sensor(Statechart* handle, int32_t value)
run_cycle(handle); run_cycle(handle);
} }
void statechart_raise_buttonPressed(Statechart* handle) void statechart_raise_buttonState(Statechart* handle, sc_boolean value)
{ {
statechart_add_event_to_queue(&(handle->in_event_queue), Statechart_buttonPressed); statechart_add_value_event_to_queue(&(handle->in_event_queue), Statechart_buttonState, &value);
run_cycle(handle);
}
void statechart_raise_buttonReleased(Statechart* handle)
{
statechart_add_event_to_queue(&(handle->in_event_queue), Statechart_buttonReleased);
run_cycle(handle); run_cycle(handle);
} }
@ -329,7 +379,7 @@ static void statechart_internal_set_pid_vars(Statechart* handle, pid_vars_t valu
/* implementations of all internal functions */ /* implementations of all internal functions */
/* Entry action for state 'responding'. */ /* Entry action for state 'responding'. */
static void enact_main_region_on_r1_responding(Statechart* handle) static void enact_main_region_everything_r1_on_r1_responding(Statechart* handle)
{ {
/* Entry action for state 'responding'. */ /* Entry action for state 'responding'. */
statechart_internal_set_speed(handle, statechart_pid(handle,handle->iface.sensor_value, handle->internal.pid_vars)); statechart_internal_set_speed(handle, statechart_pid(handle,handle->iface.sensor_value, handle->internal.pid_vars));
@ -344,7 +394,7 @@ static void enact_main_region_on_r1_responding(Statechart* handle)
} }
/* Entry action for state 'sensor_error'. */ /* Entry action for state 'sensor_error'. */
static void enact_main_region_on_r1_sensor_error(Statechart* handle) static void enact_main_region_everything_r1_on_r1_sensor_error(Statechart* handle)
{ {
/* Entry action for state 'sensor_error'. */ /* Entry action for state 'sensor_error'. */
{ {
@ -358,68 +408,92 @@ static void enact_main_region_on_r1_sensor_error(Statechart* handle)
} }
/* Entry action for state 'pressed'. */ /* Entry action for state 'pressed'. */
static void enact_main_region_on_r2_pressed(Statechart* handle) static void enact_main_region_everything_r1_on_r2_pressed(Statechart* handle)
{ {
/* Entry action for state 'pressed'. */ /* Entry action for state 'pressed'. */
statechart_set_timer(handle, (sc_eventid) &(handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised) , (((sc_time) 2) * 1000), bool_false); statechart_set_timer(handle, (sc_eventid) &(handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised) , (((sc_time) 2) * 1000), bool_false);
} }
/* Exit action for state 'pressed'. */ /* Exit action for state 'pressed'. */
static void exact_main_region_on_r2_pressed(Statechart* handle) static void exact_main_region_everything_r1_on_r2_pressed(Statechart* handle)
{ {
/* Exit action for state 'pressed'. */ /* Exit action for state 'pressed'. */
statechart_unset_timer(handle, (sc_eventid) &(handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised) ); statechart_unset_timer(handle, (sc_eventid) &(handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised) );
}
/* 'default' enter sequence for state everything */
static void enseq_main_region_everything_default(Statechart* handle)
{
/* 'default' enter sequence for state everything */
enseq_main_region_everything_r1_default(handle);
enseq_main_region_everything_pollButton_default(handle);
}
/* 'default' enter sequence for state off */
static void enseq_main_region_everything_r1_off_default(Statechart* handle)
{
/* 'default' enter sequence for state off */
handle->stateConfVector[0] = Statechart_main_region_everything_r1_off;
handle->stateConfVectorPosition = 0;
} }
/* 'default' enter sequence for state on */ /* 'default' enter sequence for state on */
static void enseq_main_region_on_default(Statechart* handle) static void enseq_main_region_everything_r1_on_default(Statechart* handle)
{ {
/* 'default' enter sequence for state on */ /* 'default' enter sequence for state on */
enseq_main_region_on_r1_default(handle); enseq_main_region_everything_r1_on_r1_default(handle);
enseq_main_region_on_r2_default(handle); enseq_main_region_everything_r1_on_r2_default(handle);
} }
/* 'default' enter sequence for state responding */ /* 'default' enter sequence for state responding */
static void enseq_main_region_on_r1_responding_default(Statechart* handle) static void enseq_main_region_everything_r1_on_r1_responding_default(Statechart* handle)
{ {
/* 'default' enter sequence for state responding */ /* 'default' enter sequence for state responding */
enact_main_region_on_r1_responding(handle); enact_main_region_everything_r1_on_r1_responding(handle);
handle->stateConfVector[0] = Statechart_main_region_on_r1_responding; handle->stateConfVector[0] = Statechart_main_region_everything_r1_on_r1_responding;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 0;
} }
/* 'default' enter sequence for state sensor_error */ /* 'default' enter sequence for state sensor_error */
static void enseq_main_region_on_r1_sensor_error_default(Statechart* handle) static void enseq_main_region_everything_r1_on_r1_sensor_error_default(Statechart* handle)
{ {
/* 'default' enter sequence for state sensor_error */ /* 'default' enter sequence for state sensor_error */
enact_main_region_on_r1_sensor_error(handle); enact_main_region_everything_r1_on_r1_sensor_error(handle);
handle->stateConfVector[0] = Statechart_main_region_on_r1_sensor_error; handle->stateConfVector[0] = Statechart_main_region_everything_r1_on_r1_sensor_error;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 0;
} }
/* 'default' enter sequence for state not_pressed */ /* 'default' enter sequence for state not_pressed */
static void enseq_main_region_on_r2_not_pressed_default(Statechart* handle) static void enseq_main_region_everything_r1_on_r2_not_pressed_default(Statechart* handle)
{ {
/* 'default' enter sequence for state not_pressed */ /* 'default' enter sequence for state not_pressed */
handle->stateConfVector[1] = Statechart_main_region_on_r2_not_pressed; handle->stateConfVector[1] = Statechart_main_region_everything_r1_on_r2_not_pressed;
handle->stateConfVectorPosition = 1; handle->stateConfVectorPosition = 1;
} }
/* 'default' enter sequence for state pressed */ /* 'default' enter sequence for state pressed */
static void enseq_main_region_on_r2_pressed_default(Statechart* handle) static void enseq_main_region_everything_r1_on_r2_pressed_default(Statechart* handle)
{ {
/* 'default' enter sequence for state pressed */ /* 'default' enter sequence for state pressed */
enact_main_region_on_r2_pressed(handle); enact_main_region_everything_r1_on_r2_pressed(handle);
handle->stateConfVector[1] = Statechart_main_region_on_r2_pressed; handle->stateConfVector[1] = Statechart_main_region_everything_r1_on_r2_pressed;
handle->stateConfVectorPosition = 1; handle->stateConfVectorPosition = 1;
} }
/* 'default' enter sequence for state off */ /* 'default' enter sequence for state button0 */
static void enseq_main_region_off_default(Statechart* handle) static void enseq_main_region_everything_pollButton_button0_default(Statechart* handle)
{ {
/* 'default' enter sequence for state off */ /* 'default' enter sequence for state button0 */
handle->stateConfVector[0] = Statechart_main_region_off; handle->stateConfVector[2] = Statechart_main_region_everything_pollButton_button0;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 2;
}
/* 'default' enter sequence for state button1 */
static void enseq_main_region_everything_pollButton_button1_default(Statechart* handle)
{
/* 'default' enter sequence for state button1 */
handle->stateConfVector[2] = Statechart_main_region_everything_pollButton_button1;
handle->stateConfVectorPosition = 2;
} }
/* 'default' enter sequence for region main region */ /* 'default' enter sequence for region main region */
@ -430,69 +504,99 @@ static void enseq_main_region_default(Statechart* handle)
} }
/* 'default' enter sequence for region r1 */ /* 'default' enter sequence for region r1 */
static void enseq_main_region_on_r1_default(Statechart* handle) static void enseq_main_region_everything_r1_default(Statechart* handle)
{ {
/* 'default' enter sequence for region r1 */ /* 'default' enter sequence for region r1 */
react_main_region_on_r1__entry_Default(handle); react_main_region_everything_r1__entry_Default(handle);
}
/* 'default' enter sequence for region r1 */
static void enseq_main_region_everything_r1_on_r1_default(Statechart* handle)
{
/* 'default' enter sequence for region r1 */
react_main_region_everything_r1_on_r1__entry_Default(handle);
} }
/* 'default' enter sequence for region r2 */ /* 'default' enter sequence for region r2 */
static void enseq_main_region_on_r2_default(Statechart* handle) static void enseq_main_region_everything_r1_on_r2_default(Statechart* handle)
{ {
/* 'default' enter sequence for region r2 */ /* 'default' enter sequence for region r2 */
react_main_region_on_r2__entry_Default(handle); react_main_region_everything_r1_on_r2__entry_Default(handle);
}
/* 'default' enter sequence for region pollButton */
static void enseq_main_region_everything_pollButton_default(Statechart* handle)
{
/* 'default' enter sequence for region pollButton */
react_main_region_everything_pollButton__entry_Default(handle);
}
/* Default exit sequence for state off */
static void exseq_main_region_everything_r1_off(Statechart* handle)
{
/* Default exit sequence for state off */
handle->stateConfVector[0] = Statechart_main_region_everything;
handle->stateConfVectorPosition = 0;
} }
/* Default exit sequence for state on */ /* Default exit sequence for state on */
static void exseq_main_region_on(Statechart* handle) static void exseq_main_region_everything_r1_on(Statechart* handle)
{ {
/* Default exit sequence for state on */ /* Default exit sequence for state on */
exseq_main_region_on_r1(handle); exseq_main_region_everything_r1_on_r1(handle);
exseq_main_region_on_r2(handle); exseq_main_region_everything_r1_on_r2(handle);
handle->stateConfVector[0] = Statechart_last_state; handle->stateConfVector[0] = Statechart_main_region_everything;
handle->stateConfVector[1] = Statechart_last_state; handle->stateConfVector[1] = Statechart_main_region_everything;
handle->stateConfVectorPosition = 1; handle->stateConfVectorPosition = 1;
} }
/* Default exit sequence for state responding */ /* Default exit sequence for state responding */
static void exseq_main_region_on_r1_responding(Statechart* handle) static void exseq_main_region_everything_r1_on_r1_responding(Statechart* handle)
{ {
/* Default exit sequence for state responding */ /* Default exit sequence for state responding */
handle->stateConfVector[0] = Statechart_main_region_on; handle->stateConfVector[0] = Statechart_main_region_everything_r1_on;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 0;
} }
/* Default exit sequence for state sensor_error */ /* Default exit sequence for state sensor_error */
static void exseq_main_region_on_r1_sensor_error(Statechart* handle) static void exseq_main_region_everything_r1_on_r1_sensor_error(Statechart* handle)
{ {
/* Default exit sequence for state sensor_error */ /* Default exit sequence for state sensor_error */
handle->stateConfVector[0] = Statechart_main_region_on; handle->stateConfVector[0] = Statechart_main_region_everything_r1_on;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 0;
} }
/* Default exit sequence for state not_pressed */ /* Default exit sequence for state not_pressed */
static void exseq_main_region_on_r2_not_pressed(Statechart* handle) static void exseq_main_region_everything_r1_on_r2_not_pressed(Statechart* handle)
{ {
/* Default exit sequence for state not_pressed */ /* Default exit sequence for state not_pressed */
handle->stateConfVector[1] = Statechart_main_region_on; handle->stateConfVector[1] = Statechart_main_region_everything_r1_on;
handle->stateConfVectorPosition = 1; handle->stateConfVectorPosition = 1;
} }
/* Default exit sequence for state pressed */ /* Default exit sequence for state pressed */
static void exseq_main_region_on_r2_pressed(Statechart* handle) static void exseq_main_region_everything_r1_on_r2_pressed(Statechart* handle)
{ {
/* Default exit sequence for state pressed */ /* Default exit sequence for state pressed */
handle->stateConfVector[1] = Statechart_main_region_on; handle->stateConfVector[1] = Statechart_main_region_everything_r1_on;
handle->stateConfVectorPosition = 1; handle->stateConfVectorPosition = 1;
exact_main_region_on_r2_pressed(handle); exact_main_region_everything_r1_on_r2_pressed(handle);
} }
/* Default exit sequence for state off */ /* Default exit sequence for state button0 */
static void exseq_main_region_off(Statechart* handle) static void exseq_main_region_everything_pollButton_button0(Statechart* handle)
{ {
/* Default exit sequence for state off */ /* Default exit sequence for state button0 */
handle->stateConfVector[0] = Statechart_last_state; handle->stateConfVector[2] = Statechart_main_region_everything;
handle->stateConfVectorPosition = 0; handle->stateConfVectorPosition = 2;
}
/* Default exit sequence for state button1 */
static void exseq_main_region_everything_pollButton_button1(Statechart* handle)
{
/* Default exit sequence for state button1 */
handle->stateConfVector[2] = Statechart_main_region_everything;
handle->stateConfVectorPosition = 2;
} }
/* Default exit sequence for region main region */ /* Default exit sequence for region main region */
@ -502,19 +606,19 @@ static void exseq_main_region(Statechart* handle)
/* Handle exit of all possible states (of Statechart.main_region) at position 0... */ /* Handle exit of all possible states (of Statechart.main_region) at position 0... */
switch(handle->stateConfVector[ 0 ]) switch(handle->stateConfVector[ 0 ])
{ {
case Statechart_main_region_on_r1_responding : case Statechart_main_region_everything_r1_off :
{ {
exseq_main_region_on_r1_responding(handle); exseq_main_region_everything_r1_off(handle);
break; break;
} }
case Statechart_main_region_on_r1_sensor_error : case Statechart_main_region_everything_r1_on_r1_responding :
{ {
exseq_main_region_on_r1_sensor_error(handle); exseq_main_region_everything_r1_on_r1_responding(handle);
break; break;
} }
case Statechart_main_region_off : case Statechart_main_region_everything_r1_on_r1_sensor_error :
{ {
exseq_main_region_off(handle); exseq_main_region_everything_r1_on_r1_sensor_error(handle);
break; break;
} }
default: default:
@ -524,14 +628,31 @@ static void exseq_main_region(Statechart* handle)
/* Handle exit of all possible states (of Statechart.main_region) at position 1... */ /* Handle exit of all possible states (of Statechart.main_region) at position 1... */
switch(handle->stateConfVector[ 1 ]) switch(handle->stateConfVector[ 1 ])
{ {
case Statechart_main_region_on_r2_not_pressed : case Statechart_main_region_everything_r1_on_r2_not_pressed :
{ {
exseq_main_region_on_r2_not_pressed(handle); exseq_main_region_everything_r1_on_r2_not_pressed(handle);
break; break;
} }
case Statechart_main_region_on_r2_pressed : case Statechart_main_region_everything_r1_on_r2_pressed :
{ {
exseq_main_region_on_r2_pressed(handle); exseq_main_region_everything_r1_on_r2_pressed(handle);
break;
}
default:
/* do nothing */
break;
}
/* Handle exit of all possible states (of Statechart.main_region) at position 2... */
switch(handle->stateConfVector[ 2 ])
{
case Statechart_main_region_everything_pollButton_button0 :
{
exseq_main_region_everything_pollButton_button0(handle);
break;
}
case Statechart_main_region_everything_pollButton_button1 :
{
exseq_main_region_everything_pollButton_button1(handle);
break; break;
} }
default: default:
@ -541,20 +662,20 @@ static void exseq_main_region(Statechart* handle)
} }
/* Default exit sequence for region r1 */ /* Default exit sequence for region r1 */
static void exseq_main_region_on_r1(Statechart* handle) static void exseq_main_region_everything_r1_on_r1(Statechart* handle)
{ {
/* Default exit sequence for region r1 */ /* Default exit sequence for region r1 */
/* Handle exit of all possible states (of Statechart.main_region.on.r1) at position 0... */ /* Handle exit of all possible states (of Statechart.main_region.everything.r1.on.r1) at position 0... */
switch(handle->stateConfVector[ 0 ]) switch(handle->stateConfVector[ 0 ])
{ {
case Statechart_main_region_on_r1_responding : case Statechart_main_region_everything_r1_on_r1_responding :
{ {
exseq_main_region_on_r1_responding(handle); exseq_main_region_everything_r1_on_r1_responding(handle);
break; break;
} }
case Statechart_main_region_on_r1_sensor_error : case Statechart_main_region_everything_r1_on_r1_sensor_error :
{ {
exseq_main_region_on_r1_sensor_error(handle); exseq_main_region_everything_r1_on_r1_sensor_error(handle);
break; break;
} }
default: default:
@ -564,20 +685,20 @@ static void exseq_main_region_on_r1(Statechart* handle)
} }
/* Default exit sequence for region r2 */ /* Default exit sequence for region r2 */
static void exseq_main_region_on_r2(Statechart* handle) static void exseq_main_region_everything_r1_on_r2(Statechart* handle)
{ {
/* Default exit sequence for region r2 */ /* Default exit sequence for region r2 */
/* Handle exit of all possible states (of Statechart.main_region.on.r2) at position 1... */ /* Handle exit of all possible states (of Statechart.main_region.everything.r1.on.r2) at position 1... */
switch(handle->stateConfVector[ 1 ]) switch(handle->stateConfVector[ 1 ])
{ {
case Statechart_main_region_on_r2_not_pressed : case Statechart_main_region_everything_r1_on_r2_not_pressed :
{ {
exseq_main_region_on_r2_not_pressed(handle); exseq_main_region_everything_r1_on_r2_not_pressed(handle);
break; break;
} }
case Statechart_main_region_on_r2_pressed : case Statechart_main_region_everything_r1_on_r2_pressed :
{ {
exseq_main_region_on_r2_pressed(handle); exseq_main_region_everything_r1_on_r2_pressed(handle);
break; break;
} }
default: default:
@ -587,41 +708,71 @@ static void exseq_main_region_on_r2(Statechart* handle)
} }
/* The reactions of state null. */ /* The reactions of state null. */
static void react_main_region_on_r1__choice_0(Statechart* handle) static void react_main_region_everything_r1_on_r1__choice_0(Statechart* handle)
{ {
/* The reactions of state null. */ /* The reactions of state null. */
if ((handle->iface.sensor_value) < (0)) if ((handle->iface.sensor_value) < (0))
{ {
enseq_main_region_on_r1_sensor_error_default(handle); enseq_main_region_everything_r1_on_r1_sensor_error_default(handle);
} else } else
{ {
enseq_main_region_on_r1_responding_default(handle); enseq_main_region_everything_r1_on_r1_responding_default(handle);
} }
} }
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
static void react_main_region_on_r1__entry_Default(Statechart* handle) static void react_main_region_everything_r1__entry_Default(Statechart* handle)
{ {
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
enseq_main_region_on_r1_responding_default(handle); enseq_main_region_everything_r1_off_default(handle);
} }
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
static void react_main_region_on_r2__entry_Default(Statechart* handle) static void react_main_region_everything_r1_on_r1__entry_Default(Statechart* handle)
{ {
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
enseq_main_region_on_r2_not_pressed_default(handle); enseq_main_region_everything_r1_on_r1_responding_default(handle);
}
/* Default react sequence for initial entry */
static void react_main_region_everything_r1_on_r2__entry_Default(Statechart* handle)
{
/* Default react sequence for initial entry */
enseq_main_region_everything_r1_on_r2_not_pressed_default(handle);
}
/* Default react sequence for initial entry */
static void react_main_region_everything_pollButton__entry_Default(Statechart* handle)
{
/* Default react sequence for initial entry */
enseq_main_region_everything_pollButton_button0_default(handle);
} }
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
static void react_main_region__entry_Default(Statechart* handle) static void react_main_region__entry_Default(Statechart* handle)
{ {
/* Default react sequence for initial entry */ /* Default react sequence for initial entry */
enseq_main_region_off_default(handle); enseq_main_region_everything_default(handle);
} }
static sc_integer main_region_on_r1_responding_react(Statechart* handle, const sc_integer transitioned_before) static sc_integer main_region_everything_r1_off_react(Statechart* handle, const sc_integer transitioned_before)
{
/* The reactions of state off. */
sc_integer transitioned_after = transitioned_before;
if ((transitioned_after) < (0))
{
if (handle->internal.buttonPressed_raised == bool_true)
{
exseq_main_region_everything_r1_off(handle);
enseq_main_region_everything_r1_on_default(handle);
transitioned_after = 0;
}
}
return transitioned_after;
}
static sc_integer main_region_everything_r1_on_r1_responding_react(Statechart* handle, const sc_integer transitioned_before)
{ {
/* The reactions of state responding. */ /* The reactions of state responding. */
sc_integer transitioned_after = transitioned_before; sc_integer transitioned_after = transitioned_before;
@ -629,15 +780,15 @@ static sc_integer main_region_on_r1_responding_react(Statechart* handle, const s
{ {
if (handle->iface.sensor_raised == bool_true) if (handle->iface.sensor_raised == bool_true)
{ {
exseq_main_region_on_r1_responding(handle); exseq_main_region_everything_r1_on_r1_responding(handle);
react_main_region_on_r1__choice_0(handle); react_main_region_everything_r1_on_r1__choice_0(handle);
transitioned_after = 0; transitioned_after = 0;
} }
} }
return transitioned_after; return transitioned_after;
} }
static sc_integer main_region_on_r1_sensor_error_react(Statechart* handle, const sc_integer transitioned_before) static sc_integer main_region_everything_r1_on_r1_sensor_error_react(Statechart* handle, const sc_integer transitioned_before)
{ {
/* The reactions of state sensor_error. */ /* The reactions of state sensor_error. */
sc_integer transitioned_after = transitioned_before; sc_integer transitioned_after = transitioned_before;
@ -645,24 +796,24 @@ static sc_integer main_region_on_r1_sensor_error_react(Statechart* handle, const
{ {
if (handle->iface.sensor_raised == bool_true) if (handle->iface.sensor_raised == bool_true)
{ {
exseq_main_region_on_r1_sensor_error(handle); exseq_main_region_everything_r1_on_r1_sensor_error(handle);
react_main_region_on_r1__choice_0(handle); react_main_region_everything_r1_on_r1__choice_0(handle);
transitioned_after = 0; transitioned_after = 0;
} }
} }
return transitioned_after; return transitioned_after;
} }
static sc_integer main_region_on_r2_not_pressed_react(Statechart* handle, const sc_integer transitioned_before) static sc_integer main_region_everything_r1_on_r2_not_pressed_react(Statechart* handle, const sc_integer transitioned_before)
{ {
/* The reactions of state not_pressed. */ /* The reactions of state not_pressed. */
sc_integer transitioned_after = transitioned_before; sc_integer transitioned_after = transitioned_before;
if ((transitioned_after) < (1)) if ((transitioned_after) < (1))
{ {
if (handle->iface.buttonPressed_raised == bool_true) if (handle->internal.buttonPressed_raised == bool_true)
{ {
exseq_main_region_on_r2_not_pressed(handle); exseq_main_region_everything_r1_on_r2_not_pressed(handle);
enseq_main_region_on_r2_pressed_default(handle); enseq_main_region_everything_r1_on_r2_pressed_default(handle);
transitioned_after = 1; transitioned_after = 1;
} }
} }
@ -675,24 +826,24 @@ static sc_integer main_region_on_r2_not_pressed_react(Statechart* handle, const
return transitioned_after; return transitioned_after;
} }
static sc_integer main_region_on_r2_pressed_react(Statechart* handle, const sc_integer transitioned_before) static sc_integer main_region_everything_r1_on_r2_pressed_react(Statechart* handle, const sc_integer transitioned_before)
{ {
/* The reactions of state pressed. */ /* The reactions of state pressed. */
sc_integer transitioned_after = transitioned_before; sc_integer transitioned_after = transitioned_before;
if ((transitioned_after) < (1)) if ((transitioned_after) < (1))
{ {
if (handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised == bool_true) if (handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised == bool_true)
{ {
exseq_main_region_on(handle); exseq_main_region_everything_r1_on(handle);
handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised = bool_false; handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised = bool_false;
enseq_main_region_off_default(handle); enseq_main_region_everything_r1_off_default(handle);
transitioned_after = 1; transitioned_after = 1;
} else } else
{ {
if (handle->iface.buttonReleased_raised == bool_true) if (handle->internal.buttonReleased_raised == bool_true)
{ {
exseq_main_region_on_r2_pressed(handle); exseq_main_region_everything_r1_on_r2_pressed(handle);
enseq_main_region_on_r2_not_pressed_default(handle); enseq_main_region_everything_r1_on_r2_not_pressed_default(handle);
transitioned_after = 1; transitioned_after = 1;
} }
} }
@ -706,17 +857,41 @@ static sc_integer main_region_on_r2_pressed_react(Statechart* handle, const sc_i
return transitioned_after; return transitioned_after;
} }
static sc_integer main_region_off_react(Statechart* handle, const sc_integer transitioned_before) static sc_integer main_region_everything_pollButton_button0_react(Statechart* handle, const sc_integer transitioned_before)
{ {
/* The reactions of state off. */ /* The reactions of state button0. */
sc_integer transitioned_after = transitioned_before; sc_integer transitioned_after = transitioned_before;
if ((transitioned_after) < (0)) if ((transitioned_after) < (2))
{ {
if (handle->iface.buttonPressed_raised == bool_true) if (((handle->iface.buttonState_raised) == bool_true) && ((handle->iface.buttonState_value) == bool_true))
{ {
exseq_main_region_off(handle); exseq_main_region_everything_pollButton_button0(handle);
enseq_main_region_on_default(handle); statechart_add_event_to_queue(&(handle->internal_event_queue), Statechart_internal_buttonPressed);
transitioned_after = 0; enseq_main_region_everything_pollButton_button1_default(handle);
transitioned_after = 2;
}
}
/* If no transition was taken */
if ((transitioned_after) == (transitioned_before))
{
/* then execute local reactions. */
transitioned_after = transitioned_before;
}
return transitioned_after;
}
static sc_integer main_region_everything_pollButton_button1_react(Statechart* handle, const sc_integer transitioned_before)
{
/* The reactions of state button1. */
sc_integer transitioned_after = transitioned_before;
if ((transitioned_after) < (2))
{
if (((handle->iface.buttonState_raised) == bool_true) && ((!(handle->iface.buttonState_value)) == bool_true))
{
exseq_main_region_everything_pollButton_button1(handle);
statechart_add_event_to_queue(&(handle->internal_event_queue), Statechart_internal_buttonReleased);
enseq_main_region_everything_pollButton_button0_default(handle);
transitioned_after = 2;
} }
} }
/* If no transition was taken */ /* If no transition was taken */
@ -804,19 +979,25 @@ static sc_boolean statechart_dispatch_event(Statechart* handle, const statechart
handle->iface.sensor_value = event->value.Statechart_sensor_value; handle->iface.sensor_value = event->value.Statechart_sensor_value;
return bool_true; return bool_true;
} }
case Statechart_buttonPressed: case Statechart_buttonState:
{ {
handle->iface.buttonPressed_raised = bool_true; handle->iface.buttonState_raised = bool_true;
handle->iface.buttonState_value = event->value.Statechart_buttonState_value;
return bool_true; return bool_true;
} }
case Statechart_buttonReleased: case Statechart_internal_buttonPressed:
{ {
handle->iface.buttonReleased_raised = bool_true; handle->internal.buttonPressed_raised = bool_true;
return bool_true; return bool_true;
} }
case Statechart_Statechart_main_region_on_r2_pressed_time_event_0: case Statechart_internal_buttonReleased:
{ {
handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised = bool_true; handle->internal.buttonReleased_raised = bool_true;
return bool_true;
}
case Statechart_Statechart_main_region_everything_r1_on_r2_pressed_time_event_0:
{
handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised = bool_true;
return bool_true; return bool_true;
} }
default: default:
@ -828,7 +1009,10 @@ static statechart_event statechart_get_next_event(Statechart* handle)
{ {
statechart_event next_event; statechart_event next_event;
statechart_event_init(&next_event, Statechart_invalid_event); statechart_event_init(&next_event, Statechart_invalid_event);
if(statechart_eventqueue_size(&(handle->in_event_queue)) > 0) { if(statechart_eventqueue_size(&(handle->internal_event_queue)) > 0) {
next_event = statechart_eventqueue_pop(&(handle->internal_event_queue));
}
else if(statechart_eventqueue_size(&(handle->in_event_queue)) > 0) {
next_event = statechart_eventqueue_pop(&(handle->in_event_queue)); next_event = statechart_eventqueue_pop(&(handle->in_event_queue));
} }
return next_event; return next_event;
@ -843,8 +1027,8 @@ static sc_boolean statechart_dispatch_next_event(Statechart* handle)
static StatechartEventID statechart_get_timed_event_name(Statechart* handle, sc_eventid evid) static StatechartEventID statechart_get_timed_event_name(Statechart* handle, sc_eventid evid)
{ {
if(evid == &handle->timeEvents.statechart_main_region_on_r2_pressed_tev0_raised) { if(evid == &handle->timeEvents.statechart_main_region_everything_r1_on_r2_pressed_tev0_raised) {
return Statechart_Statechart_main_region_on_r2_pressed_time_event_0; return Statechart_Statechart_main_region_everything_r1_on_r2_pressed_time_event_0;
} }
return Statechart_invalid_event; return Statechart_invalid_event;
} }
@ -860,6 +1044,9 @@ static void statechart_event_value_init(statechart_event * ev, StatechartEventID
case Statechart_sensor: case Statechart_sensor:
ev->value.Statechart_sensor_value = *((int32_t*)value); ev->value.Statechart_sensor_value = *((int32_t*)value);
break; break;
case Statechart_buttonState:
ev->value.Statechart_buttonState_value = *((sc_boolean*)value);
break;
default: default:
/* do nothing */ /* do nothing */
break; break;

View file

@ -35,6 +35,7 @@ typedef struct StatechartTimeEvents StatechartTimeEvents;
#include "../src/sc_types.h" #include "../src/sc_types.h"
#include "../src/sc_rxc.h" #include "../src/sc_rxc.h"
#include "../src/sc_rxc_int32_t.h" #include "../src/sc_rxc_int32_t.h"
#include "../src/sc_rxc_bool.h"
#include "../src/sc_rxc_int32_t.h" #include "../src/sc_rxc_int32_t.h"
#include "../src/sc_rxc_int32_t.h" #include "../src/sc_rxc_int32_t.h"
@ -52,30 +53,37 @@ Header of the state machine 'Statechart'.
#ifndef STATECHART_IN_EVENTQUEUE_BUFFERSIZE #ifndef STATECHART_IN_EVENTQUEUE_BUFFERSIZE
#define STATECHART_IN_EVENTQUEUE_BUFFERSIZE STATECHART_EVENTQUEUE_BUFFERSIZE #define STATECHART_IN_EVENTQUEUE_BUFFERSIZE STATECHART_EVENTQUEUE_BUFFERSIZE
#endif #endif
#ifndef STATECHART_INTERNAL_EVENTQUEUE_BUFFERSIZE
#define STATECHART_INTERNAL_EVENTQUEUE_BUFFERSIZE STATECHART_EVENTQUEUE_BUFFERSIZE
#endif
#ifndef SC_INVALID_EVENT_VALUE #ifndef SC_INVALID_EVENT_VALUE
#define SC_INVALID_EVENT_VALUE 0 #define SC_INVALID_EVENT_VALUE 0
#endif #endif
/*! Define number of states in the state enum */ /*! Define number of states in the state enum */
#define STATECHART_STATE_COUNT 6 #define STATECHART_STATE_COUNT 9
/*! Define dimension of the state configuration vector for orthogonal states. */ /*! Define dimension of the state configuration vector for orthogonal states. */
#define STATECHART_MAX_ORTHOGONAL_STATES 2 #define STATECHART_MAX_ORTHOGONAL_STATES 3
/*! Define maximum number of time events that can be active at once */ /*! Define maximum number of time events that can be active at once */
#define STATECHART_MAX_PARALLEL_TIME_EVENTS 1 #define STATECHART_MAX_PARALLEL_TIME_EVENTS 1
/*! Define indices of states in the StateConfVector */ /*! Define indices of states in the StateConfVector */
#define SCVI_STATECHART_MAIN_REGION_ON 0 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING 0
#define SCVI_STATECHART_MAIN_REGION_ON_R1_RESPONDING 0 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_OFF 0
#define SCVI_STATECHART_MAIN_REGION_ON_R1_SENSOR_ERROR 0 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON 0
#define SCVI_STATECHART_MAIN_REGION_ON_R2_NOT_PRESSED 1 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R1_RESPONDING 0
#define SCVI_STATECHART_MAIN_REGION_ON_R2_PRESSED 1 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R1_SENSOR_ERROR 0
#define SCVI_STATECHART_MAIN_REGION_OFF 0 #define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R2_NOT_PRESSED 1
#define SCVI_STATECHART_MAIN_REGION_EVERYTHING_R1_ON_R2_PRESSED 1
#define SCVI_STATECHART_MAIN_REGION_EVERYTHING_POLLBUTTON_BUTTON0 2
#define SCVI_STATECHART_MAIN_REGION_EVERYTHING_POLLBUTTON_BUTTON1 2
/* /*
* Union of all possible event value types. * Union of all possible event value types.
*/ */
typedef union { typedef union {
int32_t Statechart_sensor_value; int32_t Statechart_sensor_value;
sc_boolean Statechart_buttonState_value;
} statechart_event_value; } statechart_event_value;
/* /*
@ -84,9 +92,10 @@ typedef union {
typedef enum { typedef enum {
Statechart_invalid_event = SC_INVALID_EVENT_VALUE, Statechart_invalid_event = SC_INVALID_EVENT_VALUE,
Statechart_sensor, Statechart_sensor,
Statechart_buttonPressed, Statechart_buttonState,
Statechart_buttonReleased, Statechart_internal_buttonPressed,
Statechart_Statechart_main_region_on_r2_pressed_time_event_0 Statechart_internal_buttonReleased,
Statechart_Statechart_main_region_everything_r1_on_r2_pressed_time_event_0
} StatechartEventID; } StatechartEventID;
/* /*
@ -113,12 +122,15 @@ typedef struct statechart_eventqueue_s {
typedef enum typedef enum
{ {
Statechart_last_state, Statechart_last_state,
Statechart_main_region_on, Statechart_main_region_everything,
Statechart_main_region_on_r1_responding, Statechart_main_region_everything_r1_off,
Statechart_main_region_on_r1_sensor_error, Statechart_main_region_everything_r1_on,
Statechart_main_region_on_r2_not_pressed, Statechart_main_region_everything_r1_on_r1_responding,
Statechart_main_region_on_r2_pressed, Statechart_main_region_everything_r1_on_r1_sensor_error,
Statechart_main_region_off Statechart_main_region_everything_r1_on_r2_not_pressed,
Statechart_main_region_everything_r1_on_r2_pressed,
Statechart_main_region_everything_pollButton_button0,
Statechart_main_region_everything_pollButton_button1
} StatechartStates; } StatechartStates;
@ -129,8 +141,8 @@ struct StatechartIface
{ {
sc_boolean sensor_raised; sc_boolean sensor_raised;
int32_t sensor_value; int32_t sensor_value;
sc_boolean buttonPressed_raised; sc_boolean buttonState_raised;
sc_boolean buttonReleased_raised; sc_boolean buttonState_value;
sc_observable_int32_t setMotorR; sc_observable_int32_t setMotorR;
sc_observable_int32_t setMotorL; sc_observable_int32_t setMotorL;
}; };
@ -140,6 +152,8 @@ struct StatechartIface
/*! Type declaration of the data structure for the StatechartInternal interface scope. */ /*! Type declaration of the data structure for the StatechartInternal interface scope. */
struct StatechartInternal struct StatechartInternal
{ {
sc_boolean buttonPressed_raised;
sc_boolean buttonReleased_raised;
int32_t speed; int32_t speed;
pid_vars_t pid_vars; pid_vars_t pid_vars;
}; };
@ -149,7 +163,7 @@ struct StatechartInternal
/*! Type declaration of the data structure for the StatechartTimeEvents interface scope. */ /*! Type declaration of the data structure for the StatechartTimeEvents interface scope. */
struct StatechartTimeEvents struct StatechartTimeEvents
{ {
sc_boolean statechart_main_region_on_r2_pressed_tev0_raised; sc_boolean statechart_main_region_everything_r1_on_r2_pressed_tev0_raised;
}; };
@ -169,6 +183,8 @@ struct Statechart
StatechartTimeEvents timeEvents; StatechartTimeEvents timeEvents;
sc_boolean isExecuting; sc_boolean isExecuting;
sc_integer stateConfVectorPosition; sc_integer stateConfVectorPosition;
statechart_eventqueue internal_event_queue;
statechart_event internal_buffer[STATECHART_INTERNAL_EVENTQUEUE_BUFFERSIZE];
statechart_eventqueue in_event_queue; statechart_eventqueue in_event_queue;
statechart_event in_buffer[STATECHART_IN_EVENTQUEUE_BUFFERSIZE]; statechart_event in_buffer[STATECHART_IN_EVENTQUEUE_BUFFERSIZE];
}; };
@ -196,10 +212,8 @@ extern void statechart_raise_time_event(Statechart* handle, sc_eventid evid);
/*! Raises the in event 'sensor' that is defined in the default interface scope. */ /*! Raises the in event 'sensor' that is defined in the default interface scope. */
extern void statechart_raise_sensor(Statechart* handle, int32_t value); extern void statechart_raise_sensor(Statechart* handle, int32_t value);
/*! Raises the in event 'buttonPressed' that is defined in the default interface scope. */ /*! Raises the in event 'buttonState' that is defined in the default interface scope. */
extern void statechart_raise_buttonPressed(Statechart* handle); extern void statechart_raise_buttonState(Statechart* handle, sc_boolean value);
/*! Raises the in event 'buttonReleased' that is defined in the default interface scope. */
extern void statechart_raise_buttonReleased(Statechart* handle);
/*! Returns the observable for the out event 'setMotorR' that is defined in the default interface scope. */ /*! Returns the observable for the out event 'setMotorR' that is defined in the default interface scope. */
extern sc_observable_int32_t* statechart_get_setMotorR(Statechart* handle); extern sc_observable_int32_t* statechart_get_setMotorR(Statechart* handle);

View file

@ -0,0 +1,6 @@
/* Generated by itemis CREATE code generator. */
#include "sc_rxc_bool.h"
define_sc_reactive_extensions(bool)

View file

@ -0,0 +1,19 @@
/* Generated by itemis CREATE code generator. */
#ifndef SC_RXC_BOOL_H_
#define SC_RXC_BOOL_H_
#include "sc_rxc.h"
#ifdef __cplusplus
extern "C" {
#endif
declare_sc_reactive_extensions(bool)
#ifdef __cplusplus
}
#endif
#endif /* SC_RXC_BOOL_H_ */