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 | MString str;
|
---|
1034 | str.Print("%12.6f", mjd);
|
---|
1035 | fMjd->SetText(new TGString(str));
|
---|
1036 | oldmjd = (ULong_t)(1000000*mjd);
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | return mjd;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, /*ZdAz off,*/ RaDec radec,
|
---|
1043 | ZdAz soll, UInt_t stat, UInt_t stat2, Bool_t armed)
|
---|
1044 | {
|
---|
1045 | // acc [rad]
|
---|
1046 | acc *= kRad2Deg; // [deg]
|
---|
1047 |
|
---|
1048 | const double mjd = UpdateTime();
|
---|
1049 | fSkyPosition->Update(pos, mjd);
|
---|
1050 | //UpdateOffset(off);
|
---|
1051 | UpdateRaDec(pos, mjd, radec);
|
---|
1052 | UpdateZdAz(soll);
|
---|
1053 |
|
---|
1054 | EnableLabel(fError, stat&MDriveCom::kError);
|
---|
1055 | EnableLabel(fMoving, stat&MDriveCom::kMoving);
|
---|
1056 | EnableLabel(fTracking, stat&MDriveCom::kTracking);
|
---|
1057 | EnableLabel(fStopping, stat&MDriveCom::kStopping);
|
---|
1058 | EnableLabel(fStopped, stat&MDriveCom::kStopped);
|
---|
1059 | EnableLabel(fRaSoll, stat&MDriveCom::kTracking);
|
---|
1060 | EnableLabel(fDecSoll, stat&MDriveCom::kTracking);
|
---|
1061 | EnableLabel(fZdSoll, stat&MDriveCom::kMoving);
|
---|
1062 | EnableLabel(fAzSoll, stat&MDriveCom::kMoving);
|
---|
1063 |
|
---|
1064 | SetLabelColor(fAvailMac1, stat2&0x01);
|
---|
1065 | SetLabelColor(fAvailMac2, stat2&0x02);
|
---|
1066 | //SetLabelColor(fAvailMac3, stat2&0x04);
|
---|
1067 | SetLabelColor(fAvailSe1, stat2&0x08);
|
---|
1068 | SetLabelColor(fAvailSe2, stat2&0x10);
|
---|
1069 | SetLabelColor(fAvailSe3, stat2&0x20);
|
---|
1070 |
|
---|
1071 | EnableLabel(fArmed, armed);//stat2&0x40);
|
---|
1072 |
|
---|
1073 | if (stat&MDriveCom::kTracking)
|
---|
1074 | {
|
---|
1075 | fAccuracy->Update(pos, acc);
|
---|
1076 | // fAccuracyTime->Update(pos, acc);
|
---|
1077 | // fVelocity->Update(vel);
|
---|
1078 | fAccuracy->MapWindow();
|
---|
1079 | // fAccuracyTime->MapWindow();
|
---|
1080 | // fVelocity->MapWindow();
|
---|
1081 | }
|
---|
1082 | else
|
---|
1083 | {
|
---|
1084 | fAccuracy->UnmapWindow();
|
---|
1085 | // fAccuracyTime->UnmapWindow();
|
---|
1086 | // fVelocity->UnmapWindow();
|
---|
1087 | }
|
---|
1088 | // stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow();
|
---|
1089 |
|
---|
1090 | //unsigned char empty[(768/2-1)*(576/2-1)];
|
---|
1091 | //fImage->DrawImg(empty);
|
---|
1092 | //fImage->DoRedraw();
|
---|
1093 |
|
---|
1094 | // if (IsMapped())
|
---|
1095 | // fImage->DoRedraw();
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | void MGCosy::UpdateWeather(const MCeCoCom &com)
|
---|
1099 | {
|
---|
1100 | ULong_t color;
|
---|
1101 | switch (com.GetWeatherStatus())
|
---|
1102 | {
|
---|
1103 | case 0:
|
---|
1104 | color=TGFrame::GetDefaultFrameBackground();
|
---|
1105 | break;
|
---|
1106 | case 1:
|
---|
1107 | gClient->GetColorByName("Yellow", color);
|
---|
1108 | break;
|
---|
1109 | case 2:
|
---|
1110 | gClient->GetColorByName("Orange", color);
|
---|
1111 | break;
|
---|
1112 | default:
|
---|
1113 | gClient->GetColorByName("Red", color);
|
---|
1114 | break;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | if (com.HasAlarm())
|
---|
1118 | {
|
---|
1119 | static int i=0;
|
---|
1120 | if ((i++/4)%2==0)
|
---|
1121 | color = TGFrame::GetDefaultFrameBackground();
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | const TString old(fWeather->GetText()->GetString());
|
---|
1125 | const TString txt(com.GetWeather());
|
---|
1126 |
|
---|
1127 | // Color is only updated if the text has changed
|
---|
1128 | if (old!=txt || color!=fWeather->GetBackground())
|
---|
1129 | fWeather->SetText(txt);
|
---|
1130 |
|
---|
1131 | if (color!=fWeather->GetBackground())
|
---|
1132 | fWeather->SetBackgroundColor(color);
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | void MGCosy::CloseWindow()
|
---|
1136 | {
|
---|
1137 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
1138 | // (which destroys the window) and terminate the application.
|
---|
1139 | // The close message is generated by the window manager when its close
|
---|
1140 | // window menu item is selected.
|
---|
1141 |
|
---|
1142 | // gSystem->ExitLoop();
|
---|
1143 | // gSystem->DispatchOneEvent(kTRUE);
|
---|
1144 |
|
---|
1145 | // TGMainFrame::CloseWindow();
|
---|
1146 | cout << "Closing window - waiting until all nodes are stopped." << endl;
|
---|
1147 | fQueue->PostMsg(WM_QUIT);
|
---|
1148 | cout << "Closing window - done." << endl;
|
---|
1149 | // gApplication->Terminate(0);
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | void MGCosy::StartTrack(bool track)
|
---|
1153 | {
|
---|
1154 | cout << "Start tracking." << endl;
|
---|
1155 |
|
---|
1156 | XY xy0 = fCRaDec->GetCoordinates();
|
---|
1157 | XY xy1 = track ? xy0 : fCCalib->GetCoordinates();
|
---|
1158 |
|
---|
1159 | RaDec dest0(xy0.X()*15., xy0.Y()); // xy.X() [h]->[ø]
|
---|
1160 | RaDec dest1(xy1.X()*15., xy1.Y()); // xy.X() [h]->[ø]
|
---|
1161 |
|
---|
1162 | cout << "TrackPos: " << dest0.Ra() << "\xb0 " << dest0.Dec() << "\xb0" << endl;
|
---|
1163 | cout << "CalibPos: " << dest1.Ra() << "\xb0 " << dest1.Dec() << "\xb0" << endl;
|
---|
1164 |
|
---|
1165 | RaDec dest[2] = { dest0, dest1 };
|
---|
1166 |
|
---|
1167 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
---|
1168 |
|
---|
1169 | cout << "PostMsg (WM_Track) returned." << endl;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | void MGCosy::StartTrackPos(Long_t mp1)
|
---|
1173 | {
|
---|
1174 | cout << "Start tracking Zd/Az pos." << endl;
|
---|
1175 |
|
---|
1176 | const XY &xy = fCZdAz->GetCoordinates();
|
---|
1177 |
|
---|
1178 | ZdAz za(xy.X(), xy.Y());
|
---|
1179 |
|
---|
1180 | switch (mp1)
|
---|
1181 | {
|
---|
1182 | case kPB_ZDm:
|
---|
1183 | za.Zd(za.Zd()-360/16384.);
|
---|
1184 | break;
|
---|
1185 | case kPB_ZDp:
|
---|
1186 | za.Zd(za.Zd()+360/16384.);
|
---|
1187 | break;
|
---|
1188 | case kPB_AZm:
|
---|
1189 | za.Az(za.Az()-360/16384.);
|
---|
1190 | break;
|
---|
1191 | case kPB_AZp:
|
---|
1192 | za.Az(za.Az()+360/16384.);
|
---|
1193 | break;
|
---|
1194 | }
|
---|
1195 |
|
---|
1196 | cout << za.Zd() << "\xb0 " << za.Az() << "\xb0" << endl;
|
---|
1197 |
|
---|
1198 | fQueue->PostMsg(WM_TRACKPOS, &za, sizeof(za));
|
---|
1199 |
|
---|
1200 | cout << "PostMsg (WM_TrackPos) returned." << endl;
|
---|
1201 | }
|
---|
1202 |
|
---|
1203 | void MGCosy::StartPos()
|
---|
1204 | {
|
---|
1205 | cout << "Start positioning." << endl;
|
---|
1206 |
|
---|
1207 | XY xy = fCZdAz->GetCoordinates();
|
---|
1208 | ZdAz dest(xy.X(), xy.Y());
|
---|
1209 |
|
---|
1210 | cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
|
---|
1211 |
|
---|
1212 | fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
|
---|
1213 |
|
---|
1214 | cout << "PostMsg (WM_Position) returned." << endl;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | //
|
---|
1218 | // ************************** For demo purpose **********************
|
---|
1219 | //
|
---|
1220 | #ifdef HAS_DEMO
|
---|
1221 |
|
---|
1222 | #include <TRandom.h>
|
---|
1223 | class MDemo : public MThread
|
---|
1224 | {
|
---|
1225 | private:
|
---|
1226 | MsgQueue *fQueue;
|
---|
1227 | TRandom fRand;
|
---|
1228 |
|
---|
1229 | public:
|
---|
1230 | MDemo() : MThread(false) {}
|
---|
1231 |
|
---|
1232 | void SetQueue(MsgQueue *q) { fQueue = q; }
|
---|
1233 |
|
---|
1234 | bool Wait(int s, int m)
|
---|
1235 | {
|
---|
1236 | int i = 0;
|
---|
1237 | while (!HasStopFlag() && i++<m)
|
---|
1238 | usleep(s);
|
---|
1239 | if (HasStopFlag())
|
---|
1240 | return false;
|
---|
1241 | return true;
|
---|
1242 | }
|
---|
1243 |
|
---|
1244 | bool Move(float zd, float az, int s, int m)
|
---|
1245 | {
|
---|
1246 | ZdAz dest1(zd, az);
|
---|
1247 | fQueue->PostMsg(WM_POSITION1, &dest1, sizeof(dest1));
|
---|
1248 | return Wait(s, m); // 30s?
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | virtual void *Thread()
|
---|
1252 | {
|
---|
1253 | if (!Move(90, -65, 1000000, 27))
|
---|
1254 | return NULL;
|
---|
1255 |
|
---|
1256 | Int_t i=1;
|
---|
1257 | while (i-->0)
|
---|
1258 | {
|
---|
1259 | //Timer tm;
|
---|
1260 | //tm.Now();
|
---|
1261 |
|
---|
1262 | if (!Move(75, -80, 1000000, 13))
|
---|
1263 | break;
|
---|
1264 | if (!Move(60, -65, 1000000, 13))
|
---|
1265 | break;
|
---|
1266 | if (!Move(75, -50, 1000000, 13))
|
---|
1267 | break;
|
---|
1268 | if (!Move(90, -65, 1000000, 13))
|
---|
1269 | break;
|
---|
1270 | }
|
---|
1271 | if (!Move(60, -65, 1000000, 17))
|
---|
1272 | return NULL;
|
---|
1273 | if (!Move(90, -65, 1000000, 19))
|
---|
1274 | return NULL;
|
---|
1275 | if (!Move(90, -10, 1000000, 28))
|
---|
1276 | return NULL;
|
---|
1277 |
|
---|
1278 | cout << "Demo Thread: done." << endl;
|
---|
1279 | return NULL;
|
---|
1280 | }
|
---|
1281 | };
|
---|
1282 |
|
---|
1283 | MDemo demo;
|
---|
1284 |
|
---|
1285 | void MGCosy::StartDemo()
|
---|
1286 | {
|
---|
1287 | cout << "Start Demo." << endl;
|
---|
1288 |
|
---|
1289 | demo.SetQueue(fQueue);
|
---|
1290 | demo.Start();
|
---|
1291 |
|
---|
1292 | cout << "PostMsg (WM_Demo) returned." << endl;
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | void StopDemo()
|
---|
1296 | {
|
---|
1297 | cout << "Stopping demo." << endl;
|
---|
1298 | demo.Stop();
|
---|
1299 | }
|
---|
1300 | #endif //HAS_DEMO
|
---|
1301 |
|
---|
1302 | /*
|
---|
1303 | void MGCosy::StartCalib()
|
---|
1304 | {
|
---|
1305 | cout << "Start Calibration." << endl;
|
---|
1306 |
|
---|
1307 | XY xy = fCCalib->GetCoordinates();
|
---|
1308 | RaDec pos(xy.X()*360/24, xy.Y());
|
---|
1309 |
|
---|
1310 | fQueue->PostMsg(WM_CALIB, &pos, sizeof(pos));
|
---|
1311 |
|
---|
1312 | cout << "PostMsg (WM_Calib) returned." << endl;
|
---|
1313 | }
|
---|
1314 | */
|
---|
1315 | void MGCosy::StartTPoint()
|
---|
1316 | {
|
---|
1317 | cout << "Start writing tpoint pair." << endl;
|
---|
1318 |
|
---|
1319 | XY xy = fCCalib->GetCoordinates();
|
---|
1320 | RaDec pos(xy.X()*360/24, xy.Y());
|
---|
1321 |
|
---|
1322 | //fQueue->PostMsg(WM_TPOINT, &pos, sizeof(pos));
|
---|
1323 | fQueue->Proc(WM_TPOINT, &pos);
|
---|
1324 |
|
---|
1325 | cout << "PostMsg (WM_TPoint) returned." << endl;
|
---|
1326 | }
|
---|
1327 | //
|
---|
1328 | // ******************************************************************
|
---|
1329 | //
|
---|
1330 |
|
---|
1331 | Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
1332 | {
|
---|
1333 | //
|
---|
1334 | // This processing is serialized!
|
---|
1335 | //
|
---|
1336 | switch (GET_MSG(msg))
|
---|
1337 | {
|
---|
1338 | case kC_COMMAND:
|
---|
1339 | switch (GET_SUBMSG(msg))
|
---|
1340 | {
|
---|
1341 | case kCM_COMBOBOX:
|
---|
1342 | switch (mp1)
|
---|
1343 | {
|
---|
1344 | case kCB_PredefPos:
|
---|
1345 | {
|
---|
1346 | MStar *pos = fPreDefList[mp2];
|
---|
1347 | if (pos)
|
---|
1348 | fCZdAz->SetCoordinates(ZdAz(pos->GetX(), pos->GetY()));
|
---|
1349 | return kTRUE;
|
---|
1350 | }
|
---|
1351 | case kCB_StarList:
|
---|
1352 | {
|
---|
1353 | MStar *pos = fStarList[mp2];
|
---|
1354 | if (pos)
|
---|
1355 | fCCalib->SetCoordinates(RaDec(pos->GetX(), pos->GetY()));
|
---|
1356 | return kTRUE;
|
---|
1357 | }
|
---|
1358 | }
|
---|
1359 | return kTRUE;
|
---|
1360 |
|
---|
1361 | case kCM_TAB:
|
---|
1362 | //cout << "Tab: " << mp1 << endl;
|
---|
1363 | return kTRUE;
|
---|
1364 |
|
---|
1365 | case kCM_BUTTON:
|
---|
1366 |
|
---|
1367 | switch (mp1)
|
---|
1368 | {
|
---|
1369 | /*
|
---|
1370 | case kPB_POSITION:
|
---|
1371 | Start(0);
|
---|
1372 | return kTRUE;
|
---|
1373 |
|
---|
1374 | case kPB_TRACK:
|
---|
1375 | Start(1);
|
---|
1376 | return kTRUE;
|
---|
1377 | */
|
---|
1378 | case kPB_START:
|
---|
1379 | switch (fTab->GetCurrent())
|
---|
1380 | {
|
---|
1381 | case 0:
|
---|
1382 | StartPos();
|
---|
1383 | return kTRUE;
|
---|
1384 | case 1:
|
---|
1385 | StartTrack(true);
|
---|
1386 | return kTRUE;
|
---|
1387 | case 2:
|
---|
1388 | fCRaDec->SetCoordinates(fCCalib->GetCoordinates());
|
---|
1389 | StartTrack(false);
|
---|
1390 | return kTRUE;
|
---|
1391 | case 3:
|
---|
1392 | fQueue->Proc(WM_TESTSE, (void*)1);
|
---|
1393 | return kTRUE;
|
---|
1394 | case 4:
|
---|
1395 | fQueue->Proc(WM_GEAR, (void*)1);
|
---|
1396 | return kTRUE;
|
---|
1397 | #ifdef HAS_DEMO
|
---|
1398 | case 5:
|
---|
1399 | StartDemo();
|
---|
1400 | return kTRUE;
|
---|
1401 | #endif
|
---|
1402 | }
|
---|
1403 | return kTRUE;
|
---|
1404 |
|
---|
1405 | case kPB_STOP:
|
---|
1406 | cout << "Sending stop movement msg." << endl;
|
---|
1407 | #ifdef HAS_DEMO
|
---|
1408 | StopDemo();
|
---|
1409 | #endif
|
---|
1410 | fQueue->PostMsg(WM_STOP);
|
---|
1411 | if (fTab->GetCurrent()==3)
|
---|
1412 | fQueue->Proc(WM_TESTSE);
|
---|
1413 | if (fTab->GetCurrent()==4)
|
---|
1414 | fQueue->Proc(WM_GEAR);
|
---|
1415 | cout << "PostMsg (WM_Stop) returned." << endl;
|
---|
1416 | return kTRUE;
|
---|
1417 |
|
---|
1418 | case kPB_CALCALTAZ:
|
---|
1419 | {
|
---|
1420 | XY xy = fCRaDec->GetCoordinates();
|
---|
1421 | fQueue->Proc(WM_CALCALTAZ, &xy);
|
---|
1422 | }
|
---|
1423 | return kTRUE;
|
---|
1424 |
|
---|
1425 | case kPB_SavePreDef:
|
---|
1426 | {
|
---|
1427 | ofstream fout("prepos.txt", ios::app);
|
---|
1428 | XY za = fCZdAz->GetCoordinates();
|
---|
1429 | fout << setprecision(7) << za.X() << " \t" << za.Y();
|
---|
1430 | fout << " New Position" << endl;
|
---|
1431 | }
|
---|
1432 | return kTRUE;
|
---|
1433 | case kPB_SaveStar:
|
---|
1434 | {
|
---|
1435 | ofstream fout("stars.txt", ios::app);
|
---|
1436 | XY za = fCCalib->GetCoordinates();
|
---|
1437 |
|
---|
1438 | UShort_t d, m, s;
|
---|
1439 | Char_t sgn;
|
---|
1440 | MAstro::Deg2Dms(za.X(), sgn, d, m, s);
|
---|
1441 | if (sgn=='-') fout << sgn;
|
---|
1442 | fout << d << " " << m << " " << s << " \t";
|
---|
1443 | MAstro::Deg2Dms(za.Y(), sgn, d, m, s);
|
---|
1444 | if (sgn=='-') fout << sgn;
|
---|
1445 | fout << d << " " << m << " " << s << " \t";
|
---|
1446 | fout << " New Star/Source" << endl;
|
---|
1447 | }
|
---|
1448 | return kTRUE;
|
---|
1449 |
|
---|
1450 | case kPB_RAp:
|
---|
1451 | case kPB_RAm:
|
---|
1452 | case kPB_DECp:
|
---|
1453 | case kPB_DECm:
|
---|
1454 | {
|
---|
1455 | XY xy = fCRaDec->GetCoordinates();
|
---|
1456 | switch (mp1)
|
---|
1457 | {
|
---|
1458 | case kPB_RAp:
|
---|
1459 | xy.Set(xy.X()+1./60, xy.Y());
|
---|
1460 | break;
|
---|
1461 | case kPB_RAm:
|
---|
1462 | xy.Set(xy.X()-1./60, xy.Y());
|
---|
1463 | break;
|
---|
1464 | case kPB_DECp:
|
---|
1465 | xy.Set(xy.X(), xy.Y()+1./60);
|
---|
1466 | break;
|
---|
1467 | case kPB_DECm:
|
---|
1468 | xy.Set(xy.X(), xy.Y()-1./60);
|
---|
1469 | break;
|
---|
1470 | }
|
---|
1471 | fCRaDec->SetCoordinates(xy);
|
---|
1472 | StartTrack(false);
|
---|
1473 | /*
|
---|
1474 | RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]
|
---|
1475 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
---|
1476 | //fQueue->Proc(WM_NEWTRACK, &dest);
|
---|
1477 | */
|
---|
1478 | //cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
|
---|
1479 | }
|
---|
1480 | return kTRUE;
|
---|
1481 |
|
---|
1482 | case kPB_ZDp:
|
---|
1483 | case kPB_ZDm:
|
---|
1484 | case kPB_AZp:
|
---|
1485 | case kPB_AZm:
|
---|
1486 | StartTrackPos(mp1);
|
---|
1487 | return kTRUE;
|
---|
1488 |
|
---|
1489 | case kPB_TPOINT:
|
---|
1490 | StartTPoint();
|
---|
1491 | return kTRUE;
|
---|
1492 |
|
---|
1493 | case kPB_ENDSWITCH:
|
---|
1494 | fQueue->Proc(WM_ENDSWITCH);
|
---|
1495 | return kTRUE;
|
---|
1496 | /*
|
---|
1497 | case kPB_CALIBSE:
|
---|
1498 | StartCalib();
|
---|
1499 | return kTRUE;
|
---|
1500 | */
|
---|
1501 | case kPB_LoadBending:
|
---|
1502 | fQueue->Proc(WM_LOADBENDING);
|
---|
1503 | return kTRUE;
|
---|
1504 | case kPB_ResetBending:
|
---|
1505 | fQueue->Proc(WM_RESETBENDING);
|
---|
1506 | return kTRUE;
|
---|
1507 | /*
|
---|
1508 | case kPB_HOME:
|
---|
1509 | fQueue->PostMsg(WM_HOME, 0, 0);
|
---|
1510 | return kTRUE;
|
---|
1511 | */
|
---|
1512 | case kPB_TRACKPOS:
|
---|
1513 | StartTrackPos();
|
---|
1514 | return kTRUE;
|
---|
1515 | case kPB_ARM:
|
---|
1516 | fQueue->PostMsg(WM_ARM);
|
---|
1517 | return kTRUE;
|
---|
1518 | case kPB_DISPLAY1:
|
---|
1519 | case kPB_DISPLAY2:
|
---|
1520 | fQueue->PostMsg(WM_DISPLAY);
|
---|
1521 | return kTRUE;
|
---|
1522 |
|
---|
1523 | default:
|
---|
1524 | return kTRUE;
|
---|
1525 | }
|
---|
1526 | return kTRUE;
|
---|
1527 |
|
---|
1528 | case kCM_MENU:
|
---|
1529 |
|
---|
1530 | switch (mp1)
|
---|
1531 | {
|
---|
1532 | case IDM_EXIT:
|
---|
1533 | cout << "IDM_EXIT: Posting WM_QUIT." << endl;
|
---|
1534 | fQueue->PostMsg(WM_QUIT);
|
---|
1535 | cout << "IDM_EXIT: WM_QUIT done." << endl;
|
---|
1536 | //cout << "Idm_Exit." << endl;
|
---|
1537 | //CloseWindow();
|
---|
1538 | return kTRUE;
|
---|
1539 | case IDM_ASPECT:
|
---|
1540 | {
|
---|
1541 | Int_t w = GetWidth();
|
---|
1542 | Int_t h = GetHeight();
|
---|
1543 | if (w>940*h/660)
|
---|
1544 | w = 940*h/660;
|
---|
1545 | else
|
---|
1546 | h = 660*w/940;
|
---|
1547 | Resize(w, h);
|
---|
1548 | }
|
---|
1549 | return kTRUE;
|
---|
1550 | case kLogClear:
|
---|
1551 | fLog->Clear();
|
---|
1552 | return kTRUE;
|
---|
1553 | case kLogCopy:
|
---|
1554 | fLog->Copy();
|
---|
1555 | return kTRUE;
|
---|
1556 | case kLogSelect:
|
---|
1557 | fLog->SelectAll();
|
---|
1558 | return kTRUE;
|
---|
1559 | case kLogSearch:
|
---|
1560 | //virtual Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive);
|
---|
1561 | return kTRUE;
|
---|
1562 | case kLogSave:
|
---|
1563 | cout << "Saving log... " << flush;
|
---|
1564 | if (fLog->GetText()->Save("cosylog.txt"))
|
---|
1565 | cout << "done." << endl;
|
---|
1566 | else
|
---|
1567 | cout << "failed!" << endl;
|
---|
1568 | return kTRUE;
|
---|
1569 |
|
---|
1570 | case kLogAppend:
|
---|
1571 | cout << "Appending log... " << flush;
|
---|
1572 | if (fLog->GetText()->Append("cosylog.txt"))
|
---|
1573 | cout << "done." << endl;
|
---|
1574 | else
|
---|
1575 | cout << "failed!" << endl;
|
---|
1576 | return kTRUE;
|
---|
1577 | }
|
---|
1578 | return kTRUE;
|
---|
1579 | }
|
---|
1580 | }
|
---|
1581 |
|
---|
1582 | //
|
---|
1583 | // Start a thread to process the message.
|
---|
1584 | //
|
---|
1585 | // fQueue->PostMsg(msg, mp1, mp2);
|
---|
1586 | return kTRUE;
|
---|
1587 |
|
---|
1588 | }
|
---|