The machine is the basic component on which the EFM language relies. It is defined by its sections, which are described in file SECTIONS.md
A specification could be totally defined with machines but, for the sake of simplicity, the EFM language provides several types of high-level machines:
[ design ] [modifier] machine [ < [ moc: ] statekind > ] aMachineID { machine_section_list } design ::= model | prototype modifier ::= input_enabled | timed statekind ::= and | or machine_section_list ::= [ @parameter: … ] [ @declaration: … ] [ @machine: … ] [ @transition: … ] [ @moe: … ] [ @com: … ] instance machine [< [ model: ] aModelID > ] anInstanceID [ params ] ; params ::= ( ([ paramID : ] expression ,)+ )
The EFM language supports the « model-instance » paradigm: a machine can either be
By default, for the sake of simplicity, any machine will be a « prototype ».
Several kinds of machines can be defined thanks to the « modifier » attribute.
This attribute enables the definition of a communicating machine that can react to any incoming event, at any time. For example, an « input-enabled » statemachine must be able to react to any input in any of its states. The use of this attribute can have strong semantical consequences. For example, in the case of asynchronous communication via buffers, if a transition receives a message that is not expected at that moment, this message is simply lost.
For a machine with the « timed » attribute, Diversity adds elements that enable handling of symbolic time.
For every composite machine, the « moc: » attribute can be used to define concurrency when evaluating its components (in the « @machine » section):
By default, the model of computation of a machine is « or ». Atomic machines (i.e. non-composite) are not concerned.
model machine < moc:or > myModelMachine { @parameter: var int u; @machine: machine myPrototypeSubmachine1 { ... } machine myPrototypeSubmachine2 { ... } @moe: @run{ if u == 42 { run myPrototypeSubmachine1; } else run myPrototypeSubmachine2; } } ... } instance machine < model:myModelMachine > myInstanceMachine( u:42 );
In a EFM specification, the main machine is called a « system ».
[modifier] system [ < [ moc: ] statekind > ] aSystemID { machine_section_list }
Attributes « modifier » and « moc » can still be used with a system.
System< and > mySystem { @machine: model machine< or > myModelMachine { ... } instance machine< myModelMachine > myInstanceMachine42( 42 ); instance machine< myModelMachine > myInstanceMachine18( 18 ); }
Unlike in Example 1, here, labels such as “moc:” or “model:” are omitted.