问题
In Enterprise Architect, I have a class defined with an attribute which is an enum. Is it possible to create a transition in a state machine based on a test of that enum's value? How?
I find the only way to create transitions with triggers or signals very limited.
My intent is to export the state machine to a requirements document. Although, I would think this should work with simulation.
回答1:
A trigger is what causes a token to flow along a state transition. Take for example this state transition:
When you open the properties of the transition you see
Now you can add a trigger by clicking the ellipsis right to Name:
. Here you either select an existing trigger or you create a new one on the fly.
The trigger type can be selected from the drop down:
Signal
is the default and you can choose one from the ellipsis right to the Specification:
. You can model the signal like this:
and you would describe in it's note that (e.g.) it fires whenever the enumeration changes.
The diagram does not show the use of the signal, but it's hidden in the connector's properties. To visualize that you could add appropriate notes and link them up to connector and elements:
Note: state machines are modeled for classes (and you usually put them inside the class). If you instantiate that class the instance will also have that state machine which can run as some kind of code inside the instance.
来源:https://stackoverflow.com/questions/50882494/enterprise-architect-refering-to-an-instantiated-classs-attribute-in-a-state-t