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