StateMachine in c# and xml, v3 (updated)

By ramon
September 30, 2005
0

Updated:
 – New archive to download (v3)
 – XML updated
 – Code rewrite with delegates and helper methods

I added unittest for a switch in version 1. Leslie had some troubles with building his trafficsign. I now added a trafficsign as a unittest and it outputs the following:

<?xml version="1.0"?>
<Machine Id="Switch" InitialState="On" xmlns="Exyll.StateMachine">
  <SubStates>
    <State Id="On" InitialState="Red">
      <SubStates>
        <State Id="Red">
          <Transitions>
            <Transition EventName="TimeTrigger" Target="Green" Guard="TimerIs4" Action="TimerReset" />
            <Transition EventName="TimeTrigger" Target="Red" Action="TimerIncrement" />
          </Transitions>
        </State>
        <State Id="Yellow">
          <Transitions>
            <Transition EventName="TimeTrigger" Target="Red" Guard="TimerIs2" Action="TimerReset" />
            <Transition EventName="TimeTrigger" Target="Yellow" Action="TimerIncrement" />
          </Transitions>
        </State>
        <State Id="Green">
          <Transitions>
            <Transition EventName="TimeTrigger" Target="Yellow" Guard="TimerIs4" Action="TimerReset" />
            <Transition EventName="TimeTrigger" Target="Green" Action="TimerIncrement" />
          </Transitions>
        </State>
      </SubStates>
      <Transitions>
        <Transition EventName="TurnOff" Target="Off" />
      </Transitions>
    </State>
    <State Id="Off">
      <Transitions>
        <Transition EventName="TurnOn" Target="On" />
      </Transitions>
    </State>
  </SubStates>
  <Events>
    <Event>TimeTrigger</Event>
    <Event>TurnOff</Event>
    <Event>TurnOn</Event>
  </Events>
</Machine>

Download link : StateMachine version 3

Comments: 0

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta