1 | #include "MGCosy.h"
|
---|
2 |
|
---|
3 | #include <iostream.h>
|
---|
4 |
|
---|
5 | #include "msgqueue.h"
|
---|
6 | #include "coord.h"
|
---|
7 |
|
---|
8 | #include <TROOT.h>
|
---|
9 |
|
---|
10 | #include <TGTab.h> // TGTab
|
---|
11 | #include <TGMenu.h> // TGPopupMenu
|
---|
12 | #include <TGButton.h> // TGButton
|
---|
13 | #include <TSystem.h> // gSystem
|
---|
14 | #include <TGLabel.h> // TGLabel
|
---|
15 | #include <TGListBox.h> // TGListBox
|
---|
16 | #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter)
|
---|
17 | #include <TGTextEntry.h> // TGTextEntry
|
---|
18 | #include <TGFrame.h> // TGGroupFrame
|
---|
19 | #include <TApplication.h> // gApplication
|
---|
20 |
|
---|
21 | //#include "timer.h" // Timer
|
---|
22 |
|
---|
23 | #include "MCosy.h"
|
---|
24 | #include "MGList.h"
|
---|
25 | #include "MGAccuracy.h"
|
---|
26 | #include "MGCoordinates.h"
|
---|
27 | #include "MGSkyPosition.h"
|
---|
28 | #include "MGVelocity.h"
|
---|
29 |
|
---|
30 | #include "SlaStars.h"
|
---|
31 |
|
---|
32 | #undef DEBUG
|
---|
33 |
|
---|
34 | ClassImp(MGCosy);
|
---|
35 |
|
---|
36 | #define IDM_EXIT 1
|
---|
37 | #define IDM_TEXT 2
|
---|
38 | #define IDM_ASPECT 3
|
---|
39 |
|
---|
40 | enum
|
---|
41 | {
|
---|
42 | kPB_POSITION,
|
---|
43 | kPB_TRACK,
|
---|
44 | kPB_STOP,
|
---|
45 | kPB_HOME,
|
---|
46 | kPB_CALCALTAZ,
|
---|
47 | kPB_TPOINT,
|
---|
48 | kPB_START,
|
---|
49 | kPB_RAp,
|
---|
50 | kPB_RAm,
|
---|
51 | kPB_DECp,
|
---|
52 | kPB_DECm,
|
---|
53 | kPB_LoadBending,
|
---|
54 | kPB_ResetBending,
|
---|
55 | kPB_CALIBSE
|
---|
56 | };
|
---|
57 |
|
---|
58 | void MGCosy::CreateMenu()
|
---|
59 | {
|
---|
60 | fLayMenuBar = new TGLayoutHints (kLHintsNormal | kLHintsExpandX);
|
---|
61 | fLayMenuItem = new TGLayoutHints (kLHintsNormal, 0, 4, 0, 0);
|
---|
62 |
|
---|
63 | //
|
---|
64 | // crate the menu bar
|
---|
65 | //
|
---|
66 | TGPopupMenu *fFileMenu = new TGPopupMenu(gClient->GetRoot());
|
---|
67 | fFileMenu->AddEntry("Set Aspect", IDM_ASPECT);
|
---|
68 | fFileMenu->AddEntry("Exit", IDM_EXIT);
|
---|
69 | fFileMenu->Associate(this);
|
---|
70 | fList->Add(fFileMenu);
|
---|
71 |
|
---|
72 | //
|
---|
73 | // the button messages are handled by main frame (this)
|
---|
74 | //
|
---|
75 | TGMenuBar *fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
---|
76 | fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem);
|
---|
77 | AddFrame(fMenuBar, fLayMenuBar);
|
---|
78 | fList->Add(fMenuBar);
|
---|
79 |
|
---|
80 | //
|
---|
81 | // Seperator beyond menubar
|
---|
82 | //
|
---|
83 |
|
---|
84 | TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
|
---|
85 | AddFrame(fLineSep, fLayMenuBar);
|
---|
86 | fList->Add(fLineSep);
|
---|
87 | }
|
---|
88 |
|
---|
89 | void MGCosy::CreateLabel(TGCompositeFrame *f)
|
---|
90 | {
|
---|
91 | const int x = 180;
|
---|
92 | const int y = 25;
|
---|
93 |
|
---|
94 | TGLabel *l;
|
---|
95 |
|
---|
96 | l = new TGLabel(f, "UTC:");
|
---|
97 | l->Move(x-60, y);
|
---|
98 | fList->Add(l);
|
---|
99 |
|
---|
100 | l = new TGLabel(f, "Mjd:");
|
---|
101 | l->Move(x-60, y+17);
|
---|
102 | fList->Add(l);
|
---|
103 |
|
---|
104 | fUtc = new TGLabel(f, "0000/00/00 00:00:00.0");
|
---|
105 | fMjd = new TGLabel(f, "00000.000000");
|
---|
106 | fUtc->Move(x-25, y);
|
---|
107 | fMjd->Move(x-25, y+17);
|
---|
108 | fList->Add(fUtc);
|
---|
109 | fList->Add(fMjd);
|
---|
110 |
|
---|
111 | l = new TGLabel(f, "SE-Az:");
|
---|
112 | l->Move(x-60, y+40);
|
---|
113 | fList->Add(l);
|
---|
114 |
|
---|
115 | l = new TGLabel(f, "SE-Zd1:");
|
---|
116 | l->Move(x-60, y+57);
|
---|
117 | fList->Add(l);
|
---|
118 |
|
---|
119 | l = new TGLabel(f, "SE-Zd2:");
|
---|
120 | l->Move(x-60, y+74);
|
---|
121 | fList->Add(l);
|
---|
122 |
|
---|
123 | fLabel1 = new TGLabel*[3];
|
---|
124 | fLabel1[0] = new TGLabel(f, "00000"); // Max: 16384
|
---|
125 | fLabel1[1] = new TGLabel(f, "000"); // Max: 256
|
---|
126 | fLabel1[2] = new TGLabel(f, "000"); // Max: 256
|
---|
127 | fLabel1[0]->SetTextJustify(kTextRight);
|
---|
128 | fLabel1[1]->SetTextJustify(kTextRight);
|
---|
129 | fLabel1[2]->SetTextJustify(kTextRight);
|
---|
130 | fLabel1[0]->Move(x, y+40);
|
---|
131 | fLabel1[1]->Move(x+43, y+40);
|
---|
132 | fLabel1[2]->Move(x+70, y+40);
|
---|
133 | fList->Add(fLabel1[0]);
|
---|
134 | fList->Add(fLabel1[1]);
|
---|
135 | fList->Add(fLabel1[2]);
|
---|
136 | //f->AddFrame(fLabel1[0]);
|
---|
137 | //f->AddFrame(fLabel1[1]);
|
---|
138 | //f->AddFrame(fLabel1[2]);
|
---|
139 |
|
---|
140 | fLabel2 = new TGLabel*[3];
|
---|
141 | fLabel2[0] = new TGLabel(f, "00000");
|
---|
142 | fLabel2[1] = new TGLabel(f, "000");
|
---|
143 | fLabel2[2] = new TGLabel(f, "000");
|
---|
144 | fLabel2[0]->SetTextJustify(kTextRight);
|
---|
145 | fLabel2[1]->SetTextJustify(kTextRight);
|
---|
146 | fLabel2[2]->SetTextJustify(kTextRight);
|
---|
147 | fLabel2[0]->Move(x, y+57);
|
---|
148 | fLabel2[1]->Move(x+43, y+57);
|
---|
149 | fLabel2[2]->Move(x+70, y+57);
|
---|
150 | fList->Add(fLabel2[0]);
|
---|
151 | fList->Add(fLabel2[1]);
|
---|
152 | fList->Add(fLabel2[2]);
|
---|
153 | //f->AddFrame(fLabel2[0]);
|
---|
154 | //f->AddFrame(fLabel2[1]);
|
---|
155 | //f->AddFrame(fLabel2[2]);
|
---|
156 |
|
---|
157 | fLabel3 = new TGLabel*[3];
|
---|
158 | fLabel3[0] = new TGLabel(f, "00000");
|
---|
159 | fLabel3[1] = new TGLabel(f, "000");
|
---|
160 | fLabel3[2] = new TGLabel(f, "000");
|
---|
161 | fLabel3[0]->SetTextJustify(kTextRight);
|
---|
162 | fLabel3[1]->SetTextJustify(kTextRight);
|
---|
163 | fLabel3[2]->SetTextJustify(kTextRight);
|
---|
164 | fLabel3[0]->Move(x, y+74);
|
---|
165 | fLabel3[1]->Move(x+43, y+74);
|
---|
166 | fLabel3[2]->Move(x+70, y+74);
|
---|
167 | fList->Add(fLabel3[0]);
|
---|
168 | fList->Add(fLabel3[1]);
|
---|
169 | fList->Add(fLabel3[2]);
|
---|
170 | //f->AddFrame(fLabel3[0]);
|
---|
171 | //f->AddFrame(fLabel3[1]);
|
---|
172 | //f->AddFrame(fLabel3[2]);
|
---|
173 |
|
---|
174 | l = new TGLabel(f, "Offset-Zd:");
|
---|
175 | l->Move(x-60, y+102);
|
---|
176 | fList->Add(l);
|
---|
177 |
|
---|
178 | l = new TGLabel(f, "Offset-Az:");
|
---|
179 | l->Move(x-60, y+119);
|
---|
180 | fList->Add(l);
|
---|
181 |
|
---|
182 | fOffsetZd = new TGLabel(f, "0000000");
|
---|
183 | fOffsetAz = new TGLabel(f, "0000000");
|
---|
184 | fOffsetZd->SetTextJustify(kTextRight);
|
---|
185 | fOffsetAz->SetTextJustify(kTextRight);
|
---|
186 | fOffsetZd->Move(x, y+102);
|
---|
187 | fOffsetAz->Move(x, y+119);
|
---|
188 | fList->Add(fOffsetZd);
|
---|
189 | fList->Add(fOffsetAz);
|
---|
190 |
|
---|
191 | l = new TGLabel(f, "Ra (estimated):");
|
---|
192 | l->Move(x-60, y+142);
|
---|
193 | fList->Add(l);
|
---|
194 |
|
---|
195 | l = new TGLabel(f, "Ra (soll):");
|
---|
196 | l->Move(x-60, y+159);
|
---|
197 | fList->Add(l);
|
---|
198 |
|
---|
199 | l = new TGLabel(f, "Dec (estimated):");
|
---|
200 | l->Move(x-60, y+182);
|
---|
201 | fList->Add(l);
|
---|
202 |
|
---|
203 | l = new TGLabel(f, "Dec (soll):");
|
---|
204 | l->Move(x-60, y+199);
|
---|
205 | fList->Add(l);
|
---|
206 |
|
---|
207 | l = new TGLabel(f, "Zd (soll):");
|
---|
208 | l->Move(x-60, y+222);
|
---|
209 | fList->Add(l);
|
---|
210 |
|
---|
211 | l = new TGLabel(f, "Az (soll):");
|
---|
212 | l->Move(x-60, y+239);
|
---|
213 | fList->Add(l);
|
---|
214 |
|
---|
215 | fRaEst = new TGLabel(f, "+000h 00.0m");
|
---|
216 | fDecEst = new TGLabel(f, "+000h 00.0m");
|
---|
217 | fRaSoll = new TGLabel(f, "+000h 00.0m");
|
---|
218 | fDecSoll = new TGLabel(f, "+000h 00.0m");
|
---|
219 | fZdSoll = new TGLabel(f, "+000h 00.0m");
|
---|
220 | fAzSoll = new TGLabel(f, "+000h 00.0m");
|
---|
221 | fRaEst->SetTextJustify(kTextRight);
|
---|
222 | fDecEst->SetTextJustify(kTextRight);
|
---|
223 | fRaSoll->SetTextJustify(kTextRight);
|
---|
224 | fDecSoll->SetTextJustify(kTextRight);
|
---|
225 | fZdSoll->SetTextJustify(kTextRight);
|
---|
226 | fAzSoll->SetTextJustify(kTextRight);
|
---|
227 | fRaEst->Move(x+30, y+142);
|
---|
228 | fRaSoll->Move(x+30, y+159);
|
---|
229 | fDecEst->Move(x+30, y+182);
|
---|
230 | fDecSoll->Move(x+30, y+199);
|
---|
231 | fZdSoll->Move(x+30, y+222);
|
---|
232 | fAzSoll->Move(x+30, y+239);
|
---|
233 | fList->Add(fRaEst);
|
---|
234 | fList->Add(fDecEst);
|
---|
235 | fList->Add(fRaSoll);
|
---|
236 | fList->Add(fDecSoll);
|
---|
237 | fList->Add(fZdSoll);
|
---|
238 | fList->Add(fAzSoll);
|
---|
239 |
|
---|
240 |
|
---|
241 | fError = new TGLabel(f, "Error");
|
---|
242 | fMoving = new TGLabel(f, "Moving");
|
---|
243 | fTracking = new TGLabel(f, "Tracking");
|
---|
244 | fStopping = new TGLabel(f, "Stopping");
|
---|
245 | fStopped = new TGLabel(f, "Stopped");
|
---|
246 |
|
---|
247 |
|
---|
248 | ULong_t color;
|
---|
249 |
|
---|
250 | gClient->GetColorByName("Red", color);
|
---|
251 | fError->SetBackgroundColor(color);
|
---|
252 | gClient->GetColorByName("LightBlue", color);
|
---|
253 | fMoving->SetBackgroundColor(color);
|
---|
254 | gClient->GetColorByName("Blue", color);
|
---|
255 | fTracking->SetBackgroundColor(color);
|
---|
256 | gClient->GetColorByName("Orange", color);
|
---|
257 | fStopping->SetBackgroundColor(color);
|
---|
258 | gClient->GetColorByName("Green", color);
|
---|
259 | fStopped->SetBackgroundColor(color);
|
---|
260 |
|
---|
261 | fError ->Move(10, 25);
|
---|
262 | fMoving ->Move(10, 25+20);
|
---|
263 | fTracking->Move(10, 25+40);
|
---|
264 | fStopping->Move(10, 25+60);
|
---|
265 | fStopped ->Move(10, 25+80);
|
---|
266 |
|
---|
267 | fError ->Resize(60, 20);
|
---|
268 | fMoving ->Resize(60, 20);
|
---|
269 | fTracking->Resize(60, 20);
|
---|
270 | fStopping->Resize(60, 20);
|
---|
271 | fStopped ->Resize(60, 20);
|
---|
272 |
|
---|
273 | fList->Add(fError);
|
---|
274 | fList->Add(fMoving);
|
---|
275 | fList->Add(fTracking);
|
---|
276 | fList->Add(fStopping);
|
---|
277 | fList->Add(fStopped);
|
---|
278 | }
|
---|
279 |
|
---|
280 | void MGCosy::CreateTabs(TGTab *fTab)
|
---|
281 | {
|
---|
282 | TGCompositeFrame *tf1 = fTab->AddTab("Position");
|
---|
283 | TGCompositeFrame *tf2 = fTab->AddTab("Track");
|
---|
284 | TGCompositeFrame *tf4 = fTab->AddTab("Calibration");
|
---|
285 | TGCompositeFrame *tf3 = fTab->AddTab("Demo");
|
---|
286 |
|
---|
287 | fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
|
---|
288 | fCZdAz->Move(27, 105);
|
---|
289 | fList->Add(fCZdAz);
|
---|
290 |
|
---|
291 | fCRaDec = new MGCoordinates(tf2, kETypeRaDec);
|
---|
292 | fCRaDec->Move(27, 105);
|
---|
293 | fList->Add(fCRaDec);
|
---|
294 |
|
---|
295 | fCCalib = new MGCoordinates(tf4, kETypeRaDec);
|
---|
296 | fCCalib->Move(27, 105);
|
---|
297 | fList->Add(fCCalib);
|
---|
298 |
|
---|
299 | const int x=15;
|
---|
300 | const int y=12;
|
---|
301 | const int h=16;
|
---|
302 |
|
---|
303 | TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in");
|
---|
304 | TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates");
|
---|
305 | TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates, which means that the");
|
---|
306 | TGLabel *l4 = new TGLabel(tf1, "coordinates are corrected for the bending of");
|
---|
307 | TGLabel *l5 = new TGLabel(tf1, "the telescope.");
|
---|
308 | l1->Move(x, y);
|
---|
309 | l2->Move(x, y+h);
|
---|
310 | l3->Move(x, y+2*h);
|
---|
311 | l4->Move(x, y+3*h);
|
---|
312 | l5->Move(x, y+4*h);
|
---|
313 | fList->Add(l1);
|
---|
314 | fList->Add(l2);
|
---|
315 | fList->Add(l3);
|
---|
316 | fList->Add(l4);
|
---|
317 | fList->Add(l5);
|
---|
318 |
|
---|
319 | l1 = new TGLabel(tf2, "Track a position given in sky coordinates.");
|
---|
320 | l2 = new TGLabel(tf2, "Right Ascension and declination must be given");
|
---|
321 | l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system.");
|
---|
322 | l1->Move(x, y);
|
---|
323 | l2->Move(x, y+h);
|
---|
324 | l3->Move(x, y+2*h);
|
---|
325 | fList->Add(l1);
|
---|
326 | fList->Add(l2);
|
---|
327 | fList->Add(l3);
|
---|
328 |
|
---|
329 | l1 = new TGLabel(tf4, "Start the calibration using the Start button.");
|
---|
330 | l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using");
|
---|
331 | l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset");
|
---|
332 | l4 = new TGLabel(tf4, "use the Calib SE button.");
|
---|
333 | l1->Move(x, y);
|
---|
334 | l2->Move(x, y+h);
|
---|
335 | l3->Move(x, y+2*h);
|
---|
336 | l4->Move(x, y+3*h);
|
---|
337 | fList->Add(l1);
|
---|
338 | fList->Add(l2);
|
---|
339 | fList->Add(l3);
|
---|
340 | fList->Add(l4);
|
---|
341 |
|
---|
342 | //
|
---|
343 | // light green: 3 light red: 2 blue?: 2
|
---|
344 | // dark green: 8 dark red: 50 dark blue?: 1
|
---|
345 |
|
---|
346 | //
|
---|
347 | // blue: 0-7, 9, 10,11, 14, 15, 18, 19, 22, 23, 27, 31, 33-39, 41-43
|
---|
348 | // 46, 47
|
---|
349 | // green: 8, 12,13, 16, 17, 20, 21, 24, 25, 26, 28, 29, 30, 40, 44
|
---|
350 | // 45, 48
|
---|
351 | // gray: 31, 113-
|
---|
352 | // red: 164, 192, 224, 232
|
---|
353 | //
|
---|
354 | TGTextButton *but;
|
---|
355 |
|
---|
356 | but= new TGTextButton(tf2, "Ra -", kPB_RAm);
|
---|
357 | but->Resize(50, 25);
|
---|
358 | but->Move(25, 210);
|
---|
359 | but->SetToolTipText("Right ascension -= 1'");
|
---|
360 | but->Associate(this);
|
---|
361 | fList->Add(but);
|
---|
362 | but= new TGTextButton(tf2, "RA +", kPB_RAp);
|
---|
363 | but->Resize(50, 25);
|
---|
364 | but->Move(90, 210);
|
---|
365 | but->SetToolTipText("Right ascension += 1'");
|
---|
366 | but->Associate(this);
|
---|
367 | fList->Add(but);
|
---|
368 | but= new TGTextButton(tf2, "DEC +", kPB_DECp);
|
---|
369 | but->Resize(50, 25);
|
---|
370 | but->Move(55, 185);
|
---|
371 | but->SetToolTipText("Declination += 1'");
|
---|
372 | but->Associate(this);
|
---|
373 | fList->Add(but);
|
---|
374 | but= new TGTextButton(tf2, "DEC -", kPB_DECm);
|
---|
375 | but->Resize(50, 25);
|
---|
376 | but->Move(55, 235);
|
---|
377 | but->SetToolTipText("Declination -= 1'");
|
---|
378 | but->Associate(this);
|
---|
379 | fList->Add(but);
|
---|
380 |
|
---|
381 | but = new TGTextButton(tf1, "Home", kPB_HOME);
|
---|
382 | but->Resize(80, 25);
|
---|
383 | but->Move(160, 197);
|
---|
384 | but->SetToolTipText("Initiate Home Drive.");
|
---|
385 | but->Associate(this);
|
---|
386 | fList->Add(but);
|
---|
387 |
|
---|
388 | but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ);
|
---|
389 | but->Resize(80, 25);
|
---|
390 | but->Move(165, 197);
|
---|
391 | but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
|
---|
392 | but->Associate(this);
|
---|
393 | fList->Add(but);
|
---|
394 |
|
---|
395 | but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
|
---|
396 | but->Resize(80, 25);
|
---|
397 | but->Move(25, 190);
|
---|
398 | but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
|
---|
399 | but->Associate(this);
|
---|
400 | fList->Add(but);
|
---|
401 |
|
---|
402 | but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE);
|
---|
403 | but->Resize(80, 25);
|
---|
404 | but->Move(160, 197);
|
---|
405 | but->SetToolTipText("Set SE to given coordinates.");
|
---|
406 | but->Associate(this);
|
---|
407 | fList->Add(but);
|
---|
408 |
|
---|
409 | but = new TGTextButton(tf4, "Load", kPB_LoadBending);
|
---|
410 | but->Resize(80, 25);
|
---|
411 | but->Move(25, 220);
|
---|
412 | but->SetToolTipText("Load bending corrections from file 'bending.txt'");
|
---|
413 | but->Associate(this);
|
---|
414 | fList->Add(but);
|
---|
415 |
|
---|
416 | but = new TGTextButton(tf4, "Reset", kPB_ResetBending);
|
---|
417 | but->Resize(80, 25);
|
---|
418 | but->Move(25, 250);
|
---|
419 | but->SetToolTipText("Reset bending correction (coefficients=0)");
|
---|
420 | but->Associate(this);
|
---|
421 | fList->Add(but);
|
---|
422 |
|
---|
423 | ULong_t color;
|
---|
424 |
|
---|
425 | but = new TGTextButton(this, "Start", kPB_START);
|
---|
426 | gClient->GetColorByName("Green", color);
|
---|
427 | but->SetBackgroundColor(color);
|
---|
428 | but->Move(147, 295);
|
---|
429 | but->Resize(62, 25);
|
---|
430 | but->SetToolTipText("Start a telescope movement.");
|
---|
431 | fList->Add(but);
|
---|
432 |
|
---|
433 | but = new TGTextButton(this, "Stop", kPB_STOP);
|
---|
434 |
|
---|
435 | gClient->GetColorByName("Red", color);
|
---|
436 | but->SetBackgroundColor(color);
|
---|
437 | but->Move(212, 295);
|
---|
438 | but->Resize(62, 25);
|
---|
439 | but->SetToolTipText("Stop any movement of telescope.");
|
---|
440 | fList->Add(but);
|
---|
441 |
|
---|
442 | /*
|
---|
443 | const Double_t ca = 0; // Left-Right Collimation Error
|
---|
444 | const Double_t an = 0; // Azimuth Axis Misalignment (N-S)
|
---|
445 | const Double_t aw = 0; // Azimuth Axis Misalignment (E-W)
|
---|
446 | const Double_t npae = 0; // Az-El Nonperpendicularity
|
---|
447 | const Double_t nrx = 0; // Nasmyth rotator displacement, horizontan
|
---|
448 | const Double_t nry = 0; // Nasmyth rotator displacement, vertical
|
---|
449 | const Double_t crx = 0; // Alt/Az Coude Displacement (N-S)
|
---|
450 | const Double_t cry = 0; // Alt/Az Coude Displacement (E-W)
|
---|
451 | l1 = new TGLabel(tf5, "CA");
|
---|
452 | l1->SetTextJustify(kTextLeft);
|
---|
453 | l1->Move(x, y+2*h*1.5);
|
---|
454 | l1->MapWindow();
|
---|
455 | fList->Add(l1);
|
---|
456 | l1 = new TGLabel(tf5, "AN");
|
---|
457 | l1->SetTextJustify(kTextLeft);
|
---|
458 | l1->Move(x, y+3*h*1.5);
|
---|
459 | l1->MapWindow();
|
---|
460 | fList->Add(l1);
|
---|
461 | l1 = new TGLabel(tf5, "AW");
|
---|
462 | l1->SetTextJustify(kTextLeft);
|
---|
463 | l1->Move(x, y+4*h*1.5);
|
---|
464 | l1->MapWindow();
|
---|
465 | fList->Add(l1);
|
---|
466 | l1 = new TGLabel(tf5, "NPAE");
|
---|
467 | l1->SetTextJustify(kTextLeft);
|
---|
468 | l1->Move(x, y+5*h*1.5);
|
---|
469 | l1->MapWindow();
|
---|
470 | fList->Add(l1);
|
---|
471 | l1 = new TGLabel(tf5, "NRX");
|
---|
472 | l1->SetTextJustify(kTextLeft);
|
---|
473 | l1->Move(x, y+6*h*1.5);
|
---|
474 | l1->MapWindow();
|
---|
475 | fList->Add(l1);
|
---|
476 | l1 = new TGLabel(tf5, "NRY");
|
---|
477 | l1->SetTextJustify(kTextLeft);
|
---|
478 | l1->Move(x, y+7*h*1.5);
|
---|
479 | l1->MapWindow();
|
---|
480 | fList->Add(l1);
|
---|
481 | l1 = new TGLabel(tf5, "CRX");
|
---|
482 | l1->SetTextJustify(kTextLeft);
|
---|
483 | l1->Move(x, y+8*h*1.5);
|
---|
484 | l1->MapWindow();
|
---|
485 | fList->Add(l1);
|
---|
486 | l1 = new TGLabel(tf5, "CRY");
|
---|
487 | l1->SetTextJustify(kTextLeft);
|
---|
488 | l1->Move(x, y+9*h*1.5);
|
---|
489 | l1->MapWindow();
|
---|
490 | fList->Add(l1);
|
---|
491 | const Double_t ie = 0; // Index Error in Elevation
|
---|
492 | const Double_t ia = 0; // Index Error in Azimuth
|
---|
493 | const Double_t eces = 0; // Elevation Centering Error (sin)
|
---|
494 | const Double_t ecec = 0; // Elevation Centering Error (cos)
|
---|
495 | const Double_t aces = 0; // Azimuth Centering Error (sin)
|
---|
496 | const Double_t acec = 0; // Azimuth Centering Error (cos)
|
---|
497 | l1 = new TGLabel(tf5, "IE");
|
---|
498 | l1->SetTextJustify(kTextLeft);
|
---|
499 | l1->Move(x+150, y+3*h*1.5);
|
---|
500 | l1->MapWindow();
|
---|
501 | fList->Add(l1);
|
---|
502 | l1 = new TGLabel(tf5, "IA");
|
---|
503 | l1->SetTextJustify(kTextLeft);
|
---|
504 | l1->Move(x+150, y+4*h*1.5);
|
---|
505 | l1->MapWindow();
|
---|
506 | fList->Add(l1);
|
---|
507 | l1 = new TGLabel(tf5, "ECES");
|
---|
508 | l1->SetTextJustify(kTextLeft);
|
---|
509 | l1->Move(x+150, y+5*h*1.5);
|
---|
510 | l1->MapWindow();
|
---|
511 | fList->Add(l1);
|
---|
512 | l1 = new TGLabel(tf5, "ECEC");
|
---|
513 | l1->SetTextJustify(kTextLeft);
|
---|
514 | l1->Move(x+150, y+6*h*1.5);
|
---|
515 | l1->MapWindow();
|
---|
516 | fList->Add(l1);
|
---|
517 | l1 = new TGLabel(tf5, "ACES");
|
---|
518 | l1->SetTextJustify(kTextLeft);
|
---|
519 | l1->Move(x+150, y+4*h*1.5);
|
---|
520 | l1->MapWindow();
|
---|
521 | fList->Add(l1);
|
---|
522 | l1 = new TGLabel(tf5, "IA");
|
---|
523 | l1->SetTextJustify(kTextLeft);
|
---|
524 | l1->Move(x+150, y+4*h*1.5);
|
---|
525 | l1->MapWindow();
|
---|
526 | fList->Add(l1);
|
---|
527 |
|
---|
528 |
|
---|
529 | TGTextEntry *entry = new TGTextEntry(tf5, "****", kEF_BendIE);
|
---|
530 | entry->Associate(this);
|
---|
531 | entry->Move(x+50, y+2*h*1.5);
|
---|
532 | entry->MapWindow();
|
---|
533 | fList->Add(entry);
|
---|
534 |
|
---|
535 | entry = new TGTextEntry(tf5, "*****", kEF_BendIA);
|
---|
536 | entry->Associate(this);
|
---|
537 | entry->Move(x+50, y+3*h*1.5);
|
---|
538 | entry->MapWindow();
|
---|
539 | fList->Add(entry);
|
---|
540 | */
|
---|
541 | }
|
---|
542 |
|
---|
543 | MGCosy::MGCosy(MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)
|
---|
544 | : TGMainFrame(p, w, h), fQueue(q)
|
---|
545 | {
|
---|
546 | fList = new MGList;
|
---|
547 |
|
---|
548 | #ifdef DEBUG
|
---|
549 | cout << "MGCosy: Creating Menu" << endl;
|
---|
550 | #endif
|
---|
551 | CreateMenu();
|
---|
552 |
|
---|
553 | #ifdef DEBUG
|
---|
554 | cout << "MGCosy: Creating TGCompositeFrame" << endl;
|
---|
555 | #endif
|
---|
556 | TGHorizontalFrame *f1 = new TGHorizontalFrame(this, 0, 0);
|
---|
557 | TGHorizontalFrame *f2 = new TGHorizontalFrame(this, 0, 0);
|
---|
558 | fList->Add(f1);
|
---|
559 | fList->Add(f2);
|
---|
560 |
|
---|
561 | #ifdef DEBUG
|
---|
562 | cout << "MGCosy: Creating TGTab" << endl;
|
---|
563 | #endif
|
---|
564 | fTab = new TGTab(f1, 300, 300);
|
---|
565 | fList->Add(fTab);
|
---|
566 |
|
---|
567 | #ifdef DEBUG
|
---|
568 | cout << "MGCosy: Creating MGSkyPosition" << endl;
|
---|
569 | #endif
|
---|
570 | fSkyPosition = new MGSkyPosition(f1, 300);
|
---|
571 | #ifdef DEBUG
|
---|
572 | cout << "MGCosy: Creating MGAccuracy" << endl;
|
---|
573 | #endif
|
---|
574 | fAccuracy = new MGAccuracy (f1, 300);
|
---|
575 | #ifdef DEBUG
|
---|
576 | cout << "MGCosy: Creating MGVelocity" << endl;
|
---|
577 | #endif
|
---|
578 | fVelocity = new MGVelocity (f2, "Velocity [\"/min]", 300);
|
---|
579 | // fOffset = new MGVelocity (f, "Offset se-re [']", 300);
|
---|
580 |
|
---|
581 | fList->Add(fSkyPosition);
|
---|
582 | fList->Add(fAccuracy);
|
---|
583 | fList->Add(fVelocity);
|
---|
584 | // fList->Add(fOffset);
|
---|
585 |
|
---|
586 | #ifdef DEBUG
|
---|
587 | cout << "MGCosy: Creating TGGroupFrame" << endl;
|
---|
588 | #endif
|
---|
589 | TGGroupFrame *frame = new TGGroupFrame(f2, "Status");
|
---|
590 | frame->Resize(300, 300);
|
---|
591 | fList->Add(frame);
|
---|
592 |
|
---|
593 | #ifdef DEBUG
|
---|
594 | cout << "MGCosy: Creating TGListBox" << endl;
|
---|
595 | #endif
|
---|
596 | fLog = new TGListBox(f2, -1, kSunkenFrame); //kSunkenFrame|kDoubleBorder,
|
---|
597 | fLog->Resize(300, 300);
|
---|
598 | fLog->ChangeBackground(TGFrame::GetBlackPixel());
|
---|
599 | fList->Add(fLog);
|
---|
600 |
|
---|
601 | TGLayoutHints *hints1 = new TGLayoutHints(kLHintsNormal | kLHintsExpandX|kLHintsExpandY, 6, 6, 6, 3);
|
---|
602 | TGLayoutHints *hints2 = new TGLayoutHints(kLHintsNormal | kLHintsExpandX|kLHintsExpandY, 6, 6, 3, 6);
|
---|
603 | TGLayoutHints *hints1a = new TGLayoutHints(kLHintsLeft | kLHintsTop |kLHintsExpandX|kLHintsExpandY);
|
---|
604 | TGLayoutHints *hints2a = new TGLayoutHints(kLHintsCenterY | kLHintsTop |kLHintsExpandX|kLHintsExpandY, 6, 6);
|
---|
605 | TGLayoutHints *hints3a = new TGLayoutHints(kLHintsRight | kLHintsTop |kLHintsExpandX|kLHintsExpandY);
|
---|
606 | TGLayoutHints *hints1b = new TGLayoutHints(kLHintsLeft | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
|
---|
607 | TGLayoutHints *hints2b = new TGLayoutHints(kLHintsCenterY | kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 6, 6);
|
---|
608 | TGLayoutHints *hints3b = new TGLayoutHints(kLHintsRight | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
|
---|
609 |
|
---|
610 | fList->Add(hints1);
|
---|
611 | fList->Add(hints2);
|
---|
612 | fList->Add(hints1a);
|
---|
613 | fList->Add(hints2a);
|
---|
614 | fList->Add(hints3a);
|
---|
615 | fList->Add(hints1b);
|
---|
616 | fList->Add(hints2b);
|
---|
617 | fList->Add(hints3b);
|
---|
618 |
|
---|
619 | // Layout upper frame
|
---|
620 | f1->AddFrame(fTab, hints1a);
|
---|
621 | f1->AddFrame(fSkyPosition, hints2a);
|
---|
622 | f1->AddFrame(fAccuracy, hints3a);
|
---|
623 |
|
---|
624 | // Layout upper frame
|
---|
625 | f2->AddFrame(frame, hints1b);
|
---|
626 | f2->AddFrame(fVelocity, hints2b);
|
---|
627 | f2->AddFrame(fLog, hints3b);
|
---|
628 |
|
---|
629 | // Layout window
|
---|
630 | AddFrame(f1, hints1);
|
---|
631 | AddFrame(f2, hints2);
|
---|
632 |
|
---|
633 | //
|
---|
634 | // FIXME!
|
---|
635 | //
|
---|
636 | #ifdef DEBUG
|
---|
637 | cout << "MGCosy: Creating Tabs" << endl;
|
---|
638 | #endif
|
---|
639 | CreateTabs(fTab);
|
---|
640 | #ifdef DEBUG
|
---|
641 | cout << "MGCosy: Creating Label" << endl;
|
---|
642 | #endif
|
---|
643 | CreateLabel(frame);
|
---|
644 |
|
---|
645 | //
|
---|
646 | // Map the window, set up the layout, etc.
|
---|
647 | //
|
---|
648 | #ifdef DEBUG
|
---|
649 | cout << "MGCosy: Setting Size" << endl;
|
---|
650 | #endif
|
---|
651 | const Int_t w = 940;
|
---|
652 | const Int_t h = 660;
|
---|
653 | SetWMSizeHints(w, h, 1280, 900, 10, 10); // set the smallest and biggest size of the Main frame
|
---|
654 |
|
---|
655 | SetWindowName("Cosy Main Window");
|
---|
656 | SetIconName("Cosy");
|
---|
657 |
|
---|
658 | #ifdef DEBUG
|
---|
659 | cout << "MGCosy: Map Window" << endl;
|
---|
660 | #endif
|
---|
661 | MapSubwindows();
|
---|
662 | Resize(w, h); //GetDefaultSize());
|
---|
663 | MapWindow();
|
---|
664 | }
|
---|
665 |
|
---|
666 | // ======================================================================
|
---|
667 |
|
---|
668 | MGCosy::~MGCosy()
|
---|
669 | {
|
---|
670 | cout << "MGCosy::~MGCosy called." << endl;
|
---|
671 |
|
---|
672 | delete fLayMenuBar;
|
---|
673 | delete fLayMenuItem;
|
---|
674 |
|
---|
675 | cout << "Deleting MGCosy::fList" << endl;
|
---|
676 |
|
---|
677 | delete fList;
|
---|
678 |
|
---|
679 | cout << "MGCosy::~MGCosy done." << endl;
|
---|
680 | }
|
---|
681 | // ======================================================================
|
---|
682 | void MGCosy::EnableLabel(TGLabel *label, Bool_t stat)
|
---|
683 | {
|
---|
684 | stat ? label->MapWindow() : label->UnmapWindow();
|
---|
685 |
|
---|
686 | /*
|
---|
687 | TGGC *fRedTextGC(TGButton::GetDefaultGC())
|
---|
688 | // Set foreground color in graphics context for drawing of
|
---|
689 | // TGlabel and TGButtons with text in red.
|
---|
690 | ULong_t red;
|
---|
691 | gClient->GetColorByName("red", red);
|
---|
692 | fRedTextGC.SetForeground(red);
|
---|
693 | */
|
---|
694 | }
|
---|
695 |
|
---|
696 | void MGCosy::UpdateRaDec(ZdAz &pos, double mjd, RaDec &radec)
|
---|
697 | {
|
---|
698 | static Int_t rai=~0;
|
---|
699 | static Int_t deci=~0;
|
---|
700 | static Int_t ras=~0;
|
---|
701 | static Int_t decs=~0;
|
---|
702 |
|
---|
703 | static SlaStars sla;
|
---|
704 | sla.SetMjd(mjd);
|
---|
705 |
|
---|
706 | RaDec rd = sla.CalcRaDec(pos*2*TMath::Pi()/360);
|
---|
707 |
|
---|
708 | char text[64];
|
---|
709 |
|
---|
710 | rd.Ra(rd.Ra() * 24/2/TMath::Pi());
|
---|
711 | rd.Dec(rd.Dec()*360/2/TMath::Pi());
|
---|
712 |
|
---|
713 | radec.Ra(radec.Ra() * 24/2/TMath::Pi());
|
---|
714 | radec.Dec(radec.Dec()*360/2/TMath::Pi());
|
---|
715 |
|
---|
716 | RaDec test = rd*600;
|
---|
717 |
|
---|
718 | if (rai!=(int)test.Ra())
|
---|
719 | {
|
---|
720 | rai = (int)test.Ra();
|
---|
721 | sprintf(text, "%c%dh %.1fm", rd.Ra()<0?'-':'+', abs((int)rd.Ra()), 0.1*(abs((int)test.Ra())%600));
|
---|
722 | fRaEst->SetText(new TGString(text));
|
---|
723 | }
|
---|
724 | if (deci!=(int)test.Dec())
|
---|
725 | {
|
---|
726 | deci = (int)test.Dec();
|
---|
727 | sprintf(text, "%c%dd %.1fm", rd.Dec()<0?'-':'+' , abs((int)rd.Dec()), 0.1*(abs((int)test.Dec())%600));
|
---|
728 | fDecEst->SetText(new TGString(text));
|
---|
729 | }
|
---|
730 |
|
---|
731 | if (radec.Dec()>90|| radec.Dec()<-90)
|
---|
732 | {
|
---|
733 | radec.Ra(radec.Ra()+12);
|
---|
734 | radec.Dec(180-radec.Dec());
|
---|
735 | }
|
---|
736 | radec.Ra(fmod((radec.Ra()+48), 24));
|
---|
737 |
|
---|
738 | test = radec*600;
|
---|
739 |
|
---|
740 | if (ras!=(int)test.Ra())
|
---|
741 | {
|
---|
742 | ras = (int)test.Ra();
|
---|
743 | sprintf(text, "%c%dh %.1fm", radec.Ra()<0?'-':'+', abs((int)radec.Ra()), 0.1*(abs((int)test.Ra())%600));
|
---|
744 | fRaSoll->SetText(new TGString(text));
|
---|
745 | }
|
---|
746 | if (decs!=(int)test.Dec())
|
---|
747 | {
|
---|
748 | decs = (int)test.Dec();
|
---|
749 | sprintf(text, "%c%dd %.1fm", radec.Dec()<0?'-':'+' , abs((int)radec.Dec()), 0.1*(abs((int)test.Dec())%600));
|
---|
750 | fDecSoll->SetText(new TGString(text));
|
---|
751 | }
|
---|
752 | }
|
---|
753 |
|
---|
754 | void MGCosy::UpdateOffset(ZdAz &off)
|
---|
755 | {
|
---|
756 | static Int_t zd=~0;
|
---|
757 | static Int_t az=~0;
|
---|
758 |
|
---|
759 | char text[21];
|
---|
760 |
|
---|
761 | if (zd!=(Int_t)off.Zd())
|
---|
762 | {
|
---|
763 | zd = (Int_t)off.Zd();
|
---|
764 | sprintf(text, "%dre", zd);
|
---|
765 | fOffsetZd->SetText(new TGString(text));
|
---|
766 | }
|
---|
767 | if (az!=(Int_t)off.Az())
|
---|
768 | {
|
---|
769 | az = (Int_t)off.Az();
|
---|
770 | sprintf(text, "%dre", az);
|
---|
771 | fOffsetAz->SetText(new TGString(text));
|
---|
772 | }
|
---|
773 | }
|
---|
774 |
|
---|
775 | void MGCosy::UpdateZdAz(ZdAz &soll)
|
---|
776 | {
|
---|
777 | soll *= 360/2/TMath::Pi();
|
---|
778 |
|
---|
779 | static Int_t zd=~0;
|
---|
780 | static Int_t az=~0;
|
---|
781 |
|
---|
782 | char text[21];
|
---|
783 |
|
---|
784 | ZdAz test = soll*600;
|
---|
785 |
|
---|
786 | if (zd!=(int)test.Zd())
|
---|
787 | {
|
---|
788 | zd = (int)test.Zd();
|
---|
789 | sprintf(text, "%c%dh %.1fm", soll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));
|
---|
790 | fZdSoll->SetText(new TGString(text));
|
---|
791 | }
|
---|
792 | if (az!=(int)test.Az())
|
---|
793 | {
|
---|
794 | az = (int)test.Az();
|
---|
795 | sprintf(text, "%c%dd %.1fm", soll.Az()<0?'-':'+' , abs((int)soll.Az()), 0.1*(abs((int)test.Az())%600));
|
---|
796 | fAzSoll->SetText(new TGString(text));
|
---|
797 | }
|
---|
798 | }
|
---|
799 |
|
---|
800 | double MGCosy::UpdateTime()
|
---|
801 | {
|
---|
802 | Timer time;
|
---|
803 | time.Now();
|
---|
804 |
|
---|
805 | char text[256];
|
---|
806 |
|
---|
807 | strcpy(text, time.GetTimeStr());
|
---|
808 |
|
---|
809 | char *dot = strrchr(text, '.');
|
---|
810 |
|
---|
811 | if (dot)
|
---|
812 | dot[2] = 0;
|
---|
813 |
|
---|
814 | fUtc->SetText(new TGString(text));
|
---|
815 |
|
---|
816 | double mjd = time.CalcMjd();
|
---|
817 |
|
---|
818 | sprintf(text, "%12.6f", mjd);
|
---|
819 | fMjd->SetText(new TGString(text));
|
---|
820 |
|
---|
821 | return mjd;
|
---|
822 | }
|
---|
823 |
|
---|
824 | void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, RaDec radec,
|
---|
825 | ZdAz soll, UInt_t stat)
|
---|
826 | {
|
---|
827 | double mjd = UpdateTime();
|
---|
828 | fSkyPosition->Update(pos, mjd);
|
---|
829 | fAccuracy->Update(pos, acc);
|
---|
830 | fVelocity->Update(vel);
|
---|
831 | UpdateOffset(off);
|
---|
832 | UpdateRaDec(pos, mjd, radec);
|
---|
833 | UpdateZdAz(soll);
|
---|
834 |
|
---|
835 | #define kError 0x01
|
---|
836 | #define kMoving 0x02
|
---|
837 | #define kTracking 0x04
|
---|
838 | #define kStopping 0x08
|
---|
839 | #define kStopped 0x10
|
---|
840 |
|
---|
841 | EnableLabel(fError, stat&kError);
|
---|
842 | EnableLabel(fMoving, stat&kMoving);
|
---|
843 | EnableLabel(fTracking, stat&kTracking);
|
---|
844 | EnableLabel(fStopping, stat&kStopping);
|
---|
845 | EnableLabel(fStopped, stat&kStopped);
|
---|
846 | EnableLabel(fRaSoll, stat&kTracking);
|
---|
847 | EnableLabel(fDecSoll, stat&kTracking);
|
---|
848 | EnableLabel(fZdSoll, stat&kMoving);
|
---|
849 | EnableLabel(fAzSoll, stat&kMoving);
|
---|
850 |
|
---|
851 | stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow();
|
---|
852 | stat&kTracking ? fVelocity->MapWindow() : fVelocity->UnmapWindow();
|
---|
853 | // stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow();
|
---|
854 |
|
---|
855 | if (fLog->TestBit(kHasChanged))
|
---|
856 | {
|
---|
857 | fLog->MapSubwindows();
|
---|
858 | fLog->Layout();
|
---|
859 | fLog->ResetBit(kHasChanged);
|
---|
860 | }
|
---|
861 | }
|
---|
862 | // ======================================================================
|
---|
863 |
|
---|
864 | void MGCosy::CloseWindow()
|
---|
865 | {
|
---|
866 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
867 | // (which destroys the window) and terminate the application.
|
---|
868 | // The close message is generated by the window manager when its close
|
---|
869 | // window menu item is selected.
|
---|
870 |
|
---|
871 | // gSystem->ExitLoop();
|
---|
872 | // gSystem->DispatchOneEvent(kTRUE);
|
---|
873 |
|
---|
874 | // TGMainFrame::CloseWindow();
|
---|
875 | cout << "Closing window - waiting until all nodes are stopped." << endl;
|
---|
876 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
---|
877 | cout << "Closing window - done." << endl;
|
---|
878 | // gApplication->Terminate(0);
|
---|
879 | }
|
---|
880 |
|
---|
881 | void MGCosy::StartTrack()
|
---|
882 | {
|
---|
883 | cout << "Start tracking." << endl;
|
---|
884 |
|
---|
885 | XY xy = fCRaDec->GetCoordinates();
|
---|
886 | RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]
|
---|
887 |
|
---|
888 | cout << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
|
---|
889 |
|
---|
890 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
---|
891 |
|
---|
892 | cout << "PostMsg (WM_Track) returned." << endl;
|
---|
893 | }
|
---|
894 |
|
---|
895 | void MGCosy::StartPos()
|
---|
896 | {
|
---|
897 | cout << "Start positioning." << endl;
|
---|
898 |
|
---|
899 | XY xy = fCZdAz->GetCoordinates();
|
---|
900 | ZdAz dest(xy.X(), xy.Y());
|
---|
901 |
|
---|
902 | cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
|
---|
903 |
|
---|
904 | fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
|
---|
905 |
|
---|
906 | cout << "PostMsg (WM_Position) returned." << endl;
|
---|
907 | }
|
---|
908 |
|
---|
909 | //
|
---|
910 | // ************************** For demo purpose **********************
|
---|
911 | //
|
---|
912 | #include <TRandom.h>
|
---|
913 | class MDemo : public MThread
|
---|
914 | {
|
---|
915 | private:
|
---|
916 | MsgQueue *fQueue;
|
---|
917 | TRandom fRand;
|
---|
918 |
|
---|
919 | public:
|
---|
920 | MDemo() : MThread(false) {}
|
---|
921 |
|
---|
922 | void SetQueue(MsgQueue *q) { fQueue = q; }
|
---|
923 |
|
---|
924 | virtual void *Thread()
|
---|
925 | {
|
---|
926 | while (1)
|
---|
927 | {
|
---|
928 | Timer tm;
|
---|
929 | tm.Now();
|
---|
930 |
|
---|
931 | Float_t h = 2.+tm.H()+(10.7+tm.M())/60.;
|
---|
932 | RaDec dest(h*15, 129.7);
|
---|
933 |
|
---|
934 | cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl;
|
---|
935 |
|
---|
936 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
---|
937 |
|
---|
938 | int i = 0;
|
---|
939 | while (!HasStopFlag() && i++<60) // 2.5min
|
---|
940 | usleep(1000000);
|
---|
941 | if (HasStopFlag())
|
---|
942 | break;
|
---|
943 |
|
---|
944 | //fQueue->PostMsg(WM_STOP, 0, 0);
|
---|
945 |
|
---|
946 | ZdAz dest1(fRand.Integer(36)+25, fRand.Integer(360));
|
---|
947 |
|
---|
948 | cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl;
|
---|
949 |
|
---|
950 | fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1));
|
---|
951 |
|
---|
952 | i = 0;
|
---|
953 | while (!HasStopFlag() && i++<15) // 30s
|
---|
954 | usleep(1000000);
|
---|
955 | if (HasStopFlag())
|
---|
956 | break;
|
---|
957 |
|
---|
958 | //ZdAz dest2(5, 30);
|
---|
959 | //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2));
|
---|
960 | /*
|
---|
961 | i = 0;
|
---|
962 | while (!HasStopFlag() && i++<30) // 30s
|
---|
963 | usleep(1000000);
|
---|
964 | */
|
---|
965 | //if (HasStopFlag())
|
---|
966 | // break;
|
---|
967 | }
|
---|
968 | cout << "Demo Thread: done." << endl;
|
---|
969 | return NULL;
|
---|
970 | }
|
---|
971 | };
|
---|
972 |
|
---|
973 | MDemo demo;
|
---|
974 |
|
---|
975 | void MGCosy::StartDemo()
|
---|
976 | {
|
---|
977 | cout << "Start Demo." << endl;
|
---|
978 |
|
---|
979 | demo.SetQueue(fQueue);
|
---|
980 | demo.Start();
|
---|
981 |
|
---|
982 | cout << "PostMsg (WM_Demo) returned." << endl;
|
---|
983 | }
|
---|
984 |
|
---|
985 | void StopDemo()
|
---|
986 | {
|
---|
987 | cout << "Stopping demo." << endl;
|
---|
988 | demo.Stop();
|
---|
989 | }
|
---|
990 |
|
---|
991 | void MGCosy::StartCalib()
|
---|
992 | {
|
---|
993 | cout << "Start Calibration." << endl;
|
---|
994 |
|
---|
995 | XY xy = fCCalib->GetCoordinates();
|
---|
996 | RaDec pos(xy.X()*360/24, xy.Y());
|
---|
997 |
|
---|
998 | fQueue->PostMsg(WM_CALIB, &pos, sizeof(pos));
|
---|
999 |
|
---|
1000 | cout << "PostMsg (WM_Calib) returned." << endl;
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | void MGCosy::StartTPoint()
|
---|
1004 | {
|
---|
1005 | cout << "Start writing tpoint pair." << endl;
|
---|
1006 |
|
---|
1007 | XY xy = fCCalib->GetCoordinates();
|
---|
1008 | RaDec pos(xy.X()*360/24, xy.Y());
|
---|
1009 |
|
---|
1010 | //fQueue->PostMsg(WM_TPOINT, &pos, sizeof(pos));
|
---|
1011 | fQueue->Proc(WM_TPOINT, &pos);
|
---|
1012 |
|
---|
1013 | cout << "PostMsg (WM_TPoint) returned." << endl;
|
---|
1014 | }
|
---|
1015 | //
|
---|
1016 | // ******************************************************************
|
---|
1017 | //
|
---|
1018 |
|
---|
1019 | Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
1020 | {
|
---|
1021 | //
|
---|
1022 | // This processing is serialized!
|
---|
1023 | //
|
---|
1024 | switch (GET_MSG(msg))
|
---|
1025 | {
|
---|
1026 | case kC_COMMAND:
|
---|
1027 | switch (GET_SUBMSG(msg))
|
---|
1028 | {
|
---|
1029 | case kCM_TAB:
|
---|
1030 | //cout << "Tab: " << mp1 << endl;
|
---|
1031 | return kTRUE;
|
---|
1032 |
|
---|
1033 | case kCM_BUTTON:
|
---|
1034 |
|
---|
1035 | switch (mp1)
|
---|
1036 | {
|
---|
1037 | /*
|
---|
1038 | case kPB_POSITION:
|
---|
1039 | Start(0);
|
---|
1040 | return kTRUE;
|
---|
1041 |
|
---|
1042 | case kPB_TRACK:
|
---|
1043 | Start(1);
|
---|
1044 | return kTRUE;
|
---|
1045 | */
|
---|
1046 | case kPB_START:
|
---|
1047 | switch (fTab->GetCurrent())
|
---|
1048 | {
|
---|
1049 | case 0:
|
---|
1050 | StartPos();
|
---|
1051 | return kTRUE;
|
---|
1052 | case 1:
|
---|
1053 | StartTrack();
|
---|
1054 | return kTRUE;
|
---|
1055 | case 2:
|
---|
1056 | fCRaDec->SetCoordinates(fCCalib->GetCoordinates());
|
---|
1057 | return kTRUE;
|
---|
1058 | case 3:
|
---|
1059 | StartDemo();
|
---|
1060 | return kTRUE;
|
---|
1061 | }
|
---|
1062 | return kTRUE;
|
---|
1063 |
|
---|
1064 | case kPB_STOP:
|
---|
1065 | cout << "Sending stop movement msg." << endl;
|
---|
1066 | StopDemo();
|
---|
1067 | fQueue->PostMsg(WM_STOP, 0, 0);
|
---|
1068 | cout << "PostMsg (WM_Stop) returned." << endl;
|
---|
1069 | return kTRUE;
|
---|
1070 |
|
---|
1071 | case kPB_CALCALTAZ:
|
---|
1072 | {
|
---|
1073 | XY xy = fCRaDec->GetCoordinates();
|
---|
1074 | fQueue->Proc(WM_CALCALTAZ, &xy);
|
---|
1075 | }
|
---|
1076 | return kTRUE;
|
---|
1077 |
|
---|
1078 | case kPB_RAp:
|
---|
1079 | case kPB_RAm:
|
---|
1080 | case kPB_DECp:
|
---|
1081 | case kPB_DECm:
|
---|
1082 | {
|
---|
1083 | XY xy = fCRaDec->GetCoordinates();
|
---|
1084 | switch (mp1)
|
---|
1085 | {
|
---|
1086 | case kPB_RAp:
|
---|
1087 | xy.X(xy.X()+1./60);
|
---|
1088 | break;
|
---|
1089 | case kPB_RAm:
|
---|
1090 | xy.X(xy.X()-1./60);
|
---|
1091 | break;
|
---|
1092 | case kPB_DECp:
|
---|
1093 | xy.Y(xy.Y()+1./60);
|
---|
1094 | break;
|
---|
1095 | case kPB_DECm:
|
---|
1096 | xy.Y(xy.Y()-1./60);
|
---|
1097 | break;
|
---|
1098 | }
|
---|
1099 | RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]
|
---|
1100 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
---|
1101 | //fQueue->Proc(WM_NEWTRACK, &dest);
|
---|
1102 | fCRaDec->SetCoordinates(xy);
|
---|
1103 |
|
---|
1104 | cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
|
---|
1105 | }
|
---|
1106 | return kTRUE;
|
---|
1107 |
|
---|
1108 | case kPB_TPOINT:
|
---|
1109 | StartTPoint();
|
---|
1110 | return kTRUE;
|
---|
1111 | case kPB_CALIBSE:
|
---|
1112 | StartCalib();
|
---|
1113 | return kTRUE;
|
---|
1114 | case kPB_LoadBending:
|
---|
1115 | fQueue->Proc(WM_LOADBENDING, NULL);
|
---|
1116 | return kTRUE;
|
---|
1117 | case kPB_ResetBending:
|
---|
1118 | fQueue->Proc(WM_RESETBENDING, NULL);
|
---|
1119 | return kTRUE;
|
---|
1120 | case kPB_HOME:
|
---|
1121 | fQueue->PostMsg(WM_HOME, 0, 0);
|
---|
1122 | return kTRUE;
|
---|
1123 |
|
---|
1124 | default:
|
---|
1125 | return kTRUE;
|
---|
1126 | }
|
---|
1127 | return kTRUE;
|
---|
1128 |
|
---|
1129 | case kCM_MENU:
|
---|
1130 |
|
---|
1131 | switch (mp1)
|
---|
1132 | {
|
---|
1133 | case IDM_EXIT:
|
---|
1134 | cout << "IDM_EXIT: Posting WM_QUIT." << endl;
|
---|
1135 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
---|
1136 | cout << "IDM_EXIT: WM_QUIT done." << endl;
|
---|
1137 | //cout << "Idm_Exit." << endl;
|
---|
1138 | //CloseWindow();
|
---|
1139 | return kTRUE;
|
---|
1140 | case IDM_ASPECT:
|
---|
1141 | Int_t w = GetWidth();
|
---|
1142 | Int_t h = GetHeight();
|
---|
1143 | if (w>940*h/660)
|
---|
1144 | w = 940*h/660;
|
---|
1145 | else
|
---|
1146 | h = 660*w/940;
|
---|
1147 | Resize(w, h);
|
---|
1148 | return kTRUE;
|
---|
1149 | }
|
---|
1150 | return kTRUE;
|
---|
1151 | }
|
---|
1152 | }
|
---|
1153 |
|
---|
1154 | //
|
---|
1155 | // Start a thread to process the message.
|
---|
1156 | //
|
---|
1157 | // fQueue->PostMsg(msg, mp1, mp2);
|
---|
1158 | return kTRUE;
|
---|
1159 |
|
---|
1160 | }
|
---|