77db170384e5722dbf350db145c88be6943244ea
[apps/agl-service-windowmanager-2017.git] / src / policy_manager / stm / zipc / src / StateTransitionor / ZST_StateTransitionor_func.c
1 /************************************************************/
2 /*     ZST_StateTransitionor_func.c                         */
3 /*     Function and variable source file                    */
4 /*     ZIPC Designer Version 1.2.0                          */
5 /************************************************************/
6 #include "ZST_include.h"
7
8 /*************************************************************
9     Function definition
10 *************************************************************/
11
12 #include <string.h>
13
14
15 const char* kStmEventName[] = {
16     "none",
17     "activate",
18     "deactivate",
19     "restriction_mode_off",
20     "restriction_mode_1_on",
21     "restriction_mode_2_on",
22     "undo",
23 };
24
25 const char* kStmCategoryName[] = {
26     "none",
27     "homescreen",
28     "map",
29     "general",
30     "splitable",
31     "pop_up",
32     "system_alert",
33     "restriction",
34     "system",
35     "software_keyboard",
36 };
37
38 const char* kStmAreaName[] = {
39     "none",
40     "fullscreen",
41     "normal.full",
42     "split.main",
43     "split.sub",
44     "on_screen",
45     "restriction.normal",
46     "restriction.split.main",
47     "restriction.split.sub",
48     "software_keyboard",
49 };
50
51 const char* kStmLayoutName[] = {
52     "none",
53     "pop_up",
54     "system_alert",
55     "map.normal",
56     "map.split",
57     "map.fullscreen",
58     "splitable.normal",
59     "splitable.split",
60     "general.normal",
61     "homescreen",
62     "restriction.normal",
63     "restriction.split.main",
64     "restriction.split.sub",
65     "system.normal",
66     "software_keyboard",
67 };
68
69 const char* kStmLayerName[] = {
70     "homescreen",
71     "apps",
72     "near_homescreen",
73     "restriction",
74     "on_screen",
75 };
76
77 const char* kStmModeName[] = {
78     "trans_gear",
79     "parking_brake",
80     "accel_pedal",
81     "running",
82     "lamp",
83     "lightstatus_brake",
84     "restriction_mode",
85 };
86
87 const char* kStmRestrictionModeStateName[] = {
88     "off",
89     "1on",
90     "2on",
91 };
92
93 const char** kStmModeStateNameList[] = {
94     kStmRestrictionModeStateName,
95 };
96
97
98 //=================================
99 // API
100 //=================================
101 /**
102  *  Initialize STM
103  */
104 void stmInitialize() {
105     // Initialize previous state
106     memset(&g_stm_prv_state, 0, sizeof(g_stm_prv_state));
107
108     // Initialize current state
109     g_stm_crr_state = g_stm_prv_state;
110
111         /* Initialize restriction mode state */
112         stm_rem_initialize();
113         stm_rem_initialize_variable();
114
115         // Initialize homecsreen layer
116         stm_hsl_initialize();
117         stm_hsl_initialize_variable();
118
119         // Initialize apps layer
120         stm_apl_initialize();
121         stm_apl_initialize_variable();
122
123         // Initialize near_homecsreen layer
124         stm_nhl_initialize();
125         stm_nhl_initialize_variable();
126
127         /* Initialize restriction layer */
128         stm_rel_initialize();
129         stm_rel_initialize_variable();
130
131         g_stm_map_is_activated = STM_FALSE;
132 }
133
134 /**
135  *  Transition State
136  */
137 int stmTransitionState(int event_id, StmState* state) {
138     g_stm_event    = STM_GET_EVENT_FROM_ID(event_id);
139     g_stm_category = STM_GET_CATEGORY_FROM_ID(event_id);
140     g_stm_area     = STM_GET_AREA_FROM_ID(event_id);
141
142     // restriction mode
143     stm_rem_event_call();
144
145     // homescreen layer
146     stm_hsl_event_call();
147
148     // apps layer
149     stm_apl_event_call();
150
151     // near_homecsreen layer
152     stm_nhl_event_call();
153
154     // restriction layer
155     stm_rel_event_call();
156
157     // on_screen layer
158     stm_osl_event_call();
159
160     // Copy current state for return
161     memcpy(state, &g_stm_crr_state, sizeof(g_stm_crr_state));
162
163     return 0;
164 }
165
166 /**
167  *  Undo State
168  */
169 void stmUndoState() {
170     g_stm_event = StmEvtNoUndo;
171
172     // apps layer
173     stm_apl_event_call();
174
175     // near_homecsreen layer
176     stm_nhl_event_call();
177
178     // restriction layer
179     stm_rel_event_call();
180
181     // on_screen layer
182     stm_osl_event_call();
183
184         g_stm_crr_state = g_stm_prv_state;
185 }
186
187