source: trunk/MagicSoft/Cosy/cosy.cc@ 1722

Last change on this file since 1722 was 1703, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.2 KB
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
21TROOT root("Cosy", "Magic Control System");
22
23int main(int argc, char **argv)
24{
25 gLog << "==================================================" << endl;
26 gLog << " Cosy V0.1 " << endl;
27 gLog << " Magic Drive Control System Softwware " << endl;
28 gLog << " Compiled on <" << __DATE__ << ">" << endl;
29 gLog << " Using ROOT v" << ROOTVER << endl;
30 gLog << "==================================================" << endl;
31 gLog << endl;
32
33 Timer time;
34 time.Now();
35
36 //
37 // this must move to MGCosy !!!! (or MApplication)
38 //
39 MLog *l = new MLog("log/cosy.log", kTRUE);
40 MLog &lout = *l;
41 lout.EnableOutputDevice(MLog::eStdout);
42
43 clog("Starting Cosy at " << time.GetTimeStr() << " ...");
44
45 //
46 // start the main window
47 //
48 clog("- Initialising Root environment.");
49
50 TApplication* app = new TApplication("App", &argc, argv);
51
52 //
53 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
54 //
55 clog("- Constructing MCosy.");
56
57 //
58 // check for the right usage of the program
59 //
60 int mode = 0;
61 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
62 switch (argv[1][2])
63 {
64 case '0': // standard
65 mode = 0;
66 break;
67 case '1': // SE mode
68 mode = 1;
69 break;
70 case '2': // GUI demo mode
71 mode = 2;
72 break;
73 }
74
75 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 500, lout);
76
77 clog("- Starting MCosy.");
78 cosy->Start();
79
80 clog("- Starting mainloop.");
81 app->Run(kTRUE);
82
83 clog("- Stopping cosy.");
84 cosy->Stop();
85 clog("- cosy stopped.");
86
87 delete cosy;
88
89 clog("- Terminating Program.");
90
91 delete l;
92
93 cout << "The End." << endl;
94
95}
Note: See TracBrowser for help on using the repository browser.