aboutsummaryrefslogtreecommitdiffstats
path: root/src/policy_manager/zipc/dummy_stm.h
blob: 3c803105dd4c3098df0d7e71c116c8c037895fae (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TMCAGLWM_DUMMY_STM_HPP
#define TMCAGLWM_DUMMY_STM_HPP

// TODO: This file should be existed in STM

//
#define STM_TRUE 1
#define STM_FALSE 0

// Event number
#define STM_EVT_NO_ACTIVATE              0x01
#define STM_EVT_NO_DEACTIVATE            0x02
#define STM_EVT_NO_TRANS_GEAR_N          0x03
#define STM_EVT_NO_TRANS_GEAR_NOT_N      0x04
#define STM_EVT_NO_PARKING_BRAKE_OFF     0x05
#define STM_EVT_NO_PARKING_BRAKE_ON      0x06
#define STM_EVT_NO_ACCEL_PEDAL_OFF       0x07
#define STM_EVT_NO_ACCEL_PEDAL_ON        0x08
#define STM_EVT_NO_TIMER_EXPIRED         0x09
#define STM_EVT_NO_LAMP_OFF              0x0A
#define STM_EVT_NO_LAMP_ON               0x0B
#define STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF 0x0C
#define STM_EVT_NO_LIGHTSTATUS_BRAKE_ON  0x0D
#define STM_EVT_NO_RESTRICTION_MODE_OFF  0x0E
#define STM_EVT_NO_RESTRICTION_MODE_ON   0x0F

// Category number
#define STM_CTG_NO_HOMESCREEN   0x0100
#define STM_CTG_NO_MAP          0x0200
#define STM_CTG_NO_GENERAL      0x0300
#define STM_CTG_NO_SPLITABLE    0x0400
#define STM_CTG_NO_POPUP        0x0500
#define STM_CTG_NO_SYSTEM_ALERT 0x0600
#define STM_CTG_NO_RESTRICTION  0x0700
#define STM_CTG_NO_SYSTEM       0x0800

// Area number
#define STM_ARA_NO_NONE                   0x010000
#define STM_ARA_NO_FULL                   0x020000
#define STM_ARA_NO_NORMAL                 0x030000
#define STM_ARA_NO_SPLIT_MAIN             0x040000
#define STM_ARA_NO_SPLIT_SUB              0x050000
#define STM_ARA_NO_ON_SCREEN              0x060000
#define STM_ARA_NO_RESTRICTION_NORMAL     0x070000
#define STM_ARA_NO_RESTRICTION_SPLIT_MAIN 0x080000
#define STM_ARA_NO_RESTRICTION_SPLIT_SUB  0x090000

// Mask
#define STM_MSK_EVT_NO 0x0000FF
#define STM_MSK_CTG_NO 0x00FF00
#define STM_MSK_ARA_NO 0xFF0000

// Enum for state
enum stm_trans_gear_state_ {
    gStmTransGearStateNoN = 0,
    gStmTransGearStateNoNotN
};

enum stm_parking_brake_state_ {
    gStmParkingBrakeStateNoOff = 0,
    gStmParkingBrakeStateNoOn
};

enum stm_accel_pedal_state_ {
    gStmAccelPedalStateNoOff = 0,
    gStmAccelPedalStateNoOn
};

enum stm_car_state_ {
    gStmRunningNoStop = 0,
    gStmRunningNoRun
};

enum stm_lamp_state_ {
    gStmLampStateNoOff = 0,
    gStmLampStateNoOn
};

enum stm_lightstatus_brake_state_ {
    gStmLightstatusBrakeStateNoOff = 0,
    gStmLightstatusBrakeStateNoOn
};

enum stm_restriction_mode_state_ {
    gStmRestrictionModeStateNoOff = 0,
    gStmRestrictionModeStateNoOn
};

enum stm_layout_ {
    gStmLayoutNoNone = 0,
    gStmLayoutNoPu,
    gStmLayoutNoSa,
    gStmLayoutNoM1,
    gStmLayoutNoM2,
    gStmLayoutNoMf,
    gStmLayoutNoS1,
    gStmLayoutNoS2,
    gStmLayoutNoG,
    gStmLayoutNoHs,
    gStmLayoutNoRestriction,
    gStmLayoutNoRestrictionSplitMain,
    gStmLayoutNoRestrictionSplitSub,
    gStmLayoutNoSystem,
};

enum stm_event_ {
    gStmEventNoActive = 0,
    gStmEventNoDeactive,
    gStmEventNoTransGearN,
    gStmEventNoTransGearNotN,
    gStmEventNoParkingBrakeOff,
    gStmEventNoParkingBrakeOn,
    gStmEventNoAccelPedalOff,
    gStmEventNoAccelPedalOn,
    gStmEventNoTimerExpired,
    gStmEventNoLampOff,
    gStmEventNoLampOn,
    gStmEventNoLightstatusBrakeOff,
    gStmEventNoLightstatusBrakeOn,
    gStmEventNoRestrictionModeOff,
    gStmEventNoRestrictionModeOn,

    gStmEventNoNum,

    gStmEventNoMin = gStmEventNoActive,
    gStmEventNoMax = gStmEventNoNum - 1,
};

enum stm_category_ {
    gStmCategoryNoHomescreen = 0,
    gStmCategoryNoMap,
    gStmCategoryNoGeneral,
    gStmCategoryNoSplitable,
    gStmCategoryNoPopup,
    gStmCategoryNoSystemAlert,
    gStmCategoryNoRestriction,

    gStmCategoryNoNum,

    gStmCategoryNoMin = gStmCategoryNoHomescreen,
    gStmCategoryNoMax = gStmCategoryNoNum - 1,
};

enum stm_area_ {
    gStmAreaNoNone = 0,
    gStmAreaNoFullscreen,
    gStmAreaNoNormal,
    gStmAreaNoSplitMain,
    gStmAreaNoSplitSub,
    gStmAreaNoOnScreen,
    gStmAreaNoRestrictionNormal,
    gStmAreaNoRestrictionSplitMain,
    gStmAreaNoRestrictionSplitSub,

    gStmAreaNoNum,

    gStmAreaNoMin = gStmAreaNoNone,
    gStmAreaNoMax = gStmAreaNoNum - 1,
};

enum stm_layer_ {
    gStmLayerNoHomescreen = 0,
    gStmLayerNoApps,
    gStmLayerNoRestriction,
    gStmLayerNoOnScreen,

    gStmLayerNoNum,

    gStmLayerNoMin = gStmLayerNoHomescreen,
    gStmLayerNoMax = gStmLayerNoNum - 1,
};

enum stm_car_element_ {
    gStmCarElementNoTransGear = 0,
    gStmCarElementNoParkingBrake,
    gStmCarElementNoAccelPedal,
    gStmCarElementNoRunning,
    gStmCarElementNoLamp,
    gStmCarElementNoLightstatusBrake,
    gStmCarElementNoRestrictionMode,

    gStmCarElementNoNum,

    gStmCarElementNoMin = gStmCarElementNoTransGear,
    gStmCarElementNoMax = gStmCarElementNoNum - 1,
};

// String for state
extern const char* gStmEventName[];
extern const int gStmEventNo[];
extern const char* gStmCategoryName[];
extern const int gStmCategoryNo[];
extern const char* gStmAreaName[];
extern const int gStmAreaNo[];
extern const char* gStmLayoutName[];
extern const char* gStmLayerName[];
extern const char* gStmCarElementName[];
extern const char** gStmCarStateNameList[];

// Struct for state
typedef struct stm_base_state_ {
    int changed;
    int state;
} stm_base_state;

typedef struct {
    stm_base_state car_element[gStmCarElementNoNum];
    stm_base_state layer[gStmLayerNoNum];
} stm_state_t;


void stmInitialize();
int stmTransitionState(int event_no, stm_state_t* state);
void stmUndoState();


#endif  // TMCAGLWM_DUMMY_STM_HPP