sverweij / state-machine-cat

write beautiful state charts :scream_cat:
https://state-machine-cat.js.org
MIT License
802 stars 45 forks source link

Example in the documentation for a composite state with history, entry and exit actions and a set of substates #192

Closed marcelbaumann closed 1 year ago

marcelbaumann commented 1 year ago

Documentation example in the documentation for a composite state with history, entry and exit actions and a set of substates

Expected Behavior

I am looking for a documentation showing how to declare a

Current Behavior

I am maybe too dump. I could not infer the correct syntax for such a note. It is clear how to create a composite state with substates and history or a state with entry and exit actions. But I could not find out how to do both. Such a situation exists as described in the UML statechart documentation.

Possible Solution

Please extend the cool readme with this additional example.

Steps to Reproduce (for bugs)

missing in the readme

Context

Documentation missing. I have such FSM. The visual quality of state machine cat is awesome so I would like to display my FSM with it instead of PlantUML.

Your Environment

Used to online tool to validate syntax and display the diagram.

Thanks for this cool tool. I hope you can just extend the documentation with this example.

Sincerely

sverweij commented 1 year ago

Hi @marcelbaumann thanks for this feedback!

I gather you mean something like this?

image

You can get that with the following smcat script:

atomic: 
    entry/ entry for atomic 
    exit/ exit for atomic
    an activity,
composite: 
   entry/ entry action for composite state
   exit/ exit action for composite state
   an activity for composite state
{
    composite.history,
    "sub state a":
      entry/ entry for a
      exit/ exit for a
      an activity for a,
    "sub state b",
    c,    
    composite.final;

    "sub state a" => "sub state b";
    "sub state b" => c;
    c => "sub state a";
    c => composite.final;

};

initial => atomic;
atomic => composite;

From the documentation it's indeed not immediately obvious where to put these actions relative to the state machine within the composite state. If this is what you're looking for (check?), I'll add it to the readme.

marcelbaumann commented 1 year ago

Exactly the information I was looking for. Thanks a lot. I have the diagrams created by hand working as expected. Additionally, I extended my generator to support the correct syntax.

I think it is worth to add to the README file.

Thanks for the fast answer.

sverweij commented 9 months ago

Found I hadn't updated the README with an example on how to do do activities (like entry & exit triggers) on composite states yet. That's now corrected in commit 976f32a.