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

Last change on this file since 6204 was 4105, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.1 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <fstream>
4
5#include <TSystem.h>
6#include <TApplication.h>
7
8#include "MCosy.h"
9#include "MTime.h"
10#include "MLogManip.h"
11
12#include "MStarguider.h"
13
14#define EXPERT
15
16#define clog(txt) \
17 { \
18 const Bool_t is = lout.IsOutputDeviceEnabled(MLog::eStdout); \
19 lout << edev(MLog::eStdout) << txt << endl; \
20 if (is) \
21 lout.EnableOutputDevice(MLog::eStdout); \
22 }
23
24/* ---------------------------------------------------------------------- */
25int main(int argc, char **argv)
26{
27 gLog << "==================================================" << endl;
28 gLog << " Cosy V0.1 " << endl;
29 gLog << " Magic Drive Control System Software " << endl;
30 gLog << " Compiled on <" << __DATE__ << ">" << endl;
31 gLog << " Using ROOT v" << ROOTVER << endl;
32 gLog << "==================================================" << endl;
33 gLog << endl;
34
35 Int_t channel = 0;
36 for (int i=0; i<argc; i++)
37 {
38 TString arg(argv[i]);
39 if (arg=="-1")
40 channel = 1;
41 if (arg=="-0")
42 channel = 0;
43 if (arg=="-c")
44 channel = -1;
45 }
46
47 //
48 // this must move to MGCosy !!!!
49 //
50 const TString name = MCosy::GetFileName("log/cosy_%s.log");
51 cout << "Open Logfile: " << name << endl;
52
53 MLog *l = new MLog(name, kTRUE);
54 MLog &lout = *l;
55 lout.SetNoColors();
56
57 MTime now(-1);
58 clog("Starting Cosy at " << now << " ...");
59
60 //
61 // start the main window
62 //
63 clog("- Initialising Root environment.");
64
65 // FIXME: Fails deleteing something in TGClient::fWlist
66 TApplication *app=new TApplication("App", &argc, argv);
67
68 //
69 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
70 //
71 clog("- Constructing MCosy.");
72/*
73 //
74 // check for the right usage of the program
75 //
76 int mode = 0;
77 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
78 switch (argv[1][2])
79 {
80 case '0': // standard
81 mode = 0;
82 break;
83 case '1': // SE mode
84 mode = 1;
85 break;
86 case '2': // GUI demo mode
87 mode = 2;
88 break;
89 }
90*/
91 MCosy *cosy = new MCosy("/dev/dpm_00", 125, lout);
92
93 clog("- Starting MCosy.");
94#ifndef EXPERT
95 lout.DisableOutputDevice(MLog::eStdout);
96#endif
97 cosy->Start();
98
99 MStarguider *client=0;
100 if (channel>=0)
101 {
102 clog("- Starting Camera.");
103 client=new MStarguider(MObservatory::kMagic1, channel);
104 cosy->SetStarguider(client);
105 client->SetCosy(cosy);
106 }
107
108 clog("- Starting mainloop.");
109#ifndef EXPERT
110 lout.DisableOutputDevice(MLog::eStdout);
111#endif
112 app->Run(kTRUE);
113
114 if (channel>=0)
115 {
116 client->SetCosy(NULL);
117 cosy->SetStarguider(NULL);
118 clog("- Stopping starg.");
119 delete client;
120 }
121
122 clog("- Stopping cosy.");
123 cosy->Stop();
124
125 now.Now();
126 clog(now << ": MCosy stopped.");
127
128 delete cosy;
129
130 now.Now();
131 clog("Terminating cosy at " << now);
132
133 delete l;
134
135 cout << "The End." << endl;
136}
Note: See TracBrowser for help on using the repository browser.