3

I thought I could differentiate between event and guard. But I came across an event being similar to guard:

counter > 4 [pin is high] / switch on
^^^^^^^^^^^ 
   event

where I viewed the variable counter changes from some value smaller than 4 to that greater than 4 as event. Does that mean event can also be a condition like guard?

kaosad
  • 1,233
  • 1
  • 11
  • 15

1 Answers1

2

An event is the thing that triggers the transition. In your case counter > 4 is a change event, meaning "the counter value has changed and its value is now greater than 4".

The code between the brackets is the guard. In your case pin is high, meaning "the transition is only enabled if the pin is high".

switch on is the behavior that is executed when the transition is executed.

Footnote: In your example the event is indeed very similar to the guard.

In C it could look like that:

/** 
 * this interrupt is triggered when the
 * counter exceeds the threshold (4)
 */
static void counter_isr(void)
{
   if (pin_is_high(PIN))
       switch_on();
} 

From the UML 2.5 specification:

14.2.3.8 Transitions ... A Transition may own a set of Triggers, each of which specifies an Event whose occurrence, when dispatched, may trigger traversal of the Transition. A Transition trigger is said to be enabled if the dispatched Event occurrence matches its Event type.

14.2.4.9 Transition ... The default textual notation for a Transition is defined by the following BNF expression:

[<trigger> [‘,’ <trigger>]* [‘[‘ <guard>’]’] [‘/’ <behavior-expression>]]

In other words: trigger [guard] / behavior

sergej
  • 17,147
  • 6
  • 52
  • 89