<?xml version="1.0" ?>
<diagram author="Simon Van Mierlo" name="Timer (Threaded Version)">
    <top>
        import time
    </top>
    
    <inport name="input" />        
    <outport name="output" />

    <class name="MainApp" default="true">
        <constructor>
            <body>
                self.starting_time = time.time()
            </body>
        </constructor>
        <scxml initial="running">
            <state id="running">
                <transition target="." after="0.05">
                    <raise event="time_update" port="output">
                        <parameter expr="self.getSimulatedTime()" />
                        <parameter expr="time.time() - self.starting_time" />
                    </raise>
                </transition>
                <transition target="../interrupted" event="interrupt" port="input">
                    <raise event="time_update" port="output">
                        <parameter expr="self.getSimulatedTime()" />
                        <parameter expr="time.time() - self.starting_time" />
                    </raise>
                </transition>
            </state>
            <state id="interrupted">
                <transition target="." event="interrupt" port="input">
                    <raise event="time_update" port="output">
                        <parameter expr="self.getSimulatedTime()" />
                        <parameter expr="time.time() - self.starting_time" />
                    </raise>
                </transition>
                <transition target="../running" event="continue" port="input">
                    <raise event="time_update" port="output">
                        <parameter expr="self.getSimulatedTime()" />
                        <parameter expr="time.time() - self.starting_time" />
                    </raise>
                </transition>
            </state>
        </scxml>
    </class>
</diagram>