rsmp-nordic / rsmp_schema

JSON Schema for automatically validating RSMP messages
MIT License
1 stars 0 forks source link

validate message depending on object type #61

Open emiltin opened 1 year ago

emiltin commented 1 year ago

We're currently not verifying messages according to what object type you send them to or receive them from.

In an RMSP message, the receiver/sender is identified by a compoment id, which does not directly indicate the object type:

{ "mType":"rSMsg", "type":"StatusRequest", "mId":"9b6591b4-5633-401f-b882-e393393e97fe", "ntsOId":"KK+AG0503=001TC000", "xNId":"", "cId":"KK+AG0503=001TC000", "sS":[{ "sCI":"S0091", "n":"user" }] }

In this messages, we're sending a message to the component KK+AG0503=001TC000. In this case the 'TC' in the name implies a Traffic Light Controller, but unfortunately the component naming is not standardized, so I don't think there's any way the type can be inferred by the component name, using only the info from the standardized SXL YAML.

We could be more explicit about what object type you're sending a message to or from in the rsmp messages:

"cId":"Traffic Light Controller/KK+AG0503=001TC000", or

"cTy":"Traffic Light Controller", "cId":"KK+AG0503=001TC000",

This would requires a change in the core spec.

otterdahl commented 1 year ago

In a way, this problem has historically already been solved, but in a different way.

Mapping object types to individual objects has previously been part of the SXL. The sxl.yaml doesn't contain this information, but in order to use the RSMP simulator, I've made this additional yaml file which is merged with sxl.yaml before use with the RSMP-simulator.

---
sites:
  AA+BBCC:
    description: Anl. ??
    objects:
      Traffic Light Controller:
        Traffic Light Controller:
          componentId: AA+BBCCC=DDDEEFFF
          ntsObjectId: AA+BBCCC=DDDEEFFF
      Signal group:
        SG1:
          componentId: AA+BBCCC=DDDEEFF1
          ntsObjectId: AA+BBCCC=DDDEEFFF
        SG2:
          componentId: AA+BBCCC=DDDEEFF2
          ntsObjectId: AA+BBCCC=DDDEEFFF
        SG3:
          componentId: AA+BBCCC=DDDEEFF3
          ntsObjectId: AA+BBCCC=DDDEEFFF
emiltin commented 1 year ago

Right, that a way to create a mapping from actual name to object type.

But I think an issue with that approach is that it requires the validator to have access to site-specific info to validate messages.