list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

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;
      after(180000) [!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;
      after(180000) [!boatBlockingGate]
        -> ClosingLowerGate;
    }

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

      

Load the above code into UmpleOnline