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

Last change on this file since 1959 was 1953, 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 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 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.