Draw on the right, write (Umple) model code on the left. Analyse models and generate code. This tool stores your data in cookies and on a server. I understand. Click to learn about privacy. Download Donate For help: User manual Ask questions Report issue
// UML state machine diagram of a traffic light system, written in Umple class IntersectionTimerDriven { // Traffic lights are green for 25s in one direction // and 20s in the other. Integer directionOneGoTime = 25; Integer directionTwoGoTime = 20; // Lights are yellow for 5s Integer yellowTime = 5; // Pedestrians have 10s extra warning Integer extraPedestrianWarning = 10; flow { FourWayStop { entry / { setDirectionOneLight(DirectionOneLight.FlashingRed); setDirectionTwoLight(DirectionTwoLight.FlashingRed); } initiateRegularOperation -> DirectionOneGo; } DirectionOneGo { entry / { setDirectionOneLight(DirectionOneLight.Green); setDirectionTwoLight(DirectionTwoLight.Red); } after(directionOneGoTime) -> DirectionOneHalting; detectMalfunction -> FourWayStop; } DirectionOneHalting { entry / {setDirectionOneLight(DirectionOneLight.Yellow);} after(yellowTime) -> DirectionTwoGo; detectMalfunction -> FourWayStop; } DirectionTwoGo { entry / { setDirectionOneLight(DirectionOneLight.Red); setDirectionTwoLight(DirectionTwoLight.Green); } after(directionOneGoTime) -> DirectionTwoHalting; detectMalfunction -> FourWayStop; } DirectionTwoHalting { entry / {setDirectionTwoLight(DirectionTwoLight.Yellow);} after(yellowTime) -> DirectionOneGo; detectMalfunction -> FourWayStop; } } pedestrianFlow { FourWayStop { entry / { setP1Light(P1Light.DoNotWalk); setP2Light(P2Light.DoNotWalk); } initiateRegularOperation -> P2Go; } P1Go { entry / {setP1Light(P1Light.Walk);} after(directionOneGoTime-extraPedestrianWarning)-> P1Halting; detectMalfunction -> FourWayStop; } P1Halting { entry / {setP1Light(P1Light.Flashing);} after(extraPedestrianWarning+yellowTime) -> P2Go; detectMalfunction -> FourWayStop; } P2Go { entry / {setP2Light(P2Light.Walk);} after(directionTwoGoTime-extraPedestrianWarning) -> P2Halting; detectMalfunction -> FourWayStop; } P2Halting { entry / {setP2Light(P2Light.Flashing);} after(extraPedestrianWarning+yellowTime) -> P1Go; detectMalfunction -> FourWayStop; } } DirectionOneLight { FlashingRed {} Red {} Yellow {} Green {} } DirectionTwoLight { FlashingRed {} Red {} Yellow {} Green {} } P1Light { DoNotWalk {} Flashing {} Walk {} } P2Light { DoNotWalk {} Flashing {} Walk {} } } //$?[End_of_model]$?