Skip to content

Network messages

Benedek Horvath edited this page Feb 18, 2018 · 22 revisions

Messages are separated for two categories: command and state. The previous one is to send command to the recipient for which it replies with a state / status response.

The messages as of 07.09.2017 are defined by the Protocol Buffers (protobuf) format. They are inside the hu.bme.mit.inf.modes3.messaging.proto.messages project, in the /src/main/proto folder. In order to generate Java classes from the proto files, you should:

  1. Install gradle on your machine.

  2. Go to the root java folder of the repository.

  3. Run the following command in command-line:

./gradlew :messaging:proto.messages:generateProto

Notes:

  • You may notice that each field has an equation mark and a number on the right hand side that is due to the protobuf data format. One may ignore it when interpreting the different fields.

  • There is a separate Java class for every message (except from the ComplexGesture and the [TurnoutReferenceCommand]) in the hu.bme.mit.inf.modes3.messaging.messages project. One should use this representation in a Java project, instead of the serialization dependent one.

  • Enums that are used by several messages are defined in one place, on the Enums figure.

Command messages

DccOperationsCommand

message DccOperationsCommand {
	DccOperations dccOperations = 1;
}

Operation command that should be executed by the DCC (via XPressNet) protocol.

SegmentCommand

message SegmentCommand {
	uint32 segmentID = 1;
	SegmentStateValue state = 2;
}

A command if a segment should be enabled or disabled.

SendAllStatus

message SendAllStatus {
}

Every recipient should send status information about everything it controls or knows about. See Status messages

TrainReferenceSpeedCommand

message TrainReferenceSpeedCommand {
	uint32 trainID = 1;
	int32 referenceSpeed = 2;
	TrainDirectionValue direction = 3;
}

A command to set the speed and direction of a train. It should be executed by the DCC (via XPressNet) protocol.

TurnoutCommand

message TurnoutCommand {
	uint32 turnoutID = 1;
	TurnoutStateValue state = 2;
}

A command if a turnout should be set straight or divergent.

Status messages

ComplexGesture

message ComplexGesture {
  optional int32 id = 1;
  optional bool valid = 7;
enum Type {
  TYPE_INVALID = 0;
  TYPE_SWIPE = 1;
  TYPE_CIRCLE = 2;
  TYPE_SCREEN_TAP = 3;
  TYPE_KEY_TAP = 4;
  TYPE_GRAB = 5;
  TYPE_SPEED_UP = 6;
  TYPE_SLOW_DOWN = 7;
  TYPE_SELECTION = 8;
  TYPE_STOP = 9;
}
  optional Type type = 9;
  optional int64 timestamp = 10;
}

A complex gesture message created by the motion sensor.

Note

This message is not translated into Java.

ComputerVisionObjectPositions

message ComputerVisionObjectPositions{
	map<string , PhysicalObject> physicalObjects = 1;
	int64 timestamp 			 = 2;
	int64 frameindex 			 = 3;
}

message PhysicalObject{ string name = 1; map<string , Marker> markers = 2; }

message Marker{ string name = 1; ThreeDPosition realposition = 2; repeated TwoDPosition screenPositions = 3; repeated bool tracked = 4; }

message ThreeDPosition{ double x = 1; double y = 2; double z = 3; }

message TwoDPosition{ double x = 1; double y = 2; }

Position information about physical objects on the track. The information is originates from CV.

DccOperationsState

message DccOperationsState {
	DccOperations dccOperations = 1;
}

Status info about the DCC operation.

SegmentOccupancy

message SegmentOccupancy {
	uint32 segmentID = 1;
	SegmentOccupancyValue state = 2;
}

Status info about a segment if it is occupied or free.

SegmentState

message SegmentState {
	uint32 segmentID = 1;
	SegmentStateValue state = 2;
}

Status info about a segment if it is enabled or disabled.

TrainReferenceSpeed

message TrainReferenceSpeed {
	uint32 trainID = 1;
	int32 referenceSpeed = 2;
	TrainDirectionValue direction = 3;
}

Status info about a train’s reference speed.

TurnoutReferenceState

message TurnoutReferenceState {
	uint32 turnoutID = 1;
	TurnoutStateValue state = 2;
}

Status info about a turnout’s reference state (if it is straight or divergent), set by the train controller (MultiMaus).

TurnoutState

message TurnoutState {
	uint32 turnoutID = 1;
	TurnoutStateValue state = 2;
}

Status info about a turnout’s reference state, if it is straight or divergent)

Enums

enum DccOperations {
	NORMAL_OPERATIONS = 0;
	STOP_ALL_LOCOMOTIVES = 1;
	STOP_OPERATIONS = 2;
}

enum MessageType { NULL = 0; SEGMENT_COMMAND = 1; SEGMENT_STATE = 2; TRAIN_REFERENCE_SPEED = 3; TRAIN_REFERENCE_SPEED_COMMAND = 4; TURNOUT_COMMAND = 5; TURNOUT_STATE = 6; SEGMENT_OCCUPANCY = 7; TURNOUT_REFERENCE_STATE = 8; DCC_OPERATIONS_COMMAND = 9; DCC_OPERATIONS_STATE = 10; SEND_ALL_STATUS = 11; COMPUTER_VISION_OBJECT_POSITIONS = 23; }

enum SegmentStateValue { DISABLED = 0; ENABLED = 1; }

enum TrainDirectionValue { FORWARD = 0; BACKWARD = 1; }

enum TurnoutStateValue { STRAIGHT = 0; DIVERGENT = 1; }

Used by the messages.

Clone this wiki locally