statecharts

10 views
Skip to first unread message

Mikhail Bessonov

unread,
Dec 28, 2009, 8:07:10 AM12/28/09
to gaphor-dev
Hi,

I've just started looking at Gaphor with an intent to add some project-
specific code generation plugin eventually. At the moment, I play
around with the tool as an end user (and my expectations are largely
formed by Rhapsody).

I could not figure out how to do some things with state diagrams:

1. How can I express that a particular statechart defines the behavior
of a particular class? In some tools, I can right-click on a class (in
a diagram or in a tree view), then click on an "Add..." item in a drop-
down menu, and select "Statechart". There is a one-to-one relationship
formed between the class and the state machine. Is there some way of
achieving it in Gaphor? Just an informal note will not do, because the
future code generation must be able to navigate between the class and
the state machine.

2. I could not add any events, guards or actions to transitions. There
is a little gray box showing up when I click on a transition, but I
could not type anything in the box.

3. Is there any way to specify entry and exit actions for a state?

4. Are nested states recognized? Nothing visible happens when I move
one state inside the other (or let them partially overlap).

5. Can I specify orthogonal states (or regions within a state)?

I'm asking these questions, in particular, because the meta-model
(UML2.gaphor) seems to have all the necessary attributes and
associations in place. It seems to be relatively straightforward to
add this kind of functionality, if it was never in place before. Is
someone working on this?

Best,
Mike

Artur Wroblewski

unread,
Dec 28, 2009, 11:51:52 AM12/28/09
to gapho...@googlegroups.com
On Mon, Dec 28, 2009 at 1:07 PM, Mikhail Bessonov <za...@mail.ru> wrote:
> Hi,
>
> I've just started looking at Gaphor with an intent to add some project-
> specific code generation plugin eventually. At the moment, I play
> around with the tool as an end user (and my expectations are largely
> formed by Rhapsody).
>
> I could not figure out how to do some things with state diagrams:
>
> 1. How can I express that a particular statechart defines the behavior
> of a particular class? In some tools, I can right-click on a class (in
> a diagram or in a tree view), then click on an "Add..." item in a drop-
> down menu, and select "Statechart". There is a one-to-one relationship
> formed between the class and the state machine. Is there some way of
> achieving it in Gaphor? Just an informal note will not do, because the
> future code generation must be able to navigate between the class and
> the state machine.

It is not possible at the moment.

> 2. I could not add any events, guards or actions to transitions. There
> is a little gray box showing up when I click on a transition, but I
> could not type anything in the box.

Which version of Gaphor are you using? I do remember fixing
some bug recently, which prevented from adding a guard to
a transition.

> 3. Is there any way to specify entry and exit actions for a state?

Not yet, but I am working on it at the moment.

> 4. Are nested states recognized? Nothing visible happens when I move
> one state inside the other (or let them partially overlap).

Not yet. But should be easy to implement.

> 5. Can I specify orthogonal states (or regions within a state)?

Not yet.

> I'm asking these questions, in particular, because the meta-model
> (UML2.gaphor) seems to have all the necessary attributes and
> associations in place. It seems to be relatively straightforward to
> add this kind of functionality, if it was never in place before. Is
> someone working on this?

Some parts... yes :) Anyway, if you would like to do some coding
by yourself, I would be more than happy to guide you if you
need some help. If not, then I would appreciate feature requests
in the issues tracker.

Recently, Gaphor and Gaphas were moved from devjavu.com (as
it ceased its operation), so I am not sure where our issues tracker
is at the moment. Arjan?

Best regards,

w

Arjan Molenaar

unread,
Dec 28, 2009, 3:50:06 PM12/28/09
to gapho...@googlegroups.com
Hi,

Regarding code generation from state diagrams: I've done some of that in the past. I've dropped the code on GitHub as cr2.zaakbegeleider.

> Recently, Gaphor and Gaphas were moved from devjavu.com (as
> it ceased its operation), so I am not sure where our issues tracker
> is at the moment. Arjan?

Yeah, Uhhmm.. Currently issues are tracked at github. I've been experimenting with lighthouseapp.com a bit. It looks promising and can so basically all that Trac could (how I miss that tool :( ).

Regards,

