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