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