Arjan

Mikhail Bessonov

unread,
Dec 28, 2009, 5:42:00 PM12/28/09
to gaphor-dev
Hi,

Yes, I would like to give it a try with the coding. Any hints would be
very much appreciated, I'm getting a grip on the code tree quite
slowly by now.

I'm using the head version from the git depository on github.

The bug with the guards seems to be there:

2009-12-28 19:26:22,052 ERROR Could not construct property page for
Properties
Traceback (most recent call last):
File "/home/mikeb/src/gaphor/gaphor/ui/propertyeditor.py", line 67,
in create_pages
page = adapter.construct()
File "/home/mikeb/src/gaphor/gaphor/adapters/states/
propertypages.py", line 27, in construct
subject = self.context.subject
AttributeError: 'TransitionPropertyPage' object has no attribute
'context'

I think, self.subject instead of self.context.subject should do the
right thing.

How should I post the patches, diff by e-mail?

It looks like I can create new issues at github.

Best regards,
Mike

Mikhail Bessonov

unread,
Dec 28, 2009, 5:43:56 PM12/28/09
to gaphor-dev
Hi,

> Regarding code generation from state diagrams: I've done some of that in the past. I've dropped the code on GitHub as cr2.zaakbegeleider.

Unfortunately, I could not find it there. Could you please post a URL?

Many thanks,
Mike

> Regards,
>
> Arjan

Mikhail Bessonov

unread,
Dec 29, 2009, 4:29:31 AM12/29/09
to gaphor-dev
Sorry, I've found it.

Mikhail Bessonov

unread,
Dec 29, 2009, 9:41:00 AM12/29/09
to gaphor-dev
I've posted a bug to the github with a patch that supposedly fixes the
transition properties issue. Should I proceed with bugs/patches in the
tracker instead of polluting this group? Obviously, I can not commit
directly to github.

Arjan Molenaar

unread,
Dec 29, 2009, 11:20:27 AM12/29/09
to gapho...@googlegroups.com

On 28 Dec 2009, at 23:43, Mikhail Bessonov wrote:

> Hi,
>
>> Regarding code generation from state diagrams: I've done some of that in the past. I've dropped the code on GitHub as cr2.zaakbegeleider.
>
> Unfortunately, I could not find it there. Could you please post a URL?

You should be able to find it at http://github.com/amolenaar/cr2.zaakbegeleider

(just uploaded it last night ;) )

Regards,

Arjan

> Many thanks,
> Mike
>
>> Regards,
>>
>> Arjan
>

> --
>
> You received this message because you are subscribed to the Google Groups "gaphor-dev" group.
> To post to this group, send email to gapho...@googlegroups.com.
> To unsubscribe from this group, send email to gaphor-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gaphor-dev?hl=en.
>
>

Arjan Molenaar

unread,
Dec 29, 2009, 11:22:53 AM12/29/09
to gapho...@googlegroups.com

On 29 Dec 2009, at 15:41, Mikhail Bessonov wrote:

> I've posted a bug to the github with a patch that supposedly fixes the
> transition properties issue. Should I proceed with bugs/patches in the
> tracker instead of polluting this group? Obviously, I can not commit
> directly to github.

What you can do (if you have an account), is fork gaphor. Then you can send pull requests to me. I haven't tried this before but it ought to be an awesome feature :)

Regards,

Arjan

> On 29 дек, 01:42, Mikhail Bessonov <za...@mail.ru> wrote:
>> Hi,
>>
>> Yes, I would like to give it a try with the coding. Any hints would be
>> very much appreciated, I'm getting a grip on the code tree quite
>> slowly by now.
>>
>> I'm using the head version from the git depository on github.
>>
>> The bug with the guards seems to be there:
>>
>> 2009-12-28 19:26:22,052 ERROR Could not construct property page for
>> Properties
>> Traceback (most recent call last):
>> File "/home/mikeb/src/gaphor/gaphor/ui/propertyeditor.py", line 67,
>> in create_pages
>> page = adapter.construct()
>> File "/home/mikeb/src/gaphor/gaphor/adapters/states/
>> propertypages.py", line 27, in construct
>> subject = self.context.subject
>> AttributeError: 'TransitionPropertyPage' object has no attribute
>> 'context'
>>
>> I think, self.subject instead of self.context.subject should do the
>> right thing.
>>
>> How should I post the patches, diff by e-mail?
>>
>> It looks like I can create new issues at github.
>>
>> Best regards,
>> Mike
>

