-
Notifications
You must be signed in to change notification settings - Fork 7
/
mainwindow.h
401 lines (337 loc) · 13.4 KB
/
mainwindow.h
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QTreeWidget>
#include <QLabel>
#include <QGroupBox>
#include <QHeaderView>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QRect>
#include <QTimer>
#include <QTableWidget>
#include <QSignalMapper>
#include <QInputDialog>
#include <QLineEdit>
#include <QClipboard>
#include <QTime>
#include <QProgressDialog>
#include <QListWidget>
#include <QCheckBox>
#include <QStandardItemModel>
#include <QStackedWidget>
#include <QSplashScreen>
#include <calibration_maps.h>
#include <calibration_treewidget.h>
#include <protocol_select.h>
#include <vehicle_select.h>
#include <definition_file_convert.h>
#include <biu_operations_subaru.h>
#include <get_key_operations_subaru.h>
//#include <ecu_operations_nissan.h>
//#include <ecu_operations_mercedes.h>
//#include <ecu_operations_subaru.h>
//#include <ecu_operations_manual.h>
#include <file_actions.h>
#include <logbox.h>
#include <settings.h>
#include <serial_port/serial_port_actions.h>
// Flash modules
#include <modules/flash_ecu_subaru_denso_mc68hc16y5_02.h>
#include <modules/flash_ecu_subaru_denso_sh7055_02.h>
#include <modules/flash_ecu_subaru_denso_sh705x_densocan.h>
#include <modules/flash_ecu_subaru_denso_sh705x_kline.h>
#include <modules/flash_ecu_subaru_denso_sh7058_can.h>
#include <modules/flash_ecu_subaru_denso_sh7058_can_diesel.h>
#include <modules/flash_ecu_subaru_unisia_jecs.h>
#include <modules/flash_ecu_subaru_unisia_jecs_m32r.h>
#include <modules/flash_ecu_subaru_hitachi_m32r_kline.h>
#include <modules/flash_ecu_subaru_hitachi_m32r_can.h>
#include <modules/flash_tcu_subaru_hitachi_m32r_kline.h>
#include <modules/flash_tcu_subaru_hitachi_m32r_can.h>
#include <modules/flash_tcu_cvt_subaru_hitachi_m32r_can.h>
#include <modules/flash_tcu_subaru_denso_sh705x_can.h>
#include <modules/flash_tcu_cvt_subaru_mitsu_mh8104_can.h>
#include <modules/flash_tcu_cvt_subaru_mitsu_mh8111_can.h>
#include <modules/flash_ecu_subaru_mitsu_m32r_kline.h>
#include <modules/flash_ecu_subaru_hitachi_sh7058_can.h>
#include <modules/flash_ecu_subaru_hitachi_sh72543r_can.h>
#include <modules/flash_ecu_subaru_denso_sh72531_can.h>
#include <modules/unbrick/flash_ecu_unbrick_subaru_denso_mc68hc16y5_02.h>
#include <modules/eeprom_ecu_subaru_denso_sh705x_kline.h>
#include <modules/eeprom_ecu_subaru_denso_sh705x_can.h>
#include <modules/flash_ecu_subaru_denso_sh7xxx_densocan.h>
//
#include <remote_utility/remote_utility.h>
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QString peerAddress = "", QWidget *parent = nullptr);
~MainWindow();
void delay(int n);
private:
QString software_name;
QString software_title;
QString software_version;
QSplashScreen *startUpSplash;
QLabel *startUpSplashLabel;
QProgressBar *startUpSplashProgressBar;
QString peerAddress;
QSplashScreen *splash;
QWebSocket *clientWebSocket;
RemoteUtility *remote_utility;
static const QColor RED_LIGHT_OFF;
static const QColor RED_LIGHT_ON;
static const QColor YELLOW_LIGHT_OFF;
static const QColor YELLOW_LIGHT_ON;
static const QColor GREEN_LIGHT_OFF;
static const QColor GREEN_LIGHT_ON;
bool logging_state = false;
bool log_params_request_started = false;
bool ecu_init_started = false;
bool ecu_init_complete = false;
bool haltech_ic7_display_on = false;
bool simulate_obd_on = false;
bool can_listener_on = false;
int ecuCalDefIndex = 0;
int mapCellWidthSelectable = 240;
int mapCellWidth1D = 96;
int mapCellWidth = 54;
int mapCellHeight = 26;
int cellFontSize = mapCellHeight / 2.25;
int xSize = 0;
int ySize = 0;
int connectionTimeOutDelay = 5;
int connectionTimeOutDelayCount = 50;
FileActions *fileActions;
FileActions::LogValuesStructure *logValues;
FileActions::ConfigValuesStructure *configValues;
FileActions::EcuCalDefStructure *ecuCalDef[100];
//FileActions::EcuCalDefStructure *ecuCalDefTemp;
/* Flash modules */
/* Denso ECU */
FlashEcuSubaruDensoSH705xDensoCan *flashEcuSubaruDensoSH705xDensoCan;
FlashEcuSubaruDensoMC68HC16Y5_02 *flashEcuSubaruDensoMC68HC16Y5_02;
FlashEcuSubaruDensoSH7055_02 *flashEcuSubaruDensoSH7055_02;
FlashEcuSubaruDensoSH705xKline *flashEcuSubaruDensoSH705xKline;
FlashEcuSubaruDensoSH7058Can *flashEcuSubaruDensoSH7058Can;
FlashEcuSubaruDensoSH7058CanDiesel *flashEcuSubaruDensoSH7058CanDiesel;
FlashEcuSubaruDensoSH72531Can *flashEcuSubaruDensoSh72531Can;
/* Denso ECU unbrick */
FlashEcuUnbrickSubaruDensoMC68HC16Y5_02 *flashEcuUnbrickSubaruDensoMC68HC16Y5_02 ;
/* Denso ECU EEPROM */
EepromEcuSubaruDensoSH705xKline *eepromEcuSubaruDensoKline;
EepromEcuSubaruDensoSH705xCan *eepromEcuSubaruDensoCan;
/* Denso TCU */
FlashTcuSubaruDensoSH705xCan *flashTcuSubaruDensoSH705xCan;
/* Hitachi ECU */
FlashEcuSubaruUnisiaJecs *flashEcuSubaruUnisiaJecs;
FlashEcuSubaruUnisiaJecsM32r *flashEcuSubaruUnisiaJecsM32r;
FlashEcuSubaruHitachiM32rKline *flashEcuSubaruHitachiM32rKline;
FlashEcuSubaruHitachiM32rCan *flashEcuSubaruHitachiM32rCan;
FlashEcuSubaruMitsuM32rKline *flashEcuSubaruMitsuM32rKline;
FlashEcuSubaruHitachiSH7058Can *flashEcuSubaruHitachiSh7058Can;
FlashEcuSubaruHitachiSH72543rCan *flashEcuSubaruHitachiSh72543rCan;
/* Hitachi TCU */
FlashTcuSubaruHitachiM32rKline *flashTcuSubaruHitachiM32rKline;
FlashTcuSubaruHitachiM32rCan *flashTcuSubaruHitachiM32rCan;
FlashTcuCvtSubaruHitachiM32rCan *flashTcuCvtSubaruHitachiM32rCan;
/* Mitsu TCU */
FlashTcuCvtSubaruMitsuMH8104Can *flashTcuCvtSubaruMitsuMH8104Can;
FlashTcuCvtSubaruMitsuMH8111Can *flashTcuCvtSubaruMitsuMH8111Can;
FlashEcuSubaruDensoSH7xxxDensoCan *flashEcuSubaruDensoSH7xxxCan;
/* Flash modules */
SerialPortActions *serial;
//QTimer *serial_poll_timer;
uint16_t serial_poll_timer_timeout = 500;
QString serial_port_baudrate = "4800";
QString default_serial_port_baudrate = "4800";
QString serial_port_linux = "/dev/ttyUSB0";
QString serial_port_windows = "COM67";
QString serial_port;
QString previous_serial_port;
QString serial_port_prefix;
QStringList serial_ports;
int ecu_protocols_list_length = 6;
QString current_car_model ="";
//QStringList flash_methods;
QStringList flash_transports;
QStringList log_transports;
// "Mercedes", "CR3 EDC16C31", "K-Line", "K-Line", "iso14230", "Mercedes Benz 320CDI",
enum RomInfoEnum {
XmlId,
InternalIdAddress,
Make,
Model,
SubModel,
Market,
Transmission,
Year,
EcuId,
InternalIdString,
MemModel,
ChecksumModule,
RomBase,
FlashMethod,
FileSize,
};
QString ecuid = "";
QString protocol = "";
QString log_protocol = "";
//QTimer *ssm_init_poll_timer;
uint16_t ssm_init_poll_timer_timeout = 250;
QTimer *logging_poll_timer;
uint16_t logging_poll_timer_timeout = 150;
uint16_t logging_counter = 0;
bool logging_request_active = false;
QTimer *logparams_poll_timer;
uint16_t logparams_poll_timer_timeout = 10;
bool logparams_read_active = false;
QElapsedTimer *log_speed_timer;
LogBox *logBoxes;
QRadioButton *ecu_radio_button;
QRadioButton *tcu_radio_button;
QTreeWidget treeWidget;
CalibrationTreeWidget *calibrationTreeWidget = new CalibrationTreeWidget();
QLabel *status_bar_connection_label = new QLabel("");
QLabel *status_bar_ecu_label = new QLabel("");
QMenu *mainWindowMenu;
QPushButton *refresh_serial_port_list;
QComboBox *serial_port_list;
QComboBox *flash_transport_list;
QComboBox *log_transport_list;
QFile log_file;
QTextStream log_file_outstream;
bool write_log_to_file = false;
bool log_file_open = false;
QElapsedTimer *log_file_timer;
QDialog *settings_dialog;
QListWidget *contents_widget;
QStackedWidget *pages_widget;
QSize toolbar_item_size = QSize(24, 24);
Ui::MainWindow *ui;
bool eventFilter(QObject *target, QEvent *event);
// fileactions.c
bool open_calibration_file(QString filename);
void save_calibration_file();
void save_calibration_file_as();
QStringList parse_stringlist_from_expression_string(QString expression, QString x);
float calculate_value_from_expression(QStringList expression);
// log_operations
void kline_listener();
void canbus_listener();
void ssm_init();
void ssm_kline_init();
void ssm_can_init();
QString parse_log_params(QByteArray received, QString protocol);
void parse_log_value_list(QByteArray received, QString protocol);
QByteArray add_ssm_header(QByteArray output, bool dec_0x100);
uint8_t calculate_checksum(QByteArray output, bool dec_0x100);
void log_to_file();
// logvalues.c
void change_log_values(int tabIndex, QString protocol);
// mainwindow.c
//Connect signals for any flash class and execute ::run() method
template <typename FLASH_CLASS>
FLASH_CLASS* connect_signals_and_run_module(FLASH_CLASS *object);
void SetComboBoxItemEnabled(QComboBox * comboBox, int index, bool enabled);
void set_flash_arrow_state();
void update_protocol_info(int rom_number);
QStringList create_flash_transports_list();
QStringList create_log_transports_list();
//QString check_kernel(QString flash_method);
void setSplashScreenProgress(QString text, int incValue);
// menuactions.c
void inc_dec_value(QString action);
void set_value();
void interpolate_value(QString action);
void copy_value();
void paste_value();
int connect_to_ecu();
void disconnect_from_ecu();
void ecu_definition_manager();
void logger_definition_manager();
void winols_csv_to_romraider_xml();
void set_realtime_state(bool state);
void toggle_realtime();
void toggle_log_to_file();
void set_maptablewidget_items();
QString get_rom_data_value(uint8_t map_rom_number, uint32_t map_data_address, uint16_t map_value_index, QString map_value_storagetype, QString map_value_endian);
void set_rom_data_value(uint8_t map_rom_number, uint32_t map_data_address, uint16_t map_value_index, QString map_value_storagetype, QString map_value_endian, float map_value);
int get_mapvalue_decimal_count(QString valueFormat);
int get_map_cell_colors(FileActions::EcuCalDefStructure *ecuCalDef, float mapDataValue, int mapIndex);
void show_preferences_window();
void toggle_haltech_ic7_display();
int test_haltech_ic7_display();
void toggle_simulate_obd();
void toggle_can_listener();
int simulate_obd();
void show_subaru_biu_window();
void show_subaru_get_key_window();
//#include <modules/flash_sti04.h>
protected:
void closeEvent(QCloseEvent *event);
bool event(QEvent *event);
void resizeEvent( QResizeEvent * event);
private slots:
//External logger slot for string messages
void external_logger(QString message);
//External progress bar slot
void external_logger_set_progressbar_value(int value);
// calibrationtreewidget.c
void calibration_files_treewidget_item_selected(QTreeWidgetItem* item);
void calibration_data_treewidget_item_selected(QTreeWidgetItem* item);
void calibration_data_treewidget_item_expanded(QTreeWidgetItem* item);
void calibration_data_treewidget_item_collapsed(QTreeWidgetItem* item);
// log_operations.c
bool ecu_init();
void log_ssm_values();
void read_log_serial_data();
// menu_actions.c
void menu_action_triggered(QString action);
// mainwindow.c
void select_protocol();
void select_protocol_finished(int result);
void select_vehicle();
void select_vehicle_finished(int result);
void log_transport_changed();
void flash_transport_changed();
void check_serial_ports();
void open_serial_port();
int can_listener();
int start_ecu_operations(QString cmd_type);
void close_calibration();
void close_calibration_map(QObject* obj);
void change_gauge_values();
void change_digital_values();
void change_switch_values();
void update_logboxes(QString protocol);
void update_logbox_values(QString protocol);
void add_new_ecu_definition_file();
void remove_ecu_definition_file();
void add_new_logger_definition_file();
void remove_logger_definition_file();
QString parse_message_to_hex(QByteArray received);
QString parse_ecuid(QByteArray received);
void set_status_bar_label(bool serialConnectionState, bool ecuConnectionState, QString romId);
void custom_menu_requested(QPoint pos);
void selectable_combobox_item_changed(QString item);
void checkbox_state_changed(int state);
void close_app();
// logvalues.c
void change_log_gauge_value(int index);
void change_log_digital_value(int index);
void change_log_switch_value(int index);
signals:
void check_serial_port();
void send_serial_data(QByteArray output);
};
#endif // MAINWINDOW_H