aboutsummaryrefslogtreecommitdiffstats
path: root/src/policy_manager/stm/zipc/src/StateTransitionor/ZST_StateTransitionor_func.c
blob: 77db170384e5722dbf350db145c88be6943244ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/************************************************************/
/*     ZST_StateTransitionor_func.c                         */
/*     Function and variable source file                    */
/*     ZIPC Designer Version 1.2.0                          */
/************************************************************/
#include "ZST_include.h"

/*************************************************************
    Function definition
*************************************************************/

#include <string.h>


const char* kStmEventName[] = {
    "none",
    "activate",
    "deactivate",
    "restriction_mode_off",
    "restriction_mode_1_on",
    "restriction_mode_2_on",
    "undo",
};

const char* kStmCategoryName[] = {
    "none",
    "homescreen",
    "map",
    "general",
    "splitable",
    "pop_up",
    "system_alert",
    "restriction",
    "system",
    "software_keyboard",
};

const char* kStmAreaName[] = {
    "none",
    "fullscreen",
    "normal.full",
    "split.main",
    "split.sub",
    "on_screen",
    "restriction.normal",
    "restriction.split.main",
    "restriction.split.sub",
    "software_keyboard",
};

const char* kStmLayoutName[] = {
    "none",
    "pop_up",
    "system_alert",
    "map.normal",
    "map.split",
    "map.fullscreen",
    "splitable.normal",
    "splitable.split",
    "general.normal",
    "homescreen",
    "restriction.normal",
    "restriction.split.main",
    "restriction.split.sub",
    "system.normal",
    "software_keyboard",
};

const char* kStmLayerName[] = {
    "homescreen",
    "apps",
    "near_homescreen",
    "restriction",
    "on_screen",
};

const char* kStmModeName[] = {
    "trans_gear",
    "parking_brake",
    "accel_pedal",
    "running",
    "lamp",
    "lightstatus_brake",
    "restriction_mode",
};

const char* kStmRestrictionModeStateName[] = {
    "off",
    "1on",
    "2on",
};

const char** kStmModeStateNameList[] = {
    kStmRestrictionModeStateName,
};


//=================================
// API
//=================================
/**
 *  Initialize STM
 */
void stmInitialize() {
    // Initialize previous state
    memset(&g_stm_prv_state, 0, sizeof(g_stm_prv_state));

    // Initialize current state
    g_stm_crr_state = g_stm_prv_state;

	/* Initialize restriction mode state */
	stm_rem_initialize();
	stm_rem_initialize_variable();

	// Initialize homecsreen layer
	stm_hsl_initialize();
	stm_hsl_initialize_variable();

	// Initialize apps layer
	stm_apl_initialize();
	stm_apl_initialize_variable();

	// Initialize near_homecsreen layer
	stm_nhl_initialize();
	stm_nhl_initialize_variable();

	/* Initialize restriction layer */
	stm_rel_initialize();
	stm_rel_initialize_variable();

	g_stm_map_is_activated = STM_FALSE;
}

/**
 *  Transition State
 */
int stmTransitionState(int event_id, StmState* state) {
    g_stm_event    = STM_GET_EVENT_FROM_ID(event_id);
    g_stm_category = STM_GET_CATEGORY_FROM_ID(event_id);
    g_stm_area     = STM_GET_AREA_FROM_ID(event_id);

    // restriction mode
    stm_rem_event_call();

    // homescreen layer
    stm_hsl_event_call();

    // apps layer
    stm_apl_event_call();

    // near_homecsreen layer
    stm_nhl_event_call();

    // restriction layer
    stm_rel_event_call();

    // on_screen layer
    stm_osl_event_call();

    // Copy current state for return
    memcpy(state, &g_stm_crr_state, sizeof(g_stm_crr_state));

    return 0;
}

/**
 *  Undo State
 */
void stmUndoState() {
    g_stm_event = StmEvtNoUndo;

    // apps layer
    stm_apl_event_call();

    // near_homecsreen layer
    stm_nhl_event_call();

    // restriction layer
    stm_rel_event_call();

    // on_screen layer
    stm_osl_event_call();

	g_stm_crr_state = g_stm_prv_state;
}