Mikhail Bessonov

unread,
Dec 29, 2009, 12:34:13 PM12/29/09
to gaphor-dev
Hi,

I would like to discuss the issues below in more detail.

> > 1. How can I express that a particular statechart defines the behavior
> > of a particular class?
>

> It is not possible at the moment.

I presume, the right way is to use the 'context' attribute of the
StateMachine and the 'ownedBehavior' of Class to set up such a
relationship, right?

The way it should be expressed in a diagram is another story, we
probably need a concept of links here for fast switching between a
class and its state machine.

> > 3. Is there any way to specify entry and exit actions for a state?
>
> Not yet, but I am working on it at the moment.

Excellent! The action part of a transition seems to be a related
issue. They all are currently associated with a rather generic
Behavior metaclass. What is really needed is probably Activity (with
'body' and 'language' attributes; I could imagine multiple
implementations of the same action in different languages). There is
also an Action metaclass in the BasicActivities package, which seems
to be rather off target.

Which approach have you taken with entry and exit actions?

> > 4. Are nested states recognized? Nothing visible happens when I move
> > one state inside the other (or let them partially overlap).
>
> Not yet. But should be easy to implement.

Was something similar done already somewhere else in the code? Nesting
a class into a package, a package into package, a class into another
class, etc.? Where should I start?

> > 5. Can I specify orthogonal states (or regions within a state)?
>
> Not yet.

Well, this seems complex and can wait.

Best,
Mike

Artur Wroblewski

unread,
Dec 30, 2009, 6:49:18 AM12/30/09
to gapho...@googlegroups.com
On Tue, Dec 29, 2009 at 5:34 PM, Mikhail Bessonov <za...@mail.ru> wrote:
> Hi,
>
> I would like to discuss the issues below in more detail.
>
>> > 1. How can I express that a particular statechart defines the behavior
>> > of a particular class?
>>
>> It is not possible at the moment.
>
> I presume, the right way is to use the 'context' attribute of the
> StateMachine and the 'ownedBehavior' of Class to set up such a
> relationship, right?

Looking roughly at the specs - yes.

> The way it should be expressed in a diagram is another story, we
> probably need a concept of links here for fast switching between a
> class and its state machine.

Not sure about state machines, but in case of interaction diagrams
there is similar problem between Lifeline and a classifier. In this
case, Lifeline is supposed to have an icon of a classifier's shape
or look like the classifier itself - but I am not sure at the moment.

>> > 3. Is there any way to specify entry and exit actions for a state?
>>
>> Not yet, but I am working on it at the moment.
>
> Excellent!  The action part of a transition seems to be a related
> issue. They all are currently associated with a rather generic
> Behavior metaclass. What is really needed is probably Activity (with
> 'body' and 'language' attributes; I could imagine multiple
> implementations of the same action in different languages). There is
> also an Action metaclass in the BasicActivities package, which seems
> to be rather off target.
>
> Which approach have you taken with entry and exit actions?

For body/language attributes - do you mean OpaqueBehavior?

I am still not sure how to implement this part actually. I was thinking
about Activity instance assigned to entry/exit/doActivity state attributes
and then setting Acttivity.specification... I need to read more about it.

Any suggestions are welcome. :)

>> > 4. Are nested states recognized? Nothing visible happens when I move
>> > one state inside the other (or let them partially overlap).
>>
>> Not yet. But should be easy to implement.
>
> Was something similar done already somewhere else in the code? Nesting
> a class into a package, a package into package, a class into another
> class, etc.? Where should I start?

Yes. From user perspective
- put node (deployments) on a diagram, then drop artifact/component/another node
on the node item
- put interaction (interactions) on a diagram, then drop lifeline on
the interaction
item
- subsystem (components) accepts use cases
- and the most advanced (still needs some polishing) - put a swimline
on a diagram,
then try to nest swimlines within swimlines and actions within swimlines

From the code perspective look at gaphor/adapters/grouping.py.

