Skip to content
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

State Machine Triggers / Actions missing #2845

Open
AdamZsofi opened this issue Nov 16, 2023 · 4 comments
Open

State Machine Triggers / Actions missing #2845

AdamZsofi opened this issue Nov 16, 2023 · 4 comments
Labels
feature A new feature

Comments

@AdamZsofi
Copy link

Is your feature request related to a problem?

The state machine diagram feels really nice to use with composite states, guards, etc., but the lack of actions and triggers on transitions makes Gaphor for state machine modeling inadequate (at least for me).

I would like to use Gaphor in education: teaching UML state machines (among other diagrams). Correct syntax and understanding of basic semantics (e.g. in which order events are executed) is crucial and these elements play an important role in that.

Describe the solution you'd like

I would like to have two simple labels on state machine transitions, where I can add actions and triggers (simply strings, just as it is for guards).
I would like the value of these to show around the middle of the transition in the following manner: trigger [guard] / action.

Describe alternatives you've considered

I considered using the "name" label, but that shows up at the end of the transition and is often hard to read. I also considered adding all these to the guard field, but then the action and the trigger are showing in brackets (syntactically incorrect).

If it would be possible to show the value of the name field around the middle of the transition or if it would be movable, that would be adequate for me as well. I do not care about code generation and similar features, I just need a label around the middle of the transition, which I can write to.

I am not sure why this has not come up yet, I tried to search in older issue, but could not find anything. If the reason for this missing is just lack of developer time, I would also be willing to implement it (it seems fairly simple).

Thanks in advance!

@marek-piirikivi
Copy link
Contributor

Thank you for drawing attention to that. This would definitely be a fine addition.

If you want to get started with this on your own, few pointers to get you started quicker:

  1. from gaphor/UML/uml.py you can see that class Transition already has guard and effect
  2. To allow editing effect, you have to work with gaphor/UML/states/propertypages.py
  3. For trigger, UML model has to be changed. Gaphor uses auto-generated uml.py, so after model is changed, uml.py needs to be regenerated which would allow you to enable editing trigger on the property page as well. Open UML.gaphor with the gaphor itself, define necessary relationships in the UML model; save it; and run poetry run poe uml to generate code.
  4. For getting the transition information correctly drawn on the diagram, see gaphor/UML/states/transition.py

@mikekidner
Copy link
Contributor

Hi @marek-piirikivi,
Thanks for the tips re remaking the model from the gaphor file. I was wondering how to do that.
I had a go at running poetry to recreate raaml.py from the RAAML model and it complained:

poetry run poe raaml
ModuleNotFoundError: No module named 'defusedxml'

But
Requirement already satisfied: defusedxml in blah/blah/lib/python3.11/site-packages (0.7.1)

Some path weirdness in poetry perhaps?

@marek-piirikivi
Copy link
Contributor

Hi @mikekidner

Maybe you have missing dependencies. poetry install maybe fixes the problem? I tried and the raaml generation runs just fine.

I believe @amolenaar or @danyeaw can help you better. Seems to be worth a separate discussion.

@danyeaw
Copy link
Member

danyeaw commented Nov 20, 2023

I would try removing your virtualenv and then recreating it and run poetry install again.

@amolenaar amolenaar added the feature A new feature label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

5 participants