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

Last change on this file since 3570 was 2615, checked in by tbretz, 21 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 "Camera.h"
13#include "PngReader.h"
14#include "MStarguider.h"
15
16//#define EXPERT
17//#define HAVE_CAMERA
18
19#define clog(txt) \
20 { \
21 const Bool_t is = lout.IsOutputDeviceEnabled(MLog::eStdout); \
22 lout << edev(MLog::eStdout) << txt << endl; \
23 if (is) \
24 lout.EnableOutputDevice(MLog::eStdout); \
25 }
26
27/* ---------------------------------------------------------------------- */
28int main(int argc, char **argv)
29{
30 gLog << "==================================================" << endl;
31 gLog << " Cosy V0.1 " << endl;
32 gLog << " Magic Drive Control System Software " << endl;
33 gLog << " Compiled on <" << __DATE__ << ">" << endl;
34 gLog << " Using ROOT v" << ROOTVER << endl;
35 gLog << "==================================================" << endl;
36 gLog << endl;
37
38 //
39 // this must move to MGCosy !!!!
40 //
41 MTime time;
42 TString name;
43 while (1)
44 {
45 time.Now();
46 name = Form("log/cosy_%s.log", (const char*)time.GetFileName());
47 cout << "Test: " << time.GetFileName() << " " << name << endl;
48 if (gSystem->AccessPathName(name, kFileExists))
49 break;
50 }
51
52 cout << "Open Logfile: " << name << endl;
53
54 MLog *l = new MLog(name, kTRUE);
55 MLog &lout = *l;
56
57 clog("Starting Cosy at " << time << " ...");
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);
101 Camera *cam = new Camera(*client);
102 cam->Loop(0);
103
104 cosy->SetStarguider(client);
105 client->SetCosy(cosy);
106#endif
107 clog("- Starting mainloop.");
108#ifndef EXPERT
109 lout.DisableOutputDevice(MLog::eStdout);
110#endif
111 app->Run(kTRUE);
112#ifdef HAVE_CAMERA
113 client->SetCosy(NULL);
114 cosy->SetStarguider(NULL);
115
116 clog("- Stopping starg.");
117 cam->ExitLoop();
118 delete cam;
119 delete client;
120#endif
121 clog("- Stopping cosy.");
122 cosy->Stop();
123
124 time.Now();
125 clog(time << ": MCosy stopped.");
126
127 delete cosy;
128
129 time.Now();
130 clog("Terminating cosy at " << time);
131
132 delete l;
133
134 cout << "The End." << endl;
135}
Note: See TracBrowser for help on using the repository browser.