123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- #include <stdlib.h>
- #include <string.h>
- #include "sc_types.h"
- #include "StatechartLocalReactions.h"
- /*! \file Implementation of the state machine 'StatechartLocalReactions'
- */
- /* prototypes of all internal functions */
- static sc_boolean statechartLocalReactions_check__lr0(const StatechartLocalReactions* handle);
- static sc_boolean statechartLocalReactions_check__lr1(const StatechartLocalReactions* handle);
- static sc_boolean statechartLocalReactions_check_main_region_S1_tr0_tr0(const StatechartLocalReactions* handle);
- static sc_boolean statechartLocalReactions_check_main_region_S2_tr0_tr0(const StatechartLocalReactions* handle);
- static void statechartLocalReactions_effect__lr0(StatechartLocalReactions* handle);
- static void statechartLocalReactions_effect__lr1(StatechartLocalReactions* handle);
- static void statechartLocalReactions_effect_main_region_S1_tr0(StatechartLocalReactions* handle);
- static void statechartLocalReactions_effect_main_region_S2_tr0(StatechartLocalReactions* handle);
- static void statechartLocalReactions_enseq_main_region_S1_default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_enseq_main_region_S2_default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_enseq_region2_a_default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_enseq_main_region_default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_enseq_region2_default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_exseq_main_region_S1(StatechartLocalReactions* handle);
- static void statechartLocalReactions_exseq_main_region_S2(StatechartLocalReactions* handle);
- static void statechartLocalReactions_exseq_region2_a(StatechartLocalReactions* handle);
- static void statechartLocalReactions_exseq_main_region(StatechartLocalReactions* handle);
- static void statechartLocalReactions_exseq_region2(StatechartLocalReactions* handle);
- static void statechartLocalReactions_react_main_region_S1(StatechartLocalReactions* handle);
- static void statechartLocalReactions_react_main_region_S2(StatechartLocalReactions* handle);
- static void statechartLocalReactions_react_region2_a(StatechartLocalReactions* handle);
- static void statechartLocalReactions_react_main_region__entry_Default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_react_region2__entry_Default(StatechartLocalReactions* handle);
- static void statechartLocalReactions_clearInEvents(StatechartLocalReactions* handle);
- static void statechartLocalReactions_clearOutEvents(StatechartLocalReactions* handle);
- void statechartLocalReactions_init(StatechartLocalReactions* handle)
- {
- sc_integer i;
- for (i = 0; i < STATECHARTLOCALREACTIONS_MAX_ORTHOGONAL_STATES; ++i)
- {
- handle->stateConfVector[i] = StatechartLocalReactions_last_state;
- }
-
-
- handle->stateConfVectorPosition = 0;
- statechartLocalReactions_clearInEvents(handle);
- statechartLocalReactions_clearOutEvents(handle);
- /* Default init sequence for statechart StatechartLocalReactions */
- handle->iface.myInt = 0;
- }
- void statechartLocalReactions_enter(StatechartLocalReactions* handle)
- {
- /* Default enter sequence for statechart StatechartLocalReactions */
- statechartLocalReactions_enseq_main_region_default(handle);
- statechartLocalReactions_enseq_region2_default(handle);
- }
- void statechartLocalReactions_exit(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for statechart StatechartLocalReactions */
- statechartLocalReactions_exseq_main_region(handle);
- statechartLocalReactions_exseq_region2(handle);
- }
- sc_boolean statechartLocalReactions_isActive(const StatechartLocalReactions* handle)
- {
- sc_boolean result;
- if (handle->stateConfVector[0] != StatechartLocalReactions_last_state || handle->stateConfVector[1] != StatechartLocalReactions_last_state)
- {
- result = bool_true;
- }
- else
- {
- result = bool_false;
- }
- return result;
- }
- /*
- * Always returns 'false' since this state machine can never become final.
- */
- sc_boolean statechartLocalReactions_isFinal(const StatechartLocalReactions* handle)
- {
- return bool_false;
- }
- static void statechartLocalReactions_clearInEvents(StatechartLocalReactions* handle)
- {
- }
- static void statechartLocalReactions_clearOutEvents(StatechartLocalReactions* handle)
- {
- }
- void statechartLocalReactions_runCycle(StatechartLocalReactions* handle)
- {
-
- statechartLocalReactions_clearOutEvents(handle);
-
- for (handle->stateConfVectorPosition = 0;
- handle->stateConfVectorPosition < STATECHARTLOCALREACTIONS_MAX_ORTHOGONAL_STATES;
- handle->stateConfVectorPosition++)
- {
-
- switch (handle->stateConfVector[handle->stateConfVectorPosition])
- {
- case StatechartLocalReactions_main_region_S1 :
- {
- statechartLocalReactions_react_main_region_S1(handle);
- break;
- }
- case StatechartLocalReactions_main_region_S2 :
- {
- statechartLocalReactions_react_main_region_S2(handle);
- break;
- }
- case StatechartLocalReactions_region2_a :
- {
- statechartLocalReactions_react_region2_a(handle);
- break;
- }
- default:
- break;
- }
- }
-
- statechartLocalReactions_clearInEvents(handle);
- }
- sc_boolean statechartLocalReactions_isStateActive(const StatechartLocalReactions* handle, StatechartLocalReactionsStates state)
- {
- sc_boolean result = bool_false;
- switch (state)
- {
- case StatechartLocalReactions_main_region_S1 :
- result = (sc_boolean) (handle->stateConfVector[0] == StatechartLocalReactions_main_region_S1
- );
- break;
- case StatechartLocalReactions_main_region_S2 :
- result = (sc_boolean) (handle->stateConfVector[0] == StatechartLocalReactions_main_region_S2
- );
- break;
- case StatechartLocalReactions_region2_a :
- result = (sc_boolean) (handle->stateConfVector[1] == StatechartLocalReactions_region2_a
- );
- break;
- default:
- result = bool_false;
- break;
- }
- return result;
- }
- sc_integer statechartLocalReactionsIface_get_myInt(const StatechartLocalReactions* handle)
- {
- return handle->iface.myInt;
- }
- void statechartLocalReactionsIface_set_myInt(StatechartLocalReactions* handle, sc_integer value)
- {
- handle->iface.myInt = value;
- }
- /* implementations of all internal functions */
- static sc_boolean statechartLocalReactions_check__lr0(const StatechartLocalReactions* handle)
- {
- return bool_true;
- }
- static sc_boolean statechartLocalReactions_check__lr1(const StatechartLocalReactions* handle)
- {
- return (handle->iface.myInt == 100) ? bool_true : bool_false;
- }
- static sc_boolean statechartLocalReactions_check_main_region_S1_tr0_tr0(const StatechartLocalReactions* handle)
- {
- return bool_true;
- }
- static sc_boolean statechartLocalReactions_check_main_region_S2_tr0_tr0(const StatechartLocalReactions* handle)
- {
- return bool_true;
- }
- static void statechartLocalReactions_effect__lr0(StatechartLocalReactions* handle)
- {
- handle->iface.myInt += 1;
- }
- static void statechartLocalReactions_effect__lr1(StatechartLocalReactions* handle)
- {
- handle->iface.myInt = 0;
- }
- static void statechartLocalReactions_effect_main_region_S1_tr0(StatechartLocalReactions* handle)
- {
- statechartLocalReactions_exseq_main_region_S1(handle);
- statechartLocalReactions_enseq_main_region_S2_default(handle);
- }
- static void statechartLocalReactions_effect_main_region_S2_tr0(StatechartLocalReactions* handle)
- {
- statechartLocalReactions_exseq_main_region_S2(handle);
- statechartLocalReactions_enseq_main_region_S1_default(handle);
- }
- /* 'default' enter sequence for state S1 */
- static void statechartLocalReactions_enseq_main_region_S1_default(StatechartLocalReactions* handle)
- {
- /* 'default' enter sequence for state S1 */
- handle->stateConfVector[0] = StatechartLocalReactions_main_region_S1;
- handle->stateConfVectorPosition = 0;
- }
- /* 'default' enter sequence for state S2 */
- static void statechartLocalReactions_enseq_main_region_S2_default(StatechartLocalReactions* handle)
- {
- /* 'default' enter sequence for state S2 */
- handle->stateConfVector[0] = StatechartLocalReactions_main_region_S2;
- handle->stateConfVectorPosition = 0;
- }
- /* 'default' enter sequence for state a */
- static void statechartLocalReactions_enseq_region2_a_default(StatechartLocalReactions* handle)
- {
- /* 'default' enter sequence for state a */
- handle->stateConfVector[1] = StatechartLocalReactions_region2_a;
- handle->stateConfVectorPosition = 1;
- }
- /* 'default' enter sequence for region main region */
- static void statechartLocalReactions_enseq_main_region_default(StatechartLocalReactions* handle)
- {
- /* 'default' enter sequence for region main region */
- statechartLocalReactions_react_main_region__entry_Default(handle);
- }
- /* 'default' enter sequence for region region2 */
- static void statechartLocalReactions_enseq_region2_default(StatechartLocalReactions* handle)
- {
- /* 'default' enter sequence for region region2 */
- statechartLocalReactions_react_region2__entry_Default(handle);
- }
- /* Default exit sequence for state S1 */
- static void statechartLocalReactions_exseq_main_region_S1(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for state S1 */
- handle->stateConfVector[0] = StatechartLocalReactions_last_state;
- handle->stateConfVectorPosition = 0;
- }
- /* Default exit sequence for state S2 */
- static void statechartLocalReactions_exseq_main_region_S2(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for state S2 */
- handle->stateConfVector[0] = StatechartLocalReactions_last_state;
- handle->stateConfVectorPosition = 0;
- }
- /* Default exit sequence for state a */
- static void statechartLocalReactions_exseq_region2_a(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for state a */
- handle->stateConfVector[1] = StatechartLocalReactions_last_state;
- handle->stateConfVectorPosition = 1;
- }
- /* Default exit sequence for region main region */
- static void statechartLocalReactions_exseq_main_region(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for region main region */
- /* Handle exit of all possible states (of StatechartLocalReactions.main_region) at position 0... */
- switch(handle->stateConfVector[ 0 ])
- {
- case StatechartLocalReactions_main_region_S1 :
- {
- statechartLocalReactions_exseq_main_region_S1(handle);
- break;
- }
- case StatechartLocalReactions_main_region_S2 :
- {
- statechartLocalReactions_exseq_main_region_S2(handle);
- break;
- }
- default: break;
- }
- }
- /* Default exit sequence for region region2 */
- static void statechartLocalReactions_exseq_region2(StatechartLocalReactions* handle)
- {
- /* Default exit sequence for region region2 */
- /* Handle exit of all possible states (of StatechartLocalReactions.region2) at position 1... */
- switch(handle->stateConfVector[ 1 ])
- {
- case StatechartLocalReactions_region2_a :
- {
- statechartLocalReactions_exseq_region2_a(handle);
- break;
- }
- default: break;
- }
- }
- /* The reactions of state S1. */
- static void statechartLocalReactions_react_main_region_S1(StatechartLocalReactions* handle)
- {
- /* The reactions of state S1. */
- statechartLocalReactions_effect__lr0(handle);
- if (statechartLocalReactions_check__lr1(handle) == bool_true)
- {
- statechartLocalReactions_effect__lr1(handle);
- }
- statechartLocalReactions_effect_main_region_S1_tr0(handle);
- }
- /* The reactions of state S2. */
- static void statechartLocalReactions_react_main_region_S2(StatechartLocalReactions* handle)
- {
- /* The reactions of state S2. */
- statechartLocalReactions_effect__lr0(handle);
- if (statechartLocalReactions_check__lr1(handle) == bool_true)
- {
- statechartLocalReactions_effect__lr1(handle);
- }
- statechartLocalReactions_effect_main_region_S2_tr0(handle);
- }
- /* The reactions of state a. */
- static void statechartLocalReactions_react_region2_a(StatechartLocalReactions* handle)
- {
- }
- /* Default react sequence for initial entry */
- static void statechartLocalReactions_react_main_region__entry_Default(StatechartLocalReactions* handle)
- {
- /* Default react sequence for initial entry */
- statechartLocalReactions_enseq_main_region_S1_default(handle);
- }
- /* Default react sequence for initial entry */
- static void statechartLocalReactions_react_region2__entry_Default(StatechartLocalReactions* handle)
- {
- /* Default react sequence for initial entry */
- statechartLocalReactions_enseq_region2_a_default(handle);
- }
|