Evaluate enumeration input in a fucntion (for decisionNode)

Moderator: Moderators

Evaluate enumeration input in a fucntion (for decisionNode)

Postby karstenk » Thu Jul 17, 2014 1:56 am

Hello,

I want to evaluate in a function (which should be used for a decisionNode) incoming itemFlows.
The itemFlows are typed by enumerations.
How can I set the outgoing result depending of the input?

Overview.jpg

I tried to evaluate the incoming itemflows in the function "determine" by a javascript, but the enum input is not correct detected.

Code: Select all
result = 0;
if(side == Side.left && location == Location.top)
{
result = 1;

if(side == Side.right && location == Location.top)
{
result = 2;
}


ERROR: Cannot evaluate Function Behavior determine: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "Side" is not defined. (<Unknown source>#2) in <Unknown source> at line number 2.

How can I build up in the decisionNode (function) the result, which then can be used in the guards?

Best regards
Karsten
You do not have the required permissions to view the files attached to this post.
karstenk
Forum Newbie
Forum Newbie
 
Posts: 13
Posts Rating:0
Joined: Tue Jun 18, 2013 12:42 am

Re: Evaluate enumeration input in a fucntion (for decisionNode)

Postby kritsana_u » Thu Jul 17, 2014 9:37 pm

Dear Karsten,

When the decision has two incoming edges, the UML v2.4.1 Superstructure Specification describes only the case that one is object flow and another is the control flow (See the constraints of DecisionNode). So, we support only such case. But from your attached picture, there are two object flows come to a decision node. We would suggest to change you model as the following figure (no need for the script, the guard condition must be specified by the instanceValue of an enumeration literal).

Screen Shot 2557-07-18 at 10.34.39 AM.png


Screen Shot 2557-07-18 at 10.18.05 AM.png


Screen Shot 2557-07-18 at 10.17.55 AM.png


We also attached the model here
sample.mdzip


Best regards,

Kritsana U.
You do not have the required permissions to view the files attached to this post.
kritsana_u
Forum Expert
Forum Expert
 
Posts: 116
Posts Rating:3
Joined: Wed Jan 27, 2010 3:02 am

Re: Evaluate enumeration input in a fucntion (for decisionNode)

Postby karstenk » Fri Jul 18, 2014 6:23 am

Dear Kritsana,

thank you for your hint regarding the multiplicity of incomming control flows and item flows to one decesion node.
I have changed our model. Now the simulation works.

Best regards
Karsten
karstenk
Forum Newbie
Forum Newbie
 
Posts: 13
Posts Rating:0
Joined: Tue Jun 18, 2013 12:42 am


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 0 guests