-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.py
165 lines (132 loc) · 2.69 KB
/
launcher.py
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
#! /usr/bin/env python3
def createDefaultCfg():
with open('settings.cfg', 'w') as f:
f.write(
'''[video settings]
width = 800
height = 480
[variables]
rpm = true
tps = false
t_h20 = true
t_air = false
t_oil = false
vbb = false
lambda1_avg = false
lambda1_raw = false
k_lambda1 = false
inj_low = false
inj_high = false
gear = true
velGPS = false
vel_fsx = true
vel_fdx = true
vel_rsx = true
vel_rdx = true
[rects]
left = t_h20
right = tps
[absolute max]
rpm = 12500
t_h20 = 120
vbb = 14.7
[serialSettings]
name = /dev/ttyUSB0
baudrate = 115200
stopBit = 1
length = 8
parity = N
timeout = 192
#timeout = baudrate/600
bytesToRead = 1
startChar = \\x02
endChar = \\x03
[variables dict]
engineFrame = {
'rpm' : -1,
'tps' : -1,
't_h20' : -1,
't_air' : -1,
't_oil' : -1,
'vbb' : -1,
'lambda1_avg' : -1,
'lambda1_raw' : -1,
'k_lambda1' : -1,
'inj_low' : -1,
'inj_high' : -1,
'gear' : -1
}
gpsFrame = {
'hour' : -1,
'minutes' : -1,
'seconds' : -1,
'micro_seconds' : -1,
'n_s' : -1,
'e_w' : -1,
'fixQuality' : -1,
'n_sats' : -1,
'hdop' : -1,
'latitude' : -1,
'longitude' : -1,
'velGPS' : -1
}
wheelFrame = {
'vel_fsx' : -1,
'vel_fdx' : -1,
'vel_rsx' : -1,
'vel_rdx' : -1,
'pot_fdx' : -1,
'pot_fsx' : -1,
'pot_rdx' : -1,
'pot_rsx' : -1,
'potFAccuracy' : -1,
'potRAccuracy' : -1,
'steeringEncoder' : -1,
'dtF' : -1,
'dtR' : -1,
'countRSx' : -1,
'countRDx' : -1
}
gyroscope = {
'gyro_x' : -1,
'gyro_y' : -1,
'gyro_z' : -1,
'accel_x' : -1,
'accel_y' : -1,
'accel_z' : -1
}
'''
)
def createLogsFolder():
os.mkdir('logs')
def startSerial(GuiPipeSerialEnd, FHPipeSerialEnd):
import serialHandler
serialHandler.SerialHandler(GuiPipeSerialEnd, FHPipeSerialEnd).loop()
def startFH(FHPipeFHEnd):
import fileHandler
fileHandler.FileHandler(FHPipeFHEnd).loop()
def startGui(GuiPipeGuiEnd):
import gui
gui.Gui(GuiPipeGuiEnd).loop()
def main():
if not os.path.exists('settings.cfg'): #TODO
createDefaultCfg()
if not os.path.exists('logs/'): #TODO
createLogsFolder()
GuiPipeGuiEnd, GuiPipeSerialEnd = multiprocessing.Pipe()
FHPipeFHEnd, FHPipeSerialEnd = multiprocessing.Pipe()
SHProcess = multiprocessing.Process(target=startSerial, daemon = True, name = "__SHProcess__", args=(GuiPipeSerialEnd, FHPipeSerialEnd))
FHProcess = multiprocessing.Process(target=startFH, daemon = True, name = "__FHProcess__", args=(FHPipeFHEnd,))
GuiProcess = multiprocessing.Process(target=startGui, daemon = True, name = "__GuiProcess__", args=(GuiPipeGuiEnd,))
SHProcess.start()
FHProcess.start()
GuiProcess.start()
GuiProcess.join()
if __name__ == '__main__':
import multiprocessing
import os
main()
if __name__ == 'launcher':
import multiprocessing
import os
main()