button
Dependencies: BMI160 SDFileSystem USBDevice max32630fthr
Fork of MPSMAX by
src/Default.h@0:769c5a7b3939, 2018-05-07 (annotated)
- Committer:
- FaizanAhmad
- Date:
- Mon May 07 21:28:03 2018 +0000
- Revision:
- 0:769c5a7b3939
button map
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
FaizanAhmad | 0:769c5a7b3939 | 1 | |
FaizanAhmad | 0:769c5a7b3939 | 2 | #ifndef DEFAULT_H_ |
FaizanAhmad | 0:769c5a7b3939 | 3 | #define DEFAULT_H_ |
FaizanAhmad | 0:769c5a7b3939 | 4 | |
FaizanAhmad | 0:769c5a7b3939 | 5 | #include "sc_types.h" |
FaizanAhmad | 0:769c5a7b3939 | 6 | |
FaizanAhmad | 0:769c5a7b3939 | 7 | #ifdef __cplusplus |
FaizanAhmad | 0:769c5a7b3939 | 8 | extern "C" { |
FaizanAhmad | 0:769c5a7b3939 | 9 | #endif |
FaizanAhmad | 0:769c5a7b3939 | 10 | |
FaizanAhmad | 0:769c5a7b3939 | 11 | /*! \file Header of the state machine 'default'. |
FaizanAhmad | 0:769c5a7b3939 | 12 | */ |
FaizanAhmad | 0:769c5a7b3939 | 13 | |
FaizanAhmad | 0:769c5a7b3939 | 14 | |
FaizanAhmad | 0:769c5a7b3939 | 15 | /*! Enumeration of all states */ |
FaizanAhmad | 0:769c5a7b3939 | 16 | typedef enum |
FaizanAhmad | 0:769c5a7b3939 | 17 | { |
FaizanAhmad | 0:769c5a7b3939 | 18 | Default_last_state, |
FaizanAhmad | 0:769c5a7b3939 | 19 | Default_main_region_Functions, |
FaizanAhmad | 0:769c5a7b3939 | 20 | Default_main_region_Menu, |
FaizanAhmad | 0:769c5a7b3939 | 21 | Default_main_region_Ready, |
FaizanAhmad | 0:769c5a7b3939 | 22 | Default_main_region_Function_Selected, |
FaizanAhmad | 0:769c5a7b3939 | 23 | Default_r1_Function_Ready, |
FaizanAhmad | 0:769c5a7b3939 | 24 | Default_r1_Function_Active, |
FaizanAhmad | 0:769c5a7b3939 | 25 | Default_r1_Alarm, |
FaizanAhmad | 0:769c5a7b3939 | 26 | Default_r1_Move_Down, |
FaizanAhmad | 0:769c5a7b3939 | 27 | Default_r1_Move_Up |
FaizanAhmad | 0:769c5a7b3939 | 28 | } DefaultStates; |
FaizanAhmad | 0:769c5a7b3939 | 29 | |
FaizanAhmad | 0:769c5a7b3939 | 30 | /*! Type definition of the data structure for the DefaultIface interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 31 | typedef struct |
FaizanAhmad | 0:769c5a7b3939 | 32 | { |
FaizanAhmad | 0:769c5a7b3939 | 33 | sc_boolean mode_raised; |
FaizanAhmad | 0:769c5a7b3939 | 34 | sc_boolean down_raised; |
FaizanAhmad | 0:769c5a7b3939 | 35 | sc_boolean up_raised; |
FaizanAhmad | 0:769c5a7b3939 | 36 | sc_boolean back_raised; |
FaizanAhmad | 0:769c5a7b3939 | 37 | sc_boolean home_raised; |
FaizanAhmad | 0:769c5a7b3939 | 38 | sc_integer select1; |
FaizanAhmad | 0:769c5a7b3939 | 39 | sc_integer select2; |
FaizanAhmad | 0:769c5a7b3939 | 40 | } DefaultIface; |
FaizanAhmad | 0:769c5a7b3939 | 41 | |
FaizanAhmad | 0:769c5a7b3939 | 42 | /*! Type definition of the data structure for the DefaultIfaceFunc interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 43 | typedef struct |
FaizanAhmad | 0:769c5a7b3939 | 44 | { |
FaizanAhmad | 0:769c5a7b3939 | 45 | sc_boolean Selected_raised; |
FaizanAhmad | 0:769c5a7b3939 | 46 | sc_boolean Deselect_raised; |
FaizanAhmad | 0:769c5a7b3939 | 47 | sc_boolean Alarmset_raised; |
FaizanAhmad | 0:769c5a7b3939 | 48 | sc_boolean MoveDown_raised; |
FaizanAhmad | 0:769c5a7b3939 | 49 | sc_boolean MoveUp_raised; |
FaizanAhmad | 0:769c5a7b3939 | 50 | sc_integer t; |
FaizanAhmad | 0:769c5a7b3939 | 51 | } DefaultIfaceFunc; |
FaizanAhmad | 0:769c5a7b3939 | 52 | |
FaizanAhmad | 0:769c5a7b3939 | 53 | /*! Type definition of the data structure for the DefaultTimeEvents interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 54 | typedef struct |
FaizanAhmad | 0:769c5a7b3939 | 55 | { |
FaizanAhmad | 0:769c5a7b3939 | 56 | sc_boolean default_r1_Move_Down_tev0_raised; |
FaizanAhmad | 0:769c5a7b3939 | 57 | sc_boolean default_r1_Move_Up_tev0_raised; |
FaizanAhmad | 0:769c5a7b3939 | 58 | } DefaultTimeEvents; |
FaizanAhmad | 0:769c5a7b3939 | 59 | |
FaizanAhmad | 0:769c5a7b3939 | 60 | |
FaizanAhmad | 0:769c5a7b3939 | 61 | /*! Define dimension of the state configuration vector for orthogonal states. */ |
FaizanAhmad | 0:769c5a7b3939 | 62 | #define DEFAULT_MAX_ORTHOGONAL_STATES 2 |
FaizanAhmad | 0:769c5a7b3939 | 63 | |
FaizanAhmad | 0:769c5a7b3939 | 64 | /*! Define maximum number of time events that can be active at once */ |
FaizanAhmad | 0:769c5a7b3939 | 65 | #define DEFAULT_MAX_PARALLEL_TIME_EVENTS 1 |
FaizanAhmad | 0:769c5a7b3939 | 66 | |
FaizanAhmad | 0:769c5a7b3939 | 67 | /*! Define indices of states in the StateConfVector */ |
FaizanAhmad | 0:769c5a7b3939 | 68 | #define SCVI_DEFAULT_MAIN_REGION_FUNCTIONS 0 |
FaizanAhmad | 0:769c5a7b3939 | 69 | #define SCVI_DEFAULT_MAIN_REGION_MENU 0 |
FaizanAhmad | 0:769c5a7b3939 | 70 | #define SCVI_DEFAULT_MAIN_REGION_READY 0 |
FaizanAhmad | 0:769c5a7b3939 | 71 | #define SCVI_DEFAULT_MAIN_REGION_FUNCTION_SELECTED 0 |
FaizanAhmad | 0:769c5a7b3939 | 72 | #define SCVI_DEFAULT_R1_FUNCTION_READY 1 |
FaizanAhmad | 0:769c5a7b3939 | 73 | #define SCVI_DEFAULT_R1_FUNCTION_ACTIVE 1 |
FaizanAhmad | 0:769c5a7b3939 | 74 | #define SCVI_DEFAULT_R1_ALARM 1 |
FaizanAhmad | 0:769c5a7b3939 | 75 | #define SCVI_DEFAULT_R1_MOVE_DOWN 1 |
FaizanAhmad | 0:769c5a7b3939 | 76 | #define SCVI_DEFAULT_R1_MOVE_UP 1 |
FaizanAhmad | 0:769c5a7b3939 | 77 | |
FaizanAhmad | 0:769c5a7b3939 | 78 | /*! |
FaizanAhmad | 0:769c5a7b3939 | 79 | * Type definition of the data structure for the Default state machine. |
FaizanAhmad | 0:769c5a7b3939 | 80 | * This data structure has to be allocated by the client code. |
FaizanAhmad | 0:769c5a7b3939 | 81 | */ |
FaizanAhmad | 0:769c5a7b3939 | 82 | typedef struct |
FaizanAhmad | 0:769c5a7b3939 | 83 | { |
FaizanAhmad | 0:769c5a7b3939 | 84 | DefaultStates stateConfVector[DEFAULT_MAX_ORTHOGONAL_STATES]; |
FaizanAhmad | 0:769c5a7b3939 | 85 | sc_ushort stateConfVectorPosition; |
FaizanAhmad | 0:769c5a7b3939 | 86 | |
FaizanAhmad | 0:769c5a7b3939 | 87 | DefaultIface iface; |
FaizanAhmad | 0:769c5a7b3939 | 88 | DefaultIfaceFunc ifaceFunc; |
FaizanAhmad | 0:769c5a7b3939 | 89 | DefaultTimeEvents timeEvents; |
FaizanAhmad | 0:769c5a7b3939 | 90 | } Default; |
FaizanAhmad | 0:769c5a7b3939 | 91 | |
FaizanAhmad | 0:769c5a7b3939 | 92 | |
FaizanAhmad | 0:769c5a7b3939 | 93 | /*! Initializes the Default state machine data structures. Must be called before first usage.*/ |
FaizanAhmad | 0:769c5a7b3939 | 94 | extern void default_init(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 95 | |
FaizanAhmad | 0:769c5a7b3939 | 96 | /*! Activates the state machine */ |
FaizanAhmad | 0:769c5a7b3939 | 97 | extern void default_enter(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 98 | |
FaizanAhmad | 0:769c5a7b3939 | 99 | /*! Deactivates the state machine */ |
FaizanAhmad | 0:769c5a7b3939 | 100 | extern void default_exit(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 101 | |
FaizanAhmad | 0:769c5a7b3939 | 102 | /*! Performs a 'run to completion' step. */ |
FaizanAhmad | 0:769c5a7b3939 | 103 | extern void default_runCycle(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 104 | |
FaizanAhmad | 0:769c5a7b3939 | 105 | /*! Raises a time event. */ |
FaizanAhmad | 0:769c5a7b3939 | 106 | extern void default_raiseTimeEvent(const Default* handle, sc_eventid evid); |
FaizanAhmad | 0:769c5a7b3939 | 107 | |
FaizanAhmad | 0:769c5a7b3939 | 108 | /*! Raises the in event 'mode' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 109 | extern void defaultIface_raise_mode(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 110 | |
FaizanAhmad | 0:769c5a7b3939 | 111 | /*! Raises the in event 'down' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 112 | extern void defaultIface_raise_down(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 113 | |
FaizanAhmad | 0:769c5a7b3939 | 114 | /*! Raises the in event 'up' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 115 | extern void defaultIface_raise_up(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 116 | |
FaizanAhmad | 0:769c5a7b3939 | 117 | /*! Raises the in event 'back' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 118 | extern void defaultIface_raise_back(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 119 | |
FaizanAhmad | 0:769c5a7b3939 | 120 | /*! Raises the in event 'home' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 121 | extern void defaultIface_raise_home(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 122 | |
FaizanAhmad | 0:769c5a7b3939 | 123 | /*! Gets the value of the variable 'select1' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 124 | extern sc_integer defaultIface_get_select1(const Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 125 | /*! Sets the value of the variable 'select1' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 126 | extern void defaultIface_set_select1(Default* handle, sc_integer value); |
FaizanAhmad | 0:769c5a7b3939 | 127 | /*! Gets the value of the variable 'select2' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 128 | extern sc_integer defaultIface_get_select2(const Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 129 | /*! Sets the value of the variable 'select2' that is defined in the default interface scope. */ |
FaizanAhmad | 0:769c5a7b3939 | 130 | extern void defaultIface_set_select2(Default* handle, sc_integer value); |
FaizanAhmad | 0:769c5a7b3939 | 131 | /*! Raises the in event 'Selected' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 132 | extern void defaultIfaceFunc_raise_selected(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 133 | |
FaizanAhmad | 0:769c5a7b3939 | 134 | /*! Raises the in event 'Deselect' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 135 | extern void defaultIfaceFunc_raise_deselect(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 136 | |
FaizanAhmad | 0:769c5a7b3939 | 137 | /*! Raises the in event 'Alarmset' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 138 | extern void defaultIfaceFunc_raise_alarmset(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 139 | |
FaizanAhmad | 0:769c5a7b3939 | 140 | /*! Raises the in event 'MoveDown' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 141 | extern void defaultIfaceFunc_raise_moveDown(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 142 | |
FaizanAhmad | 0:769c5a7b3939 | 143 | /*! Raises the in event 'MoveUp' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 144 | extern void defaultIfaceFunc_raise_moveUp(Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 145 | |
FaizanAhmad | 0:769c5a7b3939 | 146 | /*! Gets the value of the variable 't' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 147 | extern sc_integer defaultIfaceFunc_get_t(const Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 148 | /*! Sets the value of the variable 't' that is defined in the interface scope 'Func'. */ |
FaizanAhmad | 0:769c5a7b3939 | 149 | extern void defaultIfaceFunc_set_t(Default* handle, sc_integer value); |
FaizanAhmad | 0:769c5a7b3939 | 150 | |
FaizanAhmad | 0:769c5a7b3939 | 151 | /*! |
FaizanAhmad | 0:769c5a7b3939 | 152 | * Checks whether the state machine is active (until 2.4.1 this method was used for states). |
FaizanAhmad | 0:769c5a7b3939 | 153 | * A state machine is active if it was entered. It is inactive if it has not been entered at all or if it has been exited. |
FaizanAhmad | 0:769c5a7b3939 | 154 | */ |
FaizanAhmad | 0:769c5a7b3939 | 155 | extern sc_boolean default_isActive(const Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 156 | |
FaizanAhmad | 0:769c5a7b3939 | 157 | /*! |
FaizanAhmad | 0:769c5a7b3939 | 158 | * Checks if all active states are final. |
FaizanAhmad | 0:769c5a7b3939 | 159 | * If there are no active states then the state machine is considered being inactive. In this case this method returns false. |
FaizanAhmad | 0:769c5a7b3939 | 160 | */ |
FaizanAhmad | 0:769c5a7b3939 | 161 | extern sc_boolean default_isFinal(const Default* handle); |
FaizanAhmad | 0:769c5a7b3939 | 162 | |
FaizanAhmad | 0:769c5a7b3939 | 163 | /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */ |
FaizanAhmad | 0:769c5a7b3939 | 164 | extern sc_boolean default_isStateActive(const Default* handle, DefaultStates state); |
FaizanAhmad | 0:769c5a7b3939 | 165 | |
FaizanAhmad | 0:769c5a7b3939 | 166 | |
FaizanAhmad | 0:769c5a7b3939 | 167 | |
FaizanAhmad | 0:769c5a7b3939 | 168 | #ifdef __cplusplus |
FaizanAhmad | 0:769c5a7b3939 | 169 | } |
FaizanAhmad | 0:769c5a7b3939 | 170 | #endif |
FaizanAhmad | 0:769c5a7b3939 | 171 | |
FaizanAhmad | 0:769c5a7b3939 | 172 | #endif /* DEFAULT_H_ */ |
FaizanAhmad | 0:769c5a7b3939 | 173 |