Line | |
---|
1 | #include <iomanip.h>
|
---|
2 | #include <fstream.h>
|
---|
3 | #include <iostream.h>
|
---|
4 |
|
---|
5 | #include <TROOT.h>
|
---|
6 | #include <TSystem.h>
|
---|
7 | #include <TApplication.h>
|
---|
8 |
|
---|
9 | #include "MCosy.h"
|
---|
10 | #include "MLogManip.h"
|
---|
11 | #include "base/timer.h"
|
---|
12 |
|
---|
13 | #define clog(txt) \
|
---|
14 | { \
|
---|
15 | const Bool_t is = lout.IsOutputDeviceEnabled(MLog::eStdout); \
|
---|
16 | lout << edev(MLog::eStdout) << txt << endl; \
|
---|
17 | if (is) \
|
---|
18 | lout.EnableOutputDevice(MLog::eStdout); \
|
---|
19 | }
|
---|
20 |
|
---|
21 | TROOT root("Cosy", "Magic Control System");
|
---|
22 |
|
---|
23 | int main(int argc, char **argv)
|
---|
24 | {
|
---|
25 | Timer time;
|
---|
26 | time.Now();
|
---|
27 |
|
---|
28 | //
|
---|
29 | // this must move to MGCosy !!!! (or MApplication)
|
---|
30 | //
|
---|
31 | MLog *l = new MLog("log/cosy.log", kTRUE);
|
---|
32 | MLog &lout = *l;
|
---|
33 | lout.EnableOutputDevice(MLog::eStdout);
|
---|
34 |
|
---|
35 | clog("Starting Cosy at " << time.GetTimeStr() << " ...");
|
---|
36 |
|
---|
37 | //
|
---|
38 | // start the main window
|
---|
39 | //
|
---|
40 | clog("- Initialising Root environment.");
|
---|
41 |
|
---|
42 | TApplication* app = new TApplication("App", &argc, argv);
|
---|
43 |
|
---|
44 | //
|
---|
45 | // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
|
---|
46 | //
|
---|
47 | clog("- Constructing MCosy.");
|
---|
48 |
|
---|
49 | //
|
---|
50 | // check for the right usage of the program
|
---|
51 | //
|
---|
52 | int mode = 2;
|
---|
53 | if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
|
---|
54 | switch (argv[1][2])
|
---|
55 | {
|
---|
56 | case '0': // standard
|
---|
57 | mode = 0;
|
---|
58 | break;
|
---|
59 | case '1': // SE mode
|
---|
60 | mode = 1;
|
---|
61 | break;
|
---|
62 | }
|
---|
63 |
|
---|
64 | MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 500, lout);
|
---|
65 |
|
---|
66 | clog("- Starting MCosy.");
|
---|
67 | cosy->Start();
|
---|
68 |
|
---|
69 | clog("- Starting mainloop.");
|
---|
70 | app->Run(kTRUE);
|
---|
71 |
|
---|
72 | clog("- Stopping cosy.");
|
---|
73 | cosy->Stop();
|
---|
74 | clog("- cosy stopped.");
|
---|
75 |
|
---|
76 | delete cosy;
|
---|
77 |
|
---|
78 | clog("- Terminating Program.");
|
---|
79 |
|
---|
80 | delete l;
|
---|
81 |
|
---|
82 | cout << "The End." << endl;
|
---|
83 |
|
---|
84 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.