State Scope
State Scopes allow to define Variable Declarations, Signal Declarations, and Local Reactions:
Variable Declarations
Variable Declarations in a State Scope are visible in this state and its descendant states.
A Variable:
- has a Direction,
- can be Static (optional),
- has a Datatype,
- has a Name,
- can be initialised (optional),
- can get a CombineOperator(optional)
Examples:
- input boolean A;
- output boolean A;
- input output boolean A; // double direction (input and output))
- input static boolean A; //static variable
- boolean A; //local, without direction
- input integer I=10; //the variable I is initialised
- input integer I with '+' //the combine operator is '+'
Declarations
Within State Scopes there can be declarations of variables (and signals)?.
A Variable:
- has an optional (not direction for local variables) direction,
- can be static,
- has a datatype (integer, boolean, real, string, void)
- an optional initial value
- has a CombineOperator (-, +, *, max, min, or, and, host).
VariableDefinition:
{VariableDefinition} direction=VarDirection? (isStatic?='static')? type=[types::Type|FQN] name=ID ('=' varInitialValue=Expression)? ('with' varCombineOperator=CombineOperator)?;
Examples:
Signals
4 views to implement signals:
- don't use signals. Use only variables
- Boolean variables are interpreted as signals (no Boolean variables available)
- Yakindu events are interpreted as signals
- declare a new declarations type named signal
advantage | disadvantage | |
---|---|---|
Don't use signals |
|
|
Boolean variables as signals |
|
|
Yakindu events as signals |
Declaration: in signal I; |
|
New declaration type |
Declaration: in signal I; |
|
State Reactions
Entry
is an Effect.
EntryAction returns sgraph::Effect:
{EntryAction} 'Entry' ''/' effect=ReactionEffect ';';
Inside
is an Effect.
InsideAction returns sgraph::Effect:
{InsideAction} 'Inside' '/' effect=ReactionEffect ';';
Exit
is an Effect
ExitAction returns sgraph::Effect:
{ExitAction} 'Exit' '/' effect=ReactionEffect ';';
Suspend
is a Trigger.
Suspend returns sgraph::Trigger:
{Suspend} 'Suspend' trigger=ReactionTrigger ';';
Transition
Question: use the commutativity of AND and OR? if(A!=null && A.val=1)?