1 / 10

VIP Elevator – second model

VIP Elevator – second model. A VDM++ Project Made By: Sune Wolff. Agenda. Summary of First Model Desired Improvements Class Diagram Mapping Intelligent Elevator Intelligent Queue Achieved Improvements. Summary of First Model. Basic first model FIFO queue for placing orders

Download Presentation

VIP Elevator – second model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VIP Elevator – second model A VDM++ Project Made By: Sune Wolff

  2. Agenda • Summary of First Model • Desired Improvements • Class Diagram • Mapping • Intelligent Elevator • Intelligent Queue • Achieved Improvements

  3. 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. 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. Class Diagram

  6. Mapping class EC instance variables public static floorMap : map Elevator`Floor to nat := {<none> |-> -1, <ground> |-> 0, <one> |-> 1, <two> |-> 2, <three> |-> 3, <penthouse> |-> 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 = <up> and cur <> <penthouse>) then curNum := curNum + 1 elseif (dir = <down> and cur <> <ground>) then curNum := curNum – 1; return EC`invFloorMap (curNum); ); end Elevator

  7. 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 <none>;

  8. 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 := <penthouse>; dcl bottom : Elevator`Floor := <ground>; for all f in set elevatorQueue do (if (dir = <up> and EC`floorMap(f) > EC`floorMap(cur)) then (nextSet := nextSet union {f}; for all nextF in set nextSet do (if (next = <none>) then (if (EC`floorMap(nextF) < EC`floorMap(top)) then (nextFloor := nextF; top := nextF;) elseif (EC`floorMap(nextF) < EC`floorMap(nextFloor)) then nextFloor := nextF;

  9. Intelligent Queue #2 if (nextFloor <> next and next <> <none>) then (elevatorQueue := elevatorQueue union {next}; elevatorQueue := {y | y in set elevatorQueue & y <> nextFloor}; ) elseif (next = <none>) then elevatorQueue := {y | y in set elevatorQueue & y <> nextFloor}; return nextFloor;

  10. 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 ?

More Related