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