Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Implementing Guards(Just looking for quick answer)
Implementing Guards [message #1785640] Tue, 17 April 2018 17:31 Go to next message
Eric Rapos is currently offline Eric RaposFriend
Messages: 1
Registered: April 2018
Junior Member
Hello,

I am using Papyrus-RT 1.0, and can't for the life of me figure out how to correctly implement guards.

I have a transition into a choice point, and multiple transitions out, but the only mention I see for guards is on the Code Snippet window for the transition, but cannot seem to make this work.

Any clarification would be great.

Thanks!
Re: Implementing Guards [message #1785717 is a reply to message #1785640] Wed, 18 April 2018 17:43 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 351
Registered: March 2011
Senior Member
Hi Eric.

There are two kinds of guards: transition guards and trigger guards. I assume you are looking for transition guards.

There are two approaches: use guards directly on a transition whose source is a state, and which has at least one trigger, or use guards on transitions that leave a choice point (and the transition leading to the choice point has a trigger). Both are equivalent (*). In both cases you write the guard in the "Guard" tab of the code-snippet view as you found, but keep in mind that the guard is a statement, not a condition. Hence, you should write, e.g.

return data > 0;


rather than

data > 0


See the attached example. There is a capsule with two parts. Each part is a capsule that shows the two styles.

A key thing is that the variables that you use in your guard must correspond to the parameters of the protocol message. In the attached example, the protocol message is "m" and has a unique int parameter called "data", so the guard expression uses 'data'.

You can also attach guards to triggers: select a transition, and in the Properties view, select the relevant trigger (assuming you already added a trigger) and click in the "Guard" field. This will open a "Trigger Guard" code-snippet view. In this case the transition will only be enabled when the message arrives and the trigger guard is true.

(*) Actually there is a difference: if you have a transition, say t1 that leads to a choice points that have guards, and the transition is triggered, then it will execute its action before evaluating the guards of the transitions leaving the choice point. In the other case, if the transitions with guards leave a state rather than a choice point, then their actions are executed after, and only if the message is received, and the guard in question is true.




  • Attachment: Guards.zip
    (Size: 10.22KB, Downloaded 15 times)

[Updated on: Wed, 18 April 2018 17:47]

Report message to a moderator

Previous Topic:Synchronous send() in UML-RT/Papyrus-RT
Next Topic:Flatten state machines
Goto Forum:
  


Current Time: Sun Sep 23 11:52:00 GMT 2018

Powered by FUDForum. Page generated in 0.01743 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top