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