One of the first programs I wrote when learning Java was a console application modelling the operation of an elevator. I'm trying to teach myself propositional logic and so I thought, why not use the same example?
So, suppose I have been given the task of modelling the main functions of an elevator system using propositions and predicates...
- Opening and closing doors (allowing entrance and exit at appropriate times)
- Storing and responding to floor requests from users
- Processing information from sensors (elevator load, floor position and speed sensors)
- Displaying status information on the displays (at each floor and in the cab)
My Google searches have returned very little in the way of useful insight into how this should be done or any standards that might exist. What would be the best way to do this?
Would something like this be appropriate?:
$$ F = requestedFloor, L = loadSensor(load), C = loadSensor(capacity) $$ $$ F ∧ L < C → move(F) ∧ display: print(currentFloor) $$ $$ floorSensor(currentFloor) < F → move(up)$$ $$ floorSensor(currentFloor) > F → move(down)$$
Which is simple enough, right? If there is a floor requested and load is less than capacity then move to that floor. Also, print the floor to the display.
If anyone has any suggestions or can provide some examples of how I might model this I'd love to hear them.