-
Notifications
You must be signed in to change notification settings - Fork 0
Message Protocol
Mentioned classes
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 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:
-
FloorSystemsends messages toScheduler - tbd
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": FloorMessageElevator Messages are used when:
-
Elevatorsends messages toScheduler -
Schedulersends messages toElevator -
Schedulersends messages toFloorSystem
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
}