ftsrg / BME-MODES3

Model-based Demonstrator for Smart and Safe Systems
https://inf.mit.bme.hu/research/projects/modes3
16 stars 8 forks source link

Restructure sensor message format #97

Open zsoltmazlo opened 6 years ago

zsoltmazlo commented 6 years ago

In this wiki page, the messages are sent individually for each train and wagon, which is a difficult task to collect in a receiver component. Thus, I'm suggesting the following format:

Message format:

JSON field Type Description Example
time int timestamp of the message in milliseconds 1508578744987
locomotive string name of the locomotive Taurus
length float the length of the locomotive 21.47
speed cm/s or mm/s the speed of the locomotive, only cm/s or mm/s could be used 10.67
unit cm or mm the length unit used in both the calculation the length and the speed field mm
wagons array of wagon objects wagon message for each wagon, could be empty []

Wagon object:

JSON field Type Description Example
name string name of the wagon Red
length float the length of the wagon 21.47
unit cm or mm the length unit used in calculating the length field (it is recommended to be the very same unit which used in the parent object) mm

An example message when a Taurus locomotive with two Red wagon passed by the sensor (disclaimer: the example data might not be real):

{
   "time": 1508578744987,
   "locomotive": "Taurus",
   "length": 21.47,
   "speed": 10.67,
   "unit": "cm",
   "wagons": [
      {"name": "Red", "length": 12.01, "unit": "cm"},
      {"name": "Red", "length": 12.07, "unit": "cm"}
   ]
};

This message format is open for discuss, please, comment on this issue if you have any ideas.

zsoltmazlo commented 6 years ago

As @hegyibalint pointed out, to discuss this issue it's enough to request review with tagging users a comment, thus all unnecessary assignment was removed and hereby I'm requesting review from the following users: @hegyibalint @imbur @baloghlaszlo @benedekh.

szantob commented 6 years ago

New json message added on "\modes3\locomotives" mqtt channel. { "sender": "sensor02", "time": 100, "locomotive": "Vagon", "length": 15.1454, "speed": 29.88464, "unit": "cm" }