)
[Feature("Feature1")]
static class C1
{
[Action("Foo(y, x)"]
static void MyFoo(int x, int y) { /* ... */ }
}
[Feature("Feature2")]
static class C2
{
[Action("Foo(_, z)"]
static void MyBar(int z) { /* ... */ }
}
In this example, a single action with two parameters is defined. The enabling
condition of action Foo is the conjunction of the enabling conditions given in the
body of MyFoo and MyBar. The update of action Foo is the state change produced by
invoking MyFoo and MyBar in any order (the model must be written such that order
of update of partial action methods does not matter).
A.1.4 Enabling conditions
Actions are enabled by Boolean-valued methods called enabling conditions, preconditions,
or guards.
By convention, the enabling conditions of an action method have the same name
as the action method plus Enabled, possibly followed by one or more decimal digits.
For example,
static void FooEnabled() { return mode == Mode.Start; }
static void FooEnabled(int x) { return x > 0; }
static void FooEnabled2(int x) { return x < 100; }
288 Modeling Library Reference
[Action]
static void Foo(int x)
{
mode = Mode.Running;
}
In this example, the methods FooEnabled(), FooEnabled(int), and FooEnabled2(
int) are enabling conditions of action Foo.
Note that an action method may have more than one enabling condition by
overloading. An enabling condition method may have fewer arguments than (but
no more than) its associated action method.
Pages:
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376