- Timestamp:
- 04/29/09 13:05:42 (16 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r9432 r9435 1 1 -*-*- END -*-*- 2 3 2009/04/29 Thomas Bretz (La Palma) 4 5 * cosy.cc: 6 - added possibility to switch the ccd cameras on and off remote 7 - read setup from the resource file instead of the commandline 8 9 * caos/Rings.[h,cc]: 10 - added return value to CalcRings 11 12 * catalog/StarCatalog.h: 13 - Store rotation angle 14 15 * devdrv/DevdrvLinkDef.h, Makefile: 16 - removed macs* 17 - removed shaftencoder* 18 19 * devdrv/dkc.cc: 20 - simplified the interface to the sps (removed obsolete SDOs, 21 removed obsolete subindices) 22 - removed obsolete SetDeceleration 23 24 * main/MCaos.[h,cc]: 25 - keep number of detected leds and number of detected rings 26 - make many variables a data member which can now be setup 27 from a resource file 28 - derived from MParContainer 29 30 * main/MCosy.[h,cc]: 31 - replaced SetDecelartion for pressing stop by SetAcceleration 32 - implemented WM_STARGTPOINT 33 - implemented WM_STARGMODE 34 - allow shutdown even if no connection to SPS 35 36 * main/MStargHistograms.[h,cc]: 37 - removed old obsoelte code 38 39 * main/MStarguider.[h,cc]: 40 - removed old obsolete code (StargFindStar and RoqueLampAna) 41 - moved some build in default setup to the resource file 42 - removed AMC trigger 43 - allow some setup from resource file 44 - implemented StartStarguider for remote switching of starguider 45 mode 46 - implemented DoTPoint for remote TPoint procedure 47 - some more code cleanup 48 49 * main/MTracking.cc: 50 - removed obsolete include of shaftencoder.h 51 52 * tcpip/MCeCoCom.cc: 53 - removed check for OVER 54 - use TString::Length instead of strlen(TString&) 55 56 * tcpip/MDriveCom.[h,cc]: 57 - implemented TPOINT command and STGMD command 58 - send number of LEDs and rings instead of x/y in starguider report 59 60 2 61 3 62 2009/04/22 Thomas Bretz (La Palma) -
trunk/MagicSoft/Cosy/caos/Rings.cc
r7297 r9435 44 44 n++; 45 45 } 46 47 // Expand(n);48 46 } 49 47 50 voidRings::CalcRings(Leds &leds, Float_t min, Float_t max)48 Int_t Rings::CalcRings(Leds &leds, Float_t min, Float_t max) 51 49 { 52 50 CalcCenters(leds, min, max); … … 57 55 for (int j=0; j<n; j++) 58 56 leds(j).CalcPhi(fCenter); 57 58 return GetEntries(); 59 59 } 60 60 -
trunk/MagicSoft/Cosy/caos/Rings.h
r7787 r9435 25 25 void SetMinNumberLeds(Short_t n) { fMinNumberLeds=n; } 26 26 27 voidCalcRings(Leds &leds, Float_t min=-1, Float_t max=-1);27 Int_t CalcRings(Leds &leds, Float_t min=-1, Float_t max=-1); 28 28 29 29 void Print(Option_t *o=NULL) const; -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r8847 r9435 30 30 double fSinAngle; 31 31 double fCosAngle; 32 double fAngle; 32 33 33 34 float fLimitMag; // [M] limiting magnitude for display … … 57 58 void SetPixSize(const double pixsize); 58 59 void SetLimitMag(const float mag); 59 void SetRotationAngle(const float angle) { fSinAngle = sin(angle/kRad2Deg); fCosAngle = cos(angle/kRad2Deg); }60 void SetRotationAngle(const double angle) { fSinAngle = sin(angle/kRad2Deg); fCosAngle = cos(angle/kRad2Deg); fAngle=angle; } 60 61 void Reload(); 62 63 double GetRotationAngle() { return fAngle; } 61 64 62 65 double GetPixSize() const; -
trunk/MagicSoft/Cosy/cosy.cc
r9132 r9435 6 6 #include <TApplication.h> 7 7 #include <TObjectTable.h> 8 #include <TSocket.h> 8 9 9 10 #include "ethernet.h" … … 63 64 } 64 65 66 enum Ports_t { 67 kPortTPoint = 4, 68 kPortStarguider = 5, 69 }; 70 71 Bool_t SwitchCamera(const TString ip, Ports_t port, Bool_t on) 72 { 73 if (ip.IsNull()) 74 return kTRUE; 75 76 TSocket s(ip, 80); 77 if (!s.IsValid()) 78 { 79 gLog << err << "ERROR - Could not connect to " << ip << " to switch " << (on?"on":"off") << " " << (port==kPortTPoint?"TPoint":"Starguider") << " ccd." << endl; 80 return kFALSE; 81 } 82 83 TString msg = Form("GET /ov.html?cmd=1&p=%d&s=%d HTTP/1.1\r\n", port, on?1:0); 84 85 if (s.SendRaw(msg.Data(), msg.Length()) == -1) 86 { 87 gLog << err << "ERROR - Could not talk to " << ip << " to switch " << (on?"on":"off") << " " << (port==kPortTPoint?"TPoint":"Starguider") << " ccd." << endl; 88 return kFALSE; 89 } 90 91 char buf[8192]; 92 93 if (s.RecvRaw(buf, 8192) == -1) 94 return kFALSE; 95 96 // FIXME: Eval buffer 97 98 gLog << all << "- " << (port==kPortTPoint?"TPoint":"Starguider") << " ccd switched " << (on?"on":"off") << "." << endl; 99 100 return kTRUE; 101 } 102 103 65 104 /* ---------------------------------------------------------------------- */ 66 105 int main(int argc, char **argv) … … 88 127 } 89 128 90 const Int_t channel = arg.GetIntAndRemove("--channel=", 0);91 129 const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem"); 92 130 const Bool_t kDebugThreads = arg.HasOnlyAndRemove("--debug-threads"); 93 const TString sps = arg.GetStringAndRemove("--sps=", "sps");94 const TString ceco = arg.GetStringAndRemove("--cc=", "161.72.130.60"); // ceco95 131 const Int_t ceco_tx = arg.GetIntAndRemove("--cc-tx=", 7314);//7304); 96 132 const Int_t ceco_rx = arg.GetIntAndRemove("--cc-rx=", 7414);//7404); 97 const TString pointing = arg.GetStringAndRemove("--pointing-model=", "bending2.txt"); // ceco98 133 const TString kConfig = arg.GetStringAndRemove("--config=", ".cosyrc"); // ceco 99 134 Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0; … … 120 155 return 0xfe; 121 156 } 157 158 const Int_t channel = env.GetValue("DefaultCameraChannel", 0); 159 const TString sps = env.GetValue("IpAddressSPS", "sps"); 160 const TString ceco = env.GetValue("IpAddressCentralControl", "161.72.130.60"); 161 const TString powerswitch = env.GetValue("IpAddressPowerSwitch", ""); 162 const TString pointing = env.GetValue("PointingModel", "bending.txt"); 122 163 123 164 // And move the resource options from the command line to the MEnv … … 218 259 if (channel>=0) 219 260 { 220 gLog << all << "- Starting Camera." << endl; 261 SwitchCamera(powerswitch, kPortTPoint, kTRUE); 262 SwitchCamera(powerswitch, kPortStarguider, kTRUE); 263 264 gLog << all << "- Starting Starguider." << endl; 265 221 266 client=new MStarguider(MObservatory::kMagic1, channel); 267 client->SetupEnv(env); 222 268 //client.SetDriveCom(&com); 223 269 cosy->SetStarguider(client); … … 238 284 gLog << all << "- Stopping starg." << endl; 239 285 delete client; 286 287 SwitchCamera(powerswitch, kPortTPoint, kFALSE); 288 SwitchCamera(powerswitch, kPortStarguider, kFALSE); 240 289 } 241 290 -
trunk/MagicSoft/Cosy/devdrv/DevdrvLinkDef.h
r9132 r9435 6 6 7 7 #pragma link C++ class Dkc+; 8 #pragma link C++ class Macs+;9 #pragma link C++ class ShaftEncoder+;10 8 11 9 #endif -
trunk/MagicSoft/Cosy/devdrv/Makefile
r9132 r9435 17 17 #------------------------------------------------------------------------------ 18 18 19 SRCFILES = shaftencoder.cc macs.ccdkc.cc19 SRCFILES = dkc.cc 20 20 21 21 ############################################################ -
trunk/MagicSoft/Cosy/devdrv/dkc.cc
r9431 r9435 190 190 return; 191 191 192 case 0x100c:193 gLog << inf2 << "- " << GetNodeName() << ": Guard time:" << dec << val << endl;194 return;195 196 case 0x100d:197 gLog << inf2 << "- " << GetNodeName() << ": Life time factor:" << dec << val << endl;198 return;199 200 192 case 0x2002: 201 193 gLog << inf2 << GetNodeName() << ": Current velocity: " << dec << val << endl; … … 264 256 break; 265 257 266 case 0x100c:267 switch (subidx)268 {269 case 0:270 //lout << ddev(MLog::eGui);271 gLog << inf2 << "- " << GetNodeName() << ": Guard time set." << endl;272 //lout << edev(MLog::eGui);273 return;274 }275 break;276 277 case 0x100d:278 switch (subidx)279 {280 case 0:281 //lout << ddev(MLog::eGui);282 gLog << inf2 << "- " << GetNodeName() << ": Life time factor set." << endl;283 //lout << edev(MLog::eGui);284 return;285 }286 break;287 288 case 0x1800:289 switch (subidx)290 {291 case 1:292 //lout << ddev(MLog::eGui);293 gLog << inf2 << "- " << GetNodeName() << ": Status of PDO1 set." << endl;294 //lout << edev(MLog::eGui);295 return;296 }297 break;298 299 258 case 0x2002: 300 switch (subidx) 301 { 302 case 0: 303 //lout << ddev(MLog::eGui); 304 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl; 305 //lout << edev(MLog::eGui); 306 return; 307 } 308 break; 259 //lout << ddev(MLog::eGui); 260 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl; 261 //lout << edev(MLog::eGui); 262 return; 309 263 310 264 case 0x2003: 311 switch (subidx) 312 { 313 case 0: 314 //lout << ddev(MLog::eGui); 315 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl; 316 //lout << edev(MLog::eGui); 317 return; 318 case 1: 319 //lout << ddev(MLog::eGui); 320 gLog << inf2 << "- " << GetNodeName() << ": Deceleration set." << endl; 321 //lout << edev(MLog::eGui); 322 return; 323 } 324 break; 265 //lout << ddev(MLog::eGui); 266 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl; 267 //lout << edev(MLog::eGui); 268 return; 325 269 326 270 case 0x3006: … … 359 303 return; 360 304 361 case 0x6003:362 switch (subidx)363 {364 case 0:365 //lout << ddev(MLog::eGui);366 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;367 //lout << edev(MLog::eGui);368 return;369 370 case 1:371 //lout << ddev(MLog::eGui);372 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;373 //lout << edev(MLog::eGui);374 return;375 }376 break;377 378 305 case 0x6004: 379 306 switch (subidx) … … 421 348 } 422 349 423 void Dkc::SetPDO1On(BYTE_t flag)424 {425 gLog << inf2 << "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl;426 SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31);427 WaitForSdo(0x1800, 1);428 }429 430 350 void Dkc::StartNode() 431 351 { … … 468 388 WaitForSdo(0x1003, 2); 469 389 470 SetPDO1On(TRUE);471 390 /* 472 391 if (HasError()) … … 528 447 gLog << dbg << "- Setting velocity to: " << vel << endl; 529 448 SendSDO(0x2002, vel); // velocity 530 WaitForSdo(0x2002 , 0);449 WaitForSdo(0x2002); 531 450 } 532 451 … … 535 454 gLog << dbg << "- Setting velocity to: " << vel*100 << "%" << endl; 536 455 SendSDO(0x2002, (LWORD_t)(vel*fVelMax+0.5)); // velocity 537 WaitForSdo(0x2002 , 0);456 WaitForSdo(0x2002); 538 457 } 539 458 … … 544 463 WaitForSdo(0x2003, 0); 545 464 } 546 465 /* 547 466 void Dkc::SetDeceleration(LWORD_t dec) 548 467 { … … 551 470 WaitForSdo(0x2003, 1); 552 471 } 553 472 */ 554 473 void Dkc::SetRpmMode(BYTE_t mode) 555 474 { -
trunk/MagicSoft/Cosy/main/MCaos.cc
r8818 r9435 333 333 } 334 334 335 Ring MCaos::Run(byte *img, bool printl, bool printr, const ZdAz &pos, const MTime &t , Int_t box, Double_t cut)335 Ring MCaos::Run(byte *img, bool printl, bool printr, const ZdAz &pos, const MTime &t) 336 336 { 337 337 Leds &leds = *fLeds; 338 338 leds.Clear(); 339 340 fNumDetectedLEDs = 0; 341 fNumDetectedRings = 0; 339 342 340 343 /* … … 351 354 352 355 // img width height radius sigma 353 FilterLed f(img, 768, 576, box, cut);356 FilterLed f(img, 768, 576, fSizeBox, fCut); 354 357 355 358 Int_t first=0; … … 359 362 const Led &l0 = fPositions(i); 360 363 f.Execute(leds, TMath::FloorNint(l0.GetX()), TMath::FloorNint(l0.GetY())); 364 365 fNumDetectedLEDs = leds.GetEntries(); 361 366 362 367 // Loop over newly found Leds … … 389 394 // rwagner 390 395 // rings.CalcRings(leds, 158, 164); 391 rings.CalcRings(leds, fMinRadius, fMaxRadius);396 fNumDetectedRings = rings.CalcRings(leds, fMinRadius, fMaxRadius); 392 397 393 398 const Ring ¢er = rings.GetCenter(); … … 488 493 } 489 494 495 496 Int_t MCaos::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 497 { 498 if (IsEnvDefined(env, prefix, "File", print)) 499 ReadResources(GetEnvValue(env, prefix, "File", "ledsxxx.txt")); 500 501 if (IsEnvDefined(env, prefix, "RadiusMin", print)) 502 fMinRadius = GetEnvValue(env, prefix, "RadiusMin", fMinRadius); 503 504 if (IsEnvDefined(env, prefix, "RadiusMax", print)) 505 fMaxRadius = GetEnvValue(env, prefix, "RadiusMax", fMaxRadius); 506 507 if (IsEnvDefined(env, prefix, "MinNumberLeds", print)) 508 fMaxRadius = GetEnvValue(env, prefix, "MinNumberLeds", fMinNumberLeds); 509 510 if (IsEnvDefined(env, prefix, "SizeBox", print)) 511 fSizeBox = GetEnvValue(env, prefix, "SizeBox", fSizeBox); 512 513 if (IsEnvDefined(env, prefix, "CleaningLevel", print)) 514 fCut = GetEnvValue(env, prefix, "CleaningLevel", fCut); 515 516 if (IsEnvDefined(env, prefix, "ArcsecPerPixel", print)) 517 fArcsecPerPixel = GetEnvValue(env, prefix, "ArcsecPerPixel", fArcsecPerPixel); 518 519 return kTRUE; 520 } -
trunk/MagicSoft/Cosy/main/MCaos.h
r8376 r9435 2 2 #define CAOS_MCaos 3 3 4 #ifndef MARS_MParContainer 5 #include "MParContainer.h" 6 #endif 4 7 #ifndef CAOS_Leds 5 8 #include "Leds.h" … … 21 24 class ZdAz; 22 25 23 class MCaos 26 class MCaos : public MParContainer 24 27 { 25 28 private: … … 45 48 TGraph *fGraphr; 46 49 47 Short_t fMinNumberLeds; 48 Double_t fMinRadius; 49 Double_t fMaxRadius; 50 Short_t fMinNumberLeds; // minimum number of detected leds required 51 Double_t fMinRadius; // minimum radius for cut in ring radius 52 Double_t fMaxRadius; // maximum radius for cut in ring radius 53 UShort_t fSizeBox; // Size of the search box (side length in units of pixels) 54 Double_t fCut; // Cleaning level (sigma above noise) 55 Double_t fArcsecPerPixel; // Conversion from arcseconds to pixel 56 57 Int_t fNumDetectedLEDs; 58 Int_t fNumDetectedRings; 50 59 51 60 public: 52 MCaos() : fFile(NULL), fHistpr(NULL), fMinNumberLeds(5), fMinRadius(265), fMaxRadius(268) 61 MCaos(const char *name=0, const char *title=0) 62 : fFile(NULL), fHistpr(NULL), fMinNumberLeds(5), 63 fMinRadius(265), fMaxRadius(268), fSizeBox(19), fCut(3.0) 53 64 { 54 65 fLeds = new Leds; 55 66 } 56 67 57 68 ~MCaos() 58 69 { … … 72 83 void CloseFile(); 73 84 74 void SetMinNumber Rings(Short_t n)85 void SetMinNumberLeds(Short_t n) 75 86 { 76 87 fMinNumberLeds = n; 77 88 } 78 89 79 void SetRadii(Double_t min, Double_t max) 80 { 81 fMinRadius=min; 82 fMaxRadius=max; 83 } 90 void SetMinRadius(Double_t min) { fMinRadius=min; } 91 void SetMaxRadius(Double_t max) { fMaxRadius=max; } 84 92 85 93 void InitHistograms(); … … 88 96 void ResetHistograms(); 89 97 98 Int_t GetNumDetectedLEDs() const { return fNumDetectedLEDs; } 99 Int_t GetNumDetectedRings() const { return fNumDetectedRings; } 100 101 Double_t GetArcsecPerPixel() const { return fArcsecPerPixel; } 102 90 103 Ring Run(byte *img, bool printl, bool printr, const ZdAz &pos, 91 const MTime &t, Int_t box, Double_t cut); 104 const MTime &t); 105 106 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 92 107 }; 93 108 -
trunk/MagicSoft/Cosy/main/MCosy.cc
r9132 r9435 1 #include "MCosy.h" 1 2 #include "MCosy.h" 2 3 … … 388 389 { 389 390 // FIXME: Makes sense? 390 fMac1->Set Deceleration(TMath::Nint(0.03*1000000000));391 fMac2->Set Deceleration(TMath::Nint(0.09*1000000000));391 fMac1->SetAcceleration(TMath::Nint(0.03*1000000000)); 392 fMac2->SetAcceleration(TMath::Nint(0.09*1000000000)); 392 393 393 394 fMac1->SetRpmMode(FALSE); … … 509 510 } 510 511 return 0xca1b; 512 513 case WM_STARGTPOINT: 514 if (fStarguider) 515 fStarguider->StartTPoint(); 516 return 0xca1c; 517 518 case WM_STARGMODE: 519 if (fStarguider) 520 fStarguider->StartStarguider(); 521 return 0xca1c; 511 522 512 523 case WM_TRACKPOS: … … 712 723 if (!CheckNetwork()) 713 724 { 714 gLog << err << "ERROR: Cannot shutdown CANbusnetwork." << endl;715 return 0xebb0;725 gLog << err << "ERROR: Cannot shutdown network." << endl; 726 gLog << " Please shutdown the drive system manually" << endl; 716 727 } 717 728 TerminateApp(); -
trunk/MagicSoft/Cosy/main/MCosy.h
r9132 r9435 44 44 #define WM_PREPS 0x1012 45 45 #define WM_ARM 0x1013 46 #define WM_STARGTPOINT 0x1014 47 #define WM_STARGMODE 0x1015 46 48 47 49 class Dkc; -
trunk/MagicSoft/Cosy/main/MStargHistograms.cc
r8847 r9435 71 71 tree->Branch("CenterX.", &fCenterX, "fCenterX/D"); 72 72 tree->Branch("CenterY.", &fCenterY, "fCenterY/D"); 73 // Center of Camera, offset from arb coords, in Zd, Az, deg74 // tree->Branch("CenterZd.", &fCenterZd, "fCenterZd/D");75 // tree->Branch("CenterAz.", &fCenterAz, "fCenterAz/D");76 // Position of Star in Camera in Zd, Az77 tree->Branch("StarZd.", &fStarZd, "fStarZd/D");78 tree->Branch("StarAz.", &fStarAz, "fStarAz/D");79 73 // number of spots found 80 74 tree->Branch("Spots.", &fSpots, "fSpots/D"); … … 82 76 tree->Branch("Stars.", &fStars, "fStars/D"); 83 77 tree->Branch("Bright.", &fBright, "fBright/D"); 84 85 78 86 79 cout << "Root file '" << name << "' open." << endl; … … 108 101 } 109 102 110 void MStargHistograms::InitHistograms() 111 { 112 113 } 114 115 void MStargHistograms::DeleteHistograms() 116 { 117 118 } 119 120 void MStargHistograms::ShowHistograms() 121 { 122 123 } 124 125 void MStargHistograms::ResetHistograms() 126 { 127 128 } 129 130 void MStargHistograms::Fill(Leds &spots, MStarList &stars, ZdAz &d, ZdAz sao, Ring ¢er, ZdAz &star, Double_t bright, const ZdAz &pos, const MTime &t) 103 void MStargHistograms::Fill(Leds &spots, MStarList &stars, ZdAz &d, ZdAz sao, Ring ¢er, Double_t bright, const ZdAz &pos, const MTime &t) 131 104 { 132 105 // FIXME! … … 134 107 fEvtTime = t-t0; 135 108 136 // cout << "@ evttime " << fEvtTime << endl;137 138 109 if (fFile && spots.GetEntries()>0) 139 110 { … … 147 118 fCenterX = center.GetX(); 148 119 fCenterY = center.GetY(); 149 //fCenterZd = centerzdaz.Zd();150 //fCenterAz = centerzdaz.Az();151 fStarZd = star.Zd();152 fStarAz = star.Az();153 120 fStars = stars.GetRealEntries(); 154 121 fSpots = spots.GetEntries(); 155 122 fBright = bright; 156 123 157 // cout << " Evttime=" << fEvtTime158 // << " ZD=" << fZenithDist159 // << " Az=" << fAzimuth160 // << " NomZd=" << fNomZd161 // << " NomAz=" << fNomAz162 // << " dZd=" << fdZd163 // << " dAz=" << fdAz164 // << " OffsX=" << fOffsetX165 // << " OffsY=" << fOffsetY166 // <<endl;167 168 124 TTree *t = (TTree*)fFile->Get("Data"); 169 125 t->Fill(); 170 126 } 171 172 127 } -
trunk/MagicSoft/Cosy/main/MStargHistograms.h
r8847 r9435 31 31 Double_t fSpots; 32 32 Double_t fBright; 33 // Double_t fCenterZd;34 // Double_t fCenterAz;35 Double_t fStarZd;36 Double_t fStarAz;37 38 33 39 34 public: … … 43 38 44 39 void Fill(Leds &spots, MStarList &stars, ZdAz &d, ZdAz sao, 45 Ring ¢er, /*ZdAz ¢erzdaz,*/ ZdAz &star, Double_t bright,46 40 Ring ¢er, Double_t bright, 41 const ZdAz &pos, const MTime &t); 47 42 48 43 void OpenFile(); 49 44 void CloseFile(); 50 51 void InitHistograms();52 void DeleteHistograms();53 void ShowHistograms();54 void ResetHistograms();55 56 45 }; 57 46 -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r9132 r9435 9 9 #include <TGraph.h> 10 10 #include <TTimer.h> 11 #include <TEnv.h> 11 12 #include <TSystem.h> 12 13 #include <TFile.h> // temp writeout of histos 13 #include <TSocket.h>14 //#include <TSocket.h> 14 15 15 16 #include <TGMenu.h> … … 111 112 IDM_kStargAnalysis, 112 113 IDM_kStargCaosFilter, 113 IDM_kStargFindStar,114 IDM_kRoqueLampAna,115 114 IDM_kStarguiderMode, 116 115 IDM_kTpointMode … … 273 272 fDisplay->AddEntry("Starguider", IDM_kStarguider); 274 273 fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter); 275 fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar);276 274 fDisplay->AddSeparator(); 277 275 if (channel>=0) 278 276 fDisplay->AddPopup("&Input", fChannel); 279 fDisplay->DisableEntry(IDM_kStargFindStar);280 277 fDisplay->CheckEntry(IDM_kStretch); 281 278 fDisplay->Associate(this); … … 298 295 fSetup->Associate(this); 299 296 300 fOperations->AddEntry("Roque Lamp Analysis", IDM_kRoqueLampAna);301 297 fOperations->AddEntry("Starguider Analysis", IDM_kStargAnalysis); 302 298 fOperations->DisableEntry(IDM_kStargAnalysis); … … 400 396 AddFrame(fDZdAzText); 401 397 402 #ifdef EXPERT403 l = new TGLabel(this, "Mispointing/FindStar (Experts Only!)");404 l->SetTextJustify(kTextLeft);405 l->Move(240+12+20, fMenu->GetDefaultHeight()+722+3*20-5);406 AddFrame(l);407 #endif408 409 398 // Set input box for rotation angle 410 const Double_t angle = -0.2; 411 fSao->SetRotationAngle(angle); 412 413 TString txt; 414 txt += angle; 415 416 fAngle = new TGTextEntry(this, txt, IDM_kAngle); 399 fAngle = new TGTextEntry(this, " ", IDM_kAngle); 417 400 fAngle->SetAlignment(kTextCenterX); 418 401 fAngle->Move(547-410, fMenu->GetDefaultHeight()+667); 419 402 AddFrame(fAngle); 420 403 404 SetRotationAngle(-0.2); 405 421 406 // Set input box for pixel size 422 const Double_t pixsize = 48.9; // used to be 23.4 423 424 fSao->SetPixSize(pixsize); 425 426 txt = ""; 427 txt += pixsize; 428 429 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 407 fPixSize = new TGTextEntry(this, " ", IDM_kPixSize); 430 408 fPixSize->SetAlignment(kTextCenterX); 431 409 fPixSize->Move(547-410, fMenu->GetDefaultHeight()+690); 432 410 AddFrame(fPixSize); 433 411 412 SetPixSize(48.9); 413 434 414 // Set input box for cleaning cut 435 const Double_t cut = 3.0; 436 437 txt = ""; 438 txt += cut; 439 440 fCut = new TGTextEntry(this, txt, IDM_kCut); 415 fCut = new TGTextEntry(this, " ", IDM_kCut); 441 416 fCut->SetAlignment(kTextCenterX); 442 417 fCut->Move(547-410, fMenu->GetDefaultHeight()+713); 443 418 AddFrame(fCut); 419 420 SetCut(3.0); 444 421 445 422 // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this); … … 505 482 fDx((768-kZOOM)/2), 506 483 fDy((512-kZOOM)/2), 507 fStatus(MDriveCom::kStandby) 484 fStatus(MDriveCom::kStandby), 485 fRadius(200), 486 fTPointFromCC(0) 508 487 { 509 488 gLog << warn << " #### FIXME: Make MCaos Thread safe!" << endl; … … 513 492 SetCleanup(); 514 493 515 fAmcSocket = new TSocket("amc", 7307);516 517 494 fSao = new StarCatalog(obs); 518 495 fRaDec = new RaDec(180, 40); 519 496 520 // fStargLeds = new MStargLeds;521 // fStargLeds->ReadResources();522 523 497 fCaos = new MCaos; 524 fCaos->ReadResources();525 fCaos->SetRadii(237.9, 239.9);526 527 498 fStargCaos = new MCaos; 528 fStargCaos->ReadResources("stargleds.txt");529 fStargCaos->SetMinNumberRings(3);530 fStargCaos->SetRadii(158,164);531 499 532 500 fStargHistograms = new MStargHistograms(); … … 539 507 fTime.Now(); 540 508 541 fTimeFromTp. Set(1970,1,1);509 fTimeFromTp.Clear(); 542 510 fAltAzOffsetFromTp = AltAz(-1000,-1000); 543 511 … … 550 518 } 551 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 552 561 MStarguider::~MStarguider() 553 562 { … … 564 573 delete fCaos; 565 574 delete fStargCaos; 566 // delete fStargLeds;567 575 delete fStargHistograms; 568 576 delete fSao; … … 578 586 delete fOutRq; 579 587 580 delete fAmcSocket;581 582 588 gLog << inf2 << "Camera Display destroyed." << endl; 583 }584 585 bool MStarguider::SendAmcTrigger(const char *msg)586 {587 if (!fAmcSocket->IsValid())588 return false;589 590 TString txt("TRIGGER ");591 txt += msg;592 593 const Int_t len = fAmcSocket->SendRaw(txt.Data(), txt.Length());594 if (len<0)595 {596 gLog << err << "ERROR - Sending Trigger to Amc" << endl;597 return false;598 }599 if (len!=txt.Length())600 {601 gLog << err << "Send wrong number (" << len << ") of Bytes to Amc." << endl;602 return false;603 }604 605 return true;606 589 } 607 590 … … 763 746 SwitchOff(fDisplay, IDM_kStarguider); 764 747 SwitchOff(fDisplay, IDM_kStargCaosFilter); 765 fDisplay->DisableEntry(IDM_kStargFindStar);766 748 } 767 749 else … … 858 840 return kTRUE; 859 841 860 case IDM_kRoqueLampAna:861 Toggle(fOperations, IDM_kRoqueLampAna);862 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna))863 fDisplay->CheckEntry(IDM_kStargCaosFilter);864 else865 fDisplay->UnCheckEntry(IDM_kStargCaosFilter);866 867 return kTRUE;868 869 case IDM_kStargFindStar:870 Toggle(fDisplay, IDM_kStargFindStar);871 if (fDisplay->IsEntryChecked(IDM_kStargFindStar))872 fSZdAz->MapWindow();873 else874 fSZdAz->UnmapWindow();875 return kTRUE;876 877 842 case IDM_kStarguider: 878 843 Toggle(fDisplay, IDM_kStarguider); … … 892 857 //uncheck not needed items 893 858 //general 894 fDisplay->UnCheckEntry(IDM_kStargFindStar);895 859 SwitchOff(fDisplay, IDM_kFilter); 896 860 SwitchOff(fChannel, IDM_kChannel3); 897 SwitchOff(fOperations, IDM_kRoqueLampAna);898 861 SwitchOff(fOperations, IDM_kStargAnalysis); 899 862 … … 930 893 fDisplay->EnableEntry(IDM_kFindStar); 931 894 fChannel->EnableEntry(IDM_kChannel3); 932 fOperations->EnableEntry(IDM_kRoqueLampAna);933 895 } 934 896 return kTRUE; … … 941 903 //unchecking not needed items 942 904 //general 943 fDisplay->UnCheckEntry(IDM_kStargFindStar);944 905 SwitchOff(fDisplay, IDM_kFilter); 945 906 SwitchOff(fChannel, IDM_kChannel3); 946 SwitchOff(fOperations, IDM_kRoqueLampAna);947 907 948 908 //from starguider … … 981 941 fChannel->EnableEntry(IDM_kChannel1); 982 942 fChannel->EnableEntry(IDM_kChannel3); 983 fOperations->EnableEntry(IDM_kRoqueLampAna);984 943 985 944 //tpoint … … 1013 972 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 1014 973 { 1015 fDisplay->EnableEntry(IDM_kStargFindStar);1016 974 SwitchOff(fDisplay, IDM_kCaosFilter); 1017 975 SwitchOff(fDisplay, IDM_kFindStar); … … 1023 981 fDisplay->EnableEntry(IDM_kFindStar); 1024 982 fDisplay->EnableEntry(IDM_kCaosFilter); 1025 fDisplay->DisableEntry(IDM_kStargFindStar);1026 983 } 1027 984 return kTRUE; … … 1338 1295 AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg; 1339 1296 AltAz pos1 = fSao->CalcAltAzFromPix(768/2+mx, 576/2+my)*kRad2Deg; 1340 /* 1341 ofstream fout1("pointingpos.txt"); 1342 fout1 << setprecision(10) << fSao->GetMjd()-52000 << " "; 1343 if (fCosy) 1344 fout1 << fCosy->GetPointingPos() << " "; 1345 fout1 << -pos1.Alt() << " " << pos1.Az() << endl; 1346 */ 1297 1347 1298 pos1 -= pos0; 1348 /* 1349 ofstream fout2("tracking_error.txt", ios::app); 1350 fout2 << setprecision(10) << fSao->GetMjd()-52000 << " "; 1351 if (fCosy) 1352 fout2 << fCosy->GetPointingPos() << " "; 1353 fout2 << -pos1.Alt() << " " << pos1.Az() << endl; 1354 */ 1299 1355 1300 return ZdAz(-pos1.Alt(), pos1.Az()); 1356 1301 } … … 1360 1305 { 1361 1306 num = leds.GetEntries(); 1362 //cout << "Num: " << num << endl;1363 1307 if (num < 3) //was 1 1364 1308 { 1365 1309 gLog << warn << "Sorry, less than 3 detected spot in FOV!" << endl; 1366 if (fStargTPoint->IsDown()) 1367 fStargTPoint->SetDown(kFALSE); 1310 fStargTPoint->SetDown(kFALSE); 1368 1311 return 0; 1369 1312 } 1370 1313 1371 //cout << "Cat: " << stars.GetRealEntries() << endl;1372 1314 if (stars.GetRealEntries() < 3) 1373 1315 { 1374 1316 gLog << warn << "Sorry, less than 3 stars in FOV!" << endl; 1375 if (fStargTPoint->IsDown()) 1376 fStargTPoint->SetDown(kFALSE); 1317 fStargTPoint->SetDown(kFALSE); 1377 1318 return 0; 1378 1319 } … … 1433 1374 d = TrackingError(x, y, mag, numcor); 1434 1375 if (numcor<1) 1376 { 1377 fStargTPoint->SetDown(kFALSE); 1435 1378 return 0; 1436 1437 //cout << "Cor: " << numcor << endl; 1379 } 1438 1380 1439 1381 fDZdAz->SetCoordinates(d); 1440 1441 //1442 // Calculated offsets1443 //1444 1445 #ifdef EXPERT1446 // round= floor(x+.5)1447 cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl;1448 cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl;1449 #endif1450 1382 1451 1383 // … … 1476 1408 // Get tracking coordinates 1477 1409 const XY xy = fCRaDec->GetCoordinates(); 1478 const RaDec rd(xy.X()* TMath::DegToRad()*15, xy.Y()*TMath::DegToRad());1410 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad()); 1479 1411 1480 1412 // From the star position in the camera we calculate the Alt/Az … … 1485 1417 //correction with offset from last tpoint measurement 1486 1418 za0 -= fAltAzOffsetFromTp; 1487 MTime t2 = fTimeFromTp;1488 1419 1489 1420 //if the difference between the tpoint and the starguider tpoint 1490 1421 //is too big, the starguider tpoint is not stored 1491 cout << " mjd difference: " << t.GetMjd()-t2.GetMjd() << endl; 1492 // cout << "t: " << setprecision(11) << t.GetMjd() << endl; 1493 // cout << "t2: " << setprecision(11) << t2.GetMjd() << endl; 1494 if ((t.GetMjd()-t2.GetMjd())>0.001) //1min20sec 1495 { 1496 cout << " time difference between tpoint and starguider-tpoint > 1 min *" << 1497 t.GetMjd()-t2.GetMjd() << "s) " << endl; 1422 if ((t.GetMjd()-fTimeFromTp.GetMjd())>0.001) //1min20sec 1423 { 1424 cout << " time difference between tpoint and starguider-tpoint > 1m20s" << endl; 1498 1425 cout << " => starguider tpoint hasn't been stored. " << endl; 1499 cout << " Please repeat whole procedure. " << endl;1426 cout << " Please repeat whole procedure. " << endl; 1500 1427 return numcor; 1501 1428 } … … 1503 1430 1504 1431 // Write real pointing position 1505 cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;1432 //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl; 1506 1433 *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " "; 1507 1434 1508 1435 // Write system pointing position 1509 cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl;1436 //cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl; 1510 1437 *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd(); 1511 1438 … … 1517 1444 *fOutStargTp << endl; 1518 1445 1519 fTimeFromTp. Set(1970,1,1);1446 fTimeFromTp.Clear(); 1520 1447 1521 1448 return numcor; 1522 1449 } 1523 1450 1524 XY MStarguider::FindRoqueLamp(FilterLed &f, FilterLed &f2, Ring &CameraCenter, MTime &t, Double_t cut, Int_t box, XY SearchCenter) 1525 { 1526 // Set search Paremeters (FIXME: Get them from user input!) 1527 f.SetCut(cut); // 3.5 1528 f.SetBox(box); // 70 1529 1530 // Try to find Led in this area 1531 Leds leds; 1532 f.FindStar(leds, (Int_t)SearchCenter.X(), (Int_t)SearchCenter.Y(), true); 1533 1534 // Check whether star found 1535 Led *star = (Led*)leds.At(0); 1536 if (!star || leds.GetEntries()<1) 1537 return XY(.0,.0); 1538 1539 // cout << "Found Roque Lamp @ " << flush; 1540 star->Print(); 1541 f.MarkPoint(star->GetX(), star->GetY(), 500); 1542 1543 // cout << "RoquePos: " << star->GetX() << "," << star->GetY() << endl; 1544 1545 XY roquepos(star->GetX(), star->GetY()); 1546 XY relroquepos(roquepos.X()-CameraCenter.GetX(), roquepos.Y()-CameraCenter.GetY()); 1547 1548 // If no file open: open new Roque Lamp file 1549 if (!fOutRq) 1550 { 1551 const TString name = MCosy::GetFileName("tpoint", "roquelamp", "txt"); 1552 cout << "Starg_RoqueLamp File ********* " << name << " ********** " << endl; 1553 fOutRq = new ofstream(name); 1554 *fOutRq << "# Magic Roque Lamp file " << t << endl; 1555 } 1556 1557 return relroquepos; 1558 } 1559 1560 ZdAz MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t, Double_t cut, Int_t box, Double_t scalefactor = 1.0) 1561 { 1562 // Set search Paremeters (FIXME: Get them from user input!) 1563 f.SetCut(cut); // 3.5 1564 f.SetBox(box); // 70 1565 1566 // Try to find Led in this area 1451 void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t) 1452 { 1453 // Try to find the star 1567 1454 Leds leds; 1568 1455 f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true); 1569 1570 if (leds.GetEntries()<0)1571 return ZdAz(0, 0);1572 1456 1573 1457 // Check whether star found … … 1580 1464 gLog << warn << "No star found. Couldn't take a tpoint." << endl; 1581 1465 } 1582 return ZdAz(.0,.0); 1583 } 1466 return; 1467 } 1468 1584 1469 cout << "Found star @ " << flush; 1585 1470 star->Print(); 1586 1471 f2.MarkPoint(star->GetX(), star->GetY(), 2<<2); 1587 1472 1588 // Initialize Star Catalog on th camera plane1473 // Initialize Star Catalog on the camera plane 1589 1474 MGeomCamMagic geom; 1590 1475 MAstroCamera ac; … … 1595 1480 1596 1481 // Get tracking coordinates 1597 const XY xy = fCRaDec->GetCoordinates();1598 const RaDec rd(xy.X()* TMath::DegToRad()*15, xy.Y()*TMath::DegToRad());1482 const XY xy = fCRaDec->GetCoordinates(); // [h, deg] 1483 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad()); 1599 1484 1600 1485 ac.SetRaDec(rd.Ra(), rd.Dec()); 1601 1486 1487 // Convert from Pixel to millimeter (1pix=2.6mm) [deg/pix / deg/mm = mm/pix] 1488 // Correct for abberation. 1489 const Double_t conv = fCaos->GetArcsecPerPixel()/3600/geom.GetConvMm2Deg()/ 1.0713; 1490 1602 1491 // Adapt coordinate system (GUIs and humans are counting Y in different directions) 1603 Double_t x = star->GetX()-center.GetX(); 1604 Double_t y = center.GetY()-star->GetY(); 1605 1606 #ifdef EXPERT 1607 cout << "STAR-Offset: " << MTime(-1) << " dx=" << x << "pix dy=" << y << "pix" << endl; 1608 #endif 1609 1610 // MAKE SURE THAT THIS VALUE CAN BE SETUP 1611 // (Scalefactor describes the difference between the tpoint (=1) 1612 // and the starguider (!=1) camera 1613 // Convert from Pixel to millimeter (1pix=2.6mm) 1614 x *= (2.58427 * scalefactor); 1615 y *= (2.58427 * scalefactor); 1616 1617 // Correct for abberation. 1618 x /= 1.0713; 1619 y /= 1.0713; 1492 const Double_t dx = (star->GetX()-center.GetX())*conv; 1493 const Double_t dy = (center.GetY()-star->GetY())*conv; 1620 1494 1621 1495 // Convert offset from camera plane into local ccordinates 1622 1496 Double_t dzd, daz; 1623 ac.GetDiffZdAz(x, y, dzd, daz); 1624 1625 #ifdef EXPERT 1626 cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl; 1627 #endif 1497 ac.GetDiffZdAz(dx, dy, dzd, daz); 1628 1498 1629 1499 ZdAz zdaz(dzd,daz); … … 1631 1501 // Check TPoint data set request 1632 1502 if (!fTPoint->IsDown()) 1633 return zdaz; 1503 return; 1504 1634 1505 fTPoint->SetDown(kFALSE); 1635 1506 … … 1641 1512 // 1642 1513 const TString name = MCosy::GetFileName("tpoint", "tpoint", "txt"); 1643 cout << "TPoint -StargFile ********* " << name << " ********** " << endl;1514 cout << "TPoint File ********* " << name << " ********** " << endl; 1644 1515 1645 1516 fOutTp = new ofstream(name); … … 1652 1523 1653 1524 // Output Ra/Dec the drive system thinks that it is currently tracking 1654 cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl;1525 //cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl; 1655 1526 1656 1527 // From the star position in the camera we calculate the Alt/Az … … 1664 1535 fTimeFromTp=t; 1665 1536 1666 1667 1537 // From the Shaftencoders we get the current 'pointing' position 1668 1538 // as it is seen by the drive system (system pointing position) 1669 // FIXME???? 1670 const ZdAz za1 = fCosy->GetSePos()*TMath::TwoPi(); 1539 const ZdAz za1 = fCosy->GetSePos()*360; // [deg] 1671 1540 1672 1541 // Write real pointing position 1673 cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;1542 //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl; 1674 1543 *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " "; 1675 1544 1676 1545 // Write system pointing position 1677 cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl;1546 //cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl; 1678 1547 *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd(); 1679 1548 … … 1684 1553 *fOutTp << " " << star->GetMag(); 1685 1554 *fOutTp << endl; 1686 1555 /* 1687 1556 MLog &outrep = *fCosy->GetOutRep(); 1688 1557 if (outrep.Lock("MStarguider::FindStar")) … … 1695 1564 outrep << star->GetX() << " " << star->GetY() << " "; 1696 1565 outrep << center.GetX() << " " << center.GetY() << " "; 1697 outrep << x*1.0713/2.58427 << " " << y*1.0713/2.58427<< " " << star->GetMag();1566 outrep << dx/conv << " " << dy/conv << " " << star->GetMag(); 1698 1567 outrep << setprecision(11) << t.GetMjd() << endl; 1699 1568 outrep.UnLock("MStarguider::FindStar"); 1700 } 1569 }*/ 1701 1570 1702 return zdaz;1571 // return zdaz; 1703 1572 } 1704 1573 … … 1730 1599 1731 1600 return true; 1601 } 1602 1603 void MStarguider::DrawZoomImage(const byte *img) 1604 { 1605 byte zimg[kZOOM*kZOOM]; 1606 for (int y=0; y<kZOOM; y++) 1607 for (int x=0; x<kZOOM; x++) 1608 zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768]; 1609 1610 fZoomImage->DrawImg(zimg); 1611 } 1612 1613 void MStarguider::DrawCosyImage(const byte *img) 1614 { 1615 if (!fCosy) 1616 return; 1617 1618 byte simg[(768/2-1)*(576/2-1)]; 1619 for (int y=0; y<576/2-1; y++) 1620 for (int x=0; x<768/2-1; x++) 1621 simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4; 1622 1623 fCosy->GetWin()->GetImage()->DrawImg(simg); 1624 } 1625 1626 void MStarguider::StartStarguider() 1627 { 1628 // Switch to starguider mode 1629 cout << " * Switching to Starguider mode" << endl; 1630 fMode->UnCheckEntry(IDM_kStarguiderMode); 1631 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0); 1632 } 1633 1634 Bool_t MStarguider::DoTPoint() 1635 { 1636 if (fTPointFromCC<0) 1637 return kTRUE; 1638 1639 switch (++fTPointFromCC) 1640 { 1641 case 1: 1642 fTimeFromTp.Clear(); 1643 fNumStarsDetected = 0; 1644 1645 cout << " * Switching to TPoint mode" << endl; 1646 // Switch to tpoint mode 1647 fMode->UnCheckEntry(IDM_kTpointMode); 1648 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kTpointMode, 0); 1649 return kFALSE; 1650 1651 case 2: 1652 cout << " * Waiting one frame" << endl; 1653 // Wait one frame 1654 return kFALSE; 1655 1656 case 3: 1657 cout << " * Taking TPoint" << endl; 1658 fTPoint->SetDown(); // kTRUE 1659 return kTRUE; 1660 1661 case 4: 1662 if (!fTimeFromTp) // TPoint failed 1663 break; 1664 1665 // Switch to starguider mode 1666 cout << " * Switching to Starguider mode" << endl; 1667 fMode->UnCheckEntry(IDM_kStarguiderMode); 1668 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0); 1669 return kFALSE; 1670 1671 case 5: 1672 cout << " * Waiting one frame" << endl; 1673 // Wait one frame 1674 return kFALSE; 1675 1676 case 6: 1677 cout << " * Taking Starguider TPoint" << endl; 1678 fStargTPoint->SetDown(); // kTRUE 1679 return kTRUE; 1680 1681 case 7: 1682 cout << " * Send Report" << endl; 1683 break; 1684 } 1685 1686 // Send report 1687 fTPointFromCC = -1; 1688 1689 if (!fCosy) 1690 return kTRUE; 1691 1692 MDriveCom *com = fCosy->GetDriveCom(); 1693 if (!com) 1694 return kTRUE; 1695 1696 // nominalaz, nominalel, realaz, realel, nomra, nomdec, 1697 // diffaz, diffel, mjd, numleds, artmag 1698 1699 //fTimeFromTp.Clear(); 1700 //fStatus==MDriveCom::kMonitoring 1701 //fNumStarsDetected = numstars; 1702 //fNumStarsCorrelated = rc; 1703 com->SendTPoint(fNumStarsCorrelated>0); 1704 1705 return kTRUE; 1732 1706 } 1733 1707 … … 1778 1752 f.Execute(); 1779 1753 1754 DoTPoint(); 1755 1756 Int_t numleds = 0; 1757 Int_t numrings = 0; 1758 1780 1759 // Find Center of Camera for Caos and Tpoints 1781 1760 Ring center(768/2, 576/2); … … 1787 1766 if (fCosy) 1788 1767 pos = fCosy->GetPointingPos(); 1789 center = fCaos->Run(img, printl, printr, pos, t, 19, 3.0); 1790 cout << "Caos Filter Camera center position: " << center.GetX() << " " << center.GetY() << " (R=" << center.GetR() << ")" << endl; 1791 1768 1769 center = fCaos->Run(img, printl, printr, pos, t); 1770 1771 numleds = fCaos->GetNumDetectedLEDs(); 1772 numrings = fCaos->GetNumDetectedRings(); 1792 1773 } 1793 1774 … … 1796 1777 center.GetX()>0 && center.GetY()>0) 1797 1778 { 1798 // SCALE FACTOR ASSUMED TO BE 70 1799 FindStar(f, f2, center, t, 3/*3.5*/, 70); 1800 SendAmcTrigger("TPoint"); 1801 } 1802 1803 byte zimg[kZOOM*kZOOM]; 1804 for (int y=0; y<kZOOM; y++) 1805 for (int x=0; x<kZOOM; x++) 1806 zimg[x+y*kZOOM] = img[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768]; 1807 1808 fZoomImage->DrawImg(zimg); 1809 1810 if (fCosy) 1811 { 1812 byte simg[(768/2-1)*(576/2-1)]; 1813 for (int y=0; y<576/2-1; y++) 1814 for (int x=0; x<768/2-1; x++) 1815 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; 1816 1817 fCosy->GetWin()->GetImage()->DrawImg(simg); 1818 } 1779 // Set search Paremeters (FIXME: Get them from user input!) 1780 f.SetCut(3.0); 1781 f.SetBox(70); 1782 1783 FindStar(f, f2, center, t); 1784 } 1785 1786 DrawZoomImage(img); 1787 DrawCosyImage(img); 1788 1789 // Position corresponding to the camera center (53.2, 293.6) 1790 Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px] 1819 1791 1820 1792 // Find Center of Camera in Starfield Camera picture 1821 1822 Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px]1823 //ZdAz sgcenterzdaz(0, 0); // Center of camera in SG picture [deg]1824 // // (0,0)_deg is at (53.2, 293.6)_px1825 ZdAz star(0, 0); // Star on curtain in [deg]1826 1827 1793 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 1828 1794 { … … 1831 1797 pos = fCosy->GetPointingPos(); 1832 1798 1833 sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 19, 3.0); // [px] 1834 1835 //const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px] 1836 1837 // BE CAREFULL: This transformation is WRONG. It is just 1838 // a transformation of units, but this implies, that the 1839 // coordiante axis in both units look the same. This is 1840 // wrong exspecially near the zenith were az-lines are highly 1841 // curved around the zenith! 1842 //sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 ); 1843 //sgcenterzdaz.Az((sgcenter.GetX()-53.2) * pixsize /3600 ); 1844 #ifdef EXPERT 1845 cout << "- LEDs imply offset of Zd=" 1846 << sgcenter.GetX()-53.2 << "pix Az=" 1847 << sgcenter.GetY()-293.6<< "pix" << endl; 1848 #endif 1849 if (fDisplay->IsEntryChecked(IDM_kStargFindStar) && 1850 sgcenter.GetX()>0 && sgcenter.GetY()>0) 1851 { 1852 star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg] 1853 #ifdef EXPERT 1854 cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az=" 1855 << star.Az()*60 << "'" << endl; 1856 #endif 1857 fSZdAz->SetCoordinates(star); // Mispointing found from Camera 1858 1859 SendAmcTrigger("Starguider"); 1860 } 1861 } 1862 1863 // Find Roque Lamp 1864 1865 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1866 { 1867 1868 Double_t imageclean = 1.5; 1869 Int_t boxradius = 60; 1870 //Double_t scalefactor = 1; 1871 XY searchcenter(768/2-1,576/2+25); 1872 1873 XY roquelamp = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter); 1874 1875 if (fOutRq) 1876 { 1877 ZdAz pos = fCosy->GetPointingPos(); 1878 1879 *fOutRq << "RoqueLampDirect: " << MTime(-1) << " " 1880 << pos.Zd() << " " << pos.Az() << " " 1881 << roquelamp.X() << " " << roquelamp.Y() << endl; 1882 } 1883 1884 cout << "Starguider Camera Center: " << sgcenter.GetX() << "," << sgcenter.GetY() << endl; 1885 cout << ">=>=>=> Roque Lamp found at: >=>=>=> (" << roquelamp.X() << "," 1886 << roquelamp.Y() << ") <=<=<=<" << endl; 1887 1888 } 1889 1890 // Find Spot on Camera Center in Starguider camera 1891 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1892 { 1893 XY cameraspot(0,0); 1894 1895 Double_t imageclean = 5; 1896 Int_t boxradius = 60; 1897 //Double_t scalefactor = 1; 1898 // XY searchcenter(sgcenter.GetX(),sgcenter.GetY()); 1899 XY searchcenter(60.,290.); 1900 1901 cameraspot = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter); 1902 1903 if (fOutRq) 1904 { 1905 ZdAz pos = fCosy->GetPointingPos(); 1906 1907 *fOutRq << "RoqueLampReflected: " << MTime(-1) << " " 1908 << pos.Zd() << " " << pos.Az() << " " 1909 << cameraspot.X() << " " << cameraspot.Y() << endl; 1910 } 1911 1912 cout << ">>>>> Spot on Magic camera found at: >>>>> (" << cameraspot.X() << "," 1913 << cameraspot.Y() << ") <<<<<" << endl; 1914 1915 f2.DrawCircle(sgcenter, 5.0, 0x0fa); 1916 f2.DrawCircle(sgcenter, 115.0, 0x0fa); 1917 } 1918 // we calculate the offset given by the three ETH Leds visible to 1919 // the guide camera 1920 // This is an (inferior, obsolete) alternative to the StarCaosFilter 1921 // Led offset; 1922 // if (fDisplay->IsEntryChecked(IDM_kStargLEDFilter)) 1923 // fStargLeds->Run(img,offset); 1924 1925 // Position corresponding to the camera center (53.2, 293.6) 1926 //Ring skycenter(392, 318); 1927 // MStarList spots; 1799 sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t); // [px] 1800 1801 numleds = fStargCaos->GetNumDetectedLEDs(); 1802 numrings = fStargCaos->GetNumDetectedRings(); 1803 } 1928 1804 1929 1805 // we obtain a list of stars in the FOV from the SAO catalog … … 1932 1808 MTime time(*tm); 1933 1809 1934 1935 fRaDec->Set(xy.X()* 360/24, xy.Y());//[deg,deg]1810 XY xy = fCRaDec->GetCoordinates(); //[h, deg] 1811 fRaDec->Set(xy.X()*15, xy.Y()); //[deg,deg] 1936 1812 1937 1813 UpdatePosZoom(); … … 1941 1817 fCZdAz->SetCoordinates(fSao->GetZdAz()); 1942 1818 1943 MStarList stars;1944 1819 fSao->SetBox(230); // Region of interest around center 1945 1820 1946 // very careful: If center of camera cannot be determined 1947 // sgcenter jumps to (0,0) 1948 1949 //Please never change this offsets!!! 1950 // 53.2 and 293.6 are the "preliminary" camera center 1951 // -9 and 28.5 are the offsets of the pointing position in the sky 1952 1821 // If center of camera cannot be determined sgcenter is (0,0) 1953 1822 const Bool_t centerisvalid = sgcenter.GetX()>0 && sgcenter.GetY()>0; 1954 1823 // if (centerisvalid) … … 1956 1825 // sgcenter.GetY() - 293.6); 1957 1826 1827 // We determine the ideal starfield using camera sagging info 1828 // from the LEDs 1829 //Please never change this offsets!!! 1830 // 53.2 and 293.6 are the "preliminary" camera center 1831 // -9 and 28.5 are the offsets of the pointing position in the sky 1832 const XY off(sgcenter.GetX()- 53.2-9, 1833 sgcenter.GetY()-293.6+28.5); 1834 1958 1835 // we obtain stars in the effective star FOV and draw them. 1959 1836 // coordinates are video frame coords. 1960 // We determine the ideal starfield using camera sagging info 1961 // from the LEDs 1962 const XY off(sgcenter.GetX()- 53.2-9, 1963 sgcenter.GetY()-293.6+28.5); 1964 1837 MStarList stars; 1965 1838 fSao->CalcStars(stars, 530, 292, TMath::FloorNint(off.X()), TMath::FloorNint(off.Y())); 1966 1839 fSao->DrawStars(stars, cimg); … … 2015 1888 2016 1889 if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 2017 fStargHistograms->Fill(spots, stars, fD, 2018 fSao->GetZdAz(), sgcenter, /*sgcenterzdaz,*/ 2019 star, bright, fPos, t); 1890 fStargHistograms->Fill(spots, stars, fD, fSao->GetZdAz(), 1891 sgcenter, bright, fPos, t); 2020 1892 2021 1893 fNumStarsDetected = numstars; … … 2028 1900 com->SendStargReport(fStatus, fD, fSao->GetZdAz(), 2029 1901 sgcenter, numstars, rc, bright, 2030 time.GetMjd(), 0, 0); // Report1902 time.GetMjd(), numleds, numrings); // Report 2031 1903 } 2032 1904 … … 2068 1940 if (fDisplay->IsEntryChecked(IDM_kCaosFilter) || 2069 1941 fDisplay->IsEntryChecked(IDM_kCatalog) || 2070 fDisplay->IsEntryChecked(IDM_kFindStar) || 2071 fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1942 fDisplay->IsEntryChecked(IDM_kFindStar)) 2072 1943 fImage->DrawColImg(img, cimg); 2073 1944 else -
trunk/MagicSoft/Cosy/main/MStarguider.h
r8821 r9435 21 21 class TGButton; 22 22 class TString; 23 class TSocket;23 //class TSocket; 24 24 25 25 class TTimer; … … 111 111 MCaos *fCaos; 112 112 MCaos *fStargCaos; 113 TSocket *fAmcSocket;114 113 MStargHistograms *fStargHistograms; 115 114 … … 133 132 Double_t fLastBright; 134 133 135 void SetPixSize(const double pixsize); 134 Double_t fRadius; // LED radius [cm] 135 136 Int_t fTPointFromCC; 137 136 138 void Toggle(TGPopupMenu *p, UInt_t id); 137 139 void SwitchOff(TGPopupMenu *p, UInt_t id); … … 141 143 void ToggleCaosFilter(); 142 144 void SetChannel(); 143 //void GetCoordinates();144 145 Int_t CalcTrackingError(Leds &, MStarList &, ZdAz &, MTime &, double &bright, Int_t &num); 145 //void CalcTrackingError(Leds &, MStarList &);146 146 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag, Int_t &num) const; 147 147 bool Interpolate(const unsigned long n, byte *img) const; 148 void FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t); 148 149 149 XY FindRoqueLamp(FilterLed &f, FilterLed &f2, Ring &CameraCenter, MTime &t,150 Double_t cut, Int_t box, XY SearchCenter);151 152 ZdAz FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t,153 Double_t cut, Int_t box, Double_t scalefactor);154 155 //void InitHists();156 //void InitGraphs();157 150 void InitGui(Int_t channel); 158 151 159 bool SendAmcTrigger(const char *msg);160 161 //void OpenFile();162 163 //void ResetHists();164 //void DisplayAnalysis();165 152 void UpdatePosZoom(); 153 void DrawZoomImage(const byte *img); 154 void DrawCosyImage(const byte *img); 166 155 167 156 Bool_t HandleTimer(TTimer *t); 168 //Bool_t HandleKey(Event_t* event); 157 158 void SetRotationAngle(Double_t angle); 159 void SetPixSize(Double_t size); 160 void SetCut(Double_t cut); 161 162 Bool_t DoTPoint(); 169 163 170 164 public: … … 172 166 virtual ~MStarguider(); 173 167 174 //void Update();168 void SetupEnv(TEnv &env); 175 169 176 170 void Layout(); … … 180 174 181 175 Bool_t HandleDoubleClick(Event_t *event); 182 //Bool_t HandleButton(Event_t *);183 176 184 177 void SetPointingPosition(RaDec rd); … … 195 188 void Print(Option_t *o) const { } 196 189 190 void StartTPoint() { if (fTPointFromCC<0) fTPointFromCC=0; } 191 void StartStarguider(); 192 197 193 ClassDef(MStarguider, 0) 198 194 }; -
trunk/MagicSoft/Cosy/main/MTracking.cc
r9132 r9435 4 4 5 5 #include "dkc.h" 6 #include "shaftencoder.h"6 //#include "shaftencoder.h" 7 7 8 8 #include "MCosy.h" -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r9432 r9435 42 42 bool MCeCoCom::InterpreteReport(TString &str) 43 43 { 44 if (!str.EndsWith("OVER")) 45 { 46 cout << "Communication Problem: Termination (OVER) not found." << endl; 47 fComStat = kComProblem; 48 return false; 49 } 50 44 51 int y, m, d, h, min, s, ms, len; 45 52 … … 74 81 return false; 75 82 } 83 /* 76 84 str.Remove(0, len); 77 85 … … 82 90 return false; 83 91 } 92 */ 84 93 85 94 fHumidity = hum; … … 142 151 143 152 // Send report to CC 144 const bool rc = Send(msg , strlen(msg));153 const bool rc = Send(msg.Data(), msg.Length()); 145 154 fComStat = rc ? kNoCmdReceived : kComProblem; 146 155 -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r8998 r9435 148 148 { 149 149 cout << "CC-COMMAND " << MTime(-1) << " TPOIN " << str << endl; 150 151 if (fQueue) 152 fQueue->PostMsg(WM_TPOINT);//, (void*)str.Data(), str.Length()+1); 153 154 return true; 155 } 156 157 bool MDriveCom::CommandSTGMD(TString &str) 158 { 159 cout << "CC-COMMAND " << MTime(-1) << "STGMD" << endl; 160 161 if (fQueue) 162 fQueue->PostMsg(WM_STARGMODE);//, (void*)str.Data(), str.Length()+1); 163 150 164 return true; 151 165 } … … 220 234 if (cmd==(TString)"ARM") 221 235 return CommandARM(str); 236 237 if (cmd==(TString)"STGMD") 238 return CommandSTGMD(str); 222 239 223 240 if (cmd.IsNull() && str.IsNull()) … … 278 295 str += armed ? "1 " : "0 "; 279 296 280 return SendRep("DRIVE-REPORT", str , kFALSE);297 return SendRep("DRIVE-REPORT", str.Data(), kFALSE); 281 298 } 282 299 … … 286 303 } 287 304 288 bool MDriveCom::SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Double_t x, Double_t y)305 bool MDriveCom::SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Int_t numleds, Int_t numrings) 289 306 { 290 307 // miss [deg] … … 305 322 str += MString::Format("%05.3f ", miss.Zd()); //[arcmin] 306 323 str += MString::Format("%05.3f ", miss.Az()); //[arcmin] 307 Print(str, nompos.Zd()); //[deg]308 Print(str, nompos.Az()); //[deg]309 str += MString::Format("%05.1f ", center.GetX()); // number310 str += MString::Format("%05.1f ", center.GetY()); // number311 str += MString::Format("%04d ", n); // number of correleated stars312 str += MString::Format("%03.1f ", bright); 324 Print(str, nompos.Zd()); //[deg] 325 Print(str, nompos.Az()); //[deg] 326 str += MString::Format("%05.1f ", center.GetX()); // 327 str += MString::Format("%05.1f ", center.GetY()); // 328 str += MString::Format("%04d ", n); // number of correleated stars 329 str += MString::Format("%03.1f ", bright); // arbitrary sky brightness 313 330 str += MString::Format("%12.6f ", t.GetMjd()); // mjd 314 str += MString::Format("% .1f ", x);315 str += MString::Format("% .1f ", y);316 str += MString::Format("%04d ", num); // number of detected stars331 str += MString::Format("%d ", numleds); // number of detected leds 332 str += MString::Format("%d ", numrings); // number of detected rings 333 str += MString::Format("%04d ", num); // number of detected stars 317 334 318 335 return SendRep("STARG-REPORT", str, kTRUE); … … 321 338 bool MDriveCom::SendTPoint(UInt_t stat) 322 339 { 340 //const MTime t(-1); 341 342 SetStatus(stat); 323 343 /* 324 // miss [deg] 325 // nompos [deg] 326 const MTime t(-1); 327 328 miss *= 60; // [arcmin] 329 330 // Set status flag 331 if (stat&kError) 332 SetStatus(0); 333 if (stat&kStandby) 334 SetStatus(2); 335 if (stat&kMonitoring) 336 SetStatus(4); 337 338 MString txt; 339 340 TString str; 341 str += txt.Print("%05.3f ", miss.Zd()); //[arcmin] 342 str += txt.Print("%05.3f ", miss.Az()); //[arcmin] 343 Print(str, nompos.Zd()); //[deg] 344 Print(str, nompos.Az()); //[deg] 345 str += txt.Print("%05.1f ", center.GetX()); //number 346 str += txt.Print("%05.1f ", center.GetY()); //number 347 str += txt.Print("%04d ", n); //number of correleated stars 348 str += txt.Print("%03.1f ", bright); 349 str += txt.Print("%12.6f ", t.GetMjd()); // mjd 350 str += txt.Print("%.1f ", x); 351 str += txt.Print("%.1f ", y); 352 str += txt.Print("%04d ", num); //number of detected stars 353 */ 354 344 TString str; 345 str += name; // star name 346 str += " "; 347 str += nominalaz; 348 str += nominalel; 349 str += realaz; 350 str += realel; 351 str += nomra; 352 str += nomdec; 353 str += diffaz; 354 str += diffel; 355 str += mjd; 356 str += numleds; 357 str += artmag; 358 */ 355 359 return SendRep("TPOINT-REPORT", "", kTRUE); 356 360 } -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
r8869 r9435 29 29 bool CommandARM(TString &str); 30 30 bool CommandTPOINT(TString &str); 31 bool CommandSTGMD(TString &str); 31 32 32 33 public: … … 49 50 50 51 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed); 51 bool SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Double_t x, Double_t y);52 bool SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Int_t numleds, Int_t numrings); 52 53 bool SendTPoint(UInt_t stat); 53 54 bool SendStatus(const char *stat);
Note:
See TracChangeset
for help on using the changeset viewer.