我曾以为我可以区分事件和守卫。但我发现一个事件与守卫类似:
counter > 4 [pin is high] / switch on
^^^^^^^^^^^
event
我观察到变量计数器从小于4的某个值改变为大于4的某个值,这被视为一个事件。那是否意味着事件也可以像守卫条件一样成为一个条件?
counter > 4
是一个变化事件,意思是“计数器值已经改变,并且它的值现在大于4”。pin is high
表示“只有当引脚高电平时才能执行转换”。
switch on
是执行转换时执行的行为。/**
* this interrupt is triggered when the
* counter exceeds the threshold (4)
*/
static void counter_isr(void)
{
if (pin_is_high(PIN))
switch_on();
}
来自 UML 2.5 规范:
换句话说: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>]]
触发器 [守卫条件] / 行为