- Timestamp:
- 02/14/03 23:18:37 (22 years ago)
- Location:
- trunk/MagicSoft
- Files:
-
- 2 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1757 r1758 32 32 - added dat 33 33 - added rcc 34 35 * starg.cc, catalog/SlaStars.[h,cc], catalog/Slalib.[h,cc], 36 catalog/StarCatalog.[h,cc], devdrv/macs.cc, devdrv/shaftencoder.cc, 37 gui/MGCosy.[h,cc], gui/MGSkyPosition.[h,cc], gui/MGStarguider.[h,cc]: 38 - changed to use MObservatory 39 - changed usage of timer to new style 40 41 * catalog/SlaPlanets.[h,cc]: 42 - removed old style calculation 43 - added fTt 44 45 * gui/MGCosy.cc: 46 - added new tab for SE Test 47 48 * main/MCosy.[h,cc]: 49 - don't use second SE when only one is attached 50 - added SE Test stuff 34 51 35 52 -
trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc
r1757 r1758 7 7 ClassImp(SlaPlanets); 8 8 9 SlaPlanets::SlaPlanets( ) : Slalib(), fDt(slaDt(2000.0)/60./60./24.)9 SlaPlanets::SlaPlanets(MObservatory::LocationName_t key) : Slalib(key), fDt(slaDt(2000.0)/60./60./24.) 10 10 { 11 11 } … … 15 15 } 16 16 17 void SlaPlanets::SetMjd( constdouble mjd)17 void SlaPlanets::SetMjd(double mjd) 18 18 { 19 19 Slalib::SetMjd(mjd); 20 21 fTt = mjd + slaDtt(mjd)/60./60./24.; 20 22 21 23 // … … 29 31 } 30 32 31 #include "SlaStars.h"32 33 33 void SlaPlanets::UpdatePlanetPos(ePlanets_t planet) 34 34 { 35 /*36 double cp[6] = { 0, 0, 0, 0, 0, 0 };37 38 double coord[6];39 40 switch (planet)41 {42 case kEMoon:43 //44 // -- approximate geocentric pos and vel --45 //46 slaDmoon(GetMjd() + fDt, coord);47 break;48 49 case kEMercury:50 case kEVenus:51 case kEMars:52 case kEJupiter:53 case kESaturn:54 case kEUranus:55 case kENeptune:56 case kEPluto:57 case kESun:58 {59 */60 35 // 61 // coordinates of planet: heliocentric, equatoril, J200036 // coordinates of planet: topocentric, equatorial, J2000 62 37 // 63 double ra,dec,diam; 64 // TDB, planet, elong, phi, *ra, *dec, *diam 38 double ra, dec, diam; 65 39 66 40 // One can use TT instead of TDB for all plenets 67 41 // (except the moon) 68 69 const double tt = GetMjd() + slaDtt(GetMjd())/60./60./24.; 70 71 // FIXME: Shell be UT1 72 const double ut1 = fmod(GetMjd(), 1); 73 74 // tt should be tdb, but tt can be used 75 const double tdb = tt + slaRcc(tt, ut1, GetElong(), 8300*cos(GetPhi()), 8300*sin(GetPhi() ))/60./60./24.; 76 /* 77 cout << "Dt: " << slaDtt(GetMjd()) << endl; 78 cout << "Rc: " << slaRcc(tt, ut1, GetElong(), 8300*cos(GetPhi()), 8300*sin(GetPhi() )) << endl; 79 */ 80 slaRdplan(tt, planet, GetElong(), GetPhi(), 81 &ra, &dec, &diam); 82 /* 83 switch (planet) 84 { 85 case kEMoon: cout << "Moon: "; break; 86 case kEMercury: cout << "Merkur: "; break; 87 case kEVenus: cout << "Venus: "; break; 88 case kEMars: cout << "Mars: "; break; 89 case kEJupiter: cout << "Jupiter: "; break; 90 case kESaturn: cout << "Saturn: "; break; 91 case kEUranus: cout << "Uranus: "; break; 92 case kENeptune: cout << "Neptun: "; break; 93 case kEPluto: cout << "Pluto: "; break; 94 case kESun: cout << "Sonne: "; break; 95 } 96 97 cout << (int)(ra*12/TMath::Pi()) << "h"<< (int)(ra*12/TMath::Pi()*60)%60 <<"min "; 98 cout << (int)(dec*kRad2Deg) << "deg" << (int)(dec*kRad2Deg*60)%60 << "min" << endl; 99 */ 100 /* 101 SlaStars sla; 102 sla.SetMjd(GetMjd()); 103 ZdAz za = sla.CalcZdAz(RaDec(ra,dec)); 104 cout << za.Zd()*kRad2Deg << " " << fmod(za.Az()*kRad2Deg+720,360.) << endl; 105 fZdAz[planet] = za; 106 */ 42 // TDB, planet, elong, phi, *ra, *dec, *diam 43 slaRdplan(fTt, planet, GetElong(), GetPhi(), &ra, &dec, &diam); 107 44 108 45 double az, el; 109 46 slaDe2h(GetAlpha()-ra, dec, GetPhi(), &az, &el); 110 47 111 cout << 90-el*kRad2Deg << " " << fmod(az*kRad2Deg+720,360.) << endl;112 48 fZdAz[planet].Set(TMath::Pi()/2-el, az); 113 /*114 }115 // !! Fall through!116 break;117 case kESun:118 coord[0] = cp[0] - fEarth[0];119 coord[1] = cp[1] - fEarth[1];120 coord[2] = cp[2] - fEarth[2];121 break;122 }123 fZdAz[planet] = XYZ2ZdAz(coord);124 125 if (planet==kESun)126 {127 cout << fZdAz[kESun].Zd()*kRad2Deg << " " << fZdAz[kESun].Az()*kRad2Deg << endl;128 }*/129 49 } -
trunk/MagicSoft/Cosy/catalog/SlaPlanets.h
r1109 r1758 23 23 { 24 24 private: 25 double fDt; // const: rootcint/TMemberInspector 25 double fDt; // [mjd] const: rootcint/TMemberInspector 26 double fTt; // [mjd] timescale TT 26 27 27 28 ZdAz fZdAz[10]; // [rad] … … 32 33 33 34 public: 34 SlaPlanets( );35 SlaPlanets(MObservatory::LocationName_t key); 35 36 virtual ~SlaPlanets(); 36 37 37 // const AltAz GetAltAz() const { return fAltAz*360/D2PI; } 38 // const ZdAz GetZdAz() const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; } 39 // const RaDec GetRaDec() const { return fRaDec*360/D2PI; } 40 41 void SetMjd(const double mjd); 38 void SetMjd(double mjd); 42 39 43 40 void UpdatePlanetPos(ePlanets_t planet); -
trunk/MagicSoft/Cosy/catalog/SlaStars.cc
r1757 r1758 5 5 ClassImp(SlaStars); 6 6 7 SlaStars::SlaStars( ) : Slalib()7 SlaStars::SlaStars(MObservatory::LocationName_t key) : Slalib(key) 8 8 { 9 9 } -
trunk/MagicSoft/Cosy/catalog/SlaStars.h
r1274 r1758 16 16 17 17 public: 18 SlaStars( );18 SlaStars(MObservatory::LocationName_t key); 19 19 virtual ~SlaStars(); 20 20 -
trunk/MagicSoft/Cosy/catalog/Slalib.cc
r1757 r1758 10 10 ClassImp(Slalib); 11 11 12 Slalib::Slalib( ) : Timer()12 Slalib::Slalib(MObservatory::LocationName_t key) : Timer(), MObservatory(key) 13 13 { 14 // p = pointer to MainFrame (not owner)15 16 //17 // calculate observers location (goe)18 //19 int status;20 //slaDaf2r(51, 38, 48.0, &fPhi, &status);21 //slaDaf2r( 9, 56, 36.0, &fElong, &status);22 //fHeight = 300;23 24 slaDaf2r(28, 45, 30.0, &fPhi, &status);25 slaDaf2r(17, 52, 48.0, &fElong, &status);26 27 fElong *= -1;28 fHeight = 2326;29 30 cout << "Latitude: 51\x9c 38'48.0\" = " << kRad2Deg*fPhi << " ";31 cout << "Longitude: 9\x9c 56'36.0\" = " << kRad2Deg*fElong << endl;32 14 } 33 15 … … 36 18 } 37 19 38 void Slalib::SetMjd( constdouble mjd)20 void Slalib::SetMjd(double mjd) 39 21 { 40 fMjd = mjd;41 fAlpha = slaGmst( fMjd) + fElong;22 Timer::SetMjd(mjd); 23 fAlpha = slaGmst(mjd) + GetElong(); 42 24 } 43 44 void Slalib::SetMjd2Now()45 {46 Now();47 SetMjd(CalcMjd());48 // cout << "GetMjd: "<< (*this)() << " " << GetMjd() << endl;49 }50 51 void Slalib::SetMjd(const struct timeval *tm)52 {53 SetTimer(tm);54 SetMjd(CalcMjd());55 }56 57 25 58 26 ZdAz Slalib::XYZ2ZdAz(double coord[3]) const … … 73 41 // 74 42 double alt, az; 75 slaDe2h(ha, dec, fPhi, &az, &alt);43 slaDe2h(ha, dec, GetPhi(), &az, &alt); 76 44 77 45 return ZdAz(kPiDiv2-alt, az); -
trunk/MagicSoft/Cosy/catalog/Slalib.h
r1757 r1758 5 5 6 6 #include "coord.h" 7 #include "base/timer.h" 7 #include "timer.h" 8 #include "MObservatory.h" 8 9 9 class Slalib : public Timer 10 class Slalib : public Timer, public MObservatory 10 11 { 11 12 private: 12 double fAlpha; 13 double fMjd; 14 15 double fPhi; // location of observatory 16 double fElong; 17 18 double fHeight; 13 double fAlpha; 19 14 20 15 public: 21 Slalib( );16 Slalib(MObservatory::LocationName_t key); 22 17 virtual ~Slalib(); 23 18 24 // const AltAz GetAltAz() const { return fAltAz*360/D2PI; } 25 // const ZdAz GetZdAz() const { return ZdAz(DPI/2-fAltAz.Alt(), fAltAz.Az())*360/D2PI; } 26 // const RaDec GetRaDec() const { return fRaDec*360/D2PI; } 27 28 void SetMjd2Now(); 29 void SetMjd(const struct timeval *tm); 30 31 virtual void SetMjd(const double mjd); 19 virtual void SetMjd(double mjd); 32 20 33 21 double GetAlpha() const { return fAlpha; } 34 double GetMjd() const { return fMjd; }35 36 double GetPhi() const { return fPhi; }37 double GetElong() const { return fElong; }38 39 double GetHeight() const { return fHeight; }40 22 41 23 ZdAz XYZ2ZdAz(double coord[3]) const; -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r1531 r1758 14 14 ClassImp(StarCatalog); 15 15 16 StarCatalog::StarCatalog( ) : SlaStars(), fEntries(0)16 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fEntries(0) 17 17 { 18 18 // p = pointer to MainFrame (not owner) -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r1531 r1758 71 71 72 72 public: 73 StarCatalog( );73 StarCatalog(MObservatory::LocationName_t key); 74 74 virtual ~StarCatalog(); 75 75 -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r1728 r1758 233 233 StopGuarding(); 234 234 235 usleep(2000 .*GetGuardTime());235 usleep(2000*GetGuardTime()); 236 236 237 237 lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; … … 610 610 double Macs::GetMjd() 611 611 { 612 return fPosTime. CalcMjd();612 return fPosTime.GetMjd(); 613 613 } 614 614 … … 620 620 double Macs::GetPdoMjd() 621 621 { 622 return fPdoTime. CalcMjd();622 return fPdoTime.GetMjd(); 623 623 } 624 624 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1742 r1758 213 213 double ShaftEncoder::GetMjd() 214 214 { 215 return fTime. CalcMjd();215 return fTime.GetMjd(); 216 216 } 217 217 -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1727 r1758 311 311 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 312 312 TGCompositeFrame *tf4 = fTab->AddTab("Calibration"); 313 TGCompositeFrame *tf3 = fTab->AddTab("Demo"); 313 TGCompositeFrame *tf5 = fTab->AddTab("Test SE"); 314 /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo"); 314 315 315 316 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 359 360 l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset"); 360 361 l4 = new TGLabel(tf4, "use the Calib SE button."); 362 l1->Move(x, y); 363 l2->Move(x, y+h); 364 l3->Move(x, y+2*h); 365 l4->Move(x, y+3*h); 366 fList->Add(l1); 367 fList->Add(l2); 368 fList->Add(l3); 369 fList->Add(l4); 370 371 l1 = new TGLabel(tf5, "START starts histograming the differences of"); 372 l2 = new TGLabel(tf5, "the two shaftencoders at the elevation axis."); 373 l3 = new TGLabel(tf5, "Use STOP to stop histograming and display the"); 374 l4 = new TGLabel(tf5, "results on the screen."); 361 375 l1->Move(x, y); 362 376 l2->Move(x, y+h); … … 569 583 } 570 584 571 MGCosy::MGCosy(M sgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)572 : TGMainFrame(p, w, h), f Queue(q)585 MGCosy::MGCosy(MObservatory::LocationName_t key, MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h) 586 : TGMainFrame(p, w, h), fObservatory(key), fQueue(q) 573 587 { 574 588 fList = new MGList; … … 596 610 cout << "MGCosy: Creating MGSkyPosition" << endl; 597 611 #endif 598 fSkyPosition = new MGSkyPosition(f 1, 300);612 fSkyPosition = new MGSkyPosition(fObservatory, f1, 300); 599 613 #ifdef DEBUG 600 614 cout << "MGCosy: Creating MGAccuracy" << endl; … … 750 764 static Int_t decs=~0; 751 765 752 static SlaStars sla ;766 static SlaStars sla(fObservatory); 753 767 sla.SetMjd(mjd); 754 768 … … 863 877 fUtc->SetText(new TGString(text)); 864 878 865 double mjd = time. CalcMjd();879 double mjd = time.GetMjd(); 866 880 867 881 sprintf(text, "%12.6f", mjd); … … 1114 1128 return kTRUE; 1115 1129 case 3: 1130 fQueue->Proc(WM_TESTSE, (void*)1); 1131 return kTRUE; 1132 case 4: 1116 1133 StartDemo(); 1117 1134 return kTRUE; … … 1123 1140 StopDemo(); 1124 1141 fQueue->PostMsg(WM_STOP, 0, 0); 1142 if (fTab->GetCurrent()==3) 1143 fQueue->Proc(WM_TESTSE, NULL); 1125 1144 cout << "PostMsg (WM_Stop) returned." << endl; 1126 1145 return kTRUE; -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1702 r1758 4 4 #ifndef ROOT_TGFrame 5 5 #include <TGFrame.h> 6 #endif 7 8 #ifndef MARS_MObservatory 9 #include <MObservatory.h> 6 10 #endif 7 11 … … 31 35 { 32 36 private: 37 const MObservatory::LocationName_t fObservatory; 33 38 34 39 // … … 104 109 105 110 public: 106 MGCosy(M sgQueue *q, const TGWindow *p, UInt_t w, UInt_t h);111 MGCosy(MObservatory::LocationName_t key, MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h); 107 112 ~MGCosy(); 108 113 -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1727 r1758 43 43 // Neptun 7.8 44 44 // 45 fSlaPlanet = new SlaPlanets ;46 fSlaStar = new SlaStars ;45 fSlaPlanet = new SlaPlanets(fObservatory); 46 fSlaStar = new SlaStars(fObservatory); 47 47 48 48 // … … 177 177 } 178 178 179 MGSkyPosition::MGSkyPosition( const TGWindow* p, const UInt_t w)180 : MGEmbeddedCanvas("SkyPosition", p, w, 110) 179 MGSkyPosition::MGSkyPosition(MObservatory::LocationName_t key, const TGWindow* p, const UInt_t w) 180 : MGEmbeddedCanvas("SkyPosition", p, w, 110), fObservatory(key) 181 181 { 182 182 DrawCoordinateSystem(); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r1727 r1758 11 11 #ifndef MGEMBEDDEDCANVAS_H 12 12 #include "MGEmbeddedCanvas.h" 13 #endif 14 15 #ifndef MARS_MObservatory 16 #include "MObservatory.h" 13 17 #endif 14 18 … … 46 50 SlaPlanets *fSlaPlanet; 47 51 52 const MObservatory::LocationName_t fObservatory; 53 48 54 Int_t fX[9]; 49 55 Int_t fY[9]; … … 66 72 67 73 public: 68 MGSkyPosition( const TGWindow* p, const UInt_t w);74 MGSkyPosition(MObservatory::LocationName_t key, const TGWindow* p, const UInt_t w); 69 75 ~MGSkyPosition(); 70 76 -
trunk/MagicSoft/Cosy/gui/MGStarguider.cc
r1690 r1758 72 72 #define kZOOM 96 73 73 74 MGStarguider::MGStarguider( )75 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), f Dx((768-kZOOM)/2), fDy((512-kZOOM)/2)74 MGStarguider::MGStarguider(MObservatory::LocationName_t key) 75 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), fObservatory(key), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 76 76 { 77 77 gVirtualX->GrabButton(fId, kButton2, /*kButtonPressMask|kButtonReleaseMask|*/kNone, kNone, kNone, kNone); … … 80 80 fList = new MGList; 81 81 82 fSao = new StarCatalog ;82 fSao = new StarCatalog(fObservatory); 83 83 fRaDec = new RaDec(180, 40); 84 84 … … 612 612 613 613 MStarList stars; 614 fSao->GetStars(stars, time. CalcMjd(), *fRaDec);614 fSao->GetStars(stars, time.GetMjd(), *fRaDec); 615 615 fSao->GetImg(c, cimg, stars); 616 616 //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec); -
trunk/MagicSoft/Cosy/gui/MGStarguider.h
r1690 r1758 11 11 #include "MGList.h" 12 12 #include "MGImage.h" 13 14 #ifndef MARS_MObservatory 15 #include "MObservatory.h" 16 #endif 13 17 14 18 class AltAz; … … 56 60 TTimer *fTimer; 57 61 62 const MObservatory::LocationName_t fObservatory; 63 58 64 Int_t fDx; 59 65 Int_t fDy; … … 70 76 71 77 public: 72 MGStarguider( );78 MGStarguider(MObservatory::LocationName_t key); 73 79 virtual ~MGStarguider(); 74 80 -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1757 r1758 10 10 #include <TApplication.h> 11 11 #include <TTimer.h> 12 13 #include <TH2.h> 14 #include <TProfile.h> 15 #include <TCanvas.h> 12 16 13 17 #include "MGCosy.h" … … 147 151 // are avaraged. The values are returned as a ZdAz object. 148 152 // 153 // If one of the two shaftencoders on the elevation axis is missing 154 // the other one's position is returned. 155 // 149 156 // The positions are alway up-to-date because the shaftencoders are 150 157 // sending all changes immediatly. … … 152 159 ZdAz MCosy::GetSePos() 153 160 { 161 const int pa = fAz->GetPos(); 162 if (fZd1->IsZombieNode() && fZd2->IsZombieNode()) 163 return ZdAz(0, pa); 164 154 165 // 155 166 // Get the values 156 167 // 157 const int p0 = fZd1->GetPos(); 158 const int p1 = fZd2->GetPos(); 159 const int p2 = fAz->GetPos(); 168 const int p1 = fZd1->GetPos(); 169 const int p2 = -fZd2->GetPos(); 170 171 if (fZd1->IsZombieNode()) 172 return ZdAz(p2, pa); 173 if (fZd2->IsZombieNode()) 174 return ZdAz(p1, pa); 160 175 161 176 // 162 177 // interpolate shaft encoder positions 163 178 // 164 const float p = (float)(p0-p1)/2;179 float p = (float)(p1+p2)/2; 165 180 166 181 // 167 182 // calculate 'regelabweichung' 168 183 // 169 return ZdAz(p, p 2);184 return ZdAz(p, pa); 170 185 } 171 186 … … 655 670 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad] 656 671 { 657 SlaStars sla ;672 SlaStars sla(fObservatory); 658 673 659 674 // 660 675 // Position to actual position 661 676 // 662 sla. SetMjd2Now();677 sla.Now(); 663 678 ZdAz dest = sla.CalcZdAz(dst); 664 679 … … 707 722 // 708 723 fRaDec = dst; 709 f Tracking = kTRUE;724 fBackground = kBgdTracking; 710 725 711 726 //--- ofstream fout("log/cosy.pos"); … … 729 744 // Request theoretical Position for a time in the future (To+dt) from CPU 730 745 // 731 sla.SetMjd(sla. CalcMjd()+dt/(60*60*24));746 sla.SetMjd(sla.GetMjd()+dt/(60*60*24)); 732 747 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 733 748 dest = CorrectTarget(GetSePos(), dummy); // [se] … … 817 832 } 818 833 819 f Tracking = kFALSE;834 fBackground = kBgdNone; 820 835 StopMovement(); 821 836 lout << "Tracking stopped." << endl; … … 915 930 return (void*)0xebb0; 916 931 917 SlaStars sla ;918 sla. SetMjd2Now();932 SlaStars sla(fObservatory); 933 sla.Now(); 919 934 920 935 RaDec rd = *((RaDec*)mp); … … 943 958 { 944 959 cout << "WM_TPoint: start." << endl; 945 SlaStars sla ;946 sla. SetMjd2Now();960 SlaStars sla(fObservatory); 961 sla.Now(); 947 962 948 963 RaDec rd = *((RaDec*)mp); … … 976 991 cout << "WM_Position: done. (return 0x7777)" << endl; 977 992 return (void*)0x7777; 993 994 case WM_TESTSE: 995 cout << "WM_TestSe: start." << endl; 996 fBackground = mp ? kBgdSeTest : kBgdNone; 997 cout << "WM_TestSe: done. (return 0x1e51)" << endl; 998 return (void*)0x1e51; 978 999 979 1000 case WM_TRACK: … … 1040 1061 cout << endl; 1041 1062 1042 SlaStars sla ;1043 sla. SetMjd2Now();1063 SlaStars sla(fObservatory); 1064 sla.Now(); 1044 1065 1045 1066 XY xy = *((XY*)mp); … … 1160 1181 } 1161 1182 1183 void MCosy::TalkThreadTracking() 1184 { 1185 if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode()) 1186 return; 1187 if (!fMac1 || !fMac2) 1188 return; 1189 1190 SlaStars sla(fObservatory); 1191 1192 ZdAz old; 1193 ZdAz ist; 1194 1195 ZdAz sollzd; 1196 ZdAz sollaz; 1197 1198 ZdAz istre = -fOffset; // [re] 1199 ZdAz time; 1200 1201 // 1202 // only update fTrackingError while tracking 1203 // 1204 bool phca1=false; 1205 bool phca2=false; 1206 bool phcaz=false; 1207 1208 while (fBackground==kBgdTracking) 1209 { 1210 // 1211 // Make changes (eg wind) smoother - attenuation of control function 1212 // 1213 const float weight = 1.; //0.3; 1214 1215 // 1216 // This is the time constant which defines how fast 1217 // you correct for external influences (like wind) 1218 // 1219 fZd1->ResetPosHasChanged(); 1220 fZd2->ResetPosHasChanged(); 1221 fAz->ResetPosHasChanged(); 1222 do 1223 { 1224 phca1 = fZd1->PosHasChanged(); 1225 phca2 = fZd2->PosHasChanged(); 1226 phcaz = fAz->PosHasChanged(); 1227 usleep(1); 1228 } while (!phca1 && !phca2 && !phcaz && fBackground==kBgdTracking); 1229 1230 //---usleep(100000); // 0.1s 1231 1232 // 1233 // get position, where we are 1234 // 1235 old = ist; 1236 ist = GetSePos(); // [se] 1237 1238 // 1239 // if the position didn't change continue 1240 // 1241 /*--- 1242 if ((int)ist.Zd() == (int)old.Zd() && 1243 (int)ist.Az() == (int)old.Az()) 1244 continue; 1245 */ 1246 istre = GetRePosPdo(); 1247 1248 // 1249 // Get time from last shaftencoder position change (position: ist) 1250 // FIXME: I cannot take the avarage 1251 // 1252 if (fZd1->GetMjd()>fZd2->GetMjd()) 1253 time.Zd(fZd1->GetMjd()); 1254 else 1255 time.Zd(fZd2->GetMjd()); 1256 //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0); 1257 time.Az(fAz->GetMjd()); 1258 1259 // 1260 // if Shaftencoder changed position 1261 // calculate were we should be 1262 // 1263 if (phca1 || phca2 /*(int)ist.Zd() != (int)old.Zd()*/) 1264 { 1265 sla.SetMjd(time.Zd()); 1266 1267 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1268 sollzd = CorrectTarget(ist, dummy); // [se] 1269 1270 fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight); 1271 } 1272 1273 if (phcaz /*(int)ist.Az() != (int)old.Az()*/) 1274 { 1275 sla.SetMjd(time.Az()); 1276 1277 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1278 sollaz = CorrectTarget(ist, dummy); // [se] 1279 1280 fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 1281 } 1282 1283 ZdAz soll(sollzd.Zd(), sollaz.Az()); 1284 fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384); 1285 1286 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(), 1287 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 1288 1289 //--- fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " "; 1290 //--- fout << setprecision(5) << setw(7) << fTrackingError.Zd() << " "; 1291 //--- fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " "; 1292 //--- fout << setprecision(5) << setw(7) << fTrackingError.Az() << endl; 1293 } 1294 //--- fout << endl << endl; 1295 } 1296 1297 void MCosy::TalkThreadSeTest() 1298 { 1299 // if (fZd1->IsZombieNode() || fZd2->IsZombieNode()) 1300 // return; 1301 1302 if (fHistTestSe) 1303 { 1304 lout << "You are much too fast... try again." << endl; 1305 return; 1306 } 1307 1308 fHistTestSe = new TH2F("Diff", "Difference of SE values", 1309 201, fMin.Zd(), fMax.Zd(), 101, -50, 50); 1310 fHistTestSe->SetXTitle("ZA [\\circ]"); 1311 fHistTestSe->SetYTitle("\\Delta SE"); 1312 1313 Double_t offset = 0; 1314 1315 int cnt = 0; 1316 1317 lout << "Starting Shaftencoder Test..." << endl; 1318 1319 while (fBackground==kBgdSeTest) 1320 { 1321 fZd1->ResetPosHasChanged(); 1322 fZd2->ResetPosHasChanged(); 1323 1324 while (!fZd1->PosHasChanged() && !fZd2->PosHasChanged() && 1325 fBackground==kBgdSeTest) 1326 usleep(1); 1327 1328 const Double_t pos[3] = { fZd1->GetPos(), fZd2->GetPos(), fAz->GetPos() }; 1329 1330 // 1331 // Estimate Offset from the first ten positions 1332 // 1333 if (cnt++<10) 1334 offset += pos[0]+pos[1]; 1335 if (cnt++==10) 1336 offset /= 10; 1337 if (cnt<11) 1338 continue; 1339 1340 Double_t apos = (pos[0]-pos[1])/2 * TMath::Pi()*2 / 16384; 1341 1342 ZdAz bend = fBending(ZdAz(apos, pos[2]))*kRad2Deg; 1343 1344 fHistTestSe->Fill(bend.Zd(), pos[0]+pos[1]-offset); 1345 } 1346 1347 lout << "Shaftencoder Test Stopped... displaying Histogram." << endl; 1348 } 1349 1162 1350 void MCosy::TalkThread() 1163 1351 { … … 1180 1368 /*** FOR DEMO MODE ***/ 1181 1369 1182 if (fZd1->IsZombieNode() || fZd2->IsZombieNode() || fAz->IsZombieNode())1183 return;1184 1185 if (!fMac1 || !fMac2)1186 return;1187 1188 1370 // 1189 1371 // Start the Network 1190 1372 // 1191 /*1192 TEnv env(".cosyrc");1193 1194 cout << "Setting up software endswitch..." << flush;1195 fMac1->SetNegEndswitch(Deg2AzRE(env.GetValue("Az_Min[Deg]", -1.0)));1196 fMac1->SetPosEndswitch(Deg2AzRE(env.GetValue("Az_Max[Deg]", +1.0)));1197 1198 fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("Zd_Min[Deg]", -1.0)));1199 fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("Zd_Max[Deg]", +1.0)));1200 cout << "done." << endl;1201 */1202 SlaStars sla;1203 1373 while (1) 1204 1374 { … … 1206 1376 // wait until a tracking session is started 1207 1377 // 1208 while ( !fTracking)1378 while (fBackground==kBgdNone) 1209 1379 usleep(1); 1210 1380 1211 //--- ofstream fout("log/cosy.err"); 1212 //--- fout << "Tracking:"; 1213 //--- fout << " Ra: " << Rad2Deg(fRaDec.Ra()) << "\x9c "; 1214 //--- fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl; 1215 //--- fout << " MjdZd/10ms ErrZd/re"; 1216 //--- fout << " MjdAz/10ms ErrAd/re" << endl; 1217 1218 ZdAz old; 1219 ZdAz ist; 1220 1221 ZdAz sollzd; 1222 ZdAz sollaz; 1223 1224 ZdAz istre = -fOffset; // [re] 1225 ZdAz time; 1226 1227 // 1228 // only update fTrackingError while tracking 1229 // 1230 bool phca1=false; 1231 bool phca2=false; 1232 bool phcaz=false; 1233 1234 while (fTracking) 1381 switch (fBackground) 1235 1382 { 1236 // 1237 // Make changes (eg wind) smoother - attenuation of control function 1238 // 1239 const float weight = 1.; //0.3; 1240 1241 // 1242 // This is the time constant which defines how fast 1243 // you correct for external influences (like wind) 1244 // 1245 fZd1->ResetPosHasChanged(); 1246 fZd2->ResetPosHasChanged(); 1247 fAz->ResetPosHasChanged(); 1248 do 1249 { 1250 phca1 = fZd1->PosHasChanged(); 1251 phca2 = fZd2->PosHasChanged(); 1252 phcaz = fAz->PosHasChanged(); 1253 usleep(1); 1254 } while (!phca1 && !phca2 && !phcaz && fTracking); 1255 1256 //---usleep(100000); // 0.1s 1257 1258 // 1259 // get position, where we are 1260 // 1261 old = ist; 1262 ist = GetSePos(); // [se] 1263 1264 // 1265 // if the position didn't change continue 1266 // 1267 /*--- 1268 if ((int)ist.Zd() == (int)old.Zd() && 1269 (int)ist.Az() == (int)old.Az()) 1270 continue; 1271 */ 1272 istre = GetRePosPdo(); 1273 1274 // 1275 // Get time from last shaftencoder position change (position: ist) 1276 // FIXME: I cannot take the avarage 1277 // 1278 if (fZd1->GetMjd()>fZd2->GetMjd()) 1279 time.Zd(fZd1->GetMjd()); 1280 else 1281 time.Zd(fZd2->GetMjd()); 1282 //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0); 1283 time.Az(fAz->GetMjd()); 1284 1285 // 1286 // if Shaftencoder changed position 1287 // calculate were we should be 1288 // 1289 if (phca1 || phca2 /*(int)ist.Zd() != (int)old.Zd()*/) 1290 { 1291 sla.SetMjd(time.Zd()); 1292 1293 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1294 sollzd = CorrectTarget(ist, dummy); // [se] 1295 1296 fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight); 1297 } 1298 1299 if (phcaz /*(int)ist.Az() != (int)old.Az()*/) 1300 { 1301 sla.SetMjd(time.Az()); 1302 1303 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1304 sollaz = CorrectTarget(ist, dummy); // [se] 1305 1306 fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 1307 } 1308 1309 ZdAz soll(sollzd.Zd(), sollaz.Az()); 1310 fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384); 1311 1312 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(), 1313 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 1314 1315 //--- fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " "; 1316 //--- fout << setprecision(5) << setw(7) << fTrackingError.Zd() << " "; 1317 //--- fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " "; 1318 //--- fout << setprecision(5) << setw(7) << fTrackingError.Az() << endl; 1383 case kBgdNone: 1384 continue; 1385 1386 case kBgdTracking: 1387 TalkThreadTracking(); 1388 continue; 1389 1390 case kBgdSeTest: 1391 TalkThreadSeTest(); 1392 continue; 1319 1393 } 1320 1321 //--- fout << endl << endl;1322 1394 } 1323 1395 } … … 1355 1427 fVelocity, fOffset, fRaDec, fZdAzSoll, fStatus, avail); 1356 1428 1357 1358 1429 /* 1359 1430 cout << (int)(fMac1->GetStatus()&Macs::kOutOfControl) << " "; … … 1362 1433 */ 1363 1434 1435 if (fBackground==kBgdSeTest || fHistTestSe==NULL) 1436 return kTRUE; 1437 1438 DisplayHistTestSe(); 1439 1364 1440 return kTRUE; 1365 1441 } 1366 1442 1443 void MCosy::DisplayHistTestSe() 1444 { 1445 TH2F &hist = *fHistTestSe; 1446 fHistTestSe = NULL; 1447 1448 TCanvas *c=new TCanvas("c1", "", 1000, 1000); 1449 c->Divide(1,2); 1450 1451 c->cd(1); 1452 TH2 *h=(TH2*)hist.DrawCopy(); 1453 1454 TProfile *p = h->ProfileX("_pfx", -1, 9999, "s"); 1455 p->SetLineColor(kBlue); 1456 p->Draw("same"); 1457 p->SetBit(kCanDelete); 1458 1459 c->cd(2); 1460 1461 TH1F p2("spread", "Spread of the differences", hist.GetNbinsX(), hist.GetBinLowEdge(1), 1462 hist.GetBinLowEdge(hist.GetNbinsX()+1)); 1463 p2.SetXTitle("ZA [\\circ]"); 1464 for (int i=0; i<hist.GetNbinsX(); i++) 1465 p2.SetBinError(i, p->GetBinError(i)); 1466 p2.SetLineColor(kRed); 1467 p2.SetStats(0); 1468 p2.DrawCopy(); 1469 1470 delete &hist; 1471 } 1367 1472 1368 1473 // -------------------------------------------------------------------------- … … 1450 1555 1451 1556 lout << "- Starting GUI." << endl; 1452 fWin=new MGCosy( this, gClient->GetRoot(), 1, 1);1557 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1453 1558 } 1454 1559 … … 1480 1585 1481 1586 lout << "- Starting GUI." << endl; 1482 fWin=new MGCosy( this, gClient->GetRoot(), 1, 1);1587 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1483 1588 } 1484 1589 … … 1497 1602 1498 1603 lout << "- Starting GUI." << endl; 1499 fWin=new MGCosy( this, gClient->GetRoot(), 1, 1);1604 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1500 1605 } 1501 1606 1502 1607 MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out) 1503 : Network(dev, baud, out), f Zd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fTracking(kFALSE)1608 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone) 1504 1609 { 1505 1610 TEnv env(".cosyrc"); -
trunk/MagicSoft/Cosy/main/MCosy.h
r1757 r1758 7 7 #include "MThread.h" 8 8 #include "MBending.h" 9 10 #ifndef MARS_Mobservatory 11 #include "MObservatory.h" 12 #endif 9 13 10 14 #define kDEG ((char)0x9c) // Linux 'ø' … … 22 26 #define WM_CALCALTAZ 0x1009 23 27 #define WM_HOME 0x100a 28 #define WM_TESTSE 0x100b 24 29 25 30 … … 28 33 class MGCosy; 29 34 class MCosy; 35 class TH2F; 30 36 31 37 class MTTalk : public MThread … … 46 52 }; 47 53 48 49 54 class TTimer; 50 55 class MCosy : public Network, public MsgQueue, public TObject … … 62 67 }; 63 68 69 const MObservatory::LocationName_t fObservatory; 70 64 71 ShaftEncoder *fZd1; 65 72 ShaftEncoder *fZd2; … … 76 83 // with a generic interface to both... 77 84 85 enum BackgroundAction_t 86 { 87 kBgdNone, 88 kBgdTracking, 89 kBgdSeTest 90 }; 91 92 BackgroundAction_t fBackground; // Flag for present backgroundthread 93 78 94 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re] 79 95 ZdAz fOffset; // Offset between se and re coordinate system [re] 80 96 ZdAz fZdAzSoll; // Soll position when moving 81 97 RaDec fRaDec; // Position to track 82 int fTracking; // Flag for present tracking action83 98 ZdAz fAccuracy; // Actual accuracy of Tracking 84 99 ZdAz fVelocity; // Actual velocity of Tracking 85 100 ZdAz fMin; 86 101 ZdAz fMax; 102 103 TH2F *fHistTestSe; 87 104 88 105 XY kGearRatio; // describing the gear of the system [re/se] … … 119 136 120 137 void TalkThread(); 138 void TalkThreadTracking(); 139 void TalkThreadSeTest(); 140 141 void DisplayHistTestSe(); 121 142 122 143 int SetPosition(const ZdAz &dst); -
trunk/MagicSoft/Cosy/main/Makefile
r1531 r1758 33 33 34 34 SRCFILES = MCosy.cc \ 35 MBending.cc \ 36 MStarguider.cc 35 MBending.cc 37 36 38 37 SRCS = $(SRCFILES) -
trunk/MagicSoft/Cosy/starg.cc
r1691 r1758 16 16 TApplication *app=new TApplication("Starguider", &argc, argv); 17 17 18 MGStarguider starg ;18 MGStarguider starg(MObservatory::kMagic1); 19 19 20 20 starg.Loop(0); -
trunk/MagicSoft/Mars/Changelog
r1752 r1758 1 1 2 2 -*-*- END -*-*- 3 2003/02/14: Thomas Bretz 4 5 * mtemp/MObservatory.[h,cc]: 6 - added 7 8 9 3 10 2003/02/10: Abelardo Moralejo 4 11 … … 8 15 * manalysis/Makefile, AnalysisLinkDef.h 9 16 - Changed MApplyPadding for MPadding 17 18 10 19 11 20 2003/02/07: Wolfgang Wittek … … 43 52 - does the padding ala Thomas Schweizer 44 53 54 55 45 56 2003/02/06: Thomas Bretz 46 57 47 58 * mgeom/MGeomCam.[h,cc]: 48 59 - fixed a warning (GetPixRatio(int) --> GetPixRatio(Uint) 60 49 61 50 62
Note:
See TracChangeset
for help on using the changeset viewer.