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