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

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