>> > 5. Can I specify orthogonal states (or regions within a state)?
>>
>> Not yet.
>
> Well, this seems complex and can wait.

Is it similar to swimlines problem?

Best regards,

w

Arjan Molenaar

unread,
Dec 30, 2009, 10:30:03 AM12/30/09
to gapho...@googlegroups.com

On 29 Dec 2009, at 18:34, Mikhail Bessonov wrote:

> Hi,
>
> I would like to discuss the issues below in more detail.
>
>>> 1. How can I express that a particular statechart defines the behavior
>>> of a particular class?
>>
>> It is not possible at the moment.
>
> I presume, the right way is to use the 'context' attribute of the
> StateMachine and the 'ownedBehavior' of Class to set up such a
> relationship, right?

Both have different associations. The correct one should be BehavioredClassifier.ownedBehavior. (According to UML 2.2 specs)

> The way it should be expressed in a diagram is another story, we
> probably need a concept of links here for fast switching between a
> class and its state machine.

Yes, also something like a state machine should be defined. It can be connected to a diagram if we like (then the diagram becomes the state machine, or it can be defined as we already have with Interactions. For now I'd prefer the second solution.

>>> 3. Is there any way to specify entry and exit actions for a state?
>>
>> Not yet, but I am working on it at the moment.
>
> Excellent! The action part of a transition seems to be a related
> issue. They all are currently associated with a rather generic
> Behavior metaclass. What is really needed is probably Activity (with
> 'body' and 'language' attributes; I could imagine multiple
> implementations of the same action in different languages). There is
> also an Action metaclass in the BasicActivities package, which seems
> to be rather off target.
>
> Which approach have you taken with entry and exit actions?
>
>>> 4. Are nested states recognized? Nothing visible happens when I move
>>> one state inside the other (or let them partially overlap).
>>
>> Not yet. But should be easy to implement.
>
> Was something similar done already somewhere else in the code? Nesting
> a class into a package, a package into package, a class into another
> class, etc.? Where should I start?

We have this working for Interaction and sequence/collaboration diagrams.

Regards,

Arjan

>>> 5. Can I specify orthogonal states (or regions within a state)?
>>
>> Not yet.
>
> Well, this seems complex and can wait.
>
> Best,
> Mike
>

Artur Wroblewski

unread,
Jan 1, 2010, 5:59:53 PM1/1/10
to gapho...@googlegroups.com
On Tue, Dec 29, 2009 at 2:41 PM, Mikhail Bessonov <za...@mail.ru> wrote:
> I've posted a bug to the github with a patch that supposedly fixes the
> transition properties issue. Should I proceed with bugs/patches in the
> tracker instead of polluting this group? Obviously, I can not commit
> directly to github.

I have commited another fix, which shall fix all the problems related
to state transition guard editing.

Best regards,

w

Arjan Molenaar

unread,
Jan 2, 2010, 12:00:46 PM1/2/10
to gapho...@googlegroups.com

On 28 Dec 2009, at 23:42, Mikhail Bessonov wrote:

> Hi,
>
> Yes, I would like to give it a try with the coding. Any hints would be
> very much appreciated, I'm getting a grip on the code tree quite
> slowly by now.

Can you give me a brief explanation of what you've discovered so far? I'd love to fill in the blanks and it might help me set a basis for some documentation.

Regards,

Arjan

Artur Wroblewski

unread,
Jan 19, 2010, 7:29:01 AM1/19/10
to gapho...@googlegroups.com
On Tue, Dec 29, 2009 at 5:34 PM, Mikhail Bessonov <za...@mail.ru> wrote:
[...]

>> > 3. Is there any way to specify entry and exit actions for a state?
>>
>> Not yet, but I am working on it at the moment.
>
> Excellent!  The action part of a transition seems to be a related
> issue. They all are currently associated with a rather generic
> Behavior metaclass. What is really needed is probably Activity (with
> 'body' and 'language' attributes; I could imagine multiple
> implementations of the same action in different languages). There is
> also an Action metaclass in the BasicActivities package, which seems
> to be rather off target.
>
> Which approach have you taken with entry and exit actions?

I think I will go the same way as I did with Message UML class from
interactions. In case when user enters text for an instance of Message
- entered text for message is not parsed therefore no complex structures
are created (i.e. no operation with attributes, signals, etc)
- entered text is just assigned to Message.name
- if in the future we implement parsing of message text, then it will
be easy to upgrade currently created files

Therefore, in case of entry/exit actions and doActivity I want to create
an Activity instance and assign it to appropriate State attribute (i.e.
State.entry). The text entered by user will be set to Activity.name, i.e.

act = Activity()
act.name = entry.get_text()
state.doActivity = act

This seems to be the simplest way of introducing the entry/exit actions
(and doActivity) with easy possibility to upgrade to more complex structures
in the future.

Any comments? Suggestions?

Best regards,

w

Mikhail Bessonov

unread,
Jan 20, 2010, 6:01:14 AM1/20/10
to gaphor-dev
> Therefore, in case of entry/exit actions and doActivity I want to create
> an Activity instance and assign it to appropriate State attribute (i.e.
> State.entry). The text entered by user will be set to Activity.name, i.e.
>
>    act = Activity()
>    act.name = entry.get_text()
>    state.doActivity = act
>
> This seems to be the simplest way of introducing the entry/exit actions
> (and doActivity) with easy possibility to upgrade to more complex structures
> in the future.

Looks very reasonable to me. In the end of the day, it would be cool
to offer auto-completions like association, attribute and operation
names, but it can certainly wait.

Mike

Artur Wroblewski

unread,
Jan 20, 2010, 6:16:41 AM1/20/10
to gapho...@googlegroups.com
On Wed, Jan 20, 2010 at 11:01 AM, Mikhail Bessonov <za...@mail.ru> wrote:
>> Therefore, in case of entry/exit actions and doActivity I want to create
>> an Activity instance and assign it to appropriate State attribute (i.e.
>> State.entry). The text entered by user will be set to Activity.name, i.e.
>>
>>    act = Activity()
>>    act.name = entry.get_text()
>>    state.doActivity = act
>>
>> This seems to be the simplest way of introducing the entry/exit actions
>> (and doActivity) with easy possibility to upgrade to more complex structures
>> in the future.
>
> Looks very reasonable to me.

OK! :)

