1 | #define EXPERT
|
---|
2 |
|
---|
3 | #include "MStarguider.h"
|
---|
4 |
|
---|
5 | #include <fstream.h> // ifstream
|
---|
6 | #include <iostream.h> // cout
|
---|
7 | #include <iomanip.h> // cout
|
---|
8 |
|
---|
9 | #include <TH2F.h>
|
---|
10 | #include <TGraph.h>
|
---|
11 | #include <TTimer.h>
|
---|
12 | #include <TSystem.h>
|
---|
13 | #include <TFile.h> // temp writeout of histos
|
---|
14 | #include "MAstro.h"
|
---|
15 | #include "MString.h"
|
---|
16 |
|
---|
17 | #include <TGMenu.h>
|
---|
18 | #include <TGLabel.h>
|
---|
19 | #include <TGButton.h>
|
---|
20 | #include <TGSplitter.h> // TGHorizontal3DLine
|
---|
21 | #include <TGTextEntry.h>
|
---|
22 | #include <TGLayout.h>
|
---|
23 | #include "MString.h"
|
---|
24 |
|
---|
25 | #include "MCosy.h"
|
---|
26 | #include "MCaos.h"
|
---|
27 | // #include "MStargLeds.h"
|
---|
28 | #include "MStargHistograms.h"
|
---|
29 | #include "MDriveCom.h"
|
---|
30 |
|
---|
31 | #include "MGStarg.h"
|
---|
32 | #include "TGFrame.h"
|
---|
33 |
|
---|
34 | #include "MGImage.h"
|
---|
35 | #include "MGCoordinates.h"
|
---|
36 |
|
---|
37 | #include "coord.h"
|
---|
38 |
|
---|
39 | #include "Camera.h"
|
---|
40 | #include "PngReader.h"
|
---|
41 |
|
---|
42 | #include "Led.h"
|
---|
43 | #include "Writer.h"
|
---|
44 | #include "FilterLed.h"
|
---|
45 | #include "MStarList.h"
|
---|
46 | #include "CaosFilter.h"
|
---|
47 | #include "StarCatalog.h"
|
---|
48 | #include "MGeomCamMagic.h"
|
---|
49 | #include "MAstroCamera.h"
|
---|
50 |
|
---|
51 | #include "MGMenu.h"
|
---|
52 | #include "MGCosy.h"
|
---|
53 |
|
---|
54 | ClassImp(MStarguider);
|
---|
55 |
|
---|
56 | enum {
|
---|
57 | IDM_kFilter,
|
---|
58 | IDM_kFindStar,
|
---|
59 | IDM_kCaosFilter,
|
---|
60 | IDM_kCatalog,
|
---|
61 | IDM_kStarguider,
|
---|
62 | IDM_kStart,
|
---|
63 | IDM_kStop,
|
---|
64 | IDM_kFileType,
|
---|
65 | IDM_kPPM,
|
---|
66 | IDM_kPNG,
|
---|
67 | IDM_kOnce,
|
---|
68 | IDM_kStretch,
|
---|
69 | IDM_kInput,
|
---|
70 | IDM_kChannel1,
|
---|
71 | IDM_kChannel2,
|
---|
72 | IDM_kChannel3,
|
---|
73 | IDM_kContinous,
|
---|
74 | IDM_kRate25ps,
|
---|
75 | IDM_kRate5ps,
|
---|
76 | IDM_kRate1s,
|
---|
77 | IDM_kRate5s,
|
---|
78 | IDM_kRate30s,
|
---|
79 | IDM_kRate1m,
|
---|
80 | IDM_kRate5m,
|
---|
81 | IDM_kSetup,
|
---|
82 | IDM_kLimMag3,
|
---|
83 | IDM_kLimMag4,
|
---|
84 | IDM_kLimMag5,
|
---|
85 | IDM_kLimMag6,
|
---|
86 | IDM_kLimMag7,
|
---|
87 | IDM_kLimMag8,
|
---|
88 | IDM_kLimMag9,
|
---|
89 | IDM_kPixSize,
|
---|
90 | IDM_kAngle,
|
---|
91 | IDM_kInterpol250,
|
---|
92 | IDM_kInterpol125,
|
---|
93 | IDM_kInterpol50,
|
---|
94 | IDM_kInterpol25,
|
---|
95 | IDM_kInterpol10,
|
---|
96 | IDM_kInterpol5,
|
---|
97 | IDM_kInterpol2,
|
---|
98 | IDM_kInterpol1,
|
---|
99 | IDM_kCaosPrintRings,
|
---|
100 | IDM_kCaosPrintLeds,
|
---|
101 | IDM_kCaosAnalStart,
|
---|
102 | IDM_kCaosAnalStop,
|
---|
103 | IDM_kCaosWriteStart,
|
---|
104 | IDM_kCaosWriteStop,
|
---|
105 | IDM_kResetHistograms,
|
---|
106 | IDM_kStargHistograms,
|
---|
107 | IDM_kStargAnalysis,
|
---|
108 | IDM_kStargCaosFilter,
|
---|
109 | IDM_kStargLEDFilter,
|
---|
110 | IDM_kStargFindStar,
|
---|
111 | IDM_kTPointAna,
|
---|
112 | IDM_kRoqueLampAna
|
---|
113 |
|
---|
114 | };
|
---|
115 |
|
---|
116 | Bool_t MStarguider::HandleTimer(TTimer *t)
|
---|
117 | {
|
---|
118 | if (IsMapped())
|
---|
119 | {
|
---|
120 | fImage->DoRedraw();
|
---|
121 | fZoomImage->DoRedraw();
|
---|
122 | }
|
---|
123 |
|
---|
124 | if (fCosy && fCosy->GetWin()->IsMapped())
|
---|
125 | fCosy->GetWin()->GetImage()->DoRedraw();
|
---|
126 |
|
---|
127 | fGStarg->Update(fPos, fD);
|
---|
128 |
|
---|
129 | return kTRUE;
|
---|
130 | }
|
---|
131 |
|
---|
132 | #define kZOOM 96
|
---|
133 |
|
---|
134 | XY MStarguider::GetCoordinates() const
|
---|
135 | {
|
---|
136 | return fPZdAz->GetCoordinates();
|
---|
137 | }
|
---|
138 |
|
---|
139 | void MStarguider::InitGui(Int_t channel)
|
---|
140 | {
|
---|
141 | fList = new MGList;
|
---|
142 |
|
---|
143 | const TGWindow *p=gClient->GetRoot();
|
---|
144 |
|
---|
145 | fChannel = new MGPopupMenu(p);
|
---|
146 | fChannel->AddEntry("Starfield Camera", IDM_kChannel1);
|
---|
147 | fChannel->AddEntry("TPoint Camera", IDM_kChannel2);
|
---|
148 | fChannel->AddEntry("Read from File", IDM_kChannel3);
|
---|
149 | if (channel<0) {
|
---|
150 | fChannel->CheckEntry(IDM_kChannel3);
|
---|
151 | } else {
|
---|
152 | fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2);
|
---|
153 | }
|
---|
154 | fChannel->Associate(this);
|
---|
155 | fList->Add(fChannel);
|
---|
156 |
|
---|
157 | //
|
---|
158 | // Create Menu for MStarguider Display
|
---|
159 | //
|
---|
160 | fDisplay = new MGPopupMenu(p);
|
---|
161 | fDisplay->AddEntry("&Filter", IDM_kFilter);
|
---|
162 | fDisplay->AddEntry("Find &Star", IDM_kFindStar);
|
---|
163 | fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter);
|
---|
164 | fDisplay->AddEntry("SAO &Catalog", IDM_kCatalog);
|
---|
165 | fDisplay->AddEntry("Stretch", IDM_kStretch);
|
---|
166 | fDisplay->AddSeparator();
|
---|
167 | fDisplay->AddEntry("Starguider", IDM_kStarguider);
|
---|
168 | fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter);
|
---|
169 | fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar);
|
---|
170 | fDisplay->AddEntry("Starguider Analysis", IDM_kStargAnalysis);
|
---|
171 | fDisplay->AddSeparator();
|
---|
172 | if (channel>=0)
|
---|
173 | fDisplay->AddPopup("&Input", fChannel);
|
---|
174 | fDisplay->DisableEntry(IDM_kStargAnalysis);
|
---|
175 | fDisplay->DisableEntry(IDM_kStargFindStar);
|
---|
176 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
177 | fDisplay->Associate(this);
|
---|
178 | fList->Add(fDisplay);
|
---|
179 |
|
---|
180 |
|
---|
181 | fOperations = new MGPopupMenu(p);
|
---|
182 | fOperations->AddEntry("TPoint Analysis", IDM_kTPointAna);
|
---|
183 | fOperations->AddEntry("Roque Lamp Analysis", IDM_kRoqueLampAna);
|
---|
184 | fOperations->Associate(this);
|
---|
185 | fList->Add(fOperations);
|
---|
186 |
|
---|
187 |
|
---|
188 | fFileType = new MGPopupMenu(p);
|
---|
189 | fFileType->AddEntry("PP&M", IDM_kPPM);
|
---|
190 | fFileType->AddEntry("&PNG", IDM_kPNG);
|
---|
191 | fFileType->CheckEntry(IDM_kPNG);
|
---|
192 | fFileType->Associate(this);
|
---|
193 | fList->Add(fFileType);
|
---|
194 |
|
---|
195 | fWriteType = new MGPopupMenu(p);
|
---|
196 | fWriteType->AddEntry("&Once", IDM_kOnce);
|
---|
197 | fWriteType->AddEntry("&Continous", IDM_kContinous);
|
---|
198 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
199 | fWriteType->Associate(this);
|
---|
200 | fList->Add(fWriteType);
|
---|
201 |
|
---|
202 | fWriteRate = new MGPopupMenu(p);
|
---|
203 | fWriteRate->AddEntry("25/s", IDM_kRate25ps);
|
---|
204 | fWriteRate->AddEntry("5/s", IDM_kRate5ps);
|
---|
205 | fWriteRate->AddEntry("1s", IDM_kRate1s);
|
---|
206 | fWriteRate->AddEntry("5s", IDM_kRate5s);
|
---|
207 | fWriteRate->AddEntry("30s", IDM_kRate30s);
|
---|
208 | fWriteRate->AddEntry("1min", IDM_kRate1m);
|
---|
209 | fWriteRate->AddEntry("5min", IDM_kRate5m);
|
---|
210 | fWriteRate->CheckEntry(IDM_kRate1m);
|
---|
211 | fWriteRate->Associate(this);
|
---|
212 | fList->Add(fWriteRate);
|
---|
213 |
|
---|
214 | fWrtRate = 25*60;
|
---|
215 |
|
---|
216 | fWritePictures = new MGPopupMenu(p);
|
---|
217 | fWritePictures->AddEntry("&Start", IDM_kStart);
|
---|
218 | fWritePictures->AddEntry("Sto&p", IDM_kStop);
|
---|
219 | fWritePictures->AddSeparator();
|
---|
220 | fWritePictures->AddPopup("File &Type", fFileType);
|
---|
221 | fWritePictures->AddPopup("&Write Type", fWriteType);
|
---|
222 | fWritePictures->AddPopup("Write &Rate", fWriteRate);
|
---|
223 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
224 | fWritePictures->Associate(this);
|
---|
225 | fList->Add(fWritePictures);
|
---|
226 |
|
---|
227 | fLimMag = new MGPopupMenu(p);
|
---|
228 | fLimMag->AddEntry("3", IDM_kLimMag3);
|
---|
229 | fLimMag->AddEntry("4", IDM_kLimMag4);
|
---|
230 | fLimMag->AddEntry("5", IDM_kLimMag5);
|
---|
231 | fLimMag->AddEntry("6", IDM_kLimMag6);
|
---|
232 | fLimMag->AddEntry("7", IDM_kLimMag7);
|
---|
233 | fLimMag->AddEntry("8", IDM_kLimMag8);
|
---|
234 | fLimMag->AddEntry("9", IDM_kLimMag9);
|
---|
235 | fLimMag->CheckEntry(IDM_kLimMag8);
|
---|
236 | fLimMag->Associate(this);
|
---|
237 | fList->Add(fLimMag);
|
---|
238 |
|
---|
239 | fSao->SetLimitMag(7.0);
|
---|
240 |
|
---|
241 | fInterpol = new MGPopupMenu(p);
|
---|
242 | fInterpol->AddEntry("250", IDM_kInterpol250);
|
---|
243 | fInterpol->AddEntry("125", IDM_kInterpol125);
|
---|
244 | fInterpol->AddEntry("50", IDM_kInterpol50);
|
---|
245 | fInterpol->AddEntry("25", IDM_kInterpol25);
|
---|
246 | fInterpol->AddEntry("10", IDM_kInterpol10);
|
---|
247 | fInterpol->AddEntry("5", IDM_kInterpol5);
|
---|
248 | fInterpol->AddEntry("2", IDM_kInterpol2);
|
---|
249 | fInterpol->AddEntry("Off", IDM_kInterpol1);
|
---|
250 | fInterpol->Associate(this);
|
---|
251 | fList->Add(fInterpol);
|
---|
252 |
|
---|
253 | TString disp=gVirtualX->DisplayName();
|
---|
254 | cout << "Display: " << disp << endl;
|
---|
255 | if (disp.First(':')>=0)
|
---|
256 | disp=disp(0, disp.First(':'));
|
---|
257 |
|
---|
258 | if (disp.IsNull() || disp==(TString)"localhost")
|
---|
259 | {
|
---|
260 | fInterpol->CheckEntry(IDM_kInterpol5);
|
---|
261 | fIntRate = 50;
|
---|
262 | }
|
---|
263 | else
|
---|
264 | {
|
---|
265 | fInterpol->CheckEntry(IDM_kInterpol125);
|
---|
266 | fIntRate = 125;
|
---|
267 | }
|
---|
268 |
|
---|
269 | fSetup = new MGPopupMenu(p);
|
---|
270 | fSetup->AddPopup("Lim. &Magnitude", fLimMag);
|
---|
271 | fSetup->AddPopup("Disp. &Interpolation", fInterpol);
|
---|
272 | //fSetup->AddEntry("Use Ra/Dec from file", IDM_kUseFileRaDec);
|
---|
273 | fSetup->Associate(this);
|
---|
274 | fList->Add(fSetup);
|
---|
275 |
|
---|
276 | fCaosPrint = new MGPopupMenu(p);
|
---|
277 | fCaosPrint->AddEntry("&Leds", IDM_kCaosPrintLeds);
|
---|
278 | fCaosPrint->AddEntry("&Rings", IDM_kCaosPrintRings);
|
---|
279 | fCaosPrint->Associate(this);
|
---|
280 | fList->Add(fCaosPrint);
|
---|
281 |
|
---|
282 | fCaosWrite = new MGPopupMenu(p);
|
---|
283 | fCaosWrite->AddEntry("&Start", IDM_kCaosWriteStart);
|
---|
284 | fCaosWrite->AddEntry("Sto&p", IDM_kCaosWriteStop);
|
---|
285 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
286 | fCaosWrite->Associate(this);
|
---|
287 | fList->Add(fCaosWrite);
|
---|
288 |
|
---|
289 | fCaosAnalyse = new MGPopupMenu(p);
|
---|
290 | fCaosAnalyse->AddEntry("S&tart Analysis", IDM_kCaosAnalStart);
|
---|
291 | fCaosAnalyse->AddEntry("St&op Analysis", IDM_kCaosAnalStop);
|
---|
292 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
293 | // fCaosAnalyse->AddEntry("&Reset Histograms", IDM_kResetHistograms);
|
---|
294 | // fCaosAnalyse->AddEntry("Reset &Graph", IDM_kResetGraph);
|
---|
295 | fCaosAnalyse->Associate(this);
|
---|
296 | fList->Add(fCaosAnalyse);
|
---|
297 |
|
---|
298 | fMenu = new MGMenuBar(this, 0, 0, kHorizontalFrame);
|
---|
299 | fMenu->AddPopup("&Display", fDisplay, NULL);
|
---|
300 | fMenu->AddPopup("&WritePics", fWritePictures, NULL);
|
---|
301 | fMenu->AddPopup("&Setup", fSetup, NULL);
|
---|
302 |
|
---|
303 | fMenu->AddPopup("&Operations", fOperations, NULL);
|
---|
304 |
|
---|
305 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
306 | fMenu->BindKeys(this);
|
---|
307 | AddFrame(fMenu);
|
---|
308 | fList->Add(fMenu);
|
---|
309 |
|
---|
310 | fCaOs = new MGPopupMenu(p);
|
---|
311 | fCaOs->AddPopup("&Write", fCaosWrite);
|
---|
312 | fCaOs->AddPopup("&Print", fCaosPrint);
|
---|
313 | fCaOs->AddPopup("&Analyse", fCaosAnalyse);
|
---|
314 | fCaOs->Associate(this);
|
---|
315 | fCaOs->BindKeys(fMenu, this);
|
---|
316 | fList->Add(fCaOs);
|
---|
317 |
|
---|
318 | TGLayoutHints *hints2a =
|
---|
319 | new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|
|
---|
320 | kLHintsExpandX|kLHintsExpandY,1,1);
|
---|
321 | fList->Add(hints2a);
|
---|
322 |
|
---|
323 | fGStarg = new MGStarg(this, 235);
|
---|
324 | fGStarg->Move(530,596+5);
|
---|
325 | fList->Add(fGStarg);
|
---|
326 |
|
---|
327 | fCRaDec = new MGCoordinates(this, kETypeRaDec);
|
---|
328 | fCRaDec->Move(4, fMenu->GetDefaultHeight()+584);
|
---|
329 | AddFrame(fCRaDec);
|
---|
330 | fList->Add(fCRaDec);
|
---|
331 |
|
---|
332 | fCZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
|
---|
333 | fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+581+12);
|
---|
334 | AddFrame(fCZdAz);
|
---|
335 | fList->Add(fCZdAz);
|
---|
336 |
|
---|
337 | fPZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
|
---|
338 | fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+627+2*12);
|
---|
339 | AddFrame(fPZdAz);
|
---|
340 | fList->Add(fPZdAz);
|
---|
341 |
|
---|
342 | fDZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
|
---|
343 | fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+673+3*12);
|
---|
344 | AddFrame(fDZdAz);
|
---|
345 | fList->Add(fDZdAz);
|
---|
346 |
|
---|
347 | fSZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
|
---|
348 | fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+719+4*12);
|
---|
349 | AddFrame(fSZdAz);
|
---|
350 | fList->Add(fSZdAz);
|
---|
351 |
|
---|
352 | fTPoint = new TGTextButton(this, "TPoint");
|
---|
353 | fTPoint->Move(4, fMenu->GetDefaultHeight()+722+3*12+25);
|
---|
354 | fTPoint->AllowStayDown(kTRUE);
|
---|
355 | AddFrame(fTPoint);
|
---|
356 | fList->Add(fTPoint);
|
---|
357 |
|
---|
358 | fFps = new TGLabel(this, "---fps");
|
---|
359 | fFps->SetTextJustify(kTextRight);
|
---|
360 | fFps->Move(650-440, fMenu->GetDefaultHeight()+619+13+60+20);
|
---|
361 | AddFrame(fFps);
|
---|
362 | fList->Add(fFps);
|
---|
363 |
|
---|
364 | fPosZoom = new TGLabel(this, "----.--d/----.--d (----, ----)");
|
---|
365 | fPosZoom->SetTextJustify(kTextRight);
|
---|
366 | fPosZoom->Move(4, fMenu->GetDefaultHeight()+765);
|
---|
367 | AddFrame(fPosZoom);
|
---|
368 | fList->Add(fPosZoom);
|
---|
369 |
|
---|
370 | fSkyBright = new TGLabel(this, "Sky Brightness: --- ");
|
---|
371 | fSkyBright->SetTextJustify(kTextLeft);
|
---|
372 | fSkyBright->Move(4, fMenu->GetDefaultHeight()+785);
|
---|
373 | AddFrame(fSkyBright);
|
---|
374 | fList->Add(fSkyBright);
|
---|
375 |
|
---|
376 | TGLabel *l = new TGLabel(this, "arcsec/pix");
|
---|
377 | l->SetTextJustify(kTextLeft);
|
---|
378 | l->Move(605-400, fMenu->GetDefaultHeight()+619+13+60);
|
---|
379 | AddFrame(l);
|
---|
380 | fList->Add(l);
|
---|
381 |
|
---|
382 | l = new TGLabel(this, "deg");
|
---|
383 | l->SetTextJustify(kTextLeft);
|
---|
384 | l->Move(605-410, fMenu->GetDefaultHeight()+619-10+60);
|
---|
385 | AddFrame(l);
|
---|
386 | fList->Add(l);
|
---|
387 |
|
---|
388 | l = new TGLabel(this, "Telescope pointing at");
|
---|
389 | l->SetTextJustify(kTextLeft);
|
---|
390 | l->Move(240+12+20, fMenu->GetDefaultHeight()+584-5);
|
---|
391 | AddFrame(l);
|
---|
392 | fList->Add(l);
|
---|
393 |
|
---|
394 | l = new TGLabel(this, "Starguider position");
|
---|
395 | l->SetTextJustify(kTextLeft);
|
---|
396 | l->Move(240+12+20, fMenu->GetDefaultHeight()+630+12-5);
|
---|
397 | AddFrame(l);
|
---|
398 | fList->Add(l);
|
---|
399 |
|
---|
400 | l = new TGLabel(this, "Misspointing");
|
---|
401 | l->SetTextJustify(kTextLeft);
|
---|
402 | l->Move(240+12+20, fMenu->GetDefaultHeight()+676+2*12-5);
|
---|
403 | AddFrame(l);
|
---|
404 | fList->Add(l);
|
---|
405 |
|
---|
406 | #ifdef EXPERT
|
---|
407 | l = new TGLabel(this, "Misspointing/FindStar (Experts Only!)");
|
---|
408 | l->SetTextJustify(kTextLeft);
|
---|
409 | l->Move(240+12+20, fMenu->GetDefaultHeight()+722+3*12-5);
|
---|
410 | AddFrame(l);
|
---|
411 | fList->Add(l);
|
---|
412 | #endif
|
---|
413 |
|
---|
414 | const Double_t pixsize = 48.8; // used to be 23.4
|
---|
415 |
|
---|
416 | fSao->SetPixSize(pixsize);
|
---|
417 | fSao->SetRotationAngle(0);
|
---|
418 |
|
---|
419 | TString txt;
|
---|
420 | txt += pixsize;
|
---|
421 |
|
---|
422 | fPixSize = new TGTextEntry(this, txt, IDM_kPixSize);
|
---|
423 | fPixSize->SetAlignment(kTextCenterX);
|
---|
424 | fPixSize->Move(547-410, fMenu->GetDefaultHeight()+617+13+60);
|
---|
425 | AddFrame(fPixSize);
|
---|
426 | fList->Add(fPixSize);
|
---|
427 |
|
---|
428 | fAngle = new TGTextEntry(this, " 0", IDM_kAngle);
|
---|
429 | fAngle->SetAlignment(kTextCenterX);
|
---|
430 | fAngle->Move(547-410, fMenu->GetDefaultHeight()+617-10+60);
|
---|
431 | AddFrame(fAngle);
|
---|
432 | fList->Add(fAngle);
|
---|
433 |
|
---|
434 | // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
|
---|
435 | // AddFrame(fLineSep, new TGLayoutHints (kLHintsNormal | kLHintsExpandX));
|
---|
436 | // fList->Add(fLineSep);
|
---|
437 |
|
---|
438 | //
|
---|
439 | // Create Image Display
|
---|
440 | //
|
---|
441 | fZoomImage = new MGImage(this, kZOOM, kZOOM);
|
---|
442 | // fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
|
---|
443 | fZoomImage->Move(4, 700-kZOOM-2+85);
|
---|
444 | AddFrame(fZoomImage);
|
---|
445 | fList->Add(fZoomImage);
|
---|
446 |
|
---|
447 | fImage = new MGImage(this, 768, 576);
|
---|
448 | fImage->Move(0, fMenu->GetDefaultHeight());
|
---|
449 | AddFrame(fImage);
|
---|
450 | fList->Add(fImage);
|
---|
451 |
|
---|
452 | //
|
---|
453 | // Make everything visible
|
---|
454 | //
|
---|
455 | SetWindowName("MStarguider Main Window");
|
---|
456 | SetIconName("MStarguider");
|
---|
457 |
|
---|
458 | MapSubwindows();
|
---|
459 | fTPoint->UnmapWindow();
|
---|
460 | fGStarg->UnmapWindow();
|
---|
461 | fPZdAz->UnmapWindow();
|
---|
462 | fDZdAz->UnmapWindow();
|
---|
463 | fSZdAz->UnmapWindow();
|
---|
464 | fSkyBright->UnmapWindow();
|
---|
465 | MapWindow();
|
---|
466 |
|
---|
467 |
|
---|
468 | //IconifyWindow();
|
---|
469 |
|
---|
470 | //------------------------------------------------------------
|
---|
471 | // XY xy(3.819444, 24.05333);
|
---|
472 | // fCRaDec->SetCoordinates(xy);
|
---|
473 | // fRaDec->Set(xy.X()*360/24, xy.Y());
|
---|
474 | //------------------------------------------------------------
|
---|
475 | }
|
---|
476 |
|
---|
477 | MStarguider::MStarguider(MObservatory::LocationName_t obs, Int_t channel)
|
---|
478 | : TGMainFrame(gClient->GetRoot(), 768, 840),
|
---|
479 | fCosy(NULL),
|
---|
480 | fOutTp(0),
|
---|
481 | fOutRq(0),
|
---|
482 | fDx((768-kZOOM)/2),
|
---|
483 | fDy((512-kZOOM)/2),
|
---|
484 | fStatus(MDriveCom::kStandby)
|
---|
485 | {
|
---|
486 |
|
---|
487 | cout << " #### FIXME: Make MCaos Thread safe!" << endl;
|
---|
488 |
|
---|
489 | fSao = new StarCatalog(obs);
|
---|
490 | fRaDec = new RaDec(180, 40);
|
---|
491 |
|
---|
492 | // fStargLeds = new MStargLeds;
|
---|
493 | // fStargLeds->ReadResources();
|
---|
494 |
|
---|
495 | fCaos = new MCaos;
|
---|
496 | fCaos->ReadResources();
|
---|
497 |
|
---|
498 | fStargCaos = new MCaos;
|
---|
499 | fStargCaos->ReadResources("stargleds.txt");
|
---|
500 | fStargCaos->SetMinNumberRings(2);
|
---|
501 | fStargCaos->SetRadii(158,164);
|
---|
502 |
|
---|
503 | fStargHistograms = new MStargHistograms();
|
---|
504 |
|
---|
505 | InitGui(channel);
|
---|
506 |
|
---|
507 | fTimer=new TTimer(this, 1000/25); // 40ms
|
---|
508 | fTimer->TurnOn();
|
---|
509 |
|
---|
510 | fTime.Now();
|
---|
511 |
|
---|
512 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE);
|
---|
513 |
|
---|
514 | if (channel<0)
|
---|
515 | fGetter=new PngReader(*this);
|
---|
516 | else
|
---|
517 | {
|
---|
518 | fGetter = new Camera(*this, channel);
|
---|
519 | ((Camera*)fGetter)->Loop(0);
|
---|
520 | }
|
---|
521 | }
|
---|
522 |
|
---|
523 | MStarguider::~MStarguider()
|
---|
524 | {
|
---|
525 | fGetter->ExitLoop();
|
---|
526 | delete fGetter;
|
---|
527 |
|
---|
528 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE);
|
---|
529 |
|
---|
530 | fTimer->TurnOff();
|
---|
531 | delete fTimer;
|
---|
532 |
|
---|
533 | delete fList;
|
---|
534 |
|
---|
535 | delete fCaos;
|
---|
536 | delete fStargCaos;
|
---|
537 | // delete fStargLeds;
|
---|
538 | delete fStargHistograms;
|
---|
539 | delete fSao;
|
---|
540 | delete fRaDec;
|
---|
541 |
|
---|
542 | if (fOutTp)
|
---|
543 | delete fOutTp;
|
---|
544 |
|
---|
545 | if (fOutRq)
|
---|
546 | delete fOutRq;
|
---|
547 |
|
---|
548 | cout << "Camera Display destroyed." << endl;
|
---|
549 | }
|
---|
550 |
|
---|
551 | void MStarguider::Layout()
|
---|
552 | {
|
---|
553 | // Resize(GetDefaultSize());
|
---|
554 | }
|
---|
555 |
|
---|
556 | void MStarguider::CloseWindow()
|
---|
557 | {
|
---|
558 | cout << "EventDisplay::CloseWindow: Exit Application Loop." << endl;
|
---|
559 |
|
---|
560 | //fClient.ExitLoop();
|
---|
561 | // cout << "FIXME: ExitLoop not called!!!!!!" << endl;
|
---|
562 | gSystem->ExitLoop();
|
---|
563 | }
|
---|
564 |
|
---|
565 | void MStarguider::Toggle(MGPopupMenu *p, UInt_t id)
|
---|
566 | {
|
---|
567 | if (p->IsEntryChecked(id))
|
---|
568 | p->UnCheckEntry(id);
|
---|
569 | else
|
---|
570 | p->CheckEntry(id);
|
---|
571 | }
|
---|
572 |
|
---|
573 | Bool_t MStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
574 | {
|
---|
575 | switch (GET_MSG(msg))
|
---|
576 | {
|
---|
577 | case kC_TEXTENTRY:
|
---|
578 | if (GET_SUBMSG(msg)==kTE_ENTER)
|
---|
579 | switch (mp1)
|
---|
580 | {
|
---|
581 | case IDM_kPixSize:
|
---|
582 | {
|
---|
583 | const Float_t pixsize = atof(fPixSize->GetText());
|
---|
584 | cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
|
---|
585 | fSao->SetPixSize(pixsize);
|
---|
586 | return kTRUE;
|
---|
587 | }
|
---|
588 | case IDM_kAngle:
|
---|
589 | {
|
---|
590 | const Float_t angle = atof(fAngle->GetText());
|
---|
591 | cout << "Rotation Angle changed to " << angle << "deg" << endl;
|
---|
592 | fSao->SetRotationAngle(angle);
|
---|
593 | return kTRUE;
|
---|
594 | }
|
---|
595 | }
|
---|
596 | return kTRUE;
|
---|
597 |
|
---|
598 | case kC_COMMAND:
|
---|
599 | switch (GET_SUBMSG(msg))
|
---|
600 | {
|
---|
601 | case kCM_MENU:
|
---|
602 | switch (mp1)
|
---|
603 | {
|
---|
604 | case IDM_kCatalog:
|
---|
605 | Toggle(fDisplay, IDM_kCatalog);
|
---|
606 | // if (!fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
607 | // {
|
---|
608 | // fDisplay->UnCheckEntry(IDM_kStarguider);
|
---|
609 | // fDisplay->DisableEntry(IDM_kStarguider);
|
---|
610 | // } else {
|
---|
611 | // fDisplay->EnableEntry(IDM_kStarguider);
|
---|
612 | // }
|
---|
613 | return kTRUE;
|
---|
614 |
|
---|
615 | case IDM_kRoqueLampAna:
|
---|
616 | Toggle(fOperations, IDM_kRoqueLampAna);
|
---|
617 | // if (!fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
618 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) {
|
---|
619 | fDisplay->CheckEntry(IDM_kStargCaosFilter);
|
---|
620 | }
|
---|
621 | else {
|
---|
622 | fDisplay->UnCheckEntry(IDM_kStargCaosFilter);
|
---|
623 | }
|
---|
624 |
|
---|
625 | return kTRUE;
|
---|
626 |
|
---|
627 |
|
---|
628 | case IDM_kStargFindStar:
|
---|
629 | Toggle(fDisplay, IDM_kStargFindStar);
|
---|
630 | if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) {
|
---|
631 | fSZdAz->MapWindow();
|
---|
632 | } else {
|
---|
633 | fSZdAz->UnmapWindow();
|
---|
634 | }
|
---|
635 | return kTRUE;
|
---|
636 |
|
---|
637 | case IDM_kStarguider:
|
---|
638 | Toggle(fDisplay, IDM_kStarguider);
|
---|
639 |
|
---|
640 | if (fDisplay->IsEntryChecked(IDM_kStarguider)) {
|
---|
641 |
|
---|
642 | fLastBright = 0xff;
|
---|
643 |
|
---|
644 | fDisplay->DisableEntry(IDM_kFindStar);
|
---|
645 | fDisplay->EnableEntry(IDM_kStargAnalysis);
|
---|
646 |
|
---|
647 | fPZdAz->MapWindow();
|
---|
648 | fDZdAz->MapWindow();
|
---|
649 | fSkyBright->MapWindow();
|
---|
650 |
|
---|
651 | fSao->SetLimitMag(8.3);
|
---|
652 | fIntRate = 125;
|
---|
653 |
|
---|
654 | fDisplay->CheckEntry(IDM_kCatalog);
|
---|
655 | fGStarg->MapWindow();
|
---|
656 |
|
---|
657 | const Int_t ch0 =
|
---|
658 | fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
659 | const Int_t ch1 = 0;
|
---|
660 |
|
---|
661 | if (ch0!=ch1)
|
---|
662 | {
|
---|
663 | delete fGetter;
|
---|
664 | usleep(150000); // FIX: Device or resource busy.
|
---|
665 | if (fChannel->IsEntryChecked(IDM_kChannel3)) {
|
---|
666 | fGetter=new PngReader(*this);
|
---|
667 | } else {
|
---|
668 | fGetter = new Camera(*this, ch1);
|
---|
669 | ((Camera*)fGetter)->Loop(0);
|
---|
670 | }
|
---|
671 | }
|
---|
672 |
|
---|
673 | fChannel->CheckEntry(IDM_kChannel1);
|
---|
674 | fChannel->UnCheckEntry(IDM_kChannel2);
|
---|
675 | fChannel->DisableEntry(IDM_kChannel2);
|
---|
676 |
|
---|
677 | } else {
|
---|
678 |
|
---|
679 | fStatus = MDriveCom::kStandby;
|
---|
680 |
|
---|
681 | fPZdAz->UnmapWindow();
|
---|
682 | fDZdAz->UnmapWindow();
|
---|
683 | fSkyBright->UnmapWindow();
|
---|
684 | fGStarg->UnmapWindow();
|
---|
685 | fChannel->EnableEntry(IDM_kChannel2);
|
---|
686 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
687 | fDisplay->DisableEntry(IDM_kStargAnalysis);
|
---|
688 | }
|
---|
689 |
|
---|
690 | gSystem->Unlink("tracking_error.txt");
|
---|
691 |
|
---|
692 | return kTRUE;
|
---|
693 |
|
---|
694 | case IDM_kStargAnalysis:
|
---|
695 | Toggle(fDisplay, IDM_kStargAnalysis);
|
---|
696 | if (fDisplay->IsEntryChecked(IDM_kStargAnalysis)) {
|
---|
697 | fStargHistograms->OpenFile();
|
---|
698 | } else {
|
---|
699 | fStargHistograms->CloseFile();
|
---|
700 | }
|
---|
701 |
|
---|
702 | return kTRUE;
|
---|
703 |
|
---|
704 | case IDM_kStargHistograms:
|
---|
705 | Toggle(fDisplay, IDM_kStargHistograms);
|
---|
706 | return kTRUE;
|
---|
707 |
|
---|
708 | case IDM_kStargLEDFilter:
|
---|
709 | Toggle(fDisplay, IDM_kStargLEDFilter);
|
---|
710 | return kTRUE;
|
---|
711 |
|
---|
712 | case IDM_kFilter:
|
---|
713 | Toggle(fDisplay, IDM_kFilter);
|
---|
714 | return kTRUE;
|
---|
715 |
|
---|
716 | // case IDM_kFilterStarg:
|
---|
717 | // Toggle(fDisplay, IDM_kFilterStarg);
|
---|
718 | // if (fDisplay->IsEntryChecked(IDM_kFilterStarg))
|
---|
719 | // fDisplay->EnableEntry(IDM_kStarguider);
|
---|
720 | // else
|
---|
721 | // {
|
---|
722 | // fDisplay->UnCheckEntry(IDM_kStarguider);
|
---|
723 | // fDisplay->DisableEntry(IDM_kStarguider);
|
---|
724 | // }
|
---|
725 | // return kTRUE;
|
---|
726 |
|
---|
727 | case IDM_kFindStar:
|
---|
728 | Toggle(fDisplay, IDM_kFindStar);
|
---|
729 | if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy)
|
---|
730 | fTPoint->MapWindow();
|
---|
731 | else
|
---|
732 | {
|
---|
733 | fTPoint->UnmapWindow();
|
---|
734 | fTPoint->SetDown(kFALSE);
|
---|
735 | }
|
---|
736 | return kTRUE;
|
---|
737 |
|
---|
738 | case IDM_kStretch:
|
---|
739 | Toggle(fDisplay, IDM_kStretch);
|
---|
740 | return kTRUE;
|
---|
741 |
|
---|
742 | case IDM_kCaosFilter:
|
---|
743 | //if (!fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
744 | // fCaos->OpenFile();
|
---|
745 | Toggle(fDisplay, IDM_kCaosFilter);
|
---|
746 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) {
|
---|
747 | fMenu->AddPopup("&CaOs", fCaOs, NULL);
|
---|
748 | }
|
---|
749 | else
|
---|
750 | {
|
---|
751 | if(fCaosWrite->IsEntryChecked(IDM_kCaosPrintLeds))
|
---|
752 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintLeds);
|
---|
753 | if(fCaosWrite->IsEntryChecked(IDM_kCaosPrintRings))
|
---|
754 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintRings);
|
---|
755 | if(fCaosAnalyse->IsEntryEnabled(IDM_kCaosAnalStop))
|
---|
756 | {
|
---|
757 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
758 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
759 | fCaos->DeleteHistograms();
|
---|
760 | }
|
---|
761 | if(fCaosWrite->IsEntryEnabled(IDM_kCaosWriteStop))
|
---|
762 | {
|
---|
763 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
764 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
765 | fCaos->CloseFile();
|
---|
766 | }
|
---|
767 | fMenu->RemovePopup("CaOs");
|
---|
768 | }
|
---|
769 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
770 | MapSubwindows(); // maps everything, but we don't want that
|
---|
771 | fTPoint->UnmapWindow();
|
---|
772 | fGStarg->UnmapWindow();
|
---|
773 | fPZdAz->UnmapWindow();
|
---|
774 | fDZdAz->UnmapWindow();
|
---|
775 | fSZdAz->UnmapWindow();
|
---|
776 | fSkyBright->UnmapWindow();
|
---|
777 | MapWindow();
|
---|
778 | return kTRUE;
|
---|
779 |
|
---|
780 | case IDM_kStargCaosFilter:
|
---|
781 | Toggle(fDisplay, IDM_kStargCaosFilter);
|
---|
782 | if (fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) {
|
---|
783 | fDisplay->EnableEntry(IDM_kStargFindStar);
|
---|
784 | } else {
|
---|
785 | fDisplay->DisableEntry(IDM_kStargFindStar);
|
---|
786 | }
|
---|
787 | return kTRUE;
|
---|
788 |
|
---|
789 | case IDM_kCaosPrintLeds:
|
---|
790 | case IDM_kCaosPrintRings:
|
---|
791 | Toggle(fCaosPrint, mp1);
|
---|
792 | return kTRUE;
|
---|
793 |
|
---|
794 | case IDM_kCaosAnalStart:
|
---|
795 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStart);
|
---|
796 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStop);
|
---|
797 | fCaos->InitHistograms();
|
---|
798 | return kTRUE;
|
---|
799 |
|
---|
800 | case IDM_kCaosAnalStop:
|
---|
801 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
802 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
803 | fCaos->ShowHistograms();
|
---|
804 | fCaos->DeleteHistograms();
|
---|
805 | return kTRUE;
|
---|
806 |
|
---|
807 | case IDM_kCaosWriteStart:
|
---|
808 | fCaosWrite->DisableEntry(IDM_kCaosWriteStart);
|
---|
809 | fCaosWrite->EnableEntry(IDM_kCaosWriteStop);
|
---|
810 | fCaos->OpenFile();
|
---|
811 | return kTRUE;
|
---|
812 |
|
---|
813 | case IDM_kCaosWriteStop:
|
---|
814 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
815 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
816 | fCaos->CloseFile();
|
---|
817 | return kTRUE;
|
---|
818 |
|
---|
819 | case IDM_kStart:
|
---|
820 | fWritePictures->DisableEntry(IDM_kStart);
|
---|
821 | fWritePictures->EnableEntry(IDM_kStop);
|
---|
822 | return kTRUE;
|
---|
823 |
|
---|
824 | case IDM_kStop:
|
---|
825 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
826 | fWritePictures->EnableEntry(IDM_kStart);
|
---|
827 | return kTRUE;
|
---|
828 |
|
---|
829 | case IDM_kPNG:
|
---|
830 | fFileType->CheckEntry(IDM_kPNG);
|
---|
831 | fFileType->UnCheckEntry(IDM_kPPM);
|
---|
832 | return kTRUE;
|
---|
833 |
|
---|
834 | case IDM_kPPM:
|
---|
835 | fFileType->CheckEntry(IDM_kPPM);
|
---|
836 | fFileType->UnCheckEntry(IDM_kPNG);
|
---|
837 | return kTRUE;
|
---|
838 |
|
---|
839 | case IDM_kOnce:
|
---|
840 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
841 | fWriteType->UnCheckEntry(IDM_kContinous);
|
---|
842 | return kTRUE;
|
---|
843 |
|
---|
844 | case IDM_kContinous:
|
---|
845 | fWriteType->CheckEntry(IDM_kContinous);
|
---|
846 | fWriteType->UnCheckEntry(IDM_kOnce);
|
---|
847 | return kTRUE;
|
---|
848 |
|
---|
849 | case IDM_kRate25ps:
|
---|
850 | case IDM_kRate5ps:
|
---|
851 | case IDM_kRate1s:
|
---|
852 | case IDM_kRate5s:
|
---|
853 | case IDM_kRate30s:
|
---|
854 | case IDM_kRate1m:
|
---|
855 | case IDM_kRate5m:
|
---|
856 | for (int i=IDM_kRate25ps; i<=IDM_kRate5m; i++)
|
---|
857 | if (mp1==i)
|
---|
858 | fWriteRate->CheckEntry(i);
|
---|
859 | else
|
---|
860 | fWriteRate->UnCheckEntry(i);
|
---|
861 | switch (mp1)
|
---|
862 | {
|
---|
863 | case IDM_kRate25ps:
|
---|
864 | fWrtRate = 1;
|
---|
865 | return kTRUE;
|
---|
866 | case IDM_kRate5ps:
|
---|
867 | fWrtRate = 5;
|
---|
868 | return kTRUE;
|
---|
869 | case IDM_kRate1s:
|
---|
870 | fWrtRate = 25;
|
---|
871 | return kTRUE;
|
---|
872 | case IDM_kRate5s:
|
---|
873 | fWrtRate = 5*25;
|
---|
874 | return kTRUE;
|
---|
875 | case IDM_kRate30s:
|
---|
876 | fWrtRate = 30*25;
|
---|
877 | return kTRUE;
|
---|
878 | case IDM_kRate1m:
|
---|
879 | fWrtRate = 60*25;
|
---|
880 | return kTRUE;
|
---|
881 | case IDM_kRate5m:
|
---|
882 | fWrtRate = 5*60*25;
|
---|
883 | return kTRUE;
|
---|
884 | }
|
---|
885 | return kTRUE;
|
---|
886 |
|
---|
887 | case IDM_kChannel1:
|
---|
888 | case IDM_kChannel2:
|
---|
889 | {
|
---|
890 | const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
891 | const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1;
|
---|
892 |
|
---|
893 | if (ch0==ch1)
|
---|
894 | return kTRUE;
|
---|
895 |
|
---|
896 | fChannel->CheckEntry (ch1==0?IDM_kChannel1:IDM_kChannel2);
|
---|
897 | fChannel->UnCheckEntry(ch1==1?IDM_kChannel1:IDM_kChannel2);
|
---|
898 | delete fGetter;
|
---|
899 | usleep(150000); // FIX: Device or resource busy.
|
---|
900 | if (fChannel->IsEntryChecked(IDM_kChannel3))
|
---|
901 | fGetter=new PngReader(*this);
|
---|
902 | else
|
---|
903 | {
|
---|
904 | fGetter = new Camera(*this, ch1);
|
---|
905 | ((Camera*)fGetter)->Loop(0);
|
---|
906 | }
|
---|
907 | }
|
---|
908 | return kTRUE;
|
---|
909 |
|
---|
910 | case IDM_kInterpol250:
|
---|
911 | case IDM_kInterpol125:
|
---|
912 | case IDM_kInterpol50:
|
---|
913 | case IDM_kInterpol25:
|
---|
914 | case IDM_kInterpol10:
|
---|
915 | case IDM_kInterpol5:
|
---|
916 | case IDM_kInterpol2:
|
---|
917 | case IDM_kInterpol1:
|
---|
918 | for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
|
---|
919 | if (mp1==i)
|
---|
920 | fInterpol->CheckEntry(i);
|
---|
921 | else
|
---|
922 | fInterpol->UnCheckEntry(i);
|
---|
923 | switch (mp1)
|
---|
924 | {
|
---|
925 | case IDM_kInterpol1:
|
---|
926 | fIntRate = 1;
|
---|
927 | return kTRUE;
|
---|
928 | case IDM_kInterpol2:
|
---|
929 | fIntRate = 2;
|
---|
930 | return kTRUE;
|
---|
931 | case IDM_kInterpol5:
|
---|
932 | fIntRate = 5;
|
---|
933 | return kTRUE;
|
---|
934 | case IDM_kInterpol10:
|
---|
935 | fIntRate = 10;
|
---|
936 | return kTRUE;
|
---|
937 | case IDM_kInterpol25:
|
---|
938 | fIntRate = 25;
|
---|
939 | return kTRUE;
|
---|
940 | case IDM_kInterpol50:
|
---|
941 | fIntRate = 50;
|
---|
942 | return kTRUE;
|
---|
943 | case IDM_kInterpol125:
|
---|
944 | fIntRate = 125;
|
---|
945 | return kTRUE;
|
---|
946 | case IDM_kInterpol250:
|
---|
947 | fIntRate = 250;
|
---|
948 | return kTRUE;
|
---|
949 | }
|
---|
950 | return kTRUE;
|
---|
951 |
|
---|
952 | case IDM_kLimMag3:
|
---|
953 | case IDM_kLimMag4:
|
---|
954 | case IDM_kLimMag5:
|
---|
955 | case IDM_kLimMag6:
|
---|
956 | case IDM_kLimMag7:
|
---|
957 | case IDM_kLimMag8:
|
---|
958 | case IDM_kLimMag9:
|
---|
959 | for (int i=IDM_kLimMag3; i<=IDM_kLimMag9; i++)
|
---|
960 | if (mp1==i)
|
---|
961 | fLimMag->CheckEntry(i);
|
---|
962 | else
|
---|
963 | fLimMag->UnCheckEntry(i);
|
---|
964 |
|
---|
965 | fSao->SetLimitMag(mp1-IDM_kLimMag3+3);
|
---|
966 | return kTRUE;
|
---|
967 | }
|
---|
968 | break;
|
---|
969 | }
|
---|
970 | break;
|
---|
971 | }
|
---|
972 |
|
---|
973 | return kTRUE;
|
---|
974 | }
|
---|
975 |
|
---|
976 | void MStarguider::SetPointingPosition(RaDec rd)
|
---|
977 | {
|
---|
978 | rd.Ra(rd.Ra()*24/360);
|
---|
979 | fCRaDec->SetCoordinates(rd);
|
---|
980 | }
|
---|
981 |
|
---|
982 | ZdAz MStarguider::TrackingError(TArrayF &x, TArrayF &y, TArrayF &mag) const
|
---|
983 | {
|
---|
984 | //
|
---|
985 | // Viewable area (FIXME: AZ)
|
---|
986 | //
|
---|
987 | // TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3
|
---|
988 | // chose a bit coarser binning to enhance excess
|
---|
989 | // important: chose binning symmetrical around (0|0)!
|
---|
990 | TH2F h("Hist", "dX/dY", 49, -768/2-8, 768/2+8, 37, -576/2-8, 576/2+8); // 3
|
---|
991 |
|
---|
992 | // TH1F hmag("HistMag", "Mag", 19, 0, 100);
|
---|
993 | // for (int i=0; i<mag.GetSize(); i++)
|
---|
994 | // hmag.Fill(mag[i]);
|
---|
995 |
|
---|
996 | //
|
---|
997 | // Search for matching Magnitudes
|
---|
998 | //
|
---|
999 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1000 | {
|
---|
1001 | if (mag[i]>48-15 && mag[i]<48+15)
|
---|
1002 | h.Fill(x[i], y[i]);
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | //
|
---|
1006 | // Search for an excess in the histogram
|
---|
1007 | //
|
---|
1008 | Int_t mx, my, dummy;
|
---|
1009 | h.GetMaximumBin(mx, my, dummy);
|
---|
1010 |
|
---|
1011 | const double xmax = h.GetXaxis()->GetBinCenter(mx);
|
---|
1012 | const double dx = h.GetXaxis()->GetBinWidth(mx);
|
---|
1013 |
|
---|
1014 | const double ymax = h.GetYaxis()->GetBinCenter(my);
|
---|
1015 | const double dy = h.GetYaxis()->GetBinWidth(my);
|
---|
1016 |
|
---|
1017 | #ifdef EXPERT
|
---|
1018 | cout << setprecision(3);
|
---|
1019 | cout << "Cut-XY: " << xmax << " +- " << dx << " / " << ymax << " +- " << dy << endl;
|
---|
1020 | #endif
|
---|
1021 |
|
---|
1022 | TGraph g;
|
---|
1023 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1024 | {
|
---|
1025 | if (!(x[i]>xmax-dx && x[i]<xmax+dx &&
|
---|
1026 | y[i]>ymax-dy && y[i]<ymax+dy /*&&
|
---|
1027 | mag[i]>48-15 && mag[i]<48+15*/))
|
---|
1028 | continue;
|
---|
1029 |
|
---|
1030 | g.SetPoint(g.GetN(), x[i], y[i]);
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | #ifdef EXPERT
|
---|
1034 | cout << "Offset-XY: " << g.GetMean(1) << " +- " << g.GetRMS(1) << " / ";
|
---|
1035 | cout << g.GetMean(2) << " +- " << g.GetRMS(2) << endl;
|
---|
1036 | #endif
|
---|
1037 |
|
---|
1038 | AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg;
|
---|
1039 | AltAz pos1 = fSao->CalcAltAzFromPix(768/2+g.GetMean(1), 576/2+g.GetMean(2))*kRad2Deg;
|
---|
1040 |
|
---|
1041 | ofstream fout1("pointingpos.txt");
|
---|
1042 | fout1 << setprecision(10) << fSao->GetMjd()-52000 << " ";
|
---|
1043 | if (fCosy)
|
---|
1044 | fout1 << fCosy->GetPointingPos() << " ";
|
---|
1045 | fout1 << -pos1.Alt() << " " << pos1.Az() << endl;
|
---|
1046 |
|
---|
1047 | pos1 -= pos0;
|
---|
1048 |
|
---|
1049 | ofstream fout2("tracking_error.txt", ios::app);
|
---|
1050 | fout2 << setprecision(10) << fSao->GetMjd()-52000 << " ";
|
---|
1051 | if (fCosy)
|
---|
1052 | fout2 << fCosy->GetPointingPos() << " ";
|
---|
1053 | fout2 << -pos1.Alt() << " " << pos1.Az() << endl;
|
---|
1054 |
|
---|
1055 | // if (g.GetMean(1)>9 || g.GetMean(2)>9) {
|
---|
1056 | // TFile f1("sguider-highoffset.root","UPDATE");
|
---|
1057 | // h.Write();
|
---|
1058 | // hmag.Write();
|
---|
1059 | // g.Write();
|
---|
1060 | // f1.Close();
|
---|
1061 | // } else {
|
---|
1062 | // TFile f1("sguider-niceoffset.root","UPDATE");
|
---|
1063 | // h.Write();
|
---|
1064 | // hmag.Write();
|
---|
1065 | // g.Write();
|
---|
1066 | // f1.Close();
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | // }
|
---|
1070 |
|
---|
1071 | return ZdAz(-pos1.Alt(), pos1.Az());
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | bool MStarguider::CalcTrackingError(Leds &leds, MStarList &stars, ZdAz &d, MTime &t)
|
---|
1075 | {
|
---|
1076 | const Int_t max = leds.GetEntries();
|
---|
1077 | if (stars.GetRealEntries() < 3)
|
---|
1078 | {
|
---|
1079 | cout << "Sorry, less than 3 stars in FOV!" << endl;
|
---|
1080 | return kFALSE;
|
---|
1081 | }
|
---|
1082 | if (max < 3) //was 1
|
---|
1083 | {
|
---|
1084 | cout << "Sorry, less than 3 detected spot in FOV!" << endl;
|
---|
1085 | return kFALSE;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | stars.Sort(); // Sort by magnitude
|
---|
1089 |
|
---|
1090 | #ifdef EXPERT
|
---|
1091 | TString str = "data/tracking_";
|
---|
1092 | str += fSao->GetMjd();
|
---|
1093 | str += ".txt";
|
---|
1094 |
|
---|
1095 | ofstream fout(str);
|
---|
1096 | #endif
|
---|
1097 |
|
---|
1098 | TArrayF x, y, mag;
|
---|
1099 |
|
---|
1100 | Int_t num = 0;
|
---|
1101 |
|
---|
1102 | // FIXME: Is predefined value 3 a good idea?
|
---|
1103 |
|
---|
1104 | MStar *star;
|
---|
1105 | MStarListIter NextStar(&stars);
|
---|
1106 | while ((star=NextStar()) && num++<max+3)
|
---|
1107 | {
|
---|
1108 | TIter NextSp(&leds);
|
---|
1109 | Led *spot=NULL;
|
---|
1110 | while ((spot=(Led*)NextSp()))
|
---|
1111 | {
|
---|
1112 | const XY dpos(spot->GetX()-(768-star->GetX()), spot->GetY()-star->GetY());
|
---|
1113 |
|
---|
1114 | const Int_t idx = x.GetSize();
|
---|
1115 |
|
---|
1116 | x.Set(idx+1);
|
---|
1117 | y.Set(idx+1);
|
---|
1118 | mag.Set(idx+1);
|
---|
1119 |
|
---|
1120 | x.AddAt(dpos.X(), idx);
|
---|
1121 | y.AddAt(dpos.Y(), idx);
|
---|
1122 | mag.AddAt(spot->GetMag()/star->GetMag(), idx);
|
---|
1123 | #ifdef EXPERT
|
---|
1124 | if (fout) {
|
---|
1125 | fout << spot->GetX() << " "
|
---|
1126 | << spot->GetY() << " "
|
---|
1127 | << spot->GetMag() << " "
|
---|
1128 | << star->GetX() << " "
|
---|
1129 | << star->GetY() << " "
|
---|
1130 | << star->GetMag() << " ";
|
---|
1131 | fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl;
|
---|
1132 | }
|
---|
1133 | #endif
|
---|
1134 | }
|
---|
1135 | }
|
---|
1136 |
|
---|
1137 | d = TrackingError(x, y, mag);
|
---|
1138 | fDZdAz->SetCoordinates(d);
|
---|
1139 |
|
---|
1140 | //
|
---|
1141 | // Calculated offsets
|
---|
1142 | //
|
---|
1143 |
|
---|
1144 | #ifdef EXPERT
|
---|
1145 | // round= floor(x+.5)
|
---|
1146 | cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl;
|
---|
1147 | cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl;
|
---|
1148 | #endif
|
---|
1149 |
|
---|
1150 | //
|
---|
1151 | // Current Pointing position
|
---|
1152 | //
|
---|
1153 | ZdAz cpos = fSao->GetZdAz()-d;
|
---|
1154 | fPZdAz->SetCoordinates(cpos);
|
---|
1155 |
|
---|
1156 | return kTRUE;
|
---|
1157 |
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | XY MStarguider::FindRoqueLamp(FilterLed &f, FilterLed &f2, Ring &CameraCenter, MTime &t, Double_t cut, Double_t box, XY SearchCenter)
|
---|
1161 | {
|
---|
1162 | // Set search Paremeters (FIXME: Get them from user input!)
|
---|
1163 | f.SetCut(cut); // 3.5
|
---|
1164 | f.SetBox(box); // 70
|
---|
1165 |
|
---|
1166 | // Try to find Led in this area
|
---|
1167 | Leds leds;
|
---|
1168 | f.FindStarCircle(leds, (Int_t)SearchCenter.X(), (Int_t)SearchCenter.Y());
|
---|
1169 |
|
---|
1170 | // Check whether star found
|
---|
1171 | Led *star = (Led*)leds.At(0);
|
---|
1172 | if (!star || leds.GetEntries()<1)
|
---|
1173 | return XY(.0,.0);
|
---|
1174 |
|
---|
1175 | // cout << "Found Roque Lamp @ " << flush;
|
---|
1176 | star->Print();
|
---|
1177 | f.MarkPoint(star->GetX(), star->GetY(), 500);
|
---|
1178 |
|
---|
1179 | // cout << "RoquePos: " << star->GetX() << "," << star->GetY() << endl;
|
---|
1180 |
|
---|
1181 | XY roquepos(star->GetX(), star->GetY());
|
---|
1182 | XY relroquepos(roquepos.X()-CameraCenter.GetX(), roquepos.Y()-CameraCenter.GetY());
|
---|
1183 |
|
---|
1184 | // If no file open: open new Roque Lamp file
|
---|
1185 | if (!fOutRq)
|
---|
1186 | {
|
---|
1187 | const TString name = MCosy::GetFileName("tpoint/starg_roquelamp_%s.txt");
|
---|
1188 | cout << "Starg_RoqueLamp File ********* " << name << " ********** " << endl;
|
---|
1189 | fOutRq = new ofstream(name);
|
---|
1190 | *fOutRq << "# Magic Roque Lamp file " << t << endl;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 |
|
---|
1194 | return relroquepos;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | ZdAz MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t, Double_t cut, Double_t box, Double_t scalefactor = 1.0)
|
---|
1199 | {
|
---|
1200 | // Set search Paremeters (FIXME: Get them from user input!)
|
---|
1201 | f.SetCut(cut); // 3.5
|
---|
1202 | f.SetBox(box); // 70
|
---|
1203 |
|
---|
1204 | // Try to find Led in this area
|
---|
1205 | Leds leds;
|
---|
1206 | f.FindStarCircle(leds, (Int_t)center.GetX(), (Int_t)center.GetY());
|
---|
1207 |
|
---|
1208 | // Check whether star found
|
---|
1209 | Led *star = (Led*)leds.At(0);
|
---|
1210 | if (!star || leds.GetEntries()<1)
|
---|
1211 | return ZdAz(.0,.0);
|
---|
1212 |
|
---|
1213 | cout << "Found star @ " << flush;
|
---|
1214 | star->Print();
|
---|
1215 | f2.MarkPoint(star->GetX(), star->GetY(), 2<<2);
|
---|
1216 |
|
---|
1217 | // Initialize Star Catalog on th camera plane
|
---|
1218 | MGeomCamMagic geom;
|
---|
1219 | MAstroCamera ac;
|
---|
1220 | ac.SetGeom(geom);
|
---|
1221 | ac.SetRadiusFOV(3);
|
---|
1222 | ac.SetObservatory(*fSao);
|
---|
1223 | ac.SetTime(t);
|
---|
1224 |
|
---|
1225 | // Get tracking coordinates
|
---|
1226 | const XY xy = fCRaDec->GetCoordinates();
|
---|
1227 | const RaDec rd(xy.X()*TMath::DegToRad()*15, xy.Y()*TMath::DegToRad());
|
---|
1228 |
|
---|
1229 | ac.SetRaDec(rd.Ra(), rd.Dec());
|
---|
1230 |
|
---|
1231 | // Adapt coordinate system (GUIs and humans are counting Y in different directions)
|
---|
1232 | Double_t x = star->GetX()-center.GetX();
|
---|
1233 | Double_t y = center.GetY()-star->GetY();
|
---|
1234 |
|
---|
1235 | cout << "STAR-Offset: " << MTime(-1) << " dx=" << x << "pix dy=" << y << "pix" << endl;
|
---|
1236 |
|
---|
1237 | // Convert from Pixel to millimeter (1pix=2.9mm)
|
---|
1238 | x *= (2.58427 * scalefactor);
|
---|
1239 | y *= (2.58427 * scalefactor);
|
---|
1240 |
|
---|
1241 | // Correct for abberation.
|
---|
1242 | x /= 1.0713;
|
---|
1243 | y /= 1.0713;
|
---|
1244 |
|
---|
1245 | // Calculate Offset
|
---|
1246 | Double_t dzd, daz;
|
---|
1247 | ac.GetDiffZdAz(x, y, dzd, daz);
|
---|
1248 |
|
---|
1249 | cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl;
|
---|
1250 |
|
---|
1251 | ZdAz zdaz(dzd,daz);
|
---|
1252 |
|
---|
1253 | // Check TPoint data set request
|
---|
1254 | if (!fTPoint->IsDown())
|
---|
1255 | return zdaz;
|
---|
1256 | fTPoint->SetDown(kFALSE);
|
---|
1257 |
|
---|
1258 | // If no file open: open new file
|
---|
1259 | if (!fOutTp)
|
---|
1260 | {
|
---|
1261 | //
|
---|
1262 | // open tpoint file
|
---|
1263 | //
|
---|
1264 | const TString name = MCosy::GetFileName("tpoint/starg_%s.txt");
|
---|
1265 | cout << "TPoint-Starg File ********* " << name << " ********** " << endl;
|
---|
1266 |
|
---|
1267 | fOutTp = new ofstream(name);
|
---|
1268 | *fOutTp << "Magic Model TPOINT data file" << endl;
|
---|
1269 | *fOutTp << ": ALTAZ" << endl;
|
---|
1270 | *fOutTp << "49 48 0 ";
|
---|
1271 | *fOutTp << t << endl;
|
---|
1272 | // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m)
|
---|
1273 | }
|
---|
1274 |
|
---|
1275 | // Output Ra/Dec the drive system thinks that it is currently tracking
|
---|
1276 | cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl;
|
---|
1277 |
|
---|
1278 | // From the star position in the camera we calculate the Alt/Az
|
---|
1279 | // position we are currently tracking (real pointing position)
|
---|
1280 | fSao->SetMjd(t.GetMjd());
|
---|
1281 | AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
|
---|
1282 |
|
---|
1283 | //ZdAz za0 = fSao->GetZdAz();
|
---|
1284 | za0 -= AltAz(-dzd, daz);
|
---|
1285 |
|
---|
1286 | // From the Shaftencoders we get the current 'pointing' position
|
---|
1287 | // as it is seen by the drive system (system pointing position)
|
---|
1288 | const ZdAz za1 = fCosy->GetTrackingPosRaw();
|
---|
1289 |
|
---|
1290 | // Write real pointing position
|
---|
1291 | cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
|
---|
1292 | *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
|
---|
1293 |
|
---|
1294 | // Write system pointing position
|
---|
1295 | cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl;
|
---|
1296 | *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd();
|
---|
1297 |
|
---|
1298 | *fOutTp << " " << xy.X() << " " << xy.Y();
|
---|
1299 | *fOutTp << " " << -dzd << " " << -daz;
|
---|
1300 | *fOutTp << " " << setprecision(11) << t.GetMjd();
|
---|
1301 | *fOutTp << " " << setprecision(4) << center.GetMag();
|
---|
1302 | *fOutTp << " " << star->GetMag();
|
---|
1303 | *fOutTp << endl;
|
---|
1304 |
|
---|
1305 | MLog &outrep = *fCosy->GetOutRep();
|
---|
1306 | if (outrep.Lock("MStarguider::FindStar"))
|
---|
1307 | {
|
---|
1308 | outrep << "FINDSTAR-REPORT 00 " << MTime(-1) << " " << setprecision(7);
|
---|
1309 | outrep << 90-za0.Alt() << " " << za0.Az() << " ";
|
---|
1310 | outrep << za1.Zd() << " " << za1.Az() << " ";
|
---|
1311 | outrep << xy.X() << " " << xy.Y() << " ";
|
---|
1312 | outrep << -dzd << " " << -daz << " ";
|
---|
1313 | outrep << star->GetX() << " " << star->GetY() << " ";
|
---|
1314 | outrep << center.GetX() << " " << center.GetY() << " ";
|
---|
1315 | outrep << x*1.0713/2.58427 << " " << y*1.0713/2.58427 << " " << star->GetMag();
|
---|
1316 | outrep << setprecision(11) << t.GetMjd() << endl;
|
---|
1317 | outrep.UnLock("MStarguider::FindStar");
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | return zdaz;
|
---|
1321 | }
|
---|
1322 |
|
---|
1323 | bool MStarguider::Interpolate(const unsigned long n, byte *img) const
|
---|
1324 | {
|
---|
1325 | if (fIntRate<=1)
|
---|
1326 | return true;
|
---|
1327 |
|
---|
1328 | static unsigned short myimg[768*576];
|
---|
1329 |
|
---|
1330 | unsigned short *f = myimg;
|
---|
1331 | byte *i = img;
|
---|
1332 | byte *e = img+768*576;
|
---|
1333 |
|
---|
1334 | while (i<e)
|
---|
1335 | *f++ += *i++;
|
---|
1336 |
|
---|
1337 | if (n%fIntRate)
|
---|
1338 | return false;
|
---|
1339 |
|
---|
1340 | f = myimg;
|
---|
1341 | i = img;
|
---|
1342 | e = img+768*576;
|
---|
1343 |
|
---|
1344 | while (i<e)
|
---|
1345 | *i++ = (byte)(*f++/fIntRate);
|
---|
1346 |
|
---|
1347 | memset(myimg, 0, sizeof(myimg));
|
---|
1348 |
|
---|
1349 | return true;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | void MStarguider::ProcessFrame(const unsigned long n, byte *img,
|
---|
1353 | struct timeval *tm)
|
---|
1354 | {
|
---|
1355 | static unsigned long n0 = n;
|
---|
1356 |
|
---|
1357 | MTime t(*tm);
|
---|
1358 |
|
---|
1359 | const Double_t d = t-fTime;
|
---|
1360 | if (d>1)
|
---|
1361 | {
|
---|
1362 | MString txt;
|
---|
1363 | txt.Print("%dfps", (int)((n-n0)/d+.5));
|
---|
1364 | fFps->SetText(txt);
|
---|
1365 | fTime = t;
|
---|
1366 | n0 = n;
|
---|
1367 | }
|
---|
1368 |
|
---|
1369 | if (!Interpolate(n, img))
|
---|
1370 | return;
|
---|
1371 |
|
---|
1372 | byte cimg[768*576];
|
---|
1373 | memset(cimg, 0, 768*576);
|
---|
1374 |
|
---|
1375 | FilterLed f(img, 768, 576, 2.5); // 2.5
|
---|
1376 | FilterLed f2(cimg, 768, 576); // former color 0xb0
|
---|
1377 |
|
---|
1378 | if (fDisplay->IsEntryChecked(IDM_kStretch))
|
---|
1379 | f.Stretch();
|
---|
1380 |
|
---|
1381 | if (!fWritePictures->IsEntryEnabled(IDM_kStart) &&
|
---|
1382 | (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce)))
|
---|
1383 | {
|
---|
1384 |
|
---|
1385 | if (fFileType->IsEntryChecked(IDM_kPNG))
|
---|
1386 | Writer::Png("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1387 |
|
---|
1388 | if (fFileType->IsEntryChecked(IDM_kPPM))
|
---|
1389 | Writer::Ppm("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1390 |
|
---|
1391 | if (fWriteType->IsEntryChecked(IDM_kOnce))
|
---|
1392 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStop, 0);
|
---|
1393 | }
|
---|
1394 |
|
---|
1395 | // Visual Filter, whole FOV
|
---|
1396 | if (fDisplay->IsEntryChecked(IDM_kFilter))
|
---|
1397 | f.Execute();
|
---|
1398 |
|
---|
1399 | /* ----------------------------------
|
---|
1400 | // Visual StarFilter for Starguider
|
---|
1401 | if (fDisplay->IsEntryChecked(IDM_kFilterStarg) && !fDisplay->IsEntryChecked(IDM_kStarguider)) {
|
---|
1402 | f.SetBox(230);
|
---|
1403 | f.AddIgnoreRegion(295,112,384,204);
|
---|
1404 | f.Execute(530, 292);
|
---|
1405 | }
|
---|
1406 | ------------------------------------- */
|
---|
1407 |
|
---|
1408 | // Find Center of Camera for Caos and Tpoints
|
---|
1409 | Ring center(768/2, 576/2);
|
---|
1410 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
1411 | {
|
---|
1412 | const bool printl = fCaosPrint->IsEntryChecked(IDM_kCaosPrintLeds);
|
---|
1413 | const bool printr = fCaosPrint->IsEntryChecked(IDM_kCaosPrintRings);
|
---|
1414 | ZdAz pos;
|
---|
1415 | if (fCosy)
|
---|
1416 | pos = fCosy->GetPointingPos();
|
---|
1417 | center = fCaos->Run(img, printl, printr, pos, t, 50, 3.0);
|
---|
1418 |
|
---|
1419 | cout << "Caos Filter Camera center position: " << center.GetX() << " " << center.GetY() << endl;
|
---|
1420 |
|
---|
1421 | }
|
---|
1422 |
|
---|
1423 | // Find Star at Center---for Tpoint Procedure
|
---|
1424 | if (fDisplay->IsEntryChecked(IDM_kFindStar))
|
---|
1425 | ZdAz zdaz = FindStar(f, f2, center, t, 3.5, 70);
|
---|
1426 |
|
---|
1427 | byte zimg[kZOOM*kZOOM];
|
---|
1428 | for (int y=0; y<kZOOM; y++)
|
---|
1429 | for (int x=0; x<kZOOM; x++)
|
---|
1430 | zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768];
|
---|
1431 |
|
---|
1432 | fZoomImage->DrawImg(zimg);
|
---|
1433 |
|
---|
1434 | if (fCosy)
|
---|
1435 | {
|
---|
1436 | byte simg[(768/2-1)*(576/2-1)];
|
---|
1437 | for (int y=0; y<576/2-1; y++)
|
---|
1438 | for (int x=0; x<768/2-1; x++)
|
---|
1439 | simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4;
|
---|
1440 |
|
---|
1441 | fCosy->GetWin()->GetImage()->DrawImg(simg);
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 | // Find Center of Camera in Starfield Camera picture
|
---|
1445 |
|
---|
1446 | Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px]
|
---|
1447 | ZdAz sgcenterzdaz(0, 0); // Center of camera in SG picture [deg]
|
---|
1448 | // (0,0)_deg is at (53.2, 293.6)_px
|
---|
1449 | ZdAz star(0, 0); // Star on curtain in [deg]
|
---|
1450 |
|
---|
1451 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
1452 | {
|
---|
1453 | ZdAz pos;
|
---|
1454 | if (fCosy)
|
---|
1455 | pos = fCosy->GetPointingPos();
|
---|
1456 | sgcenter =
|
---|
1457 | fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 30, 3.0); // [px]
|
---|
1458 | const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px]
|
---|
1459 |
|
---|
1460 | // BE CAREFULL: This transformation is WRONG. It is just
|
---|
1461 | // a transformation of units, but this implies, that the
|
---|
1462 | // coordiante axis in both units look the same. This is
|
---|
1463 | // wrong exspecially near the zenith were az-lines are highly
|
---|
1464 | // curved around the zenith!
|
---|
1465 | sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 );
|
---|
1466 | sgcenterzdaz.Az((sgcenter.GetX()-53.2) * pixsize /3600 );
|
---|
1467 | #ifdef EXPERT
|
---|
1468 | cout << "- LEDs imply offset of Zd="
|
---|
1469 | << sgcenter.GetX()-53.2 << "pix Az="
|
---|
1470 | << sgcenter.GetY()-293.6<< "pix" << endl;
|
---|
1471 | #endif
|
---|
1472 | if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) {
|
---|
1473 | star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg]
|
---|
1474 | #ifdef EXPERT
|
---|
1475 | cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az="
|
---|
1476 | << star.Az()*60 << "'" << endl;
|
---|
1477 | #endif
|
---|
1478 | fSZdAz->SetCoordinates(star); // Misspointing found from Camera
|
---|
1479 | }
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | // Find Roque Lamp
|
---|
1483 |
|
---|
1484 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) {
|
---|
1485 |
|
---|
1486 | XY roquelamp(0,0);
|
---|
1487 |
|
---|
1488 | Double_t imageclean = 1.5;
|
---|
1489 | Double_t boxradius = 60;
|
---|
1490 | Double_t scalefactor = 1;
|
---|
1491 | XY searchcenter(768/2-1,576/2+25);
|
---|
1492 |
|
---|
1493 | roquelamp = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter);
|
---|
1494 |
|
---|
1495 | if (fOutRq) {
|
---|
1496 | ZdAz pos = fCosy->GetPointingPos();
|
---|
1497 |
|
---|
1498 | *fOutRq << "RoqueLampDirect: " << MTime(-1) << " "
|
---|
1499 | << pos.Zd() << " " << pos.Az() << " "
|
---|
1500 | << roquelamp.X() << " " << roquelamp.Y() << endl;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | cout << "Starguider Camera Center: " << sgcenter.GetX() << "," << sgcenter.GetY() << endl;
|
---|
1504 | cout << ">=>=>=> Roque Lamp found at: >=>=>=> (" << roquelamp.X() << ","
|
---|
1505 | << roquelamp.Y() << ") <=<=<=<" << endl;
|
---|
1506 |
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | // Find Spot on Camera Center in Starguider camera
|
---|
1510 |
|
---|
1511 | if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) {
|
---|
1512 |
|
---|
1513 | XY cameraspot(0,0);
|
---|
1514 |
|
---|
1515 | Double_t imageclean = 5;
|
---|
1516 | Double_t boxradius = 60;
|
---|
1517 | Double_t scalefactor = 1;
|
---|
1518 | // XY searchcenter(sgcenter.GetX(),sgcenter.GetY());
|
---|
1519 | XY searchcenter(60.,290.);
|
---|
1520 |
|
---|
1521 | cameraspot = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter);
|
---|
1522 |
|
---|
1523 | if (fOutRq) {
|
---|
1524 | ZdAz pos = fCosy->GetPointingPos();
|
---|
1525 |
|
---|
1526 | *fOutRq << "RoqueLampReflected: " << MTime(-1) << " "
|
---|
1527 | << pos.Zd() << " " << pos.Az() << " "
|
---|
1528 | << cameraspot.X() << " " << cameraspot.Y() << endl;
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | cout << ">>>>> Spot on Magic camera found at: >>>>> (" << cameraspot.X() << ","
|
---|
1532 | << cameraspot.Y() << ") <<<<<" << endl;
|
---|
1533 |
|
---|
1534 | f2.DrawCircle(sgcenter, 5.0, 0x0fa);
|
---|
1535 | f2.DrawCircle(sgcenter, 115.0, 0x0fa);
|
---|
1536 |
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 |
|
---|
1540 |
|
---|
1541 | // we calculate the offset given by the three ETH Leds visible to
|
---|
1542 | // the guide camera
|
---|
1543 | // This is an (inferior, obsolete) alternative to the StarCaosFilter
|
---|
1544 | // Led offset;
|
---|
1545 | // if (fDisplay->IsEntryChecked(IDM_kStargLEDFilter))
|
---|
1546 | // fStargLeds->Run(img,offset);
|
---|
1547 |
|
---|
1548 | // Position corresponding to the camera center (53.2, 293.6)
|
---|
1549 | Ring skycenter(392, 318);
|
---|
1550 | // MStarList spots;
|
---|
1551 |
|
---|
1552 | // we obtain a list of stars in the FOV from the SAO catalog
|
---|
1553 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1554 | {
|
---|
1555 | MTime time(*tm);
|
---|
1556 |
|
---|
1557 | XY xy = fCRaDec->GetCoordinates();
|
---|
1558 | fRaDec->Set(xy.X()*360/24, xy.Y());
|
---|
1559 |
|
---|
1560 | UpdatePosZoom();
|
---|
1561 |
|
---|
1562 | // Always call SetMjd first!
|
---|
1563 | fSao->SetPointing(time.GetMjd(), *fRaDec);
|
---|
1564 | fCZdAz->SetCoordinates(fSao->GetZdAz());
|
---|
1565 |
|
---|
1566 | MStarList stars;
|
---|
1567 | fSao->SetBox(230); // Region of interest around center
|
---|
1568 |
|
---|
1569 | // very careful: If center of camera cannot be determined
|
---|
1570 | // sgcenter jumps to (0,0)
|
---|
1571 | double sgcenteroffsetX = 0.0;
|
---|
1572 | double sgcenteroffsetY = 0.0;
|
---|
1573 | if ((double)sgcenter.GetX() > 0.0 && (double)sgcenter.GetY() > 0.0) {
|
---|
1574 | sgcenteroffsetX = sgcenter.GetX()-53.2;
|
---|
1575 | sgcenteroffsetY = sgcenter.GetY()-293.6;
|
---|
1576 | }
|
---|
1577 |
|
---|
1578 | // we obtain stars in the effective star FOV and draw them.
|
---|
1579 | // coordinates are video frame coords.
|
---|
1580 | // We determine the ideal starfield using camera sagging info
|
---|
1581 | // from the LEDs
|
---|
1582 |
|
---|
1583 | //cout << sgcenteroffsetX << " " << sgcenteroffsetY << endl;
|
---|
1584 |
|
---|
1585 | fSao->CalcStars(stars, 530, 292,
|
---|
1586 | -8+2-3+sgcenteroffsetX, //x: star<spot =>subs
|
---|
1587 | 31.5-3+sgcenteroffsetY); //y: star<spot =>subs?
|
---|
1588 |
|
---|
1589 | fSao->DrawStars(stars, cimg);
|
---|
1590 |
|
---|
1591 | // There are two corrections to the misspointing
|
---|
1592 | // - Sagging of the camera as measured with the LEDs
|
---|
1593 | // - Star not ideally centered on MAGIC Camera
|
---|
1594 |
|
---|
1595 | // Next we evaluate the offset given by the LEDs. This we obtain
|
---|
1596 | // in Zd/Az and add it to the tracking error.
|
---|
1597 |
|
---|
1598 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
1599 | {
|
---|
1600 | Leds spots;
|
---|
1601 | f.SetBox(230);
|
---|
1602 | // f.SetCut(1.5);
|
---|
1603 | double bright;
|
---|
1604 | f.ExecuteAndMark(spots, 530, 292, bright);
|
---|
1605 | MString txt;
|
---|
1606 | txt.Print("Sky Brightness: %.1f", bright);
|
---|
1607 | fSkyBright->SetText(txt);
|
---|
1608 |
|
---|
1609 | ULong_t color;
|
---|
1610 | gClient->GetColorByName("Green", color);
|
---|
1611 | if (bright> 60) gClient->GetColorByName("Yellow", color);
|
---|
1612 | if (bright> 85) gClient->GetColorByName("Orange", color);
|
---|
1613 | if (bright> 95) gClient->GetColorByName("Red", color);
|
---|
1614 | fSkyBright->SetBackgroundColor(color);
|
---|
1615 |
|
---|
1616 | bool rc = CalcTrackingError(spots, stars, fD, t);
|
---|
1617 |
|
---|
1618 | if (rc && (bright <= 1.75* fLastBright) && (bright < 110)) {
|
---|
1619 | fStatus = MDriveCom::kMonitoring;
|
---|
1620 | } else {
|
---|
1621 | fStatus = MDriveCom::kError;
|
---|
1622 | }
|
---|
1623 |
|
---|
1624 | if (fCosy)
|
---|
1625 | fPos = fCosy->GetPointingPos();
|
---|
1626 |
|
---|
1627 | if (fDisplay->IsEntryChecked(IDM_kStargAnalysis))
|
---|
1628 | fStargHistograms->Fill(spots, stars, fD,
|
---|
1629 | fSao->GetZdAz(), sgcenter, sgcenterzdaz,
|
---|
1630 | star, bright, fPos, t);
|
---|
1631 |
|
---|
1632 | fLastBright = bright;
|
---|
1633 |
|
---|
1634 | if (fCosy) {
|
---|
1635 | MDriveCom &com = *fCosy->GetDriveCom();
|
---|
1636 | com.SendStargReport(fStatus, fD, fSao->GetZdAz(), sgcenter, spots.GetEntries(), bright, time.GetMjd()); // Report
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | } //kStarguider
|
---|
1640 |
|
---|
1641 | f2.DrawCircle(skycenter, 2.0, 0x0a);
|
---|
1642 |
|
---|
1643 | f2.DrawCircle(skycenter, 7.4, 0x0a); //0.1deg
|
---|
1644 |
|
---|
1645 | f2.DrawCircle(skycenter, 2.06*.5*74.0, 0x0a);
|
---|
1646 | f2.DrawCircle(skycenter, 2.32*.5*74.0, 0x0a);
|
---|
1647 | f2.DrawCircle(skycenter, 3.50*.5*74.0, 0x0a);
|
---|
1648 | f2.DrawCircle(skycenter, 3.84*.5*74.0, 0x0a);
|
---|
1649 | } //CalcStars
|
---|
1650 |
|
---|
1651 | // Draw Circles around center of Camera
|
---|
1652 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
1653 | {
|
---|
1654 | f2.DrawCircle(center, 0x0a);
|
---|
1655 | f2.DrawCircle(center, 5.0,
|
---|
1656 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
1657 | f2.DrawCircle(center, 115.0, 0x0a);
|
---|
1658 | f2.DrawCircle(center, 230.0, 0x0a);
|
---|
1659 | f2.DrawCircle(center, 245.0, 0x0a);
|
---|
1660 | }
|
---|
1661 |
|
---|
1662 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
1663 | {
|
---|
1664 | f2.DrawCircle(sgcenter, 0x0a);
|
---|
1665 | f2.DrawCircle(sgcenter, 5.0,
|
---|
1666 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
1667 | }
|
---|
1668 |
|
---|
1669 | // if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1670 | // {
|
---|
1671 | // fSao->PaintImg(cimg, 768, 576);
|
---|
1672 | // const float r = 60*60/fSao->GetPixSize();
|
---|
1673 | // f2.DrawCircle(0.5*r, 0x0a);
|
---|
1674 | // f2.DrawCircle(1.0*r, 0x0a);
|
---|
1675 | // f2.DrawCircle(1.5*r, 0x0a);
|
---|
1676 | // }
|
---|
1677 |
|
---|
1678 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter) ||
|
---|
1679 | fDisplay->IsEntryChecked(IDM_kCatalog) ||
|
---|
1680 | fDisplay->IsEntryChecked(IDM_kFindStar) ||
|
---|
1681 | fOperations->IsEntryChecked(IDM_kRoqueLampAna))
|
---|
1682 | fImage->DrawColImg(img, cimg);
|
---|
1683 | else
|
---|
1684 | fImage->DrawImg(img);
|
---|
1685 | }
|
---|
1686 |
|
---|
1687 | void MStarguider::UpdatePosZoom()
|
---|
1688 | {
|
---|
1689 | MString txt;
|
---|
1690 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1691 | {
|
---|
1692 | // FIXME: Necessary?
|
---|
1693 | fSao->Now();
|
---|
1694 | AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg;
|
---|
1695 | if (aa.Az()<0)
|
---|
1696 | aa.Az(aa.Az()+360);
|
---|
1697 | txt.Print("%.1fd/%.1fd (%d, %d)", -aa.Alt(), aa.Az()-180, fDx, fDy);
|
---|
1698 | }
|
---|
1699 | else
|
---|
1700 | txt.Print("(%d, %d)", fDx, fDy);
|
---|
1701 | fPosZoom->SetText(txt);
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 | Bool_t MStarguider::HandleDoubleClick(Event_t *event)
|
---|
1705 | {
|
---|
1706 | const Int_t w = fImage->GetWidth();
|
---|
1707 | const Int_t h = fImage->GetHeight();
|
---|
1708 | const Int_t x = fImage->GetX();
|
---|
1709 | const Int_t y = fImage->GetY();
|
---|
1710 |
|
---|
1711 | if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h))
|
---|
1712 | return kTRUE;
|
---|
1713 |
|
---|
1714 | Int_t dx = event->fX-x;
|
---|
1715 | Int_t dy = event->fY-y;
|
---|
1716 |
|
---|
1717 | if (dx<kZOOM/4) dx=kZOOM/4;
|
---|
1718 | if (dy<kZOOM/4) dy=kZOOM/4;
|
---|
1719 | if (dx>766-kZOOM/4) dx=766-kZOOM/4;
|
---|
1720 | if (dy>574-kZOOM/4) dy=574-kZOOM/4;
|
---|
1721 |
|
---|
1722 | fDx = dx;
|
---|
1723 | fDy = dy;
|
---|
1724 |
|
---|
1725 | UpdatePosZoom();
|
---|
1726 | return kTRUE;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | void MStarguider::Print(TString &str, Double_t deg) const
|
---|
1730 | {
|
---|
1731 | Char_t sgn;
|
---|
1732 | UShort_t d, m, s;
|
---|
1733 |
|
---|
1734 | MAstro::Deg2Dms(deg, sgn, d, m, s);
|
---|
1735 |
|
---|
1736 | MString txt;
|
---|
1737 | str += txt.Print("%c %03d %02d %03d ", sgn, d, m, s);
|
---|
1738 | }
|
---|