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

Last change on this file since 2065 was 2019, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.3 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 Software " << 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
42 clog("Starting Cosy at " << time.GetTimeStr() << " ...");
43
44 //
45 // start the main window
46 //
47 clog("- Initialising Root environment.");
48
49 TApplication* app = new TApplication("App", &argc, argv);
50
51 //
52 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
53 //
54 clog("- Constructing MCosy.");
55
56 //
57 // check for the right usage of the program
58 //
59 int mode = 0;
60 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
61 switch (argv[1][2])
62 {
63 case '0': // standard
64 mode = 0;
65 break;
66 case '1': // SE mode
67 mode = 1;
68 break;
69 case '2': // GUI demo mode
70 mode = 2;
71 break;
72 }
73
74 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 125, lout);
75
76 clog("- Starting MCosy.");
77 lout.DisableOutputDevice(MLog::eStdout);
78 cosy->Start();
79
80 clog("- Starting mainloop.");
81 lout.DisableOutputDevice(MLog::eStdout);
82 app->Run(kTRUE);
83
84 clog("- Stopping cosy.");
85 cosy->Stop();
86 clog("- cosy stopped.");
87
88 delete cosy;
89
90 clog("- Terminating Program.");
91
92 delete l;
93
94 cout << "The End." << endl;
95
96}
Note: See TracBrowser for help on using the repository browser.