> In the end of the day, it would be cool
> to offer auto-completions like association, attribute and operation
> names, but it can certainly wait.

For that we need classifier -> state association (or in other areas
classifier -> lifeline, etc),
which has its own problems to solve, i.e. what happens to state/lifeline when
classifier is deleted? How do we monitor the association? How user,
items and diagram
interaction shall work (i.e. drag and drop)? And more...

Just pointing above out to show that problem is bit complex and needs time
to solve. For sure we need more support, ideas and manpower, so
if you have any suggestions, the code itself or just the questions how
things are working, then please don't hesistate to speak.

Best regards,

w

Artur Wroblewski

unread,
Jan 23, 2010, 1:05:35 PM1/23/10
to gapho...@googlegroups.com
I have pushed the changes for state's entry/exit/doActivity.

Enjoy!

Best regards,

w

Arjan Molenaar

unread,
Jan 25, 2010, 1:19:53 AM1/25/10
to gapho...@googlegroups.com
Hi,

Looks good.

I just tried to copy the entry and it doesn't update the name. This is odd. I also checked with classes and there also the name is not copied.

So far I have not found out what's causing this. Anyway, I think we should fix this before releasing. What do you think?

(I can drop a beta though.)

Regards,

Arjan

Artur Wroblewski

unread,
Jan 25, 2010, 5:23:08 AM1/25/10
to gapho...@googlegroups.com
On Mon, Jan 25, 2010 at 6:19 AM, Arjan Molenaar <gap...@gmail.com> wrote:
> Hi,
>
> Looks good.
>
> I just tried to copy the entry and it doesn't update the name. This is odd. I also checked with classes and there also the name is not copied.

But if you open item editor, then the name is visible. Seems like
diagram item's field is not updated after pasting it onto a diagram.

> So far I have not found out what's causing this. Anyway, I think we should fix this before releasing. What do you think?

IMHO, there are still bugs we need to fix.

Best regards,

w

Reply all
Reply to author
Forward
0 new messages