Elevator Simulation

Implementing finite state machines and collaborative programming

Introduction

Elevator Simulation is a group project that was given in the course A.D.E.N. (Advanced Data Structures, Embedded Systems, and Networking) This is a time-driven and event-driven simulation. The elevators functionality will be modelled using a finite state machine, and passengers will arrive at specified times with intended destinations – just like they would in a real building.

Programming Deep-Dive

As mentioned in the introduction, an elevator is a finite state machine meaning it has no randomness and a fixed number of states. Definition of a Finite State Machine :

Finite-state machine (FSM) or finite-state automaton or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. -wikipedia.com
Here is the FSM diagram for the elevator simulation

We can divide each of these states into their own functons:

  • STOP
  • BOARD
  • OFFLOAD
  • OPENDOOR
  • CLOSEDOOR
  • MOVE 1 FLOOR

Each “tick” has 3 phases:

  • Checking for the arrival of new passengers
  • Executing the state and determining the next state
  • Updating the GUI if there are a changes
  • Executing the state and determining the state has 2 sub-phases:
  • Performing state actions:
  • Actions will occur in the Elevator, Floor and Building classes
  • Determining the next state:
  • Requires information from the Elevator, CallManager and Building classes
  • Recommend building a document for each state:
  • Define the action(s) and where they take place
  • Define the decision criteria for each possible next state and where it comes from...

Design Stages:

Analysis