-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add missing fields in plain scxml #63
Conversation
"w", | ||
encoding="utf-8", | ||
) as f: | ||
f.write(scxml_model.as_xml_string(data_type_as_argument=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that the data types are stored using the comment structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, thanks!
else_body = add_targets_to_scxml_send(entry.get_else_execution(), events_to_automata) | ||
new_body.append(ScxmlIf(if_conditionals, else_body)) | ||
elif isinstance(entry, ScxmlSend): | ||
target_automata = events_to_automata.get(entry.get_event(), {"NONE"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EnricoGhiorzi on this one I am not entirely sure: there are cases in which we send an event, but we define no transition for it.
This might be desired in case the developer wants to expose a specific information from a single automaton only for referring to it in a property.
For now, I decided to add a "NONE" target for such cases, but we can find other alternatives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the use for such a feature, but I worry about aligning the model with the implementation. Would this be how the real system implements such a feature? In other words, is it possible to monitor a topic that has a publisher but no subscribers? (I guess the monitor itself is a subscriber, but that is not modelled.)
Reguarding the "NONE" syntax, I looked up the SCXML specification but is provided no insight: there is no way to send an event into the void, and having a non-existing target would raise an error.
Another option could be to automatically create such a "NONE" automaton and just let it process any event it receives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To monitor a topic, you need to subscribe to it, and as you mentioned above, the monitor will do exactly that.
If you are fine with it, you can assume to have the NONE automaton that acts as a receiver for all events (though I am not sure it makes sense to auto-generate it: maybe it is easier to have a script removing the send events with a NONE target)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it is easier to have a script removing the send events with a NONE target
I don't get it: if we remove these sends, the events will not be observable in SCAN either. I think we either need to send the events into the void (as it is now) and allow that in SCAN, or to generate a target NONE automaton, either at AS2FM or SCAN level, possibly consistently with the actual implementation. @SofiaFaraci might have some insight on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment about (optionally) removing the NONE events was only for executing system outside of SCAN. Otherwise, I would be happy to keep it as is and allow the NONE target in SCAN, if that works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we either need to send the events into the void (as it is now) and allow that in SCAN, or to generate a target NONE automaton, either at AS2FM or SCAN level, possibly consistently with the actual implementation. @SofiaFaraci might have some insight on this.
In the actual implementation there is no need for a target for the send tag, the events are directly handled by the generated C++ code of the SMs that sends the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, it addresses so many of the issues we have with the format! There are a couple of points that I commented on but the code looks generally good.
I run the code on @SofiaFaraci's model and it works, minus adding the simplest NONE.scxml automaton to receive the messages sent to it. I think that's the main issue to address, either on AS2FM side or on SCAN side.
This PR also addresses the same topic as the branch feature/get-closer-to-standard-scxml
, maybe we could add those commits to this PR too?
"w", | ||
encoding="utf-8", | ||
) as f: | ||
f.write(scxml_model.as_xml_string(data_type_as_argument=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, thanks!
else_body = add_targets_to_scxml_send(entry.get_else_execution(), events_to_automata) | ||
new_body.append(ScxmlIf(if_conditionals, else_body)) | ||
elif isinstance(entry, ScxmlSend): | ||
target_automata = events_to_automata.get(entry.get_event(), {"NONE"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the use for such a feature, but I worry about aligning the model with the implementation. Would this be how the real system implements such a feature? In other words, is it possible to monitor a topic that has a publisher but no subscribers? (I guess the monitor itself is a subscriber, but that is not modelled.)
Reguarding the "NONE" syntax, I looked up the SCXML specification but is provided no insight: there is no way to send an event into the void, and having a non-existing target would raise an error.
Another option could be to automatically create such a "NONE" automaton and just let it process any event it receives.
The only change from that branch is this: 27ab9c2 I will have a look at renaming the event fields and to allow _event.origin in the transition (though we are not planning to really make use of that feature for now: are you?) |
Internally SCAN already supports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good!
I just fixed the remaining conversion problems and updated the test files. It should be good to go! |
After some discussion with Enrico, it seems there is a problem with verifying n-to-n communication entries (that is the standard with topics) and we opted for exporting, for plain scxml, an additional state machine that gets all the published messages and sends them to all subscribers. |
15ab218
to
b1bc59a
Compare
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
…cxml Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
…nces Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
Signed-off-by: Marco Lampacrescia <[email protected]>
b1bc59a
to
eae7ad6
Compare
elem.attrib.clear() | ||
for k in sorted(elem.keys()): | ||
elem.set(k, elem.get(k)) | ||
for k in sorted(elem_attributes.keys()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💓
This addresses the requests from @EnricoGhiorzi in #59
It will be turned into an actual PR once the BT SCXML one (#58) will be merged.
Before that happens, we can use it to better align on SCAN's actual requirements