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

Last change on this file since 2280 was 2278, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.1 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#include "Camera.h"
14#include "PngReader.h"
15#include "MStarguider.h"
16
17#define EXPERT
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
27TROOT root("Cosy", "Magic Control System");
28
29/* ---------------------------------------------------------------------- */
30//extern void InitGui();
31//VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
32
33int main(int argc, char **argv)
34{
35 gLog << "==================================================" << endl;
36 gLog << " Cosy V0.1 " << endl;
37 gLog << " Magic Drive Control System Software " << endl;
38 gLog << " Compiled on <" << __DATE__ << ">" << endl;
39 gLog << " Using ROOT v" << ROOTVER << endl;
40 gLog << "==================================================" << endl;
41 gLog << endl;
42
43 Timer time;
44 time.Now();
45
46 //
47 // this must move to MGCosy !!!! (or MApplication)
48 //
49 int i=0;
50 char name[100];
51 while (1)
52 {
53 sprintf(name, "log/cosy%03d.log", i++);
54 if (gSystem->AccessPathName(name, kFileExists))
55 break;
56 }
57
58 MLog *l = new MLog(name, kTRUE);
59 MLog &lout = *l;
60
61 clog("Starting Cosy at " << time.GetTimeStr() << " ...");
62
63 //
64 // start the main window
65 //
66 clog("- Initialising Root environment.");
67
68 TApplication* app = new TApplication("App", &argc, argv);
69
70 //
71 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps
72 //
73 clog("- Constructing MCosy.");
74
75 //
76 // check for the right usage of the program
77 //
78 int mode = 0;
79 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m'))
80 switch (argv[1][2])
81 {
82 case '0': // standard
83 mode = 0;
84 break;
85 case '1': // SE mode
86 mode = 1;
87 break;
88 case '2': // GUI demo mode
89 mode = 2;
90 break;
91 }
92
93 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 125, lout);
94
95 clog("- Starting MCosy.");
96#ifndef EXPERT
97 lout.DisableOutputDevice(MLog::eStdout);
98#endif
99 cosy->Start();
100
101 clog("- Starting Camera.");
102 MStarguider *client=new MStarguider(MObservatory::kMagic1);
103 Camera *cam = new Camera(*client);
104 cam->Loop(0);
105
106 cosy->SetStarguider(client);
107 client->SetCosy(cosy);
108
109 clog("- Starting mainloop.");
110#ifndef EXPERT
111 lout.DisableOutputDevice(MLog::eStdout);
112#endif
113 app->Run(kTRUE);
114
115 client->SetCosy(NULL);
116 cosy->SetStarguider(NULL);
117
118 clog("- Stopping starg.");
119 cam->ExitLoop();
120 delete cam;
121 delete client;
122
123 clog("- Stopping cosy.");
124 cosy->Stop();
125 clog("- cosy stopped.");
126
127 delete cosy;
128
129 clog("- Terminating Program.");
130
131 delete l;
132
133 cout << "The End." << endl;
134
135}
Note: See TracBrowser for help on using the repository browser.