Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
95 lines (83 loc) · 2.13 KB
/
Copy pathmain.cpp
File metadata and controls
95 lines (83 loc) · 2.13 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
#include <termio.h>
#include <chrono>
#include <thread>
#include "HmiEvent.h"
#include "HmiMain.h"
#include "GDC_Sim.h"
#include "Simulator.h"
#include "HMIControl.h"
void hmiMain(HmiMain* p_hmi)
{
std::cout << "HMI main thread is started!\n";
p_hmi->start();
}
void KeyboardScan(HmiMain* p_hmi)
{
unsigned int timer = 0;
while(true)
{
std::this_thread::sleep_for(std::chrono::milliseconds(500));
timer++;
#if 0
struct termios new_settings;
struct termios stored_settings;
// tty访问设置
tcgetattr(0, &stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ICANON);
new_settings.c_cc[VTIME] = 0;
tcgetattr(0, &stored_settings);
new_settings.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &new_settings);
int input = getchar();
tcsetattr(0, TCSANOW, &stored_settings);
if(input != EOF)
{
HmiEvent ev(HMI_EV_TOUCH, (unsigned long)input);
p_hmi->setReady(true);
p_hmi->addEventQueue(ev);
}
#endif
if(timer == 1)
{
timer = 0;
HmiEvent ev(HMI_EV_CYCLIC, (unsigned long)0);
p_hmi->setReady(true);
p_hmi->addEventQueue(ev);
}
}
}
static HMIControl hmi_control;
int main(int argc, char* argv[])
{
// int sig = analyzeOptions( argc, argv );
int sig = 1;
Options opts( "Simulator.ini" );
if( opts.logFileName != "" )
{
freopen( opts.logFileName.c_str(), "w", stdout );
freopen( opts.logFileName.c_str(), "w", stderr );
}
static Simulator sim;
switch(sig)
{
case 1:
{
// Simulator mode
sim.initBmp();
setSim(&sim);
static HmiMain *p_hmi = new HmiMain();
hmi_control.setHMI(p_hmi);
std::thread hmi_main(hmiMain, p_hmi);
std::thread kb_scan(KeyboardScan, p_hmi);
sim.gtkmain(argc, argv);
hmi_main.join();
kb_scan.join();
}
break;
case 2:
{}
break;
}
return 0;
}