Download presentation
Presentation is loading. Please wait.
Published byDennis George Modified over 8 years ago
1
18/5 - 20071 VIP Elevator – second model A VDM++ Project Made By: Sune Wolff
2
18/5 - 20072 Agenda Summary of First Model Desired Improvements Class Diagram Mapping Intelligent Elevator Intelligent Queue Achieved Improvements
3
18/5 - 20073 Summary of First Model Basic first model FIFO queue for placing orders Using ordered sequence of floors Elevator moved between floors in atomic fashion
4
18/5 - 20074 Desired Improvements Introduce classes for buttons and sensors Make use of mapping Make elevator more intelligent Keep track of direction Choose next floor based on direction and distance Introduce automatic test Read test sequence from file Make sure the VIP receives special treatment No neighbours in elevator when VIP wants to use it Execute VIP order as soon as possible
5
18/5 - 20075 Class Diagram
6
18/5 - 20076 Mapping class EC instance variables public static floorMap : map Elevator`Floor to nat := { |-> -1, |-> 0, |-> 1, |-> 2, |-> 3, |-> 4}; public static invFloorMap : map nat to Elevator`Floor := inverse floorMap; end EC class Elevator operations public UpdateCurrent: Dir * Floor ==> Floor UpdateCurrent(dir, cur) == (dcl curNum : nat := EC`floorMap(cur); if (dir = and cur <> ) then curNum := curNum + 1 elseif (dir = and cur <> ) then curNum := curNum – 1; return EC`invFloorMap (curNum); ); end Elevator
7
18/5 - 20077 Intelligent Elevator public MoveElevator: () ==> Floor MoveElevator() == (if (not EC`vipQueue.QueueEmpty() and EC`innerQueue.QueueEmpty()) then (nextFloor := EC`vipQueue.GetNextFromQueue(direction, currentFloor, nextFloor); currentFloor := UpdateCurrent(direction, currentFloor); return nextFloor) elseif (not EC`innerQueue.QueueEmpty()) then (nextFloor := EC`innerQueue.GetNextFromQueue(direction, currentFloor, nextFloor); currentFloor := UpdateCurrent(direction, currentFloor); return nextFloor) elseif (not EC`outerQueue.QueueEmpty()) then (nextFloor := EC`outerQueue.GetNextFromQueue(direction, currentFloor, nextFloor); currentFloor := UpdateCurrent(direction, currentFloor); return nextFloor) else (UpdateDir(direction); return ;
8
18/5 - 20078 Intelligent Queue public GetNextFromQueue: Elevator`Dir * Elevator`Floor * Elevator`Floor ==> [Elevator`Floor] GetNextFromQueue(dir, cur, next) == (dcl nextFloor : Elevator`Floor := next; dcl nextSet : set of Elevator`Floor := {}; dcl top : Elevator`Floor := ; dcl bottom : Elevator`Floor := ; for all f in set elevatorQueue do (if (dir = and EC`floorMap(f) > EC`floorMap(cur)) then (nextSet := nextSet union {f}; for all nextF in set nextSet do (if (next = ) then (if (EC`floorMap(nextF) < EC`floorMap(top)) then (nextFloor := nextF; top := nextF;) elseif (EC`floorMap(nextF) < EC`floorMap(nextFloor)) then nextFloor := nextF;
9
18/5 - 20079 Intelligent Queue #2 if (nextFloor <> next and next <> ) then (elevatorQueue := elevatorQueue union {next}; elevatorQueue := {y | y in set elevatorQueue & y <> nextFloor}; ) elseif (next = ) then elevatorQueue := {y | y in set elevatorQueue & y <> nextFloor}; return nextFloor;
10
18/5 - 200710 Achieved Improvements Introduce classes for buttons and sensors Make use of mapping Make elevator more intelligent Keep track of direction Choose next floor based on direction and distance Introduce automatic test Read test sequence from file Make sure the VIP receives special treatment No neighbours in elevator when VIP wants to use it Execute VIP order as soon as possible ? ? VDMUnit
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.