Skip to content

Message Protocol

Mayukh edited this page Feb 3, 2024 · 2 revisions

Message Protocol

Mentioned classes

Message Buffers

Different subsystems will have unique classes of message passed between each other. Messages are records which are created with their respective factories. This is done so that each message will automatically be associated with a UUID while the message themselves are still records.

Messages are passed between systems using two global shared MessageBuffers, one inbound buffer and one outbound buffer, from the perspective of the Scheduler.

Message buffers are created as follows:

MessageBuffer buf = MessageBuffer(int size);

Floor Message

Floor messages are created as follows:

FloorMessageFactory<T> factory = new FloorMessageFactory<T>();
FloorMessage<T> floorMessage = factory.createFloorMessage(String floorID, Map<String, T> data, Signal signal);

The data parameter of the create method must have its generic type T be a String and at least contain to the following structure:

// Generic:
"Time": "{hh}:{mm}:{ss}.{mmm}", "ServiceFloor": "{number}", "RequestDirection": {"up"/"down"}, "Floor": "{number}"

// Implementation:
"Time": "14:05:15.0", "ServiceFloor": "2", "RequestDirection": "up", "Floor": "4"

Floor Messages are used when:

  • FloorSystem sends messages to Scheduler
  • tbd

Elevator Message

Elevator messages are created as follows:

ElevatorMessageFactory<T> factory = new ElevatorMessageFactory<T>();
ElevatorMessage<T> elevatorMessage = factory.createElevatorMessage(String elevatorID, Map<String, T> data, Signal signal);

The data parameter of the create method must have its generic type T be FloorMessage and at least contain the following structure:

"Servicing": FloorMessage

Elevator Messages are used when:

  • Elevator sends messages to Scheduler
  • Scheduler sends messages to Elevator
  • Scheduler sends messages to FloorSystem

Signal

Signal is an enum which contains the fields WORK_REQ, EMERG, IDLE, WORKING, DONE. This enum is used as a field inside a FloorMessage which is to be interpreted by the receiver of this message.

public enum Signal {
    WORK_REQ, EMERG, IDLE, WORKING, DONE
}

Clone this wiki locally