Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic Rhapsody (steve huntington)
Decrease font size
Increase font size
Topic Title: Condition connector
Topic Summary:
Created On: 17-Dec-2006 10:07
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 17-Dec-2006 10:07
User is offline View Users Profile Print this message


Leonid Ryzhyk

Posts: 10
Joined: 27-Sep-2006

Hi,

I've just discovered that Rhapsody generates code for condition connectors in quite an unexpected (counter-intuitive?) way. For example, the attached statechart was intended to call the doSomething() method upon exit from the s1 state and then, depending on the return value, enter either s2 or s3.

Here is the code that Rhapsody generated for this fragment:

[CODE]
if(ret==true)
{
popNullTransition();
//#[ transition ROOT.running.disable_adapter.ROOT.disable_adapter.free_rx_pool.0
ret=doSomething();
//#]
free_rx_pool_subState = s2;
rootState_active = s2;
res = eventConsumed;
}
else
{
popNullTransition();
//#[ transition ROOT.running.disable_adapter.ROOT.disable_adapter.free_rx_pool.0
ret=doSomething();
//#]
free_rx_pool_subState = s3;
rootState_active = s3;
res = eventConsumed;
}

[/CODE]

This code checks the value of ret first and _then_ invokes doSomething()! In other words, Rhapsody assumes that the _incoming_ transition of the condition connector has no side effects.

Could anyone advise if this is a bug or a restriction dictated by some important correctness concerns? And in the latter case, what would be an alternative way to express this statechart in Rhapsody?

Thanks
Leonid
Report this to a Moderator Report this to a Moderator
 18-Dec-2006 01:07
User is offline View Users Profile Print this message


Jesper Gissel

Posts: 88
Joined: 20-Jul-2005

Hi Leonid.

I believe that Rhapsody generates code as the statechart semantics in the UML dictates:

First all guards are evaluated to find a way through and first then the actions are executed along that path.

This is purely a dump of my own memory, so please correct me if I'm wrong

A way to accomplish what you are trying to do, is to place a "dummy" state after your /ret = doSomething() transition and then use your current transitions on the other side of this dummy state, but of course without the doSomething action.
There might be a more clever way to do it, but I don't see way it shouldn't work.

Regards

-------------------------
Jesper Gissel
Johnson Controls Denmark, Marine Controls
Report this to a Moderator Report this to a Moderator
 18-Dec-2006 01:52
User is offline View Users Profile Print this message


Leonid Ryzhyk

Posts: 10
Joined: 27-Sep-2006

Hi Jesper,

[QUOTE=jegissel@yorkref.com]

I believe that Rhapsody generates code as the statechart semantics in the UML dictates:

First all guards are evaluated to find a way through and first then the actions are executed along that path.

This is purely a dump of my own memory, so please correct me if I'm wrong
[/QUOTE]

Thanks for pointing that out! You're right, a conditional pseudostate state is simply a shorthand for several transitions with the same trigger and different guards, which means that any triggered actions will only be executed after the guards are evaluated.

[QUOTE=jegissel@yorkref.com]

A way to accomplish what you are trying to do, is to place a "dummy" state after your /ret = doSomething() transition and then use your current transitions on the other side of this dummy state, but of course without the doSomething action.
There might be a more clever way to do it, but I don't see way it shouldn't work.
[/QUOTE]

Or I could just replace the conditional pseudostate with a real state. However, I wanted to avoid this for two reasons. First, I'd prefer not to clutter the statechart with additional states. Second, I'd like to avoid the performance impact of the additional state.

Leonid
Report this to a Moderator Report this to a Moderator
 16-Jan-2007 23:07
User is offline View Users Profile Print this message


Jan Diep

Posts: 18
Joined: 31-May-2005

I believe that if you double click on the state that you're trying to leave, it has an area to enter code upon exit of that state. So if I were you, I'd just put the doSomething code there, which guarantees that it'll run before you check the conditionals.
Report this to a Moderator Report this to a Moderator
 25-Jan-2007 17:53
User is offline View Users Profile Print this message


Gary Ceely

Posts: 1
Joined: 17-Oct-2005

You could use the doSomething() call as the guard on the transition into S2, and leave the 'else' guard into S3 as is. This will force the call to doSomething() as part of the condition evaluation process. Trying to call doSomething() as an exit action on S1 won't work because it's the condition evaluation process that determines whether or not you should leave the state in the first place.
Report this to a Moderator Report this to a Moderator
 1-Feb-2007 05:35
User is offline View Users Profile Print this message


Leonid Ryzhyk

Posts: 10
Joined: 27-Sep-2006

[QUOTE=gary_ceely@agilent.com]You could use the doSomething() call as the guard on the transition into S2, and leave the 'else' guard into S3 as is. This will force the call to doSomething() as part of the condition evaluation process. Trying to call doSomething() as an exit action on S1 won't work because it's the condition evaluation process that determines whether or not you should leave the state in the first place.[/QUOTE]

Thanks, this is my current solution, but probably not a good one, as Rhapsody documentation does not recommend using guards that have side effects.

statechart.jpg
statechart.jpg  (30 KB)

Report this to a Moderator Report this to a Moderator
 1-Feb-2007 05:38
User is offline View Users Profile Print this message


Leonid Ryzhyk

Posts: 10
Joined: 27-Sep-2006

[QUOTE=jan.diep@novatel.ca]I believe that if you double click on the state that you're trying to leave, it has an area to enter code upon exit of that state. So if I were you, I'd just put the doSomething code there, which guarantees that it'll run before you check the conditionals.[/QUOTE]

Thanks. This would work in some cases, but not for states that have several outgoing transitions labelled with different actions.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic Rhapsody forum.
There are currently 0 users logged in.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.