Page 1 of 1
Various minor issues 04/10/2022 at 00:35 #148256 | |
DonRiver
166 posts |
I've been having a lot of fun working on a Python wrapper library for SimSig - it's now at a point where it turns any SimSig frame into a friendly Python dataclass! I've found a couple of minor issues that perhaps could be tidied up at some point? - `train_location` messages share what looks like an internal int ID as the UID, not the timetable UID - see 2F02 here has UID 16 in the train_location messages and W71908 in the train_delay messages. https://imgur.com/a/OQBBVXU - Please could the sim time be included with train movement messages? - There's a command to release/unrelease a ground frame: {"framerelease": {"frame": "Fxxxx", "release": "True"|"False"}. Is there / could there also be a command to take/return the release? - `crossing` messages have an `auto_lower` field but this seems to be mislabelled - it seems to show if the crossing is set to automatically raise? - Send {"snapshot":{}} triggers a message containing duplicate keys: ``` { ····"SG_MSG": {"area_id": "royston", "obj_id": "HLITLINGTON", "obj_type": "ahb", ...}, ····"SG_MSG": {"area_id": "royston", "obj_id": "HIVY", "obj_type": "ahb", ...}, ····"SG_MSG": {"area_id": "royston", "obj_id": "L2368ARM", "obj_type": "flag", ...}, ····... ····"SG_MSG": {"area_id": "royston","obj_id": "U4861-BA","obj_type": "ulc", ...} } ``` This is technically valid JSON but in practice most parsers will only show you the data from the last key. A solution which wouldn't break existing code would be to reply with: ``` { ····"SNAPSHOT_MSG": [ ········{"SG_MSG": {"area_id": ...}}, ········{"SG_MSG": {"area_id": ...}}, ········... ········{"SG_MSG": {"area_id": ...}} ····] } ``` or perhaps ``` { ····"SNAPSHOT_MSG": [ ········{"area_id": ...}, ········{"area_id": ...}, ········... ········{"area_id": ...} ····] } ``` - on the other hand if you were in the mood for breaking changes, it'd be an improvement to use JSON values `true`, `false`, and integers vs character strings `"True"`, `"False"`, `"0"` - {"idrequest": {}} does not show the current time, but the time from the last clock_msg. (Not a significant problem since the time is usually shared multiple times per second by all the messages from the interlocking.) - Iff it's trivially easy to do, could the STOMP message headers have "content-type: application/json" instead of "content-type: text/plain"? The only time I've seen SimSig send a plain text STOMP frame is when attempting to connect to a payware sim without a valid username/password. It's not a big deal to just push the message into a JSON parser and then handle any errors from there, though. (named for the one in Tasmania, not in Russia) Last edited: 04/10/2022 at 06:40 by DonRiver Reason: None given Log in to reply |
Various minor issues 04/10/2022 at 20:26 #148268 | |
GeoffM
6376 posts |
Much of the format is the same as the NR feeds, for compatibility (reuse the code), so broadly I'm not changing that, or anything else breaking. UID is an internal sequence number, though I do see the confusion. > This is technically valid JSON but in practice most parsers will only show you the data from the last key. Sounds like a parser problem then! I'll Mantis 36746 it for the moment. SimSig Boss Log in to reply |
Various minor issues 04/10/2022 at 22:39 #148269 | |
DonRiver
166 posts |
OK, thanks Geoff, it's not hard to work around the duplicate key issue. I'm curious then that the train_delay message shows the timetable UID while train_location does not? (named for the one in Tasmania, not in Russia) Log in to reply |
Various minor issues 04/10/2022 at 23:18 #148270 | |
GeoffM
6376 posts |
DonRiver in post 148269 said:OK, thanks Geoff, it's not hard to work around the duplicate key issue.Just to note, these are not keys. It's a list of events and theoretically you could get the same message more than once if, for some reason, things got backed up and something toggled twice (for example). DonRiver in post 148269 said: I'm curious then that the train_delay message shows the timetable UID while train_location does not?There may have been a mistake there on my part... SimSig Boss Log in to reply |
Various minor issues 05/10/2022 at 01:56 #148271 | |
DonRiver
166 posts |
OK, yes, technically the JSON terminology is name/value pair not key/value pair. The problem isn't the duplicate messages, it's that the STOMP frame contains a JSON object with lots of name/value pairs where all the names are "SG_MSG". I've made a demo of the situation with an online code editor, along with a more conventional way to present a list of messages as JSON. Should show the results if you press "Run": https://www.online-python.com/LpK4XJAnh7 Re the train movement messages - is there a reason not to use the timetable UID (or to provide the timetable UID as well as the internal UID)? I have ideas about integrating gateway messages with parsed .WTT data... (named for the one in Tasmania, not in Russia) Log in to reply |