-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappmain.cxx
121 lines (99 loc) · 2.13 KB
/
appmain.cxx
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
// example.C
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>
#include <RQ_OBJECT.h>
#include <TApplication.h>
#include <TLine.h>
#include <TMath.h>
#include <TThread.h>
#include <TMutex.h>
#include <TSystem.h>
TMutex *g_mtx_disp;
#include "appframe.h"
static TCanvas *c1;
static AppFrame *af;
#include "datareader.cxx"
#if 0
static TLine *l = new TLine();
void drawline()
{
static double omega = 0;
const double domega = TMath::Pi() * 2.0 / 500;
const double r = 0.3;
const double x_offset = 0.5;
const double y_offset = 0.5;
l->DrawLine(
r * cos(omega) + x_offset,
r * sin(omega) + y_offset,
r * cos(omega + domega) + x_offset,
r * sin(omega + domega) + y_offset);
omega += domega;
}
#endif
void updater(void *arg = NULL)
{
while (true) {
TThread::Sleep(0, 100000);
#if 0
if (af->GetRunState()) {
c1->Clear();
//drawline();
c1->Update();
}
#endif
}
}
int drop_stderr()
{
int fd = open("/dev/null", O_WRONLY);
if (fd >= 0) {
int status = dup2(fd, 2);
return status;
} else {
return fd;
}
}
int main(int argc, char* argv[])
{
for (int i = 1 ; i < argc ; i++) {
std::string sargv(argv[i]);
//if (strncmp(argv[i], "--no-exit", 9) == 0) no_exit = 1;
if (sargv == "--no-exit") std::cout << "Hello" << std::endl;
}
drop_stderr();
//std::cout << "World" << std::endl;
int ta_argc = 1;
char *ta_argv[] = {const_cast<char *>("App")};
gApplication = new TApplication("App", &ta_argc, ta_argv);
g_mtx_disp = new TMutex();
// Popup the GUI...
af = new AppFrame(gClient->GetRoot(), 200, 200);
c1 = af->GetCanvas();
c1->cd(0)->SetGrid();
c1->Update();
#if 0
c1->SetFillColor(39);
l->SetLineColor(0);
l->SetLineWidth(5);
#endif
TThread threader("Reader", &reader, NULL);
threader.Run();
//TThread thupdater("Updater", &updater, NULL);
//thupdater.Run();
//gApplication->Run();
while (true) {
g_mtx_disp->Lock();
gSystem->ProcessEvents();
g_mtx_disp->UnLock();
//TThread::Sleep(0, 100000);
TThread::Sleep(0, 200000);
}
//threader.Join();
//thupdater.Join();
return 0;
}