1 | #undef EXPERT
|
---|
2 | #undef EXPERT
|
---|
3 |
|
---|
4 | #include "MStarguider.h"
|
---|
5 |
|
---|
6 | #include <fstream> // ifstream
|
---|
7 |
|
---|
8 | #include <TH2F.h>
|
---|
9 | #include <TGraph.h>
|
---|
10 | #include <TTimer.h>
|
---|
11 | #include <TEnv.h>
|
---|
12 | #include <TSystem.h>
|
---|
13 | #include <TFile.h> // temp writeout of histos
|
---|
14 | //#include <TSocket.h>
|
---|
15 |
|
---|
16 | #include <TGMenu.h>
|
---|
17 | #include <TGLabel.h>
|
---|
18 | #include <TGButton.h>
|
---|
19 | #include <TGSplitter.h> // TGHorizontal3DLine
|
---|
20 | #include <TGTextEntry.h>
|
---|
21 | #include <TGLayout.h>
|
---|
22 | #include "MString.h"
|
---|
23 |
|
---|
24 | #include "MLog.h"
|
---|
25 | #include "MLogManip.h"
|
---|
26 |
|
---|
27 | #include "MAstro.h"
|
---|
28 | #include "MString.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | #include "MCosy.h"
|
---|
32 | #include "MCaos.h"
|
---|
33 | // #include "MStargLeds.h"
|
---|
34 | #include "MStargHistograms.h"
|
---|
35 | #include "MDriveCom.h"
|
---|
36 |
|
---|
37 | #include "MGStarg.h"
|
---|
38 | #include "MGNumStars.h"
|
---|
39 |
|
---|
40 | #include "MGImage.h"
|
---|
41 | #include "MGCoordinates.h"
|
---|
42 |
|
---|
43 | #include "Camera.h"
|
---|
44 | #include "PngReader.h"
|
---|
45 |
|
---|
46 | #include "Led.h"
|
---|
47 | #include "Writer.h"
|
---|
48 | #include "FilterLed.h"
|
---|
49 | #include "MStarList.h"
|
---|
50 | #include "CaosFilter.h"
|
---|
51 | #include "StarCatalog.h"
|
---|
52 | #include "MGeomCamMagic.h"
|
---|
53 | #include "MAstroCamera.h"
|
---|
54 |
|
---|
55 | #include "MGCosy.h"
|
---|
56 |
|
---|
57 | ClassImp(MStarguider);
|
---|
58 |
|
---|
59 | using namespace std;
|
---|
60 |
|
---|
61 | enum {
|
---|
62 | IDM_kFilter,
|
---|
63 | IDM_kFindStar,
|
---|
64 | IDM_kCaosFilter,
|
---|
65 | IDM_kCatalog,
|
---|
66 | IDM_kStarguider,
|
---|
67 | IDM_kStart,
|
---|
68 | IDM_kStop,
|
---|
69 | IDM_kFileType,
|
---|
70 | IDM_kPPM,
|
---|
71 | IDM_kPNG,
|
---|
72 | IDM_kOnce,
|
---|
73 | IDM_kStretch,
|
---|
74 | IDM_kInput,
|
---|
75 | IDM_kChannel1,
|
---|
76 | IDM_kChannel2,
|
---|
77 | IDM_kChannel3,
|
---|
78 | IDM_kContinous,
|
---|
79 | IDM_kRate25ps,
|
---|
80 | IDM_kRate5ps,
|
---|
81 | IDM_kRate1s,
|
---|
82 | IDM_kRate5s,
|
---|
83 | IDM_kRate30s,
|
---|
84 | IDM_kRate1m,
|
---|
85 | IDM_kRate5m,
|
---|
86 | IDM_kSetup,
|
---|
87 | IDM_kLimMag3,
|
---|
88 | IDM_kLimMag4,
|
---|
89 | IDM_kLimMag5,
|
---|
90 | IDM_kLimMag6,
|
---|
91 | IDM_kLimMag7,
|
---|
92 | IDM_kLimMag8,
|
---|
93 | IDM_kLimMag9,
|
---|
94 | IDM_kPixSize,
|
---|
95 | IDM_kAngle,
|
---|
96 | IDM_kCut,
|
---|
97 | IDM_kInterpol250,
|
---|
98 | IDM_kInterpol125,
|
---|
99 | IDM_kInterpol50,
|
---|
100 | IDM_kInterpol25,
|
---|
101 | IDM_kInterpol10,
|
---|
102 | IDM_kInterpol5,
|
---|
103 | IDM_kInterpol2,
|
---|
104 | IDM_kInterpol1,
|
---|
105 | IDM_kCaosPrintRings,
|
---|
106 | IDM_kCaosPrintLeds,
|
---|
107 | IDM_kCaosAnalStart,
|
---|
108 | IDM_kCaosAnalStop,
|
---|
109 | IDM_kCaosWriteStart,
|
---|
110 | IDM_kCaosWriteStop,
|
---|
111 | IDM_kResetHistograms,
|
---|
112 | IDM_kStargAnalysis,
|
---|
113 | IDM_kStargCaosFilter,
|
---|
114 | IDM_kStarguiderMode,
|
---|
115 | IDM_kTpointMode
|
---|
116 |
|
---|
117 | };
|
---|
118 |
|
---|
119 | Bool_t MStarguider::HandleTimer(TTimer *t)
|
---|
120 | {
|
---|
121 | if (IsMapped())
|
---|
122 | {
|
---|
123 | fImage->DoRedraw();
|
---|
124 | fZoomImage->DoRedraw();
|
---|
125 | }
|
---|
126 |
|
---|
127 | if (fCosy && fCosy->GetWin()->IsMapped())
|
---|
128 | fCosy->GetWin()->GetImage()->DoRedraw();
|
---|
129 |
|
---|
130 | fGStarg->Update(fPos, fD);
|
---|
131 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
132 | fGNumStars->Update(fNumStarsDetected, fNumStarsCorrelated);
|
---|
133 |
|
---|
134 | return kTRUE;
|
---|
135 | }
|
---|
136 |
|
---|
137 | #define kZOOM 96
|
---|
138 |
|
---|
139 | XY MStarguider::GetCoordinates() const
|
---|
140 | {
|
---|
141 | return fPZdAz->GetCoordinates();
|
---|
142 | }
|
---|
143 |
|
---|
144 | void MStarguider::InitGui(Int_t channel)
|
---|
145 | {
|
---|
146 | fList = new MGList;
|
---|
147 | fList->SetOwner();
|
---|
148 |
|
---|
149 | const TGWindow *p=gClient->GetRoot();
|
---|
150 |
|
---|
151 | fChannel = new TGPopupMenu(p);
|
---|
152 | fChannel->AddEntry("Starfield Camera", IDM_kChannel1);
|
---|
153 | fChannel->AddEntry("TPoint Camera", IDM_kChannel2);
|
---|
154 | fChannel->AddEntry("Read from File", IDM_kChannel3);
|
---|
155 | if (channel<0)
|
---|
156 | fChannel->CheckEntry(IDM_kChannel3);
|
---|
157 | else
|
---|
158 | fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2);
|
---|
159 | fChannel->Associate(this);
|
---|
160 | fList->Add(fChannel);
|
---|
161 |
|
---|
162 | fFileType = new TGPopupMenu(p);
|
---|
163 | fFileType->AddEntry("PP&M", IDM_kPPM);
|
---|
164 | fFileType->AddEntry("&PNG", IDM_kPNG);
|
---|
165 | fFileType->CheckEntry(IDM_kPNG);
|
---|
166 | fFileType->Associate(this);
|
---|
167 | fList->Add(fFileType);
|
---|
168 |
|
---|
169 | fWriteType = new TGPopupMenu(p);
|
---|
170 | fWriteType->AddEntry("&Once", IDM_kOnce);
|
---|
171 | fWriteType->AddEntry("&Continous", IDM_kContinous);
|
---|
172 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
173 | fWriteType->Associate(this);
|
---|
174 | fList->Add(fWriteType);
|
---|
175 |
|
---|
176 | fWriteRate = new TGPopupMenu(p);
|
---|
177 | fWriteRate->AddEntry("25/s", IDM_kRate25ps);
|
---|
178 | fWriteRate->AddEntry("5/s", IDM_kRate5ps);
|
---|
179 | fWriteRate->AddEntry("1s", IDM_kRate1s);
|
---|
180 | fWriteRate->AddEntry("5s", IDM_kRate5s);
|
---|
181 | fWriteRate->AddEntry("30s", IDM_kRate30s);
|
---|
182 | fWriteRate->AddEntry("1min", IDM_kRate1m);
|
---|
183 | fWriteRate->AddEntry("5min", IDM_kRate5m);
|
---|
184 | fWriteRate->CheckEntry(IDM_kRate1m);
|
---|
185 | fWriteRate->Associate(this);
|
---|
186 | fList->Add(fWriteRate);
|
---|
187 |
|
---|
188 | fWrtRate = 25*60;
|
---|
189 |
|
---|
190 | fLimMag = new TGPopupMenu(p);
|
---|
191 | fLimMag->AddEntry("3", IDM_kLimMag3);
|
---|
192 | fLimMag->AddEntry("4", IDM_kLimMag4);
|
---|
193 | fLimMag->AddEntry("5", IDM_kLimMag5);
|
---|
194 | fLimMag->AddEntry("6", IDM_kLimMag6);
|
---|
195 | fLimMag->AddEntry("7", IDM_kLimMag7);
|
---|
196 | fLimMag->AddEntry("8", IDM_kLimMag8);
|
---|
197 | fLimMag->AddEntry("9", IDM_kLimMag9);
|
---|
198 | fLimMag->CheckEntry(IDM_kLimMag9);
|
---|
199 | fLimMag->Associate(this);
|
---|
200 | fList->Add(fLimMag);
|
---|
201 |
|
---|
202 | fSao->SetLimitMag(9.0);
|
---|
203 |
|
---|
204 | fInterpol = new TGPopupMenu(p);
|
---|
205 | fInterpol->AddEntry("250", IDM_kInterpol250);
|
---|
206 | fInterpol->AddEntry("125", IDM_kInterpol125);
|
---|
207 | fInterpol->AddEntry("50", IDM_kInterpol50);
|
---|
208 | fInterpol->AddEntry("25", IDM_kInterpol25);
|
---|
209 | fInterpol->AddEntry("10", IDM_kInterpol10);
|
---|
210 | fInterpol->AddEntry("5", IDM_kInterpol5);
|
---|
211 | fInterpol->AddEntry("2", IDM_kInterpol2);
|
---|
212 | fInterpol->AddEntry("Off", IDM_kInterpol1);
|
---|
213 | fInterpol->Associate(this);
|
---|
214 | fList->Add(fInterpol);
|
---|
215 |
|
---|
216 | TString disp=gVirtualX->DisplayName();
|
---|
217 | gLog << all << "Display: " << disp << endl;
|
---|
218 | if (disp.First(':')>=0)
|
---|
219 | disp=disp(0, disp.First(':'));
|
---|
220 |
|
---|
221 | if (disp.IsNull() || disp==(TString)"localhost")
|
---|
222 | {
|
---|
223 | fInterpol->CheckEntry(IDM_kInterpol5);
|
---|
224 | fIntRate = 50;
|
---|
225 | }
|
---|
226 | else
|
---|
227 | {
|
---|
228 | fInterpol->CheckEntry(IDM_kInterpol125);
|
---|
229 | fIntRate = 125;
|
---|
230 | }
|
---|
231 |
|
---|
232 | fCaosPrint = new TGPopupMenu(p);
|
---|
233 | fCaosPrint->AddEntry("&Leds", IDM_kCaosPrintLeds);
|
---|
234 | fCaosPrint->AddEntry("&Rings", IDM_kCaosPrintRings);
|
---|
235 | fCaosPrint->Associate(this);
|
---|
236 | fList->Add(fCaosPrint);
|
---|
237 |
|
---|
238 | fCaosWrite = new TGPopupMenu(p);
|
---|
239 | fCaosWrite->AddEntry("&Start", IDM_kCaosWriteStart);
|
---|
240 | fCaosWrite->AddEntry("Sto&p", IDM_kCaosWriteStop);
|
---|
241 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
242 | fCaosWrite->Associate(this);
|
---|
243 | fList->Add(fCaosWrite);
|
---|
244 |
|
---|
245 | fCaosAnalyse = new TGPopupMenu(p);
|
---|
246 | fCaosAnalyse->AddEntry("S&tart Analysis", IDM_kCaosAnalStart);
|
---|
247 | fCaosAnalyse->AddEntry("St&op Analysis", IDM_kCaosAnalStop);
|
---|
248 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
249 | fCaosAnalyse->Associate(this);
|
---|
250 | fList->Add(fCaosAnalyse);
|
---|
251 |
|
---|
252 | fMenu = new TGMenuBar(this, 0, 0, kHorizontalFrame);
|
---|
253 | fDisplay = fMenu->AddPopup("&Display");
|
---|
254 | fMode = fMenu->AddPopup("&Mode");
|
---|
255 | fWritePictures = fMenu->AddPopup("&WritePics");
|
---|
256 | fSetup = fMenu->AddPopup("&Setup");
|
---|
257 | fOperations = fMenu->AddPopup("&Operations");
|
---|
258 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
259 | AddFrame(fMenu);
|
---|
260 |
|
---|
261 | //
|
---|
262 | // Create Menu for MStarguider Display
|
---|
263 | //
|
---|
264 | //fDisplay = new MMGPopupMenu(p);
|
---|
265 | fDisplay->AddEntry("&Filter", IDM_kFilter);
|
---|
266 | fDisplay->AddEntry("Stretch", IDM_kStretch);
|
---|
267 | fDisplay->AddSeparator();
|
---|
268 | fDisplay->AddEntry("Find &Star", IDM_kFindStar);
|
---|
269 | fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter);
|
---|
270 | fDisplay->AddSeparator();
|
---|
271 | fDisplay->AddEntry("SAO &Catalog", IDM_kCatalog);
|
---|
272 | fDisplay->AddEntry("Starguider", IDM_kStarguider);
|
---|
273 | fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter);
|
---|
274 | fDisplay->AddSeparator();
|
---|
275 | if (channel>=0)
|
---|
276 | fDisplay->AddPopup("&Input", fChannel);
|
---|
277 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
278 | fDisplay->Associate(this);
|
---|
279 |
|
---|
280 | fMode->AddEntry("Starguider", IDM_kStarguiderMode);
|
---|
281 | fMode->AddEntry("Tpoint", IDM_kTpointMode);
|
---|
282 | fMode->Associate(this);
|
---|
283 |
|
---|
284 | fWritePictures->AddEntry("&Start", IDM_kStart);
|
---|
285 | fWritePictures->AddEntry("Sto&p", IDM_kStop);
|
---|
286 | fWritePictures->AddSeparator();
|
---|
287 | fWritePictures->AddPopup("File &Type", fFileType);
|
---|
288 | fWritePictures->AddPopup("&Write Type", fWriteType);
|
---|
289 | fWritePictures->AddPopup("Write &Rate", fWriteRate);
|
---|
290 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
291 | fWritePictures->Associate(this);
|
---|
292 |
|
---|
293 | fSetup->AddPopup("Lim. &Magnitude", fLimMag);
|
---|
294 | fSetup->AddPopup("Disp. &Interpolation", fInterpol);
|
---|
295 | fSetup->Associate(this);
|
---|
296 |
|
---|
297 | fOperations->AddEntry("Starguider Analysis", IDM_kStargAnalysis);
|
---|
298 | fOperations->DisableEntry(IDM_kStargAnalysis);
|
---|
299 | fOperations->Associate(this);
|
---|
300 |
|
---|
301 | fCaOs = new TGPopupMenu(p);
|
---|
302 | fCaOs->AddPopup("&Write", fCaosWrite);
|
---|
303 | fCaOs->AddPopup("&Print", fCaosPrint);
|
---|
304 | fCaOs->AddPopup("&Analyse", fCaosAnalyse);
|
---|
305 | fCaOs->Associate(this);
|
---|
306 | fList->Add(fCaOs);
|
---|
307 |
|
---|
308 | fGStarg = new MGStarg(this, 235);
|
---|
309 | fGStarg->DrawText("0.75'", "1.50'", "3.00'", "Mispointing [min]");
|
---|
310 | fGStarg->DrawHexagon();
|
---|
311 | fGStarg->Move(530,596+5);
|
---|
312 | fList->Add(fGStarg);
|
---|
313 |
|
---|
314 | //RA,Dec for catalog
|
---|
315 | fCRaDec = new MGCoordinates(this, kETypeRaDec);
|
---|
316 | fCRaDec->Move(4, fMenu->GetDefaultHeight()+584);
|
---|
317 | AddFrame(fCRaDec);
|
---|
318 |
|
---|
319 | //telescope position
|
---|
320 | fCZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
321 | fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+597);
|
---|
322 | AddFrame(fCZdAz);
|
---|
323 |
|
---|
324 | //starguider position
|
---|
325 | fPZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
326 | fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+640);
|
---|
327 | AddFrame(fPZdAz);
|
---|
328 |
|
---|
329 | //mispointing
|
---|
330 | fDZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
331 | fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+683);
|
---|
332 | AddFrame(fDZdAz);
|
---|
333 |
|
---|
334 | fSZdAz = new MGCoordinates(this, kETypeZdAz, 2);
|
---|
335 | fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+795);
|
---|
336 | AddFrame(fSZdAz);
|
---|
337 |
|
---|
338 | fGNumStars = new MGNumStars(this, 235);
|
---|
339 | fGNumStars->DrawText("Number of stars");
|
---|
340 | fGNumStars->Move(278, fMenu->GetDefaultHeight()+713);
|
---|
341 | fList->Add(fGNumStars);
|
---|
342 |
|
---|
343 | fTPoint = new TGTextButton(this, "TPoint");
|
---|
344 | fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
|
---|
345 | fTPoint->AllowStayDown(kTRUE);
|
---|
346 | AddFrame(fTPoint);
|
---|
347 |
|
---|
348 | fStargTPoint = new TGTextButton(this, "StargTPoint");
|
---|
349 | fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
|
---|
350 | fStargTPoint->AllowStayDown(kTRUE);
|
---|
351 | AddFrame(fStargTPoint);
|
---|
352 |
|
---|
353 | fFps = new TGLabel(this, "---fps");
|
---|
354 | fFps->SetTextJustify(kTextRight);
|
---|
355 | fFps->Move(650-495, fMenu->GetDefaultHeight()+714+23);
|
---|
356 | AddFrame(fFps);
|
---|
357 |
|
---|
358 | fPosZoom = new TGLabel(this, "(----, ----) ----.--d/----.--d");
|
---|
359 | fPosZoom->SetTextJustify(kTextLeft);
|
---|
360 | fPosZoom->Move(4, fMenu->GetDefaultHeight()+765);
|
---|
361 | AddFrame(fPosZoom);
|
---|
362 |
|
---|
363 | fSkyBright = new TGLabel(this, "Sky Brightness: --- ");
|
---|
364 | fSkyBright->SetTextJustify(kTextLeft);
|
---|
365 | fSkyBright->Move(4, fMenu->GetDefaultHeight()+785);
|
---|
366 | AddFrame(fSkyBright);
|
---|
367 |
|
---|
368 | TGLabel *l = new TGLabel(this, "deg");
|
---|
369 | l->SetTextJustify(kTextLeft);
|
---|
370 | l->Move(606-412, fMenu->GetDefaultHeight()+669);
|
---|
371 | AddFrame(l);
|
---|
372 |
|
---|
373 | l = new TGLabel(this, "arcsec/pix");
|
---|
374 | l->SetTextJustify(kTextLeft);
|
---|
375 | l->Move(606-412, fMenu->GetDefaultHeight()+692);
|
---|
376 | AddFrame(l);
|
---|
377 |
|
---|
378 | l = new TGLabel(this, "sigma");
|
---|
379 | l->SetTextJustify(kTextLeft);
|
---|
380 | l->Move(606-412, fMenu->GetDefaultHeight()+715);
|
---|
381 | AddFrame(l);
|
---|
382 |
|
---|
383 | fCZdAzText = new TGLabel(this, "Zd/Az telescope pointing at");
|
---|
384 | fCZdAzText->SetTextJustify(kTextLeft);
|
---|
385 | fCZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+584-5);
|
---|
386 | AddFrame(fCZdAzText);
|
---|
387 |
|
---|
388 | fPZdAzText = new TGLabel(this, "Zd/Az starguider pointing at");
|
---|
389 | fPZdAzText->SetTextJustify(kTextLeft);
|
---|
390 | fPZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+630+20-5-23);
|
---|
391 | AddFrame(fPZdAzText);
|
---|
392 |
|
---|
393 | fDZdAzText = new TGLabel(this, "Zd/Az mispointing");
|
---|
394 | fDZdAzText->SetTextJustify(kTextLeft);
|
---|
395 | fDZdAzText->Move(240+12+20+7, fMenu->GetDefaultHeight()+676+2*20-5-46);
|
---|
396 | AddFrame(fDZdAzText);
|
---|
397 |
|
---|
398 | // Set input box for rotation angle
|
---|
399 | fAngle = new TGTextEntry(this, " ", IDM_kAngle);
|
---|
400 | fAngle->SetAlignment(kTextCenterX);
|
---|
401 | fAngle->Move(547-410, fMenu->GetDefaultHeight()+667);
|
---|
402 | AddFrame(fAngle);
|
---|
403 |
|
---|
404 | SetRotationAngle(-0.2);
|
---|
405 |
|
---|
406 | // Set input box for pixel size
|
---|
407 | fPixSize = new TGTextEntry(this, " ", IDM_kPixSize);
|
---|
408 | fPixSize->SetAlignment(kTextCenterX);
|
---|
409 | fPixSize->Move(547-410, fMenu->GetDefaultHeight()+690);
|
---|
410 | AddFrame(fPixSize);
|
---|
411 |
|
---|
412 | SetPixSize(48.9);
|
---|
413 |
|
---|
414 | // Set input box for cleaning cut
|
---|
415 | fCut = new TGTextEntry(this, " ", IDM_kCut);
|
---|
416 | fCut->SetAlignment(kTextCenterX);
|
---|
417 | fCut->Move(547-410, fMenu->GetDefaultHeight()+713);
|
---|
418 | AddFrame(fCut);
|
---|
419 |
|
---|
420 | SetCut(3.0);
|
---|
421 |
|
---|
422 | // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
|
---|
423 | // AddFrame(fLineSep, new TGLayoutHints (kLHintsNormal | kLHintsExpandX));
|
---|
424 | // fList->Add(fLineSep);
|
---|
425 |
|
---|
426 | //
|
---|
427 | // Create Image Display
|
---|
428 | //
|
---|
429 | fZoomImage = new MGImage(this, kZOOM, kZOOM);
|
---|
430 | // fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2);
|
---|
431 | fZoomImage->Move(4, 700-kZOOM-2+85);
|
---|
432 | AddFrame(fZoomImage);
|
---|
433 |
|
---|
434 | fImage = new MGImage(this, 768, 576);
|
---|
435 | fImage->Move(0, fMenu->GetDefaultHeight());
|
---|
436 | AddFrame(fImage);
|
---|
437 |
|
---|
438 | const Int_t w = 768;
|
---|
439 | const Int_t h = 840;
|
---|
440 | SetWMSizeHints(w, h, w, h, 1, 1); // set the smallest and biggest size of the Main frame
|
---|
441 |
|
---|
442 | //
|
---|
443 | // Make everything visible
|
---|
444 | //
|
---|
445 | SetWindowName("MStarguider Main Window");
|
---|
446 | SetIconName("MStarguider");
|
---|
447 |
|
---|
448 | MapSubwindows();
|
---|
449 | fTPoint->UnmapWindow();
|
---|
450 | fStargTPoint->UnmapWindow();
|
---|
451 | fGStarg->UnmapWindow();
|
---|
452 | fGNumStars->UnmapWindow();
|
---|
453 | fCRaDec->UnmapWindow();
|
---|
454 | fCZdAz->UnmapWindow();
|
---|
455 | fCZdAzText->UnmapWindow();
|
---|
456 | fPZdAz->UnmapWindow();
|
---|
457 | fPZdAzText->UnmapWindow();
|
---|
458 | fDZdAz->UnmapWindow();
|
---|
459 | fDZdAzText->UnmapWindow();
|
---|
460 | fSZdAz->UnmapWindow();
|
---|
461 | fSkyBright->UnmapWindow();
|
---|
462 | MapWindow();
|
---|
463 |
|
---|
464 |
|
---|
465 | //IconifyWindow();
|
---|
466 |
|
---|
467 | //------------------------------------------------------------
|
---|
468 | // XY xy(3.819444, 24.05333);
|
---|
469 | // fCRaDec->SetCoordinates(xy);
|
---|
470 | // fRaDec->Set(xy.X()*360/24, xy.Y());
|
---|
471 | //------------------------------------------------------------
|
---|
472 | }
|
---|
473 |
|
---|
474 | MStarguider::MStarguider(MObservatory::LocationName_t obs, Int_t channel)
|
---|
475 | : TGMainFrame(gClient->GetRoot(), 768, 840),
|
---|
476 | fNumStarsDetected(0),
|
---|
477 | fNumStarsCorrelated(0),
|
---|
478 | fCosy(NULL),
|
---|
479 | fOutTp(0),
|
---|
480 | fOutStargTp(0),
|
---|
481 | fOutRq(0),
|
---|
482 | fDx((768-kZOOM)/2),
|
---|
483 | fDy((512-kZOOM)/2),
|
---|
484 | fStatus(MDriveCom::kStandby),
|
---|
485 | fRadius(200),
|
---|
486 | fTPointFromCC(0)
|
---|
487 | {
|
---|
488 | gLog << warn << " #### FIXME: Make MCaos Thread safe!" << endl;
|
---|
489 |
|
---|
490 | // This means that all objects added with AddFrame are deleted
|
---|
491 | // automatically, including all LayoutHints.
|
---|
492 | SetCleanup();
|
---|
493 |
|
---|
494 | fSao = new StarCatalog(obs);
|
---|
495 | fRaDec = new RaDec(180, 40);
|
---|
496 |
|
---|
497 | fCaos = new MCaos;
|
---|
498 | fStargCaos = new MCaos;
|
---|
499 |
|
---|
500 | fStargHistograms = new MStargHistograms();
|
---|
501 |
|
---|
502 | InitGui(channel);
|
---|
503 |
|
---|
504 | fTimer=new TTimer(this, 1000/25); // 40ms
|
---|
505 | fTimer->TurnOn();
|
---|
506 |
|
---|
507 | fTime.Now();
|
---|
508 |
|
---|
509 | fTimeFromTp.Clear();
|
---|
510 | fAltAzOffsetFromTp = AltAz(-1000,-1000);
|
---|
511 |
|
---|
512 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE);
|
---|
513 |
|
---|
514 | if (channel<0)
|
---|
515 | fGetter = new PngReader(*this);
|
---|
516 | else
|
---|
517 | fGetter = new Camera(*this, channel);
|
---|
518 | }
|
---|
519 |
|
---|
520 | void MStarguider::SetRotationAngle(Double_t angle)
|
---|
521 | {
|
---|
522 | fSao->SetRotationAngle(angle);
|
---|
523 |
|
---|
524 | TString txt;
|
---|
525 | txt += angle;
|
---|
526 |
|
---|
527 | fAngle->SetText(txt);
|
---|
528 | }
|
---|
529 |
|
---|
530 | void MStarguider::SetPixSize(Double_t size)
|
---|
531 | {
|
---|
532 | fSao->SetPixSize(size);
|
---|
533 |
|
---|
534 | TString txt;
|
---|
535 | txt += size;
|
---|
536 |
|
---|
537 | fPixSize->SetText(txt);
|
---|
538 | }
|
---|
539 |
|
---|
540 | void MStarguider::SetCut(Double_t cut)
|
---|
541 | {
|
---|
542 | TString txt;
|
---|
543 | txt += cut;
|
---|
544 |
|
---|
545 | fCut->SetText(txt);
|
---|
546 | }
|
---|
547 |
|
---|
548 | void MStarguider::SetupEnv(TEnv &env)
|
---|
549 | {
|
---|
550 | fCaos->ReadEnv(env, "TPointLeds", kTRUE);
|
---|
551 | fStargCaos->ReadEnv(env, "StarguiderLeds", kTRUE);
|
---|
552 |
|
---|
553 | SetRotationAngle(env.GetValue("Starguider.RotationAngle", fSao->GetRotationAngle()));
|
---|
554 | SetCut(env.GetValue("Starguider.CleaningLevel", atof(fCut->GetText())));
|
---|
555 |
|
---|
556 | SetPixSize(env.GetValue("StarguiderLeds.ArcsecPerPixel", fSao->GetPixSize()));
|
---|
557 |
|
---|
558 | fRadius = env.GetValue("Leds.Radius", fRadius);
|
---|
559 | }
|
---|
560 |
|
---|
561 | MStarguider::~MStarguider()
|
---|
562 | {
|
---|
563 | fGetter->ExitLoop();
|
---|
564 | delete fGetter;
|
---|
565 |
|
---|
566 | gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE);
|
---|
567 |
|
---|
568 | fTimer->TurnOff();
|
---|
569 | delete fTimer;
|
---|
570 |
|
---|
571 | delete fList;
|
---|
572 |
|
---|
573 | delete fCaos;
|
---|
574 | delete fStargCaos;
|
---|
575 | delete fStargHistograms;
|
---|
576 | delete fSao;
|
---|
577 | delete fRaDec;
|
---|
578 |
|
---|
579 | if (fOutTp)
|
---|
580 | delete fOutTp;
|
---|
581 |
|
---|
582 | if (fOutStargTp)
|
---|
583 | delete fOutStargTp;
|
---|
584 |
|
---|
585 | if (fOutRq)
|
---|
586 | delete fOutRq;
|
---|
587 |
|
---|
588 | gLog << inf2 << "Camera Display destroyed." << endl;
|
---|
589 | }
|
---|
590 |
|
---|
591 | void MStarguider::Layout()
|
---|
592 | {
|
---|
593 | // Resize(GetDefaultSize());
|
---|
594 | }
|
---|
595 |
|
---|
596 | void MStarguider::CloseWindow()
|
---|
597 | {
|
---|
598 | gLog << inf2 << "EventDisplay::CloseWindow: Exit Application Loop." << endl;
|
---|
599 |
|
---|
600 | //fClient.ExitLoop();
|
---|
601 | // cout << "FIXME: ExitLoop not called!!!!!!" << endl;
|
---|
602 | fGetter->ExitLoop();
|
---|
603 | gSystem->ExitLoop();
|
---|
604 | }
|
---|
605 |
|
---|
606 | void MStarguider::SwitchOff(TGPopupMenu *p, UInt_t id)
|
---|
607 | {
|
---|
608 | p->UnCheckEntry(id);
|
---|
609 | p->DisableEntry(id);
|
---|
610 | }
|
---|
611 |
|
---|
612 | void MStarguider::SetChannel()
|
---|
613 | {
|
---|
614 | if (fChannel->IsEntryChecked(IDM_kChannel3))
|
---|
615 | {
|
---|
616 | if (dynamic_cast<PngReader*>(fGetter)==0)
|
---|
617 | {
|
---|
618 | delete fGetter;
|
---|
619 | fGetter=new PngReader(*this);
|
---|
620 | }
|
---|
621 | }
|
---|
622 | else
|
---|
623 | {
|
---|
624 | const Int_t ch = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
625 | if (dynamic_cast<Camera*>(fGetter)==0)
|
---|
626 | {
|
---|
627 | delete fGetter;
|
---|
628 | fGetter = new Camera(*this, ch);
|
---|
629 | }
|
---|
630 | else
|
---|
631 | fGetter->SetChannel(ch);
|
---|
632 | }
|
---|
633 | }
|
---|
634 |
|
---|
635 | void MStarguider::Toggle(TGPopupMenu *p, UInt_t id)
|
---|
636 | {
|
---|
637 | if (p->IsEntryChecked(id))
|
---|
638 | p->UnCheckEntry(id);
|
---|
639 | else
|
---|
640 | p->CheckEntry(id);
|
---|
641 | }
|
---|
642 |
|
---|
643 | void MStarguider::ToggleStargAnalysis()
|
---|
644 | {
|
---|
645 | if (fOperations->IsEntryChecked(IDM_kStargAnalysis))
|
---|
646 | fStargHistograms->OpenFile();
|
---|
647 | else
|
---|
648 | fStargHistograms->CloseFile();
|
---|
649 | }
|
---|
650 |
|
---|
651 | void MStarguider::ToggleFindStar()
|
---|
652 | {
|
---|
653 | if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy)
|
---|
654 | fTPoint->MapWindow();
|
---|
655 | else
|
---|
656 | {
|
---|
657 | fTPoint->UnmapWindow();
|
---|
658 | fTPoint->SetDown(kFALSE);
|
---|
659 | }
|
---|
660 | }
|
---|
661 |
|
---|
662 | void MStarguider::ToggleStarguider()
|
---|
663 | {
|
---|
664 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
665 | {
|
---|
666 | fLastBright = 0xff;
|
---|
667 |
|
---|
668 | fChannel->EnableEntry(IDM_kChannel1);
|
---|
669 | fDisplay->DisableEntry(IDM_kFindStar);
|
---|
670 | fDisplay->DisableEntry(IDM_kCaosFilter);
|
---|
671 | fOperations->EnableEntry(IDM_kStargAnalysis);
|
---|
672 |
|
---|
673 | fStargTPoint->MapWindow();
|
---|
674 |
|
---|
675 | fPZdAz->MapWindow();
|
---|
676 | fDZdAz->MapWindow();
|
---|
677 | fSkyBright->MapWindow();
|
---|
678 |
|
---|
679 | for (int i=IDM_kLimMag3; i<=IDM_kLimMag9; i++)
|
---|
680 | fLimMag->UnCheckEntry(i);
|
---|
681 | fLimMag->CheckEntry(IDM_kLimMag9);
|
---|
682 | fSao->SetLimitMag(9.0);
|
---|
683 |
|
---|
684 | for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
|
---|
685 | fInterpol->UnCheckEntry(i);
|
---|
686 | fInterpol->CheckEntry(IDM_kInterpol125);
|
---|
687 | fIntRate = 125;
|
---|
688 |
|
---|
689 | //catalog
|
---|
690 | fDisplay->CheckEntry(IDM_kCatalog);
|
---|
691 | fCRaDec->MapWindow();
|
---|
692 | fCZdAz->MapWindow();
|
---|
693 | fCZdAzText->MapWindow();
|
---|
694 |
|
---|
695 | fPZdAz->MapWindow();
|
---|
696 | fPZdAzText->MapWindow();
|
---|
697 | fDZdAz->MapWindow();
|
---|
698 | fDZdAzText->MapWindow();
|
---|
699 |
|
---|
700 | fGStarg->MapWindow();
|
---|
701 | fGNumStars->MapWindow();
|
---|
702 |
|
---|
703 | SwitchOff(fChannel, IDM_kChannel2);
|
---|
704 | fChannel->CheckEntry(IDM_kChannel1);
|
---|
705 |
|
---|
706 | }
|
---|
707 | else
|
---|
708 | {
|
---|
709 | fStatus = MDriveCom::kStandby;
|
---|
710 |
|
---|
711 | fStargTPoint->UnmapWindow();
|
---|
712 | fStargTPoint->SetDown(kFALSE);
|
---|
713 |
|
---|
714 | fPZdAz->UnmapWindow();
|
---|
715 | fPZdAzText->UnmapWindow();
|
---|
716 | fDZdAz->UnmapWindow();
|
---|
717 | fDZdAzText->UnmapWindow();
|
---|
718 | fSkyBright->UnmapWindow();
|
---|
719 | //catalog
|
---|
720 | fCRaDec->UnmapWindow();
|
---|
721 | fCZdAz->UnmapWindow();
|
---|
722 | fCZdAzText->UnmapWindow();
|
---|
723 | fDisplay->UnCheckEntry(IDM_kCatalog);
|
---|
724 |
|
---|
725 | fGStarg->UnmapWindow();
|
---|
726 | fGNumStars->UnmapWindow();
|
---|
727 |
|
---|
728 | fChannel->EnableEntry(IDM_kChannel2);
|
---|
729 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
730 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
731 | fOperations->DisableEntry(IDM_kStargAnalysis);
|
---|
732 | }
|
---|
733 |
|
---|
734 | SetChannel();
|
---|
735 | //gSystem->Unlink("tracking_error.txt");
|
---|
736 | }
|
---|
737 |
|
---|
738 | void MStarguider::ToggleCaosFilter()
|
---|
739 | {
|
---|
740 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
741 | {
|
---|
742 | if (!fMode->IsEntryChecked(IDM_kStarguiderMode)
|
---|
743 | && !fMode->IsEntryChecked(IDM_kTpointMode))
|
---|
744 | fMenu->AddPopup("&CaOs", fCaOs, NULL);
|
---|
745 |
|
---|
746 | SwitchOff(fDisplay, IDM_kStarguider);
|
---|
747 | SwitchOff(fDisplay, IDM_kStargCaosFilter);
|
---|
748 | }
|
---|
749 | else
|
---|
750 | {
|
---|
751 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintLeds);
|
---|
752 | fCaosWrite->UnCheckEntry(IDM_kCaosPrintRings);
|
---|
753 |
|
---|
754 | if (fCaosAnalyse->IsEntryEnabled(IDM_kCaosAnalStop))
|
---|
755 | {
|
---|
756 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
757 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
758 | fCaos->DeleteHistograms();
|
---|
759 | }
|
---|
760 | if (fCaosWrite->IsEntryEnabled(IDM_kCaosWriteStop))
|
---|
761 | {
|
---|
762 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
763 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
764 | fCaos->CloseFile();
|
---|
765 | }
|
---|
766 | fMenu->RemovePopup("CaOs");
|
---|
767 |
|
---|
768 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
769 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
770 | }
|
---|
771 | fMenu->Resize(fMenu->GetDefaultSize());
|
---|
772 | MapSubwindows(); // maps everything, but we don't want that
|
---|
773 | fTPoint->UnmapWindow();
|
---|
774 | fStargTPoint->UnmapWindow();
|
---|
775 | fGStarg->UnmapWindow();
|
---|
776 | fGNumStars->UnmapWindow();
|
---|
777 | fCRaDec->UnmapWindow();
|
---|
778 | fCZdAz->UnmapWindow();
|
---|
779 | fCZdAzText->UnmapWindow();
|
---|
780 | fPZdAz->UnmapWindow();
|
---|
781 | fPZdAzText->UnmapWindow();
|
---|
782 | fDZdAz->UnmapWindow();
|
---|
783 | fDZdAzText->UnmapWindow();
|
---|
784 | fSZdAz->UnmapWindow();
|
---|
785 | fSkyBright->UnmapWindow();
|
---|
786 | MapWindow();
|
---|
787 | }
|
---|
788 |
|
---|
789 | Bool_t MStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
790 | {
|
---|
791 | switch (GET_MSG(msg))
|
---|
792 | {
|
---|
793 | case kC_TEXTENTRY:
|
---|
794 | if (GET_SUBMSG(msg)==kTE_ENTER)
|
---|
795 | switch (mp1)
|
---|
796 | {
|
---|
797 | case IDM_kPixSize:
|
---|
798 | {
|
---|
799 | const Float_t pixsize = atof(fPixSize->GetText());
|
---|
800 | gLog << all << "Pixel Size changed to " << pixsize << "\"/pix" << endl;
|
---|
801 | fSao->SetPixSize(pixsize);
|
---|
802 | return kTRUE;
|
---|
803 | }
|
---|
804 | case IDM_kAngle:
|
---|
805 | {
|
---|
806 | const Float_t angle = atof(fAngle->GetText());
|
---|
807 | gLog << all << "Rotation Angle changed to " << angle << "deg" << endl;
|
---|
808 | fSao->SetRotationAngle(angle);
|
---|
809 | return kTRUE;
|
---|
810 | }
|
---|
811 | case IDM_kCut:
|
---|
812 | {
|
---|
813 | const Float_t cut = atof(fCut->GetText());
|
---|
814 | gLog << all << "Starguider cleaning level changed to " << cut << " sigma." << endl;
|
---|
815 | return kTRUE;
|
---|
816 | }
|
---|
817 | }
|
---|
818 | return kTRUE;
|
---|
819 |
|
---|
820 | case kC_COMMAND:
|
---|
821 | switch (GET_SUBMSG(msg))
|
---|
822 | {
|
---|
823 | case kCM_MENU:
|
---|
824 | switch (mp1)
|
---|
825 | {
|
---|
826 | case IDM_kCatalog:
|
---|
827 | Toggle(fDisplay, IDM_kCatalog);
|
---|
828 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
829 | {
|
---|
830 | fCRaDec->MapWindow();
|
---|
831 | fCZdAz->MapWindow();
|
---|
832 | fCZdAzText->MapWindow();
|
---|
833 | }
|
---|
834 | else
|
---|
835 | {
|
---|
836 | fCRaDec->UnmapWindow();
|
---|
837 | fCZdAz->UnmapWindow();
|
---|
838 | fCZdAzText->UnmapWindow();
|
---|
839 | }
|
---|
840 | return kTRUE;
|
---|
841 |
|
---|
842 | case IDM_kStarguider:
|
---|
843 | Toggle(fDisplay, IDM_kStarguider);
|
---|
844 | ToggleStarguider();
|
---|
845 | return kTRUE;
|
---|
846 |
|
---|
847 | case IDM_kStargAnalysis:
|
---|
848 | Toggle(fOperations, IDM_kStargAnalysis);
|
---|
849 | ToggleStargAnalysis();
|
---|
850 | return kTRUE;
|
---|
851 |
|
---|
852 | case IDM_kStarguiderMode:
|
---|
853 | Toggle(fMode, IDM_kStarguiderMode);
|
---|
854 |
|
---|
855 | if (fMode->IsEntryChecked(IDM_kStarguiderMode))
|
---|
856 | {
|
---|
857 | //uncheck not needed items
|
---|
858 | //general
|
---|
859 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
860 | SwitchOff(fChannel, IDM_kChannel3);
|
---|
861 | SwitchOff(fOperations, IDM_kStargAnalysis);
|
---|
862 |
|
---|
863 | //tpoint
|
---|
864 | SwitchOff(fDisplay, IDM_kFindStar);
|
---|
865 | ToggleFindStar();
|
---|
866 | SwitchOff(fDisplay, IDM_kCaosFilter);
|
---|
867 | ToggleCaosFilter();
|
---|
868 | fMode->UnCheckEntry(IDM_kTpointMode);
|
---|
869 |
|
---|
870 | //enable starguider items
|
---|
871 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
872 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
873 | fDisplay->EnableEntry(IDM_kCatalog);
|
---|
874 |
|
---|
875 | //check needed items
|
---|
876 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
877 | fDisplay->CheckEntry(IDM_kStargCaosFilter);
|
---|
878 | fDisplay->CheckEntry(IDM_kStarguider);
|
---|
879 | ToggleStarguider();
|
---|
880 | }
|
---|
881 | else
|
---|
882 | {
|
---|
883 | //uncheck
|
---|
884 | //starguider items
|
---|
885 | fDisplay->UnCheckEntry(IDM_kStargCaosFilter);
|
---|
886 | fDisplay->UnCheckEntry(IDM_kStarguider);
|
---|
887 | ToggleStarguider();
|
---|
888 |
|
---|
889 | //general
|
---|
890 | fDisplay->UnCheckEntry(IDM_kCatalog);
|
---|
891 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
892 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
893 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
894 | fChannel->EnableEntry(IDM_kChannel3);
|
---|
895 | }
|
---|
896 | return kTRUE;
|
---|
897 |
|
---|
898 | case IDM_kTpointMode:
|
---|
899 | Toggle(fMode, IDM_kTpointMode);
|
---|
900 |
|
---|
901 | if (fMode->IsEntryChecked(IDM_kTpointMode))
|
---|
902 | {
|
---|
903 | //unchecking not needed items
|
---|
904 | //general
|
---|
905 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
906 | SwitchOff(fChannel, IDM_kChannel3);
|
---|
907 |
|
---|
908 | //from starguider
|
---|
909 | SwitchOff(fDisplay, IDM_kStargCaosFilter);
|
---|
910 | SwitchOff(fDisplay, IDM_kCatalog);
|
---|
911 | SwitchOff(fDisplay, IDM_kStarguider);
|
---|
912 | ToggleStarguider();
|
---|
913 | fMode->UnCheckEntry(IDM_kStarguiderMode);
|
---|
914 | SwitchOff(fOperations, IDM_kStargAnalysis);
|
---|
915 | ToggleStargAnalysis();
|
---|
916 |
|
---|
917 | //switch camera
|
---|
918 | SwitchOff(fChannel, IDM_kChannel1);
|
---|
919 | fChannel->CheckEntry(IDM_kChannel2);
|
---|
920 |
|
---|
921 | SetChannel();
|
---|
922 |
|
---|
923 | //checking needed items
|
---|
924 | fDisplay->CheckEntry(IDM_kStretch);
|
---|
925 | fDisplay->CheckEntry(IDM_kCaosFilter);
|
---|
926 | ToggleCaosFilter();
|
---|
927 | fDisplay->CheckEntry(IDM_kFindStar);
|
---|
928 | ToggleFindStar();
|
---|
929 | }
|
---|
930 | else
|
---|
931 | {
|
---|
932 | //enable
|
---|
933 | //starguider items
|
---|
934 | fDisplay->EnableEntry(IDM_kStargCaosFilter);
|
---|
935 | fDisplay->EnableEntry(IDM_kCatalog);
|
---|
936 | fDisplay->EnableEntry(IDM_kStarguider);
|
---|
937 | fOperations->EnableEntry(IDM_kStargAnalysis);
|
---|
938 |
|
---|
939 | //general
|
---|
940 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
941 | fChannel->EnableEntry(IDM_kChannel1);
|
---|
942 | fChannel->EnableEntry(IDM_kChannel3);
|
---|
943 |
|
---|
944 | //tpoint
|
---|
945 | fDisplay->UnCheckEntry(IDM_kCaosFilter);
|
---|
946 | ToggleCaosFilter();
|
---|
947 | fDisplay->UnCheckEntry(IDM_kFindStar);
|
---|
948 | ToggleFindStar();
|
---|
949 | }
|
---|
950 | return kTRUE;
|
---|
951 |
|
---|
952 | case IDM_kFilter:
|
---|
953 | Toggle(fDisplay, IDM_kFilter);
|
---|
954 | return kTRUE;
|
---|
955 |
|
---|
956 | case IDM_kFindStar:
|
---|
957 | Toggle(fDisplay, IDM_kFindStar);
|
---|
958 | ToggleFindStar();
|
---|
959 | return kTRUE;
|
---|
960 |
|
---|
961 | case IDM_kStretch:
|
---|
962 | Toggle(fDisplay, IDM_kStretch);
|
---|
963 | return kTRUE;
|
---|
964 |
|
---|
965 | case IDM_kCaosFilter:
|
---|
966 | Toggle(fDisplay, IDM_kCaosFilter);
|
---|
967 | ToggleCaosFilter();
|
---|
968 | return kTRUE;
|
---|
969 |
|
---|
970 | case IDM_kStargCaosFilter:
|
---|
971 | Toggle(fDisplay, IDM_kStargCaosFilter);
|
---|
972 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
973 | {
|
---|
974 | SwitchOff(fDisplay, IDM_kCaosFilter);
|
---|
975 | SwitchOff(fDisplay, IDM_kFindStar);
|
---|
976 | SwitchOff(fDisplay, IDM_kFilter);
|
---|
977 | }
|
---|
978 | else
|
---|
979 | {
|
---|
980 | fDisplay->EnableEntry(IDM_kFilter);
|
---|
981 | fDisplay->EnableEntry(IDM_kFindStar);
|
---|
982 | fDisplay->EnableEntry(IDM_kCaosFilter);
|
---|
983 | }
|
---|
984 | return kTRUE;
|
---|
985 |
|
---|
986 | case IDM_kCaosPrintLeds:
|
---|
987 | case IDM_kCaosPrintRings:
|
---|
988 | Toggle(fCaosPrint, mp1);
|
---|
989 | return kTRUE;
|
---|
990 |
|
---|
991 | case IDM_kCaosAnalStart:
|
---|
992 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStart);
|
---|
993 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStop);
|
---|
994 | fCaos->InitHistograms();
|
---|
995 | return kTRUE;
|
---|
996 |
|
---|
997 | case IDM_kCaosAnalStop:
|
---|
998 | fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop);
|
---|
999 | fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart);
|
---|
1000 | fCaos->ShowHistograms();
|
---|
1001 | fCaos->DeleteHistograms();
|
---|
1002 | return kTRUE;
|
---|
1003 |
|
---|
1004 | case IDM_kCaosWriteStart:
|
---|
1005 | fCaosWrite->DisableEntry(IDM_kCaosWriteStart);
|
---|
1006 | fCaosWrite->EnableEntry(IDM_kCaosWriteStop);
|
---|
1007 | fCaos->OpenFile();
|
---|
1008 | return kTRUE;
|
---|
1009 |
|
---|
1010 | case IDM_kCaosWriteStop:
|
---|
1011 | fCaosWrite->DisableEntry(IDM_kCaosWriteStop);
|
---|
1012 | fCaosWrite->EnableEntry(IDM_kCaosWriteStart);
|
---|
1013 | fCaos->CloseFile();
|
---|
1014 | return kTRUE;
|
---|
1015 |
|
---|
1016 | case IDM_kStart:
|
---|
1017 | fWritePictures->DisableEntry(IDM_kStart);
|
---|
1018 | fWritePictures->EnableEntry(IDM_kStop);
|
---|
1019 | return kTRUE;
|
---|
1020 |
|
---|
1021 | case IDM_kStop:
|
---|
1022 | fWritePictures->DisableEntry(IDM_kStop);
|
---|
1023 | fWritePictures->EnableEntry(IDM_kStart);
|
---|
1024 | return kTRUE;
|
---|
1025 |
|
---|
1026 | case IDM_kPNG:
|
---|
1027 | fFileType->CheckEntry(IDM_kPNG);
|
---|
1028 | fFileType->UnCheckEntry(IDM_kPPM);
|
---|
1029 | return kTRUE;
|
---|
1030 |
|
---|
1031 | case IDM_kPPM:
|
---|
1032 | fFileType->CheckEntry(IDM_kPPM);
|
---|
1033 | fFileType->UnCheckEntry(IDM_kPNG);
|
---|
1034 | return kTRUE;
|
---|
1035 |
|
---|
1036 | case IDM_kOnce:
|
---|
1037 | fWriteType->CheckEntry(IDM_kOnce);
|
---|
1038 | fWriteType->UnCheckEntry(IDM_kContinous);
|
---|
1039 | return kTRUE;
|
---|
1040 |
|
---|
1041 | case IDM_kContinous:
|
---|
1042 | fWriteType->CheckEntry(IDM_kContinous);
|
---|
1043 | fWriteType->UnCheckEntry(IDM_kOnce);
|
---|
1044 | return kTRUE;
|
---|
1045 |
|
---|
1046 | case IDM_kRate25ps:
|
---|
1047 | case IDM_kRate5ps:
|
---|
1048 | case IDM_kRate1s:
|
---|
1049 | case IDM_kRate5s:
|
---|
1050 | case IDM_kRate30s:
|
---|
1051 | case IDM_kRate1m:
|
---|
1052 | case IDM_kRate5m:
|
---|
1053 | for (int i=IDM_kRate25ps; i<=IDM_kRate5m; i++)
|
---|
1054 | if (mp1==i)
|
---|
1055 | fWriteRate->CheckEntry(i);
|
---|
1056 | else
|
---|
1057 | fWriteRate->UnCheckEntry(i);
|
---|
1058 | switch (mp1)
|
---|
1059 | {
|
---|
1060 | case IDM_kRate25ps:
|
---|
1061 | fWrtRate = 1;
|
---|
1062 | return kTRUE;
|
---|
1063 | case IDM_kRate5ps:
|
---|
1064 | fWrtRate = 5;
|
---|
1065 | return kTRUE;
|
---|
1066 | case IDM_kRate1s:
|
---|
1067 | fWrtRate = 25;
|
---|
1068 | return kTRUE;
|
---|
1069 | case IDM_kRate5s:
|
---|
1070 | fWrtRate = 5*25;
|
---|
1071 | return kTRUE;
|
---|
1072 | case IDM_kRate30s:
|
---|
1073 | fWrtRate = 30*25;
|
---|
1074 | return kTRUE;
|
---|
1075 | case IDM_kRate1m:
|
---|
1076 | fWrtRate = 60*25;
|
---|
1077 | return kTRUE;
|
---|
1078 | case IDM_kRate5m:
|
---|
1079 | fWrtRate = 5*60*25;
|
---|
1080 | return kTRUE;
|
---|
1081 | }
|
---|
1082 | return kTRUE;
|
---|
1083 |
|
---|
1084 | case IDM_kChannel1:
|
---|
1085 | case IDM_kChannel2:
|
---|
1086 | {
|
---|
1087 | const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1;
|
---|
1088 | const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1;
|
---|
1089 |
|
---|
1090 | if (ch0==ch1)
|
---|
1091 | return kTRUE;
|
---|
1092 |
|
---|
1093 | fChannel->CheckEntry (ch1==0?IDM_kChannel1:IDM_kChannel2);
|
---|
1094 | fChannel->UnCheckEntry(ch1==1?IDM_kChannel1:IDM_kChannel2);
|
---|
1095 |
|
---|
1096 | SetChannel();
|
---|
1097 | }
|
---|
1098 | return kTRUE;
|
---|
1099 |
|
---|
1100 | case IDM_kInterpol250:
|
---|
1101 | case IDM_kInterpol125:
|
---|
1102 | case IDM_kInterpol50:
|
---|
1103 | case IDM_kInterpol25:
|
---|
1104 | case IDM_kInterpol10:
|
---|
1105 | case IDM_kInterpol5:
|
---|
1106 | case IDM_kInterpol2:
|
---|
1107 | case IDM_kInterpol1:
|
---|
1108 | for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++)
|
---|
1109 | if (mp1==i)
|
---|
1110 | fInterpol->CheckEntry(i);
|
---|
1111 | else
|
---|
1112 | fInterpol->UnCheckEntry(i);
|
---|
1113 | switch (mp1)
|
---|
1114 | {
|
---|
1115 | case IDM_kInterpol1:
|
---|
1116 | fIntRate = 1;
|
---|
1117 | return kTRUE;
|
---|
1118 | case IDM_kInterpol2:
|
---|
1119 | fIntRate = 2;
|
---|
1120 | return kTRUE;
|
---|
1121 | case IDM_kInterpol5:
|
---|
1122 | fIntRate = 5;
|
---|
1123 | return kTRUE;
|
---|
1124 | case IDM_kInterpol10:
|
---|
1125 | fIntRate = 10;
|
---|
1126 | return kTRUE;
|
---|
1127 | case IDM_kInterpol25:
|
---|
1128 | fIntRate = 25;
|
---|
1129 | return kTRUE;
|
---|
1130 | case IDM_kInterpol50:
|
---|
1131 | fIntRate = 50;
|
---|
1132 | return kTRUE;
|
---|
1133 | case IDM_kInterpol125:
|
---|
1134 | fIntRate = 125;
|
---|
1135 | return kTRUE;
|
---|
1136 | case IDM_kInterpol250:
|
---|
1137 | fIntRate = 250;
|
---|
1138 | return kTRUE;
|
---|
1139 | }
|
---|
1140 | return kTRUE;
|
---|
1141 |
|
---|
1142 | case IDM_kLimMag3:
|
---|
1143 | case IDM_kLimMag4:
|
---|
1144 | case IDM_kLimMag5:
|
---|
1145 | case IDM_kLimMag6:
|
---|
1146 | case IDM_kLimMag7:
|
---|
1147 | case IDM_kLimMag8:
|
---|
1148 | case IDM_kLimMag9:
|
---|
1149 | for (int i=IDM_kLimMag3; i<=IDM_kLimMag9; i++)
|
---|
1150 | if (mp1==i)
|
---|
1151 | fLimMag->CheckEntry(i);
|
---|
1152 | else
|
---|
1153 | fLimMag->UnCheckEntry(i);
|
---|
1154 |
|
---|
1155 | fSao->SetLimitMag(mp1-IDM_kLimMag3+3);
|
---|
1156 | return kTRUE;
|
---|
1157 | }
|
---|
1158 | break;
|
---|
1159 | }
|
---|
1160 | break;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | return kTRUE;
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 | void MStarguider::SetPointingPosition(RaDec rd)
|
---|
1167 | {
|
---|
1168 | rd.Ra(rd.Ra()*24/360);
|
---|
1169 | fCRaDec->SetCoordinates(rd);
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | ZdAz MStarguider::TrackingError(TArrayF &x, TArrayF &y, TArrayF &mag,
|
---|
1173 | Int_t &num) const
|
---|
1174 | {
|
---|
1175 | num = -1;
|
---|
1176 |
|
---|
1177 | // Width of the final 2D gaussian
|
---|
1178 | const Double_t width = 0.8;
|
---|
1179 |
|
---|
1180 | // The binning is made 1.7 sigma (which, in the 1D case, gives the
|
---|
1181 | // highest significance of a gaussian signal) (1bin equiv 3x3 sigma)
|
---|
1182 | const Double_t max = 50;
|
---|
1183 | const Int_t n = TMath::Nint(2*max/(1.77*1.7*width));
|
---|
1184 | //1.77=sqrt(pi) comes from pir=bin
|
---|
1185 |
|
---|
1186 | // Fill a histogram with the dx/dy values from the file
|
---|
1187 | TH2F hist("Hist", "dX/dY", n, -max, max, n, -max, max);
|
---|
1188 | // hist.SetDirectory(0);
|
---|
1189 |
|
---|
1190 | //
|
---|
1191 | // Search for matching Magnitudes
|
---|
1192 | //
|
---|
1193 | //for (int i=0; i<mag.GetSize(); i++)
|
---|
1194 | //{
|
---|
1195 | // if (mag[i]>48-15 && mag[i]<48+15)
|
---|
1196 | // h.Fill(x[i], y[i]);
|
---|
1197 | //}
|
---|
1198 |
|
---|
1199 | // fill dx and dy into histogram
|
---|
1200 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1201 | hist.Fill(x[i], y[i]);
|
---|
1202 |
|
---|
1203 | // Remove all bins which have content of only a single event
|
---|
1204 | // including under- and overflow bins
|
---|
1205 | for (int i=0; i<hist.GetSize(); i++)
|
---|
1206 | if (hist.GetBinContent(i)<1.5)
|
---|
1207 | hist.SetBinContent(i, 0);
|
---|
1208 |
|
---|
1209 | // Find the bin containing the maximum
|
---|
1210 | Int_t bx, by, bz;
|
---|
1211 | hist.GetMaximumBin(bx, by, bz);
|
---|
1212 |
|
---|
1213 | // In the worst case the events are spread through the
|
---|
1214 | // bins which are the neighbors of the maximum
|
---|
1215 | // Normally neighbors which do not belong to the signal are empty!
|
---|
1216 | hist.GetXaxis()->SetRange(bx-1, bx+1); // 3x3bins ~8x8pix ~9x9sigma
|
---|
1217 | hist.GetYaxis()->SetRange(by-1, by+1); // 3x3bins ~8x8pix ~9x9sigma
|
---|
1218 |
|
---|
1219 | // Check whether this region contains events
|
---|
1220 | num = TMath::Nint(hist.Integral());
|
---|
1221 | if (num<1)
|
---|
1222 | return ZdAz();
|
---|
1223 |
|
---|
1224 | // Get Mean for the given axis range
|
---|
1225 | Double_t mx = hist.GetMean(1);
|
---|
1226 | Double_t my = hist.GetMean(2);
|
---|
1227 |
|
---|
1228 | const Int_t max1 = TMath::Nint(hist.GetBinContent(bx, by));
|
---|
1229 |
|
---|
1230 | // Check if the maximum is unique
|
---|
1231 | Int_t bx2, by2, bz2;
|
---|
1232 | hist.GetXaxis()->SetRange(-1, 9999);
|
---|
1233 | hist.GetYaxis()->SetRange(-1, 9999);
|
---|
1234 | hist.SetBinContent(bx, by, 0);
|
---|
1235 | hist.GetMaximumBin(bx2, by2, bz2);
|
---|
1236 |
|
---|
1237 | const Int_t max2 = TMath::Nint(hist.GetBinContent(bx2, by2));
|
---|
1238 | if (max1==max2 && TMath::Abs(bx2-bx)+TMath::Abs(by2-by)>1)
|
---|
1239 | return ZdAz();
|
---|
1240 |
|
---|
1241 | // loop again over the file and fill the histogram again.
|
---|
1242 | // to get closer to the correct value
|
---|
1243 | Double_t sumx = 0;
|
---|
1244 | Double_t sumy = 0;
|
---|
1245 | num = 0;
|
---|
1246 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1247 | {
|
---|
1248 | // only fill values into the histogram which
|
---|
1249 | // are inside 2*1.7=3.4 sigma (99.7%)
|
---|
1250 | if (TMath::Hypot(x[i]-mx, y[i]-my)>width*3.4)
|
---|
1251 | continue;
|
---|
1252 |
|
---|
1253 | sumx += x[i];
|
---|
1254 | sumy += y[i];
|
---|
1255 | num++;
|
---|
1256 | }
|
---|
1257 |
|
---|
1258 | if (num<1)
|
---|
1259 | return ZdAz();
|
---|
1260 |
|
---|
1261 | // calc MeanX and MeanY
|
---|
1262 | mx = sumx/num;
|
---|
1263 | my = sumy/num;
|
---|
1264 |
|
---|
1265 | // loop again to fill the mispointing corrected histograms
|
---|
1266 | // and fill another histogram to check the quality of the calculated
|
---|
1267 | // mispointing.
|
---|
1268 | sumx = 0;
|
---|
1269 | sumy = 0;
|
---|
1270 | num = 0;
|
---|
1271 | for (int i=0; i<mag.GetSize(); i++)
|
---|
1272 | {
|
---|
1273 | // only fill values into the histogram which
|
---|
1274 | // are inside 1.7=3.4 sigma (92%)
|
---|
1275 | // Cut at 1.7 sigma which gives the best background supression
|
---|
1276 | if (TMath::Hypot(x[i]-mx, y[i]-my)>width*1.7)
|
---|
1277 | continue;
|
---|
1278 |
|
---|
1279 | sumx += x[i];
|
---|
1280 | sumy += y[i];
|
---|
1281 | num++;
|
---|
1282 | }
|
---|
1283 |
|
---|
1284 | if (num<1)
|
---|
1285 | return ZdAz(); // FIXME!!!!!!!!!!!!
|
---|
1286 |
|
---|
1287 | // Mispointing
|
---|
1288 | mx = sumx/num;
|
---|
1289 | my = sumy/num;
|
---|
1290 |
|
---|
1291 | #ifdef EXPERT
|
---|
1292 | cout << "Offset-XY: " << mx << " +- " << my << endl;
|
---|
1293 | #endif
|
---|
1294 |
|
---|
1295 | AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg;
|
---|
1296 | AltAz pos1 = fSao->CalcAltAzFromPix(768/2+mx, 576/2+my)*kRad2Deg;
|
---|
1297 |
|
---|
1298 | pos1 -= pos0;
|
---|
1299 |
|
---|
1300 | return ZdAz(-pos1.Alt(), pos1.Az());
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 | Int_t MStarguider::CalcTrackingError(Leds &leds, MStarList &stars,
|
---|
1304 | ZdAz &d, MTime &t, double &bright, Int_t &num)
|
---|
1305 | {
|
---|
1306 | num = leds.GetEntries();
|
---|
1307 | if (num < 3) //was 1
|
---|
1308 | {
|
---|
1309 | gLog << warn << "Sorry, less than 3 detected spot in FOV!" << endl;
|
---|
1310 | fStargTPoint->SetDown(kFALSE);
|
---|
1311 | return 0;
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | if (stars.GetRealEntries() < 3)
|
---|
1315 | {
|
---|
1316 | gLog << warn << "Sorry, less than 3 stars in FOV!" << endl;
|
---|
1317 | fStargTPoint->SetDown(kFALSE);
|
---|
1318 | return 0;
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | stars.Sort(); // Sort by magnitude
|
---|
1322 |
|
---|
1323 | #ifdef EXPERT
|
---|
1324 | TString str = "data/tracking_";
|
---|
1325 | str += fSao->GetMjd();
|
---|
1326 | str += ".txt";
|
---|
1327 |
|
---|
1328 | ofstream fout(str);
|
---|
1329 | #endif
|
---|
1330 |
|
---|
1331 | TArrayF x, y, mag;
|
---|
1332 |
|
---|
1333 | // FIXME: Is predefined value 3 a good idea?
|
---|
1334 | Int_t cnt=0;
|
---|
1335 |
|
---|
1336 | MStar *star;
|
---|
1337 | MStarListIter NextStar(&stars);
|
---|
1338 | while ((star=NextStar()) && cnt<num+5)
|
---|
1339 | {
|
---|
1340 | TIter NextSp(&leds);
|
---|
1341 | Led *spot=NULL;
|
---|
1342 | while ((spot=(Led*)NextSp()))
|
---|
1343 | {
|
---|
1344 | const XY dpos(spot->GetX()-(768-star->GetX()),
|
---|
1345 | spot->GetY()-star->GetY());
|
---|
1346 |
|
---|
1347 | const Int_t idx = x.GetSize();
|
---|
1348 |
|
---|
1349 | x.Set(idx+1);
|
---|
1350 | y.Set(idx+1);
|
---|
1351 | mag.Set(idx+1);
|
---|
1352 |
|
---|
1353 | x.AddAt(dpos.X(), idx);
|
---|
1354 | y.AddAt(dpos.Y(), idx);
|
---|
1355 | mag.AddAt(log(spot->GetMag())/star->GetMag(), idx);
|
---|
1356 |
|
---|
1357 | #ifdef EXPERT
|
---|
1358 | if (fout)
|
---|
1359 | {
|
---|
1360 | fout << spot->GetX() << " "
|
---|
1361 | << spot->GetY() << " "
|
---|
1362 | << -2.5*log(spot->GetMag()) << " "
|
---|
1363 | << star->GetX() << " "
|
---|
1364 | << star->GetY() << " "
|
---|
1365 | << star->GetMag() << " ";
|
---|
1366 | fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl;
|
---|
1367 | }
|
---|
1368 | #endif
|
---|
1369 | }
|
---|
1370 | cnt++;
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | Int_t numcor = 0;
|
---|
1374 | d = TrackingError(x, y, mag, numcor);
|
---|
1375 | if (numcor<1)
|
---|
1376 | {
|
---|
1377 | fStargTPoint->SetDown(kFALSE);
|
---|
1378 | return 0;
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 | fDZdAz->SetCoordinates(d);
|
---|
1382 |
|
---|
1383 | //
|
---|
1384 | // Current Pointing position
|
---|
1385 | //
|
---|
1386 | ZdAz cpos = fSao->GetZdAz()-d;
|
---|
1387 | fPZdAz->SetCoordinates(cpos);
|
---|
1388 |
|
---|
1389 | // Check StargTPoint data set request
|
---|
1390 | if (!fStargTPoint->IsDown())
|
---|
1391 | return numcor;
|
---|
1392 | fStargTPoint->SetDown(kFALSE);
|
---|
1393 |
|
---|
1394 | // If no file open: open new file
|
---|
1395 | if (!fOutStargTp)
|
---|
1396 | {
|
---|
1397 | // open tpoint file
|
---|
1398 | const TString name = MCosy::GetFileName("tpoint", "starg", "txt");
|
---|
1399 | gLog << all << "TPoint-Starg File ********* " << name << " ********** " << endl;
|
---|
1400 |
|
---|
1401 | fOutStargTp = new ofstream(name);
|
---|
1402 | *fOutStargTp << "Magic Model STARGTPOINT data file" << endl;
|
---|
1403 | *fOutStargTp << ": ALTAZ" << endl;
|
---|
1404 | *fOutStargTp << "49 48 0 ";
|
---|
1405 | *fOutStargTp << t << endl;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | // Get tracking coordinates
|
---|
1409 | const XY xy = fCRaDec->GetCoordinates();
|
---|
1410 | const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
|
---|
1411 |
|
---|
1412 | // From the star position in the camera we calculate the Alt/Az
|
---|
1413 | // position we are currently tracking (real pointing position)
|
---|
1414 | fSao->SetMjd(t.GetMjd());
|
---|
1415 | AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
|
---|
1416 |
|
---|
1417 | //correction with offset from last tpoint measurement
|
---|
1418 | za0 -= fAltAzOffsetFromTp;
|
---|
1419 |
|
---|
1420 | //if the difference between the tpoint and the starguider tpoint
|
---|
1421 | //is too big, the starguider tpoint is not stored
|
---|
1422 | if ((t.GetMjd()-fTimeFromTp.GetMjd())>0.001) //1min20sec
|
---|
1423 | {
|
---|
1424 | cout << " time difference between tpoint and starguider-tpoint > 1m20s" << endl;
|
---|
1425 | cout << " => starguider tpoint hasn't been stored. " << endl;
|
---|
1426 | cout << " Please repeat whole procedure. " << endl;
|
---|
1427 | return numcor;
|
---|
1428 | }
|
---|
1429 |
|
---|
1430 |
|
---|
1431 | // Write real pointing position
|
---|
1432 | //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
|
---|
1433 | *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
|
---|
1434 |
|
---|
1435 | // Write system pointing position
|
---|
1436 | //cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl;
|
---|
1437 | *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd();
|
---|
1438 |
|
---|
1439 | *fOutStargTp << " " << xy.X() << " " << xy.Y();
|
---|
1440 | *fOutStargTp << " " << d.Zd() << " " << d.Az();
|
---|
1441 | *fOutStargTp << " " << setprecision(11) << t.GetMjd();
|
---|
1442 | *fOutStargTp << " " << num;
|
---|
1443 | *fOutStargTp << " " << bright;
|
---|
1444 | *fOutStargTp << endl;
|
---|
1445 |
|
---|
1446 | fTimeFromTp.Clear();
|
---|
1447 |
|
---|
1448 | return numcor;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t)
|
---|
1452 | {
|
---|
1453 | // Try to find the star
|
---|
1454 | Leds leds;
|
---|
1455 | f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true);
|
---|
1456 |
|
---|
1457 | // Check whether star found
|
---|
1458 | Led *star = (Led*)leds.At(0);
|
---|
1459 | if (!star)
|
---|
1460 | {
|
---|
1461 | if (fTPoint->IsDown())
|
---|
1462 | {
|
---|
1463 | fTPoint->SetDown(kFALSE);
|
---|
1464 | gLog << warn << "No star found. Couldn't take a tpoint." << endl;
|
---|
1465 | }
|
---|
1466 | return;
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | cout << "Found star @ " << flush;
|
---|
1470 | star->Print();
|
---|
1471 | f2.MarkPoint(star->GetX(), star->GetY(), 2<<2);
|
---|
1472 |
|
---|
1473 | // Initialize Star Catalog on the camera plane
|
---|
1474 | MGeomCamMagic geom;
|
---|
1475 | MAstroCamera ac;
|
---|
1476 | ac.SetGeom(geom);
|
---|
1477 | ac.SetRadiusFOV(3);
|
---|
1478 | ac.SetObservatory(*fSao);
|
---|
1479 | ac.SetTime(t);
|
---|
1480 |
|
---|
1481 | // Get tracking coordinates
|
---|
1482 | const XY xy = fCRaDec->GetCoordinates(); // [h, deg]
|
---|
1483 | const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
|
---|
1484 |
|
---|
1485 | ac.SetRaDec(rd.Ra(), rd.Dec());
|
---|
1486 |
|
---|
1487 | // Convert from Pixel to millimeter (1pix=2.6mm) [deg/pix / deg/mm = mm/pix]
|
---|
1488 | // Correct for abberation.
|
---|
1489 | const Double_t conv = fCaos->GetArcsecPerPixel()/3600/geom.GetConvMm2Deg()/ 1.0713;
|
---|
1490 |
|
---|
1491 | // Adapt coordinate system (GUIs and humans are counting Y in different directions)
|
---|
1492 | const Double_t dx = (star->GetX()-center.GetX())*conv;
|
---|
1493 | const Double_t dy = (center.GetY()-star->GetY())*conv;
|
---|
1494 |
|
---|
1495 | // Convert offset from camera plane into local ccordinates
|
---|
1496 | Double_t dzd, daz;
|
---|
1497 | ac.GetDiffZdAz(dx, dy, dzd, daz);
|
---|
1498 |
|
---|
1499 | ZdAz zdaz(dzd,daz);
|
---|
1500 |
|
---|
1501 | // Check TPoint data set request
|
---|
1502 | if (!fTPoint->IsDown())
|
---|
1503 | return;
|
---|
1504 |
|
---|
1505 | fTPoint->SetDown(kFALSE);
|
---|
1506 |
|
---|
1507 | // If no file open: open new file
|
---|
1508 | if (!fOutTp)
|
---|
1509 | {
|
---|
1510 | //
|
---|
1511 | // open tpoint file
|
---|
1512 | //
|
---|
1513 | const TString name = MCosy::GetFileName("tpoint", "tpoint", "txt");
|
---|
1514 | cout << "TPoint File ********* " << name << " ********** " << endl;
|
---|
1515 |
|
---|
1516 | fOutTp = new ofstream(name);
|
---|
1517 | *fOutTp << "Magic Model TPOINT data file" << endl;
|
---|
1518 | *fOutTp << ": ALTAZ" << endl;
|
---|
1519 | *fOutTp << "49 48 0 ";
|
---|
1520 | *fOutTp << t << endl;
|
---|
1521 | // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m)
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | // Output Ra/Dec the drive system thinks that it is currently tracking
|
---|
1525 | //cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl;
|
---|
1526 |
|
---|
1527 | // From the star position in the camera we calculate the Alt/Az
|
---|
1528 | // position we are currently tracking (real pointing position)
|
---|
1529 | fSao->SetMjd(t.GetMjd());
|
---|
1530 | AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg;
|
---|
1531 |
|
---|
1532 | //ZdAz za0 = fSao->GetZdAz();
|
---|
1533 | za0 -= AltAz(-dzd, daz);
|
---|
1534 | fAltAzOffsetFromTp = AltAz(-dzd, daz);
|
---|
1535 | fTimeFromTp=t;
|
---|
1536 |
|
---|
1537 | // From the Shaftencoders we get the current 'pointing' position
|
---|
1538 | // as it is seen by the drive system (system pointing position)
|
---|
1539 | const ZdAz za1 = fCosy->GetSePos()*360; // [deg]
|
---|
1540 |
|
---|
1541 | // Write real pointing position
|
---|
1542 | //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
|
---|
1543 | *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
|
---|
1544 |
|
---|
1545 | // Write system pointing position
|
---|
1546 | //cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl;
|
---|
1547 | *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd();
|
---|
1548 |
|
---|
1549 | *fOutTp << " " << xy.X() << " " << xy.Y();
|
---|
1550 | *fOutTp << " " << -dzd << " " << -daz;
|
---|
1551 | *fOutTp << " " << setprecision(11) << t.GetMjd();
|
---|
1552 | *fOutTp << " " << setprecision(4) << center.GetMag();
|
---|
1553 | *fOutTp << " " << star->GetMag();
|
---|
1554 | *fOutTp << endl;
|
---|
1555 | /*
|
---|
1556 | MLog &outrep = *fCosy->GetOutRep();
|
---|
1557 | if (outrep.Lock("MStarguider::FindStar"))
|
---|
1558 | {
|
---|
1559 | outrep << "FINDSTAR-REPORT 00 " << MTime(-1) << " " << setprecision(7);
|
---|
1560 | outrep << 90-za0.Alt() << " " << za0.Az() << " ";
|
---|
1561 | outrep << za1.Zd() << " " << za1.Az() << " ";
|
---|
1562 | outrep << xy.X() << " " << xy.Y() << " ";
|
---|
1563 | outrep << -dzd << " " << -daz << " ";
|
---|
1564 | outrep << star->GetX() << " " << star->GetY() << " ";
|
---|
1565 | outrep << center.GetX() << " " << center.GetY() << " ";
|
---|
1566 | outrep << dx/conv << " " << dy/conv << " " << star->GetMag();
|
---|
1567 | outrep << setprecision(11) << t.GetMjd() << endl;
|
---|
1568 | outrep.UnLock("MStarguider::FindStar");
|
---|
1569 | }*/
|
---|
1570 |
|
---|
1571 | // return zdaz;
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | bool MStarguider::Interpolate(const unsigned long n, byte *img) const
|
---|
1575 | {
|
---|
1576 | if (fIntRate<=1)
|
---|
1577 | return true;
|
---|
1578 |
|
---|
1579 | static unsigned short myimg[768*576];
|
---|
1580 |
|
---|
1581 | unsigned short *f = myimg;
|
---|
1582 | byte *i = img;
|
---|
1583 | byte *e = img+768*576;
|
---|
1584 |
|
---|
1585 | while (i<e)
|
---|
1586 | *f++ += *i++;
|
---|
1587 |
|
---|
1588 | if (n%fIntRate)
|
---|
1589 | return false;
|
---|
1590 |
|
---|
1591 | f = myimg;
|
---|
1592 | i = img;
|
---|
1593 | e = img+768*576;
|
---|
1594 |
|
---|
1595 | while (i<e)
|
---|
1596 | *i++ = (byte)(*f++/fIntRate);
|
---|
1597 |
|
---|
1598 | memset(myimg, 0, sizeof(myimg));
|
---|
1599 |
|
---|
1600 | return true;
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | void MStarguider::DrawZoomImage(const byte *img)
|
---|
1604 | {
|
---|
1605 | byte zimg[kZOOM*kZOOM];
|
---|
1606 | for (int y=0; y<kZOOM; y++)
|
---|
1607 | for (int x=0; x<kZOOM; x++)
|
---|
1608 | zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768];
|
---|
1609 |
|
---|
1610 | fZoomImage->DrawImg(zimg);
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | void MStarguider::DrawCosyImage(const byte *img)
|
---|
1614 | {
|
---|
1615 | if (!fCosy)
|
---|
1616 | return;
|
---|
1617 |
|
---|
1618 | byte simg[(768/2-1)*(576/2-1)];
|
---|
1619 | for (int y=0; y<576/2-1; y++)
|
---|
1620 | for (int x=0; x<768/2-1; x++)
|
---|
1621 | 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;
|
---|
1622 |
|
---|
1623 | fCosy->GetWin()->GetImage()->DrawImg(simg);
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | void MStarguider::StartStarguider()
|
---|
1627 | {
|
---|
1628 | // Switch to starguider mode
|
---|
1629 | cout << " * Switching to Starguider mode" << endl;
|
---|
1630 | fMode->UnCheckEntry(IDM_kStarguiderMode);
|
---|
1631 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0);
|
---|
1632 | }
|
---|
1633 |
|
---|
1634 | Bool_t MStarguider::DoTPoint()
|
---|
1635 | {
|
---|
1636 | if (fTPointFromCC<0)
|
---|
1637 | return kTRUE;
|
---|
1638 |
|
---|
1639 | switch (++fTPointFromCC)
|
---|
1640 | {
|
---|
1641 | case 1:
|
---|
1642 | fTimeFromTp.Clear();
|
---|
1643 | fNumStarsDetected = 0;
|
---|
1644 |
|
---|
1645 | cout << " * Switching to TPoint mode" << endl;
|
---|
1646 | // Switch to tpoint mode
|
---|
1647 | fMode->UnCheckEntry(IDM_kTpointMode);
|
---|
1648 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kTpointMode, 0);
|
---|
1649 | return kFALSE;
|
---|
1650 |
|
---|
1651 | case 2:
|
---|
1652 | cout << " * Waiting one frame" << endl;
|
---|
1653 | // Wait one frame
|
---|
1654 | return kFALSE;
|
---|
1655 |
|
---|
1656 | case 3:
|
---|
1657 | cout << " * Taking TPoint" << endl;
|
---|
1658 | fTPoint->SetDown(); // kTRUE
|
---|
1659 | return kTRUE;
|
---|
1660 |
|
---|
1661 | case 4:
|
---|
1662 | if (!fTimeFromTp) // TPoint failed
|
---|
1663 | break;
|
---|
1664 |
|
---|
1665 | // Switch to starguider mode
|
---|
1666 | cout << " * Switching to Starguider mode" << endl;
|
---|
1667 | fMode->UnCheckEntry(IDM_kStarguiderMode);
|
---|
1668 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0);
|
---|
1669 | return kFALSE;
|
---|
1670 |
|
---|
1671 | case 5:
|
---|
1672 | cout << " * Waiting one frame" << endl;
|
---|
1673 | // Wait one frame
|
---|
1674 | return kFALSE;
|
---|
1675 |
|
---|
1676 | case 6:
|
---|
1677 | cout << " * Taking Starguider TPoint" << endl;
|
---|
1678 | fStargTPoint->SetDown(); // kTRUE
|
---|
1679 | return kTRUE;
|
---|
1680 |
|
---|
1681 | case 7:
|
---|
1682 | cout << " * Send Report" << endl;
|
---|
1683 | break;
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | // Send report
|
---|
1687 | fTPointFromCC = -1;
|
---|
1688 |
|
---|
1689 | if (!fCosy)
|
---|
1690 | return kTRUE;
|
---|
1691 |
|
---|
1692 | MDriveCom *com = fCosy->GetDriveCom();
|
---|
1693 | if (!com)
|
---|
1694 | return kTRUE;
|
---|
1695 |
|
---|
1696 | // nominalaz, nominalel, realaz, realel, nomra, nomdec,
|
---|
1697 | // diffaz, diffel, mjd, numleds, artmag
|
---|
1698 |
|
---|
1699 | //fTimeFromTp.Clear();
|
---|
1700 | //fStatus==MDriveCom::kMonitoring
|
---|
1701 | //fNumStarsDetected = numstars;
|
---|
1702 | //fNumStarsCorrelated = rc;
|
---|
1703 | com->SendTPoint(fNumStarsCorrelated>0);
|
---|
1704 |
|
---|
1705 | return kTRUE;
|
---|
1706 | }
|
---|
1707 |
|
---|
1708 | void MStarguider::ProcessFrame(const unsigned long n, byte *img,
|
---|
1709 | struct timeval *tm)
|
---|
1710 | {
|
---|
1711 | static unsigned long n0 = n;
|
---|
1712 |
|
---|
1713 | MTime t(*tm);
|
---|
1714 |
|
---|
1715 | const Double_t d = t-fTime;
|
---|
1716 | if (d>1)
|
---|
1717 | {
|
---|
1718 | const TString txt = MString::Format("%dfps", (int)((n-n0)/d+.5));
|
---|
1719 | fFps->SetText(txt);
|
---|
1720 | fTime = t;
|
---|
1721 | n0 = n;
|
---|
1722 | }
|
---|
1723 |
|
---|
1724 | if (!Interpolate(n, img))
|
---|
1725 | return;
|
---|
1726 |
|
---|
1727 | byte cimg[768*576];
|
---|
1728 | memset(cimg, 0, 768*576);
|
---|
1729 |
|
---|
1730 | FilterLed f(img, 768, 576, 2.5); // 2.5
|
---|
1731 | FilterLed f2(cimg, 768, 576); // former color 0xb0
|
---|
1732 |
|
---|
1733 | if (fDisplay->IsEntryChecked(IDM_kStretch))
|
---|
1734 | f.Stretch();
|
---|
1735 |
|
---|
1736 | if (!fWritePictures->IsEntryEnabled(IDM_kStart) &&
|
---|
1737 | (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce)))
|
---|
1738 | {
|
---|
1739 |
|
---|
1740 | if (fFileType->IsEntryChecked(IDM_kPNG))
|
---|
1741 | Writer::Png("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1742 |
|
---|
1743 | if (fFileType->IsEntryChecked(IDM_kPPM))
|
---|
1744 | Writer::Ppm("pix/file", img, tm, fCRaDec->GetCoordinates());
|
---|
1745 |
|
---|
1746 | if (fWriteType->IsEntryChecked(IDM_kOnce))
|
---|
1747 | ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStop, 0);
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | // Visual Filter, whole FOV
|
---|
1751 | if (fDisplay->IsEntryChecked(IDM_kFilter))
|
---|
1752 | f.Execute();
|
---|
1753 |
|
---|
1754 | DoTPoint();
|
---|
1755 |
|
---|
1756 | Int_t numleds = 0;
|
---|
1757 | Int_t numrings = 0;
|
---|
1758 |
|
---|
1759 | // Find Center of Camera for Caos and Tpoints
|
---|
1760 | Ring center(768/2, 576/2);
|
---|
1761 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
|
---|
1762 | {
|
---|
1763 | const bool printl = fCaosPrint->IsEntryChecked(IDM_kCaosPrintLeds);
|
---|
1764 | const bool printr = fCaosPrint->IsEntryChecked(IDM_kCaosPrintRings);
|
---|
1765 | ZdAz pos;
|
---|
1766 | if (fCosy)
|
---|
1767 | pos = fCosy->GetPointingPos();
|
---|
1768 |
|
---|
1769 | center = fCaos->Run(img, printl, printr, pos, t);
|
---|
1770 |
|
---|
1771 | numleds = fCaos->GetNumDetectedLEDs();
|
---|
1772 | numrings = fCaos->GetNumDetectedRings();
|
---|
1773 | }
|
---|
1774 |
|
---|
1775 | // Find Star at Center---for Tpoint Procedure
|
---|
1776 | if (fDisplay->IsEntryChecked(IDM_kFindStar) &&
|
---|
1777 | center.GetX()>0 && center.GetY()>0)
|
---|
1778 | {
|
---|
1779 | // Set search Paremeters (FIXME: Get them from user input!)
|
---|
1780 | f.SetCut(3.0);
|
---|
1781 | f.SetBox(70);
|
---|
1782 |
|
---|
1783 | FindStar(f, f2, center, t);
|
---|
1784 | }
|
---|
1785 |
|
---|
1786 | DrawZoomImage(img);
|
---|
1787 | DrawCosyImage(img);
|
---|
1788 |
|
---|
1789 | // Position corresponding to the camera center (53.2, 293.6)
|
---|
1790 | Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px]
|
---|
1791 |
|
---|
1792 | // Find Center of Camera in Starfield Camera picture
|
---|
1793 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter))
|
---|
1794 | {
|
---|
1795 | ZdAz pos;
|
---|
1796 | if (fCosy)
|
---|
1797 | pos = fCosy->GetPointingPos();
|
---|
1798 |
|
---|
1799 | sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t); // [px]
|
---|
1800 |
|
---|
1801 | numleds = fStargCaos->GetNumDetectedLEDs();
|
---|
1802 | numrings = fStargCaos->GetNumDetectedRings();
|
---|
1803 | }
|
---|
1804 |
|
---|
1805 | // we obtain a list of stars in the FOV from the SAO catalog
|
---|
1806 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1807 | {
|
---|
1808 | MTime time(*tm);
|
---|
1809 |
|
---|
1810 | XY xy = fCRaDec->GetCoordinates(); //[h, deg]
|
---|
1811 | fRaDec->Set(xy.X()*15, xy.Y()); //[deg,deg]
|
---|
1812 |
|
---|
1813 | UpdatePosZoom();
|
---|
1814 |
|
---|
1815 | // Always call SetMjd first!
|
---|
1816 | fSao->SetPointing(time.GetMjd(), *fRaDec);
|
---|
1817 | fCZdAz->SetCoordinates(fSao->GetZdAz());
|
---|
1818 |
|
---|
1819 | fSao->SetBox(230); // Region of interest around center
|
---|
1820 |
|
---|
1821 | // If center of camera cannot be determined sgcenter is (0,0)
|
---|
1822 | const Bool_t centerisvalid = sgcenter.GetX()>0 && sgcenter.GetY()>0;
|
---|
1823 | // if (centerisvalid)
|
---|
1824 | // skycenter.SetXY(sgcenter.GetX() - 53.2,
|
---|
1825 | // sgcenter.GetY() - 293.6);
|
---|
1826 |
|
---|
1827 | // We determine the ideal starfield using camera sagging info
|
---|
1828 | // from the LEDs
|
---|
1829 | //Please never change this offsets!!!
|
---|
1830 | // 53.2 and 293.6 are the "preliminary" camera center
|
---|
1831 | // -9 and 28.5 are the offsets of the pointing position in the sky
|
---|
1832 | const XY off(sgcenter.GetX()- 53.2-9,
|
---|
1833 | sgcenter.GetY()-293.6+28.5);
|
---|
1834 |
|
---|
1835 | // we obtain stars in the effective star FOV and draw them.
|
---|
1836 | // coordinates are video frame coords.
|
---|
1837 | MStarList stars;
|
---|
1838 | fSao->CalcStars(stars, 530, 292, TMath::FloorNint(off.X()), TMath::FloorNint(off.Y()));
|
---|
1839 | fSao->DrawStars(stars, cimg);
|
---|
1840 |
|
---|
1841 | // Position around which the circles are drawn.
|
---|
1842 | const Ring skycenter(768/2-off.X(), 576/2+off.Y());
|
---|
1843 |
|
---|
1844 | // There are two corrections to the mispointing
|
---|
1845 | // - Sagging of the camera as measured with the LEDs
|
---|
1846 | // - Star not ideally centered on MAGIC Camera
|
---|
1847 |
|
---|
1848 | // Next we evaluate the offset given by the LEDs. This we obtain
|
---|
1849 | // in Zd/Az and add it to the tracking error.
|
---|
1850 | if (fDisplay->IsEntryChecked(IDM_kStarguider))
|
---|
1851 | {
|
---|
1852 | const Float_t cut = atof(fCut->GetText());
|
---|
1853 |
|
---|
1854 | Leds spots;
|
---|
1855 | f.SetBox(230);
|
---|
1856 | f.SetCut(cut);
|
---|
1857 |
|
---|
1858 | double bright;
|
---|
1859 | f.ExecuteAndMark(spots, 530, 292, bright);
|
---|
1860 |
|
---|
1861 | ULong_t color;
|
---|
1862 | gClient->GetColorByName("Green", color);
|
---|
1863 | if (bright> 60)
|
---|
1864 | gClient->GetColorByName("Yellow", color);
|
---|
1865 | if (bright> 85)
|
---|
1866 | gClient->GetColorByName("Orange", color);
|
---|
1867 | if (bright> 95)
|
---|
1868 | gClient->GetColorByName("Red", color);
|
---|
1869 | fSkyBright->SetBackgroundColor(color);
|
---|
1870 |
|
---|
1871 | const MString txt = MString::Format("Sky Brightness: %.1f", bright);
|
---|
1872 | fSkyBright->SetText(txt);
|
---|
1873 |
|
---|
1874 | const Bool_t brightnessisvalid = bright<1.75*fLastBright &&
|
---|
1875 | bright>30 && bright<110;
|
---|
1876 |
|
---|
1877 | fLastBright = bright;
|
---|
1878 |
|
---|
1879 | Int_t numstars = 0;
|
---|
1880 | const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars);
|
---|
1881 |
|
---|
1882 | const Bool_t monitoring = brightnessisvalid && centerisvalid && fNumStarsCorrelated>2;
|
---|
1883 |
|
---|
1884 | fStatus = monitoring ? MDriveCom::kMonitoring : MDriveCom::kError;
|
---|
1885 |
|
---|
1886 | if (fCosy)
|
---|
1887 | fPos = fCosy->GetPointingPos();
|
---|
1888 |
|
---|
1889 | if (fOperations->IsEntryChecked(IDM_kStargAnalysis))
|
---|
1890 | fStargHistograms->Fill(spots, stars, fD, fSao->GetZdAz(),
|
---|
1891 | sgcenter, bright, fPos, t);
|
---|
1892 |
|
---|
1893 | fNumStarsDetected = numstars;
|
---|
1894 | fNumStarsCorrelated = rc;
|
---|
1895 |
|
---|
1896 | if (fCosy)
|
---|
1897 | {
|
---|
1898 | MDriveCom *com = fCosy->GetDriveCom();
|
---|
1899 | if (com)
|
---|
1900 | com->SendStargReport(fStatus, fD, fSao->GetZdAz(),
|
---|
1901 | sgcenter, numstars, rc, bright,
|
---|
1902 | time.GetMjd(), numleds, numrings); // Report
|
---|
1903 | }
|
---|
1904 |
|
---|
1905 | } //kStarguider
|
---|
1906 |
|
---|
1907 | if (centerisvalid && fNumStarsCorrelated>2)
|
---|
1908 | {
|
---|
1909 | f2.DrawCircle(skycenter, 2.0, 0x0a);
|
---|
1910 |
|
---|
1911 | const Double_t ap = fSao->GetPixSize()/3600; //[deg/pix]
|
---|
1912 |
|
---|
1913 | f2.DrawCircle(skycenter, 0.10/ap, 0x0a); //0.1deg
|
---|
1914 | f2.DrawHexagon(skycenter, 2.06/ap, 0x0a);
|
---|
1915 | f2.DrawHexagon(skycenter, 3.50/ap, 0x0a);
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 | } //CalcStars
|
---|
1919 |
|
---|
1920 | // Draw Circles around center of Camera
|
---|
1921 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter) &&
|
---|
1922 | center.GetX()>0 && center.GetY()>0)
|
---|
1923 | {
|
---|
1924 | f2.DrawCircle(center, 0x0a);
|
---|
1925 | f2.DrawCircle(center, 7.0,
|
---|
1926 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
1927 | f2.DrawCircle(center, 115.0, 0x0a);
|
---|
1928 | f2.DrawCircle(center, 230.0, 0x0a);
|
---|
1929 | f2.DrawCircle(center, 245.0, 0x0a);
|
---|
1930 | }
|
---|
1931 |
|
---|
1932 | if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter) &&
|
---|
1933 | sgcenter.GetX()>0 && sgcenter.GetY()>0)
|
---|
1934 | {
|
---|
1935 | f2.DrawCircle(sgcenter, 0x0a);
|
---|
1936 | f2.DrawCircle(sgcenter, 5.0,
|
---|
1937 | fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
|
---|
1938 | }
|
---|
1939 |
|
---|
1940 | if (fDisplay->IsEntryChecked(IDM_kCaosFilter) ||
|
---|
1941 | fDisplay->IsEntryChecked(IDM_kCatalog) ||
|
---|
1942 | fDisplay->IsEntryChecked(IDM_kFindStar))
|
---|
1943 | fImage->DrawColImg(img, cimg);
|
---|
1944 | else
|
---|
1945 | fImage->DrawImg(img);
|
---|
1946 | }
|
---|
1947 |
|
---|
1948 | void MStarguider::UpdatePosZoom()
|
---|
1949 | {
|
---|
1950 | MString txt;
|
---|
1951 | if (fDisplay->IsEntryChecked(IDM_kCatalog))
|
---|
1952 | {
|
---|
1953 | // FIXME: Necessary?
|
---|
1954 | fSao->Now();
|
---|
1955 | AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg;
|
---|
1956 | if (aa.Az()<0)
|
---|
1957 | aa.Az(aa.Az()+360);
|
---|
1958 | txt.Form("(%d, %d) %.1fd/%.1fd", fDx, fDy, -aa.Alt(), aa.Az()-180);
|
---|
1959 | }
|
---|
1960 | else
|
---|
1961 | txt.Form("(%d, %d)", fDx, fDy);
|
---|
1962 | fPosZoom->SetText(txt);
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 | Bool_t MStarguider::HandleDoubleClick(Event_t *event)
|
---|
1966 | {
|
---|
1967 | const Int_t w = fImage->GetWidth();
|
---|
1968 | const Int_t h = fImage->GetHeight();
|
---|
1969 | const Int_t x = fImage->GetX();
|
---|
1970 | const Int_t y = fImage->GetY();
|
---|
1971 |
|
---|
1972 | if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h))
|
---|
1973 | return kTRUE;
|
---|
1974 |
|
---|
1975 | Int_t dx = event->fX-x;
|
---|
1976 | Int_t dy = event->fY-y;
|
---|
1977 |
|
---|
1978 | if (dx<kZOOM/4) dx=kZOOM/4;
|
---|
1979 | if (dy<kZOOM/4) dy=kZOOM/4;
|
---|
1980 | if (dx>766-kZOOM/4) dx=766-kZOOM/4;
|
---|
1981 | if (dy>574-kZOOM/4) dy=574-kZOOM/4;
|
---|
1982 |
|
---|
1983 | fDx = dx;
|
---|
1984 | fDy = dy;
|
---|
1985 |
|
---|
1986 | UpdatePosZoom();
|
---|
1987 | return kTRUE;
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | void MStarguider::Print(TString &str, Double_t deg) const
|
---|
1991 | {
|
---|
1992 | Char_t sgn;
|
---|
1993 | UShort_t d, m, s;
|
---|
1994 |
|
---|
1995 | MAstro::Deg2Dms(deg, sgn, d, m, s);
|
---|
1996 |
|
---|
1997 | str += MString::Format("%c %03d %02d %03d ", sgn, d, m, s);
|
---|
1998 | }
|
---|