mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-02-04 06:13:00 +08:00
183 lines
5.9 KiB
XML
183 lines
5.9 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<model version="5.2.0" links="1">
|
|
<documentation>Transition to history in a subclass of QP::QMsm</documentation>
|
|
<!--${qpcpp}-->
|
|
<framework name="qpcpp" license="../../../LICENSES/QM-EVAL-QPCPP.qlc"/>
|
|
<!--${SMs}-->
|
|
<package name="SMs" stereotype="0x02">
|
|
<!--${SMs::ToastOven}-->
|
|
<class name="ToastOven" superclass="qpcpp::QMsm">
|
|
<documentation>Oven state machine</documentation>
|
|
<!--${SMs::ToastOven::ToastOven}-->
|
|
<operation name="ToastOven" type="" visibility="0x00" properties="0x00">
|
|
<documentation>constructor</documentation>
|
|
<code> : QMsm(Q_STATE_CAST(&ToastOven::initial))</code>
|
|
</operation>
|
|
<!--${SMs::ToastOven::SM}-->
|
|
<statechart properties="0x02">
|
|
<!--${SMs::ToastOven::SM::initial}-->
|
|
<initial target="../1">
|
|
<action>(void)e; /* avoid compiler warning */</action>
|
|
<initial_glyph conn="3,2,5,1,51,4,-2">
|
|
<action box="2,-2,13,4"/>
|
|
</initial_glyph>
|
|
</initial>
|
|
<!--${SMs::ToastOven::SM::doorClosed}-->
|
|
<state name="doorClosed">
|
|
<entry>PRINTF_S("%s;", "door-Closed");</entry>
|
|
<!--${SMs::ToastOven::SM::doorClosed::initial}-->
|
|
<initial target="../8">
|
|
<initial_glyph conn="40,10,4,0,10">
|
|
<action box="0,-2,6,2"/>
|
|
</initial_glyph>
|
|
</initial>
|
|
<!--${SMs::ToastOven::SM::doorClosed::history}-->
|
|
<history type="deep" target="../8">
|
|
<history_glyph conn="52,16,1,0,-8,4"/>
|
|
</history>
|
|
<!--${SMs::ToastOven::SM::doorClosed::TERMINATE}-->
|
|
<tran trig="TERMINATE" target="../../3">
|
|
<tran_glyph conn="52,30,1,0,16,2">
|
|
<action box="0,-2,9,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorClosed::OPEN}-->
|
|
<tran trig="OPEN" target="../../2">
|
|
<tran_glyph conn="52,10,1,3,8">
|
|
<action box="0,-2,6,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorClosed::TOAST}-->
|
|
<tran trig="TOAST" target="../7/1">
|
|
<tran_glyph conn="12,38,2,2,-6">
|
|
<action box="0,-2,6,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorClosed::BAKE}-->
|
|
<tran trig="BAKE" target="../7/2">
|
|
<tran_glyph conn="26,38,2,2,-6">
|
|
<action box="0,-2,6,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorClosed::OFF}-->
|
|
<tran trig="OFF" target="../8">
|
|
<tran_glyph conn="44,38,2,2,-10">
|
|
<action box="0,-2,6,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorClosed::heating}-->
|
|
<state name="heating">
|
|
<entry>PRINTF_S("%s;", "heater-On");</entry>
|
|
<exit>PRINTF_S("%s;", "heater-Off");</exit>
|
|
<!--${SMs::ToastOven::SM::doorClosed::heating::initial}-->
|
|
<initial target="../1">
|
|
<initial_glyph conn="10,20,5,0,4,4">
|
|
<action box="0,-2,10,2"/>
|
|
</initial_glyph>
|
|
</initial>
|
|
<!--${SMs::ToastOven::SM::doorClosed::heating::toasting}-->
|
|
<state name="toasting">
|
|
<entry>PRINTF_S("%s;", "toasting");</entry>
|
|
<state_glyph node="6,24,14,8">
|
|
<entry box="1,2,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<!--${SMs::ToastOven::SM::doorClosed::heating::baking}-->
|
|
<state name="baking">
|
|
<entry>PRINTF_S("%s;", "baking");</entry>
|
|
<state_glyph node="22,24,12,8">
|
|
<entry box="1,2,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<state_glyph node="4,11,32,23">
|
|
<entry box="1,2,7,2"/>
|
|
<exit box="1,4,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<!--${SMs::ToastOven::SM::doorClosed::off}-->
|
|
<state name="off">
|
|
<entry>PRINTF_S("%s;", "toaster-Off");</entry>
|
|
<state_glyph node="38,20,12,8">
|
|
<entry box="1,2,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<state_glyph node="2,4,50,34">
|
|
<entry box="1,2,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<!--${SMs::ToastOven::SM::doorOpen}-->
|
|
<state name="doorOpen">
|
|
<entry>PRINTF_S("%s;", "door-Open,lamp-On");</entry>
|
|
<exit>PRINTF_S("%s;", "lamp-Off");</exit>
|
|
<!--${SMs::ToastOven::SM::doorOpen::CLOSE}-->
|
|
<tran trig="CLOSE" target="../../1" cpref="../../1/1">
|
|
<tran_glyph conn="60,16,3,1,-7">
|
|
<action box="-6,-2,7,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<!--${SMs::ToastOven::SM::doorOpen::TERMINATE}-->
|
|
<tran trig="TERMINATE" target="../../3">
|
|
<tran_glyph conn="72,26,2,0,6">
|
|
<action box="0,0,9,2"/>
|
|
</tran_glyph>
|
|
</tran>
|
|
<state_glyph node="60,4,20,22">
|
|
<entry box="1,2,6,2"/>
|
|
<exit box="1,4,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<!--${SMs::ToastOven::SM::final}-->
|
|
<state name="final">
|
|
<entry>PRINTF_S("%s\n", "-> final\nBye!Bye!");
|
|
QP::QF::onCleanup();
|
|
exit(0);</entry>
|
|
<state_glyph node="60,32,16,6">
|
|
<entry box="1,2,5,2"/>
|
|
</state_glyph>
|
|
</state>
|
|
<state_diagram size="81,40"/>
|
|
</statechart>
|
|
</class>
|
|
</package>
|
|
<!--${.}-->
|
|
<directory name=".">
|
|
<!--${.::history.hpp}-->
|
|
<file name="history.hpp">
|
|
<text>#ifndef HISTORY_HPP
|
|
#define HISTORY_HPP
|
|
|
|
enum ToastOvenSignals {
|
|
OPEN_SIG = QP::Q_USER_SIG,
|
|
CLOSE_SIG,
|
|
TOAST_SIG,
|
|
BAKE_SIG,
|
|
OFF_SIG,
|
|
TERMINATE_SIG // terminate the application
|
|
};
|
|
|
|
extern QP::QMsm * const the_oven; // opaque pointer to the oven MSM
|
|
|
|
#endif // HISTORY_HPP</text>
|
|
</file>
|
|
<!--${.::history.cpp}-->
|
|
<file name="history.cpp">
|
|
<text>#include "qpcpp.hpp"
|
|
#include "history.hpp"
|
|
|
|
#include "safe_std.h" // portable "safe" <stdio.h>/<string.h> facilities
|
|
#include <stdlib.h>
|
|
|
|
Q_DEFINE_THIS_FILE
|
|
|
|
$declare(SMs::ToastOven)
|
|
|
|
static ToastOven l_oven; // the only instance of the ToastOven class
|
|
|
|
// global-scope definitions ------------------------------------
|
|
QP::QMsm * const the_oven = &l_oven; // the opaque pointer
|
|
|
|
$define(SMs::ToastOven)</text>
|
|
</file>
|
|
</directory>
|
|
</model>
|