SCXML-tutorial

Contents Overview Editor Forum

SCXML Examples

W3C Examples

Qt SCXML Examples

uSCXML Examples

Preview

W3C Examples

Language Overview

This SCXML document gives an overview of the SCXML language and shows the use of its state machine transition flows LangOverview

Microwave Example

The example below shows the implementation of a simple microwave oven using SCXML MicrowaveSimple

Microwave Example (Using parallel)

The example below shows the implementation of a simple microwave oven using <parallel> and the SCXML 'In()' predicate MicrowaveParallel

Calculator Example

The example below shows the implementation of a simple calculator in SCXML Calculator

Qt SCXML Examples

Infotainment Radio Bolero Simulator (Qt QML SCXML EcmaScript)

This project is intended to test Qt QML SCXML module for designing in-vehicle infotainment systems

BoleroPreview

Dining Philosophers Problem (Qt Widgets SCXML EcmaScript)

Resource hierarchy solution of dining philosophers problem intended to show usage of communication between invoked submachines.

PhilProb

Morse Code Trainer (Qt Widgets SCXML Null EcmaScript)

This example demonstrates different techniques of using SCXML data models in applications

morse_widget

Salus RT500 Simulator (Qt Widgets SCXML CPlusPlus)

Salus RT500 (Digital Room Thermostat) Simulator is a widget-based application that demonstrates usage of Qt SCXML CPP DataModel

AppPreview

StopWatch (Qt QML SCXML EcmaScript)

Classical StopWatch with 2 buttons. All internal logic is written with SCXML EcmaScript Datamodel StopWatchPreview

Qt SCXML Standard Compliance Tester

Qt widget-based application that executes W3C SCXML tests and custom tests in sequence, and is able to build a report in Markdown format

Preview

KT76C Transponder Simulator (Qt USCXMLCLib Lua)

The BendixKing KT 76C transponder - radio transmitter/receiver which operates on radar frequencies

KT76C_Orig

Tester W3C (Qt USCXMLCLib Lua)

Qt widget-based application that executes W3C SCXML tests for Lua Datamodel in sequence

qt

Qt SCXML CPP Invoke Demo

Qt widget-based application that demonstrates how to invoke child state machines with QScxmlCppDataModel

cpp_inv_demo

uSCXML Examples

SCXML on an ATMega328

ArduinoPump

Source code

<scxml datamodel="native" initial="dark" name="ScxmlWaterPump" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"><!--we provide the datamodel inline in the scaffolding-->
	<script><![CDATA[pinMode(LED, OUTPUT);
for (char i = 0; i < 4; ++i) {
  pinMode(pump[i], OUTPUT);
  digitalWrite(pump[i], PUMP_OFF);
  bed[i].set_CS_AutocaL_Millis(0xFFFFFFFF);
}]]>
	</script>
	<state id="dark"><!--it is too dark to water flowers--><!--start to take measurements and activate single pumps if too dry-->
		<onentry>
			<script><![CDATA[for (char i = 0; i < 4; ++i) {
  digitalWrite(pump[i], PUMP_OFF);
}]]>
			</script>
		</onentry>
		<transition cond="_event-&gt;data.light &gt; LIGHT_THRES" event="light" target="light"/>
	</state>
	<state id="light"><!--delivers events for all the capsense measurements-->
		<invoke id="cap" type="capsense"/>
		<transition cond="_event-&gt;data.light &lt; LIGHT_THRES" event="light" target="dark"/>
		<state id="idle">
			<transition cond="soil[0] &lt; 0 &amp;&amp;
soil[0] &lt;= soil[1] &amp;&amp;
soil[0] &lt;= soil[2] &amp;&amp;
soil[0] &lt;= soil[3]" event="pump" target="pump1"/>
			<transition cond="soil[1] &lt; 0 &amp;&amp;
soil[1] &lt;= soil[0] &amp;&amp;
soil[1] &lt;= soil[2] &amp;&amp;
soil[1] &lt;= soil[3]" event="pump" target="pump2"/>
			<transition cond="soil[2] &lt; 0 &amp;&amp;
soil[2] &lt;= soil[0] &amp;&amp;
soil[2] &lt;= soil[1] &amp;&amp;
soil[2] &lt;= soil[3]" event="pump" target="pump3"/>
			<transition cond="soil[3] &lt; 0 &amp;&amp;
soil[3] &lt;= soil[0] &amp;&amp;
soil[3] &lt;= soil[1] &amp;&amp;
soil[3] &lt;= soil[2]" event="pump" target="pump4"/>
		</state>
		<state id="pumping">
			<onentry>
				<send delay="8000ms" event="idle"/>
			</onentry>
			<transition event="idle" target="idle"/>
			<state id="pump1">
				<invoke id="1" type="pump"/>
			</state>
			<state id="pump2">
				<invoke id="2" type="pump"/>
			</state>
			<state id="pump3">
				<invoke id="3" type="pump"/>
			</state>
			<state id="pump4">
				<invoke id="4" type="pump"/>
			</state>
		</state>
	</state>
</scxml>

TOP Contents Overview Editor Forum