list of dots

User Manual    [Previous]   [Next]   

Canal Lock State Machine

Canal Lock State Machine

See also the class diagram and requirements for the canal system.

Example

// UML state machine diagram for a canal lock,
// represented in UML 

class Lock
{
  Boolean boatGoingDown = false;
  Boolean boatGoingUp = false;
  Boolean boatBlockingGate = false;
  
  lockState {
    BothDoorsClosedLockFull {
      // Waiting for boat
      boatRequestsToEnterAndGoDown
        -> OpeningUpperGate;
      boatRequestsToEnterAndGoUp
        -> LoweringWater;
    }

    OpeningUpperGate {
      upperGateFullyOpen -> UpperGateOpen;
    }

    UpperGateOpen {
      entry / {setBoatGoingUp(false);}
      boatInLockRequestingToGoDown
        -> / {setBoatGoingDown(true);}
        ClosingUpperGate;
      after3minutes [!boatBlockingGate]
        -> ClosingUpperGate;
    }

    ClosingUpperGate {
      upperGateFullyClosed [boatGoingDown]
        -> LoweringWater;
      upperGateFullyClosed [!boatGoingDown]
        -> BothDoorsClosedLockFull;   
    }
    
    LoweringWater {
      waterLevelMatchesDownStream
        -> OpeningLowerGate;
    } 
    
    
    BothDoorsClosedLockEmpty {
      // Waiting for boat
      boatRequestsToEnterAndGoUp
        -> OpeningLowerGate;
      boatRequestsToEnterAndGoDown
        -> RaisingWater;
    }

    OpeningLowerGate {
      lowerGateFullyOpen -> LowerGateOpen;
    }

    LowerGateOpen {
      entry / {setBoatGoingDown(false);}
      boatInLockRequestingToGoUp
        -> / {setBoatGoingUp(true);}
          ClosingLowerGate;
      after3minutes [!boatBlockingGate]
        -> ClosingLowerGate;
    }

    ClosingLowerGate {
      lowerGateFullyClosed [boatGoingUp]
        -> RaisingWater;
      lowerGateFullyClosed [!boatGoingUp]
        -> BothDoorsClosedLockEmpty;   
    }
    
    RaisingWater {
      waterLevelMatchesUpStream
        -> OpeningUpperGate;
    } 
  }
}

      

Load the above code into UmpleOnline