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

Last change on this file since 7791 was 7788, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.2 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", "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 if (gROOT->IsBatch())
69 {
70 cout << "ERROR - Cannot run in Batch mode!" << endl;
71 return 0;
72 }
73
74 //
75 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
76 //
77 clog("- Constructing MCosy.");
78/*
79 //
80 // check for the right usage of the program
81 //
82 int mode = 0;
83 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
84 switch (argv[1][2])
85 {
86 case '0': // standard
87 mode = 0;
88 break;
89 case '1': // SE mode
90 mode = 1;
91 break;
92 case '2': // GUI demo mode
93 mode = 2;
94 break;
95 }
96*/
97 MCosy *cosy = new MCosy("/dev/dpm_00", 125, lout);
98
99 clog("- Starting MCosy.");
100#ifndef EXPERT
101 lout.DisableOutputDevice(MLog::eStdout);
102#endif
103 cosy->Start();
104
105 MStarguider *client=0;
106 if (channel>=0)
107 {
108 clog("- Starting Camera.");
109 client=new MStarguider(MObservatory::kMagic1, channel);
110 cosy->SetStarguider(client);
111 client->SetCosy(cosy);
112 }
113
114 clog("- Starting mainloop.");
115#ifndef EXPERT
116 lout.DisableOutputDevice(MLog::eStdout);
117#endif
118 app->Run(kTRUE);
119
120 if (channel>=0)
121 {
122 client->SetCosy(NULL);
123 cosy->SetStarguider(NULL);
124 clog("- Stopping starg.");
125 delete client;
126 }
127
128 clog("- Stopping cosy.");
129 cosy->Stop();
130
131 now.Now();
132 clog(now << ": MCosy stopped.");
133
134 delete cosy;
135
136 now.Now();
137 clog("Terminating cosy at " << now);
138
139 delete l;
140
141 cout << "The End." << endl;
142}
Note: See TracBrowser for help on using the repository browser.