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