transitions icon indicating copy to clipboard operation
transitions copied to clipboard

Add SCXML support

Open faisal00813 opened this issue 4 years ago • 3 comments

Finally, SCXML is now complete for adoption. Adding support for SCXMl will allow standardisation.

faisal00813 avatar Jun 19 '20 13:06 faisal00813

Some inspiration, https://github.com/davidkpiano/xstate

faisal00813 avatar Jun 19 '20 13:06 faisal00813

Hi @faisal00813,

Adding support for SCXML will allow standardisation.

If you are looking for a python engine capable of working with SCXML, you could have a look at PySCXML. It's not maintained anylonger but maybe it is sufficient for your purposes.

About the 'standardisation': With my current knowledge I would say that it is not possible for transitions to be SCXML-compatible:

  • transition's callbacks in general are hard to translate - this could be compensated by definining a custom event type
  • transition callbacks such as prepare, before, after, finalize are not supported by SCXML and I dont see how this can be compensated
  • SCXML's transition execution time between states is not supported by transitions. A transitions model is never 'between states'.
  • SCXML does not support 'negated' conditions like unless - it could be replaced with 'not condition' maybe
  • transitions has no <history> state - this could be a state extension maybe
  • transitions does not support datamodels - SCXML expects for instance the evaluation of ecmascript expression but I don't see something similar for transitions as evaluating strings as Python code or similar can caue a lot of damage. But afaik a datamodel other than None is not a must.
  • transition does not support a transition without a trigger/event - those could be dropped when parsing though
  • SCXML's invoke and communication with other services is (imho) out of scope for a 'simple' state machine such as transitions

Some inspiration, https://github.com/davidkpiano/xstate

It's a great state chart library for sure. But I could not find documentation about how SCXML can be imported or exported. Can you provide a link or Codepen/JSFiddle?

So, long story short: transitions and SCXML are designed significantly different. Is it possible to create an export/import system for a simple state machine without most transition callbacks, configuration capabilities and a very limited set of 'Executable content'? Probably. Will transitions support a majority of SCXML features? Probably not. Can transitions export/import xstate SCXML exports? I don't know (yet) :).

aleneum avatar Jun 19 '20 19:06 aleneum

That being said, I do think it is possible to build an SCXML engine based on transitions and add all the web technology the w3c likes to see in an SCXML implementation. This could be part of the pytransitions organisation but would be an individual module/package.

aleneum avatar Jun 22 '20 09:06 aleneum