Glossary
| Acronym | Definition |
|---|---|
| SPO | Software Production Operation |
| BL | Behavior Layer |
| ML | Middleware Layer |
| BSM | Behavior Specific Middleware |
| TSM | Target Specific Middleware |
Glossary
Referenced Documents
General ConceptsSupported ElementsAn exhaustive list of elements used by the code generator to produce the code with a summary of the purpose and impact is below:
Note: A statemachine is expected to be executed through a PeriodicExecution. Neither a ChangeEvent, a TimeEvent, nor a SignalEvent can be used to wakeup the statemchine. Instead during the periodic execution, the statemachine pools the events fired between execution two cycles. Note: If a transition is triggered by a SignalEvent and the SignalEvent references a Signal but does not reference an input port; the signal is inserted in all Interface Blocks referenced by input Proxy Ports. In addition, if no input Proxy port exists, an additional input Port is created in the ESP model with the name InputSignal to receive that input Signal. See [4] for more information. Note: If a transition is triggered by a SignalEvent and the SignalEvent references a Signal and references an input port; the input Signal is collected by reading its status on the input Port. Questions: Q:How to send a Signal from a statemachine?
Q: How to read a value coming from a Flow Port in a Statemachine?
Q: How to read a FlowProperty coming from a Proxy Port in a Statemachine?
Q: How to write a value to a Flow Port in a Statemachine?
Q: How to write a FlowProperty to a Proxy Port in a Statemachine?
Validation Constraints- Code Generator Specification
This section is divided into two parts:
Files Specifications
This Software production Operation supports UML State Machines as described in PSSM document (see [3]). The Statemachine code is composed of:
<Behavior>.c<Behavior>.c file implements the statemachine structure. This structure is implemented through a function mainly containing a switch block. Each case represents a state. Transitions are manages through if conditions at end of case. Opaque behavior associated to each state or transition is implemented in the separated <Behavior>_usr.c. File <Behavior>.c is generated for each statemachine which is either the classifier behavior or a behavior called directly or indirectly by the classifier behavior. Name of File <Behavior>.c is described in [3]. General requirements related to a file content and structure are described in [2]. To continue for the file behavior.c content Three basic functions are generated as follows:
<Behavior>_usr.c<Behavior>_usr.c file implements the statemachine opaque behaviors. The opaque behavior of each state or transition is generated in a dedicated function. File <Behavior>_usr.c is generated for each statemachine which is either the classifier behavior or is a behavior called directly or indirectly by the classifier behavior. Name of File <Behavior>_usr.c is described in [3]. General requirements related to file content and structure are described in [2]. The handy helpers section describes a set of macro definitions to access local variables #define input1 instance->input1_data Example of handy helper A user code section is inserted to let you declare the include files after handy helpers. See [2] for more information on user code section. Each Opaque behavior contained in state is implemented through dedicated functions. See Chapter 9.2 for more details. Each Opaque behavior contained in transition is implemented through dedicated functions. See Chapter 9.2 for more details. An init function is then generated to add extra behavior during init phase. You can customize behavior in the specific user code section. See [2] for more information on user code section. An end function is then generated to add extra behavior during end phase. You can customize behavior of end function in the specific user code section. See [2] for more information on user code section. A user code section is inserted before the end of a file to let you implement additional fiunctions. See [2] for more information on user code section.
#ifdef STATEMACHINE
/**********************************************************************
* handy helpers
**********************************************************************/
#define input1 instance->input1_data
/* BEG_USER_CODE(header) do not remove */
/* user-modifiable header part */
/* END_USER_CODE(header) do not remove */
<OPAQUE BEHAVIOR – See chapter 9.2>
static void StateMachine_init(AddOne_struct *instance) {
/* BEG_USER_CODE(init_state_machine) do not remove */
/* do whatever needed */
(void)instance; /* MISRA rule 2.7 (usused parameter) */
/* END_USER_CODE(init_state_machine) do not remove */
}
static void StateMachine_end(AddOne_struct *instance) {
/* BEG_USER_CODE(end_state_machine) do not remove */
/* do whatever needed */
(void)instance; /* MISRA rule 2.7 (usused parameter) */
/* END_USER_CODE(end_state_machine) do not remove */
}
/* BEG_USER_CODE(footer) do not remove */
/* user-modifiable footer part */
/* END_USER_CODE(footer) do not remove */
#endif /* STATEMACHINE */
Example: <Behavior>_usr.c file template <Behavior>.h<Behavior>.h file implements the statemachine opaque behaviors. The opaque behavior of each state or transition is generated in a dedicated function. File <Behavior>.h is generated for each statemachine, which is either the classifier behavior or is a behavior called directly or indirectly by the classifier behavior. Name of File <Behavior>.h is described in [3]. The statemachine structure contains ports values, internal variables, and an internal status. This structure is referenced by the root Class. This structure is declared in a file as follows:
typedef struct {
/* user data */
USERDATA_T USERDATA;
/* Ports */
<list of ports current values>
/* internal */
STATE_T CURRENT_STATE_0;
WALLCLOCK_T WALL_CLOCK;
EVENT_T EVENT;
Boolean FIRST;
Boolean DONE_ACTIVITY;
} <StateMachineName>_struct;
Semantic Code Specifications
This section describes the behavior of the code generator depending on the UML/SysML element. Pseudo State InitialThe pseudo state initial is the entry point of a statemachine. One initial state is mandatory in a statemachine. See rule STM_C_001. More than one initial state is forbidden in a statemachine. See rule STM_C_001. The initialization section is generated at the beginning of the step function for the initial state. If the Initial state is connected to a state, the initialization section automatically activates the state at the beginning of the step function and calls the entry action. ![]()
if(instance->FIRST != FALSE) {
instance->FIRST = FALSE;
instance->CURRENT_STATE_0 = ADDONE_STATE_T_INITIAL_0;
/* Transition INITIAL_0 -> running */
/* @generated_from _19_0_3_16600ad_1654593633996_246628_43116 */
running_Entry(instance); /* Entry of ADDONE_STATE_T_running */
instance->CURRENT_STATE_0 = ADDONE_STATE_T_running;
instance->ENTER_CLOCK_0 = instance->WALL_CLOCK;
}
Example: Pseudo Initial State connected to a State with an entry action If the Initial state is connected to a pseudo state fork, the initialization section automatically activates the state at beginning of the step function. Initial State connected to a Fork State.<Entry/Do/Exit>.OpaqueBehaviorOPAQUE BEHAVIORFor each state which declares an Entry/Do/Exit Opaque behavior, a function containing the related behavior is generated. See [2] for more information on user code section.
/**
* Function implementing "<Entry/Do/Exit>" of State:
* <state name>
* @generated from: <list of source elements used for code generation>
*/
static void <StateName>_<Entry/Do/Exit>(STATEMACHINE *instance) {
/* BEG_USER_CODE(<id>) do not remove */
… Behavior as describerd in model …
/* END_USER_CODE(<id>) do not remove */
}
Example: Generated function for an opaque behavior Transition.Effect.Opaque BehaviorOPAQUE BEHAVIORFor each transition that declares an Effect containing an Opaque Behavior, a function containing the related behavior is generated. See [2] for more information on user code section.
/**
* Documentation
*/
static void <TransitionName>_Effect(STATEMACHINE *instance) {
/* BEG_USER_CODE(<id>) do not remove */
… Behavior …
/* END_USER_CODE(<id>) do not remove */
}
Example: Generated function for an opaque behavior | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||