-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConstants.ts
More file actions
200 lines (177 loc) · 4.76 KB
/
Constants.ts
File metadata and controls
200 lines (177 loc) · 4.76 KB
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
/*
INTERFACES ========================================
*/
import uWS from "uWebSockets.js";
// JSON WS ==============================================
export interface JsonOutput {
contents?: Array<{
id: string[];
contents: any;
}>;
}
export interface SETTINGS_FILE_JSON {
type?: string;
model_file_path: string;
experiment_name: string;
}
export interface JsonMonitor {
type: string;
id?: string;
simulationIndex?: number;
}
export interface JsonPlayerAsk {
type: string;
action: string;
args: string; // JsonConvert.SerializeObject(Dictionary<string, string>)
agent: string;
}
export interface JsonPlayer {
id: string;
type: string;
expr?: string;
heartbeat?: number;
}
export interface Simulation {
experiment_name: string;
model_file_path: string;
name: string;
player_html_file: string;
player_web_interface: string;
splashscreen: string;
type: string;
type_model_file_path: string;
maximal_players: string,
minimal_players: string,
selected_monitoring: string
}
// Learning packages ==============================================
/**
* Inteface to make manipulation of the json file easier
* these are incomplete and do not represent the full structure of the json file
* but contain what is necessary to parse them
*/
export interface VU_MODEL_SETTING_JSON {
type: "json_settings";
name: string;
splashscreen: string;
model_file_path: string;
experiment_name: string;
minimal_players: string;
maximal_players: string;
selected_monitoring?: 'gama_screen';
}
export interface VU_CATALOG_SETTING_JSON {
type: "catalog";
name: string;
splashscreen?: string;
entries: VU_MODEL_SETTING_JSON[] | VU_CATALOG_SETTING_JSON[];
}
// Simplier version used to send useful information only to Monitor clients
export interface MIN_VU_MODEL_SETTING_JSON {
type: string;
name: string;
splashscreen: string;
model_index: number;
}
// Simplier version used to send useful information only to Monitor clients
export interface MIN_VU_CATALOG_SETTING_JSON {
type: string;
name: string;
splashscreen?: string;
entries: MIN_VU_MODEL_SETTING_JSON[]|MIN_VU_CATALOG_SETTING_JSON;
}
// Internal message exchange ==============================================
export interface PlayerState {
connected: boolean;
in_game: boolean;
date_connection: string;
}
export interface GamaState {
connected: boolean;
experiment_state: string;
loading: boolean;
content_error: string;
experiment_id: string;
experiment_name: string;
}
export interface Player {
id: string,
// Player Socket
ws: uWS.WebSocket<unknown>,
ping_interval: number,
is_alive: boolean,
timeout?: NodeJS.Timeout,
// Player State
connected: boolean,
in_game: boolean,
date_connection: string,
}
/*
GAMA ============================================
*/
export interface GAMA_JSON_LOAD_EXPERIMENT {
type: string,
model: string,
experiment: string
}
/*
CONSTANTS ========================================
*/
export const GAMA_ERROR_MESSAGES: string[] = [
"SimulationStatusError",
"SimulationErrorDialog",
"SimulationError",
"RuntimeError",
"GamaServerError",
"MalformedRequest",
"UnableToExecuteRequest"
];
export const HEADSET_COLOR: Record<string,string> = {
"101": "bg-blue-500",
"102": "bg-green-300",
"103": "bg-black",
"104": "bg-red-300",
"105": "bg-yellow-300",
"106": "bg-white",
"110":"bg-green-300",
"190": "red",
"21": "bg-blue-500",
"15":"bg-blue-600"
};
/**
* ANSI colors for console output
*/
export const ANSI_COLORS: Record<string,string> ={
"black": "\x1b[30m",
"red": "\x1b[31m",
"green": "\x1b[32m",
"yellow": "\x1b[33m",
"blue": "\x1b[34m",
"magenta": "\x1b[35m",
"cyan": "\x1b[36m",
"white": "\x1b[37m",
"orange": "\x1b[38;5;208m",
"purple": "\x1b[38;5;129m",
"reset": "\x1b[0m"
}
export const ON_DEVICE_ADB_GLOBAL_SETTINGS: Record<string,number|string> = {
// Probing
"captive_portal_detection_enabled": 0,
"captive_portal_mode": 0,
"captive_portal_server": "localhost",
"captive_portal_https_url": "https://localhost",
"captive_portal_http_url": "http://localhost",
// WiFi
"wifi_watchdog_on": 0,
"wifi_watchdog_poor_network_test_enabled": 0,
"network_recommendations_enabled": 0,
"network_avoid_bad_wifi": 0,
"wifi_passpoint_enabled": 0,
"wifi_sleep_policy": 2,
"stay_on_while_plugged_in": 15, // Keep on AC + USB + wireless + docked
"wifi_enhance_network_while_sleeping": 0,
// Misc
"ota_disable_automatic_update": 1,
"wifi_networks_available_notification_on": 0,
"netstats_enabled": 0
}