Changeset 9439 for trunk/MagicSoft
- Timestamp:
- 05/09/09 13:48:12 (16 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 1 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r9438 r9439 104 104 * videodev/FilterLed.[h,cc]: 105 105 - allow the search boxs to be asymmetric 106 107 * bending_magic2.txt, leds_magic2.txt, stargleds_magic2.txt, 108 prepos_magic2.txt: 109 - added 106 110 107 111 -
trunk/MagicSoft/Cosy/candrv/CandrvLinkDef.h
r8841 r9439 5 5 #pragma link off all functions; 6 6 7 #pragma link C++ class VmodIcan+;8 7 #pragma link C++ class CanOpen+; 9 8 #pragma link C++ class Network+; 10 #pragma link C++ class Ethernet+;11 //#pragma link C++ class Interface+;12 9 13 10 #pragma link C++ class NodeDrv+; -
trunk/MagicSoft/Cosy/candrv/Makefile
r8809 r9439 17 17 18 18 SRCFILES = nodedrv.cc \ 19 vmodican.cc \20 19 sdolist.cc \ 21 20 canopen.cc \ -
trunk/MagicSoft/Cosy/candrv/canopen.h
r9132 r9439 4 4 #ifndef ROOT_TCondition 5 5 #include <TCondition.h> 6 #endif 7 8 #ifdef __CINT__ 9 typedef Byte_t BYTE_t; 10 typedef UShort_t WORD_t; 11 typedef Short_t WORDS_t; 12 typedef UInt_t LWORD_t; 13 typedef Int_t LWORDS_t; 14 struct Message; 15 struct FastMessage; 16 #else 17 #include "gendef.h" 18 #include "dpm.h" 6 19 #endif 7 20 … … 12 25 #ifndef COSY_MTimeout 13 26 #include "MTimeout.h" 14 #endif15 16 #ifdef __CINT__17 typedef UInt_t LWORD_t;18 typedef Short_t WORDS_t;19 27 #endif 20 28 -
trunk/MagicSoft/Cosy/candrv/ethernet.cc
r8865 r9439 37 37 #include <TSocket.h> 38 38 39 ClassImp(Ethernet);39 //ClassImp(Ethernet); 40 40 41 41 #undef DEBUG … … 56 56 // 57 57 Ethernet::Ethernet(const char *addr, const int tx, const int rx, CanOpen *receiver) 58 : MTcpIpI(rx), /*MTcpIpO(addr, tx),*/ Interface(receiver), fTxAddress(addr), fTxPort(tx)58 : MTcpIpI(rx), /*MTcpIpO(addr, tx),*/ Interface(receiver), fTxAddress(addr), fTxPort(tx) 59 59 { 60 60 gLog << inf2 << "- Ethernet initialized." << endl; … … 68 68 Ethernet::~Ethernet() 69 69 { 70 CancelThread();70 MTcpIpI::CancelThread(); 71 71 gLog << inf2 << "- Ethernet stopped." << endl; 72 72 } … … 85 85 const TString address = MTcpIpO::GetSocketAddress(rx); 86 86 87 while (! IsThreadCanceled())87 while (!MTcpIpI::IsThreadCanceled()) 88 88 { 89 89 unsigned char c; … … 281 281 #endif 282 282 MTcpIpO::SendFrame(fTxAddress, fTxPort, (char*)(msg.data+1), msg.len-1); 283 // Send((char*)(msg.data+1), msg.len-1); 283 284 #ifdef DEBUG 284 285 st.Print(); -
trunk/MagicSoft/Cosy/candrv/ethernet.h
r8864 r9439 20 20 21 21 // Start/stop communication inherited from Interface 22 void Start() { RunThread(); }23 void Stop() { CancelThread(); }22 void Start() { MTcpIpI::RunThread(); } 23 void Stop() { MTcpIpI::CancelThread(); } 24 24 25 Bool_t HasConnection() const { return IsConnectionEstablished(); }25 Bool_t HasConnection() const { return MTcpIpI::IsConnectionEstablished(); } 26 26 27 27 public: … … 32 32 void SendCanFrame(WORD_t cobid, BYTE_t m[8], BYTE_t rtr=0); 33 33 34 ClassDef(Ethernet, 0) // hardware interface to the vmodican can module (Janz)34 // ClassDef(Ethernet, 0) // hardware interface to the vmodican can module (Janz) 35 35 }; 36 36 -
trunk/MagicSoft/Cosy/catalog/SlaPlanets.cc
r8376 r9439 40 40 double ra, dec, diam; 41 41 42 // One can use TT instead of TDB for all pl enets42 // One can use TT instead of TDB for all planets 43 43 // (except the moon) 44 44 // TDB, planet, elong, phi, *ra, *dec, *diam -
trunk/MagicSoft/Cosy/catalog/SlaStars.cc
r8847 r9439 49 49 0, 0, // polar motion x, y-coordinate (radians) 50 50 // 273.155, 1013.25, 0.5, // temp, pressure, humidity 51 273.155+ 20, 1013.25, 0.5, // temp, pressure, humidity51 273.155+10, 780.0, 0.25, // temp, pressure, humidity 52 52 // 0.2, 0.0065, // wavelength, tropo lapse rate 53 53 0.55, 0.0065, // wavelength, tropo lapse rate -
trunk/MagicSoft/Cosy/catalog/Slalib.cc
r8847 r9439 18 18 Double_t Slalib::Trunc(Double_t val) 19 19 { 20 / * dint(A) - truncate to nearest whole number towards zero (double) */20 // dint(A) - truncate to nearest whole number towards zero (double) 21 21 return val<0 ? TMath::Ceil(val) : TMath::Floor(val); 22 }23 24 Double_t Slalib::Round(Double_t val)25 {26 /* dnint(A) - round to nearest whole number (double) */27 return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);28 22 } 29 23 … … 40 34 SetMjd(fTime.GetMjd()+offset/(24*60*60)); 41 35 } 42 43 36 44 37 ZdAz Slalib::XYZ2ZdAz(double coord[3]) const -
trunk/MagicSoft/Cosy/catalog/Slalib.h
r8847 r9439 19 19 double fAlpha; 20 20 21 static Double_t Round(Double_t val);22 21 static Double_t Trunc(Double_t val); 23 22 -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r8848 r9439 17 17 using namespace std; 18 18 19 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fW(768), fH(576), fAstro(0), /*fSao(NULL), fSrt(NULL), fEntries(0),*/ fSinAngle(0), fCosAngle(1), fBox (768)19 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fW(768), fH(576), fAstro(0), /*fSao(NULL), fSrt(NULL), fEntries(0),*/ fSinAngle(0), fCosAngle(1), fBoxX(768), fBoxY(576) 20 20 { 21 21 fAstro = new MAstroCatalog; … … 32 32 { 33 33 // pixsize [arcsec/pixel] 34 fPixSize = D2PI/360.0*pixsize/3600; // [rad / (deg*pixel)]34 fPixSize = TMath::DegToRad()*pixsize/3600; // [rad / (deg*pixel)] 35 35 fAstro->SetRadiusFOV(pixsize, 768, 576); 36 // fov = hypot(768, 576)/2*pixsize/3600; 36 37 } 37 38 38 39 double StarCatalog::GetPixSize() const 39 40 { 40 return fPixSize*3600* 360.0/D2PI;41 return fPixSize*3600*TMath::RadToDeg(); 41 42 } 42 43 … … 55 56 void StarCatalog::SetAltAz(const AltAz &altaz) 56 57 { 57 fAltAz = altaz * D2PI/360.0;58 fAltAz = altaz * TMath::DegToRad(); 58 59 fRaDec = CalcRaDec(fAltAz); 59 60 … … 72 73 void StarCatalog::SetRaDec(const RaDec &radec) 73 74 { 74 const RaDec rd = fRaDec* 360.0/D2PI;;75 const RaDec rd = fRaDec*TMath::RadToDeg(); 75 76 76 77 const Bool_t same = … … 78 79 rd.Dec()>radec.Dec()-1e-5 && rd.Dec()<radec.Dec()+1e-5; 79 80 80 fRaDec = radec * D2PI/360.0;81 fRaDec = radec * TMath::DegToRad(); 81 82 fAltAz = CalcAltAz(fRaDec); 82 83 … … 153 154 154 155 void StarCatalog::CalcStars(MStarList &list, int xc, int yc, 155 int xo, int yo) const 156 { 157 // For an apropriate unit conversion to pixels [pix/rad] 158 const Double_t scale = TMath::RadToDeg()*TMath::Sqrt(768*768 + 576*576)/(fAstro->GetRadiusFOV()*2); 159 160 // Offsets to shift [-n/2;n/2] to [0;n] and to 161 // move the stars in the counterdirection of the LEDs 162 const Int_t offx = 768/2 + xo; 163 const Int_t offy = 576/2 + yo; 156 float offx, float offy) const 157 { 158 // const Int_t offx = 768/2 + xo; 159 // const Int_t offy = 576/2 + yo; 164 160 165 161 // Allow catalog stars to be a bit outside [0.2deg] of the 166 162 // monitored window. To get the std behaviour set offset=0 167 const Int_t offset = TMath::Nint(0.2*TMath::DegToRad()*scale); 168 const Int_t box = fBox+offset; 163 const Int_t offset = TMath::Nint(0.2*TMath::DegToRad()/fPixSize); 164 const Int_t boxx = fBoxX+offset; 165 const Int_t boxy = fBoxY+offset; 169 166 170 167 // CalcStars flips the picture in X defaultwise now 171 168 // This defined the box in which stars are really returned 169 const int x0 = TMath::Max((768-xc)-boxx, -offset); 170 const int y0 = TMath::Max(yc-boxy, -offset); 171 const int x1 = TMath::Min((768-xc)+boxx, fW+offset); 172 const int y1 = TMath::Min(yc+boxy, fH+offset); 173 /* 172 174 const int x0 = TMath::Max((768-xc)-box, -offset); 173 const int y0 = TMath::Max(yc-box, -offset);174 175 const int x1 = TMath::Min((768-xc)+box, fW+offset); 175 const int y1 = TMath::Min(yc+box, fH+offset); 176 176 177 const int y0 = TMath::Max(yc-box-100, -offset); 178 const int y1 = TMath::Min(yc+box+100, fH+offset); 179 */ 180 181 /* 177 182 // Align stars into telescope system 178 183 // (Move the telescope to pointing position) … … 181 186 align.RotateY(-(TMath::Pi()/2-fAltAz.Alt())); 182 187 align.RotateZ(TMath::Pi()/2); 188 */ 189 190 TRotation rot; 191 rot.RotateY(-(TMath::Pi()/2-fAltAz.Alt())); 183 192 184 193 // Get List of stars from catalog … … 200 209 const ZdAz za(CalcZdAz(rd)); 201 210 211 TVector3 v; 212 //v.SetMagThetaPhi(1., TMath::Pi()/2-za.Alt(), za.Az()-fAltAz.Az()); 213 v.SetMagThetaPhi(1., za.Zd(), za.Az()-fAltAz.Az()); 214 v *= rot; 215 216 if (v(2)<0) 217 continue; 218 219 // Stretch such, that the Z-component is alwas the same. Now 220 // X and Y contains the intersection point between the star-light 221 // and the plain of a virtual plain screen (ccd...) 222 v *= 1./v(2); 223 224 // Do unit conversion to pixels 225 v *= 1./fPixSize; 226 227 const Double_t x = -v.Y(); 228 const Double_t y = v.X(); 229 230 /* 202 231 // Virtually move telescope to pointing position 203 232 TVector3 loc; … … 215 244 216 245 // Do an apropriate unit conversion to pixels 217 loc *= scale; 218 246 loc *= 1./fPixSize; 247 248 const Double_t x = loc.X(); 249 const Double_t y = loc.Y(); 250 */ 219 251 // if (loc.Mod2()>fRadiusFOV*fRadiusFOV) 220 252 // continue; 221 253 254 222 255 // Rotate by the rotation angle of the video camera 223 256 // and add the offsets on both axis 224 Float_t xx = loc.X()*fCosAngle - loc.Y()*fSinAngle +offx;225 Float_t yy = loc.X()*fSinAngle + loc.Y()*fCosAngle +offy;257 const Double_t xx = x*fCosAngle - y*fSinAngle + 768 - offx; 258 const Double_t yy = x*fSinAngle + y*fCosAngle + offy; 226 259 227 260 // Check if the resulting star is in the … … 235 268 } 236 269 270 /* 237 271 AltAz StarCatalog::CalcAltAzFromPix(Double_t pixx, Double_t pixy) const 238 272 { … … 251 285 return AltAz(-dec, ha+fAltAz.Az()); 252 286 } 287 */ 288 289 ZdAz StarCatalog::CalcDeltaZdAzFromPix(Double_t dpixx, Double_t dpixy) const 290 { 291 double dx = dpixx*fCosAngle + dpixy*fSinAngle; 292 double dy = -dpixx*fSinAngle + dpixy*fCosAngle; 293 294 TVector3 loc(dy, -dx, 1./fPixSize); 295 296 loc.RotateY(TMath::Pi()/2-fAltAz.Alt()); 297 298 return ZdAz(loc.Theta()-TMath::Pi()/2+fAltAz.Alt(), -loc.Phi()); 299 300 /* 301 // Align stars into telescope system 302 // (Move the telescope to pointing position) 303 TRotation align; 304 align.RotateZ(-fAltAz.Az()); 305 align.RotateY(-(TMath::Pi()/2-fAltAz.Alt())); 306 align.RotateZ(TMath::Pi()/2); 307 308 309 TVector3 loc(dx, dy, 1./fPixSize); 310 311 loc *= align.Inverse(); 312 313 cout << (TMath::Pi()/2-loc.Theta()-alt)*TMath::RadToDeg() << " " << (loc.Phi()-az)*TMath::RadToDeg() << endl; 314 315 316 317 TVector3 loc(dx, -dy, 1./fPixSize); 318 319 loc *= align.Inverse(); 320 321 return ZdAz(loc.Theta(), loc.Phi());*/ 322 } -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r9435 r9439 41 41 42 42 void SetRaDec(const RaDec &radec); 43 void SetAltAz(const AltAz &altaz);44 43 45 int fBox; 44 int fBoxX; 45 int fBoxY; 46 46 47 47 public: 48 48 StarCatalog(MObservatory::LocationName_t key); 49 49 virtual ~StarCatalog(); 50 51 void SetAltAz(const AltAz &altaz); 50 52 51 53 void GetImg(byte *img, byte *cimg, MStarList &list) const; … … 65 67 double GetPixSize() const; 66 68 67 AltAz CalcAltAzFromPix(Double_t pixx, Double_t pixy) const; 69 //AltAz CalcAltAzFromPix(Double_t pixx, Double_t pixy) const; 70 ZdAz CalcDeltaZdAzFromPix(Double_t pixx, Double_t pixy) const; 68 71 69 72 virtual void SetMjd(double mjd); … … 75 78 76 79 //void CalcStars(MStarList &list); 77 void CalcStars(MStarList &list, int xc, int yc, int xo, int yo) const;80 void CalcStars(MStarList &list, int xc, int yc, float xo, float yo) const; 78 81 static void DrawStars(MStarList &list, byte *img); 79 82 80 void SetBox(int box) { fBox = box; } 83 void SetBox(int box) { fBoxX = fBoxY = box; } 84 void SetBox(int boxx, int boxy) { fBoxX = boxx; fBoxY=boxy; } 81 85 82 86 ClassDef(StarCatalog, 0) -
trunk/MagicSoft/Cosy/cosy.cc
r9435 r9439 74 74 return kTRUE; 75 75 76 gLog << all << "- Trying to switch " << (on?"on":"off") << " " << (port==kPortTPoint?"TPoint":"Starguider") << " ccd via " << ip << endl; 77 76 78 TSocket s(ip, 80); 77 79 if (!s.IsValid()) … … 160 162 const TString ceco = env.GetValue("IpAddressCentralControl", "161.72.130.60"); 161 163 const TString powerswitch = env.GetValue("IpAddressPowerSwitch", ""); 162 const TString pointing = env.GetValue("PointingModel", "bending.txt");164 const Int_t telescope = env.GetValue("Telescope", 1); 163 165 164 166 // And move the resource options from the command line to the MEnv … … 238 240 239 241 MDriveCom *com = new MDriveCom(ceco, ceco_tx, ceco_rx); 240 com->SetTelescope( 2);241 242 MCosy *cosy = new MCosy(env, com , pointing);242 com->SetTelescope(telescope); 243 244 MCosy *cosy = new MCosy(env, com); 243 245 244 246 com->SetMsgQueue(cosy); … … 254 256 if (kDebugEnv>0) 255 257 env.PrintUntouched(); 256 257 258 258 259 MStarguider *client=0; -
trunk/MagicSoft/Cosy/devdrv/dkc.cc
r9435 r9439 22 22 fStatus(0), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false), 23 23 fReport(NULL),fLabel(NULL),fUpdPos(0) 24 {25 }26 27 Dkc::~Dkc()28 24 { 29 25 } … … 165 161 { 166 162 case 0x1000: 167 if (subidx==1) 168 { 169 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl; 170 fArmed = val==1; 171 } 163 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl; 164 fArmed = val==1; 172 165 return; 173 166 174 167 case 0x1003: 175 168 // FIXME, see Init 176 if (subidx!=2)177 return;178 169 gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << hex << val << dec << endl; 179 170 CheckErrorDKC(val); … … 196 187 197 188 case 0x6004: 198 if (subidx==0) 199 { 200 fPdoPos1 = (LWORDS_t)val; 201 fPdoTime1.Set(tv); 202 fHasChangedPos1 = true; 203 } 204 if (subidx==1) 205 { 206 fPdoPos2 = (LWORDS_t)val; 207 fPdoTime2.Set(tv); 208 fHasChangedPos2 = true; 209 } 189 fPdoPos1 = (LWORDS_t)val; 190 fPdoTime1.Set(tv); 191 fHasChangedPos1 = true; 192 return; 193 194 case 0x6005: 195 fPdoPos2 = (LWORDS_t)val; 196 fPdoTime2.Set(tv); 197 fHasChangedPos2 = true; 210 198 return; 211 199 … … 246 234 { 247 235 case 0x1000: 248 switch (subidx) 249 { 250 case 1: 251 //lout << ddev(MLog::eGui); 252 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl; 253 //lout << edev(MLog::eGui); 254 return; 255 } 256 break; 236 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl; 237 return; 238 239 case 0x1001: 240 gLog << inf2 << "- " << GetNodeName() << ": PDOs requested." << endl; 241 return; 257 242 258 243 case 0x2002: 259 //lout << ddev(MLog::eGui);260 244 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl; 261 //lout << edev(MLog::eGui);262 245 return; 263 246 264 247 case 0x2003: 265 //lout << ddev(MLog::eGui);266 248 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl; 267 //lout << edev(MLog::eGui);268 249 return; 269 250 270 251 case 0x3006: 271 switch (subidx) 272 { 273 case 0: 274 //lout << ddev(MLog::eGui); 275 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl; 276 //lout << edev(MLog::eGui); 277 return; 278 279 case 1: 280 /* 281 lout << ddev(MLog::eGui); 282 lout << "- Velocity set (" << GetNodeName() << ")" << endl; 283 lout << edev(MLog::eGui); 284 */ 285 return; 286 } 287 break; 252 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl; 253 return; 254 255 case 0x3007: 256 //gLog << inf2 << "- Velocity set (" << GetNodeName() << ")" << endl; 257 return; 288 258 289 259 case 0x4000: … … 292 262 293 263 case 0x6000: 294 //lout << ddev(MLog::eGui);295 264 gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl; 296 //lout << edev(MLog::eGui);297 265 return; 298 266 299 267 case 0x6002: 300 //lout << ddev(MLog::eGui); 301 gLog << inf2 << "- " << GetNodeName() << ": Velocitz resolution set." << endl; 302 //lout << edev(MLog::eGui); 268 gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution set." << endl; 303 269 return; 304 270 305 271 case 0x6004: 306 switch (subidx) 307 { 308 case 0: 309 //lout << ddev(MLog::eGui); 310 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 311 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 312 //lout << edev(MLog::eGui); 313 return; 314 315 case 1: 316 //lout << ddev(MLog::eGui); 317 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 318 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 319 //lout << edev(MLog::eGui); 320 return; 321 } 322 break; 323 324 325 } 272 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 273 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 274 return; 275 276 case 0x6005: 277 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 278 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 279 return; 280 } 281 326 282 NodeDrv::HandleSDOOK(idx, subidx, data, tv); 327 283 } … … 348 304 } 349 305 350 void Dkc::StartNode()351 {352 //353 // Switch node from pre-operational state to operational state354 // (This is not CANOpen compatible)355 // After this the MACS will react on real movement commands.356 //357 gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl;358 SendSDO(0x1000, 1, (LWORD_t)1);359 WaitForSdo(0x1000, 1);360 }361 362 306 void Dkc::Arm() 363 307 { 364 StartNode(); 308 gLog << inf2 << "- " << GetNodeName() << ": Arming node." << endl; 309 SendSDO(0x1000, (LWORD_t)1); 310 WaitForSdo(0x1000); 365 311 } 366 312 367 313 void Dkc::Disarm() 368 314 { 369 gLog << inf2 << "- " << GetNodeName() << ": Stopping Node." << endl;370 SendSDO(0x1000, 1,(LWORD_t)0);371 WaitForSdo(0x1000 , 1);315 gLog << inf2 << "- " << GetNodeName() << ": Disarming Node." << endl; 316 SendSDO(0x1000, (LWORD_t)0); 317 WaitForSdo(0x1000); 372 318 } 373 319 … … 385 331 // 386 332 gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl; 387 RequestSDO(0x1003 , 2);388 WaitForSdo(0x1003 , 2);333 RequestSDO(0x1003); 334 WaitForSdo(0x1003); 389 335 390 336 /* … … 404 350 ReqVelMax(); // Init fVelMax 405 351 352 // Request to send all PDOs at least once 353 ReqPDOs(); 354 406 355 #ifdef EXPERT 407 StartNode();356 Arm(); 408 357 #endif 409 358 410 359 gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl; 411 RequestSDO(0x1000 , 1);412 WaitForSdo(0x1000 , 1);360 RequestSDO(0x1000); 361 WaitForSdo(0x1000); 413 362 } 414 363 … … 422 371 } 423 372 373 void Dkc::ReqPDOs() 374 { 375 gLog << inf2 << "- " << GetNodeName() << ": Requesting all PDOs." << endl; 376 377 SendSDO(0x1001, (LWORD_t)1); 378 WaitForSdo(0x1001); 379 } 380 424 381 void Dkc::ReqPos1() 425 382 { 426 383 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 1." << endl; 427 RequestSDO(0x6004 , 0);428 WaitForSdo(0x6004 , 0);384 RequestSDO(0x6004); 385 WaitForSdo(0x6004); 429 386 } 430 387 … … 432 389 { 433 390 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 2." << endl; 434 RequestSDO(0x600 4, 1);435 WaitForSdo(0x600 4, 1);391 RequestSDO(0x6005); 392 WaitForSdo(0x6005); 436 393 } 437 394 … … 460 417 { 461 418 gLog << dbg << "- Setting acceleration to: " << acc << endl; 462 SendSDO(0x2003, 0, acc); // acceleration 463 WaitForSdo(0x2003, 0); 464 } 465 /* 466 void Dkc::SetDeceleration(LWORD_t dec) 467 { 468 gLog << dbg << "- Setting deceleration to: " << dec << endl; 469 SendSDO(0x2003, 1, dec); 470 WaitForSdo(0x2003, 1); 471 } 472 */ 419 SendSDO(0x2003, acc); // acceleration 420 WaitForSdo(0x2003); 421 } 422 473 423 void Dkc::SetRpmMode(BYTE_t mode) 474 424 { … … 476 426 // SetRpmMode(FALSE) stop the motor, but lets the position control unit on 477 427 // 478 SendSDO(0x3006, 0,mode ? string('s','t','r','t') : string('s','t','o','p'));479 WaitForSdo(0x3006 , 0);428 SendSDO(0x3006, mode ? string('s','t','r','t') : string('s','t','o','p')); 429 WaitForSdo(0x3006); 480 430 } 481 431 482 432 void Dkc::SetRpmVelocity(LWORDS_t cvel) 483 433 { 484 SendSDO(0x300 6, 1, (LWORD_t)cvel);485 WaitForSdo(0x300 6, 1);434 SendSDO(0x3007, (LWORD_t)cvel); 435 WaitForSdo(0x3007); 486 436 } 487 437 … … 496 446 497 447 gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORDS_t)pos << " ticks." << endl; 498 SendSDO(0x600 4, 1, (LWORD_t)pos);448 SendSDO(0x6005, (LWORD_t)pos); 499 449 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 500 450 } … … 510 460 511 461 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << (LWORDS_t)pos << " ticks." << endl; 512 SendSDO(0x6004, 0,(LWORD_t)pos);462 SendSDO(0x6004, (LWORD_t)pos); 513 463 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 514 464 } … … 526 476 527 477 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << p << " ticks." << endl; 528 SendSDO(0x6004, 0,p);478 SendSDO(0x6004, p); 529 479 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 530 }531 532 void Dkc::StartVelSync()533 {534 //535 // The syncronization mode is disabled by a 'MOTOR STOP'536 // or by a positioning command (POSA, ...)537 //538 gLog << inf2 << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;539 SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));540 WaitForSdo(0x3007, 0);541 }542 543 void Dkc::StartPosSync()544 {545 //546 // The syncronization mode is disabled by a 'MOTOR STOP'547 // or by a positioning command (POSA, ...)548 //549 gLog << inf2 << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;550 SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));551 WaitForSdo(0x3007, 1);552 480 } 553 481 -
trunk/MagicSoft/Cosy/devdrv/dkc.h
r9132 r9439 73 73 public: 74 74 Dkc(const BYTE_t nodeid, const char *name=NULL); 75 virtual ~Dkc() ;75 virtual ~Dkc() { } 76 76 77 77 static LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0) … … 84 84 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0); 85 85 86 void ReqPDOs(); 86 87 void ReqPos1(); 87 88 void ReqPos2(); … … 91 92 void ReqVelMax(); 92 93 void SetAcceleration(LWORD_t acc); 93 void SetDeceleration(LWORD_t dec);94 // void SetDeceleration(LWORD_t dec); 94 95 void SetVelocity(LWORD_t vel); 95 96 void SetVelocityRel(Double_t vel); 96 97 void SetRpmMode(BYTE_t mode=TRUE); 97 98 void SetRpmVelocity(LWORDS_t cvel); 98 void SetPDO1On(BYTE_t flag=TRUE);99 100 void StartVelSync();101 void StartPosSync();102 99 103 100 void StartRelPos(LWORDS_t pos); 104 101 void StartAbsPos(LWORDS_t pos); 105 102 void StartAbsPosRev(Double_t pos); 106 107 void StartNode();108 103 109 104 bool IsArmed() const { return fArmed; } -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r9132 r9439 318 318 } 319 319 320 void MGCosy::CreatePredefinedPos(TGCompositeFrame *tf1 )320 void MGCosy::CreatePredefinedPos(TGCompositeFrame *tf1, const char *prepos) 321 321 { 322 322 TGComboBox *box = new TGComboBox(tf1, kCB_PredefPos); … … 331 331 fList->Add(lay); 332 332 333 ifstream fin( "prepos.txt");333 ifstream fin(prepos); 334 334 if (!fin) 335 335 { 336 gLog << err << "ERROR: Predifined positions in ' prepos.txt' not found." << endl;336 gLog << err << "ERROR: Predifined positions in '" << prepos << "' not found." << endl; 337 337 return; 338 338 } … … 391 391 } 392 392 393 void MGCosy::CreateTabs( )393 void MGCosy::CreateTabs(const char *prepos) 394 394 { 395 395 TGCompositeFrame *tf1 = fTab->AddTab("Position"); … … 408 408 fList->Add(fCZdAz); 409 409 410 CreatePredefinedPos(tf1 );410 CreatePredefinedPos(tf1, prepos); 411 411 CreateStarList(tf4); 412 412 … … 728 728 } 729 729 730 MGCosy::MGCosy(MObservatory::LocationName_t key, MsgQueue *q)730 MGCosy::MGCosy(MObservatory::LocationName_t key, const char *prepos, MsgQueue *q) 731 731 : TGMainFrame(gClient->GetRoot(), 1, 1), fObservatory(key), fQueue(q) 732 732 { … … 755 755 756 756 fAccuracy = new MGAccuracy(f1, 300); 757 fAccuracy->DrawText("0.5se", "1.0se", "2.0se", "Ctrl Deviation [min]"); 757 fAccuracy->SetColorScale(1); 758 fAccuracy->DrawText("1.0'", "2.0'", "3.0'", "Ctrl Deviation [min]"); 759 //fAccuracy->DrawText("0.5se", "1.0se", "2.0se", ""); 758 760 fAccuracy->DrawCircles(); 759 761 … … 815 817 AddFrame(f2, hints2); 816 818 817 CreateTabs( );819 CreateTabs(prepos); 818 820 CreateLabel(frame); 819 821 -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r9132 r9439 114 114 void CreateMenu(); 115 115 void CreateLabel(TGCompositeFrame *f); 116 void CreateTabs( );117 void CreatePredefinedPos(TGCompositeFrame *tf1 );116 void CreateTabs(const char *prepos); 117 void CreatePredefinedPos(TGCompositeFrame *tf1, const char *prepos); 118 118 void CreateStarList(TGCompositeFrame *tf1); 119 119 … … 133 133 134 134 public: 135 MGCosy(MObservatory::LocationName_t key, MsgQueue *q);135 MGCosy(MObservatory::LocationName_t key, const char *prepos, MsgQueue *q); 136 136 ~MGCosy(); 137 137 -
trunk/MagicSoft/Cosy/gui/MGStarg.cc
r7790 r9439 23 23 : MGAccuracy(p, w) 24 24 { 25 SetColorScale(1.5); 25 SetColorScale(1); 26 DrawText("1.0'", "2.0'", "3.0'", "Mispointing [min]"); 27 DrawHexagon(); 26 28 } -
trunk/MagicSoft/Cosy/leds_magic2.txt
r9430 r9439 5 5 370 518 0 0 6 6 170 405 0 0 7 166 174 0 0 8 25 1 870 07 #166 174 0 0 8 252 82 0 0 -
trunk/MagicSoft/Cosy/main/MCaos.cc
r9435 r9439 354 354 355 355 // img width height radius sigma 356 FilterLed f(img, 768, 576, fSizeBox, f Cut);356 FilterLed f(img, 768, 576, fSizeBox, fSizeBox, fCut); 357 357 358 358 Int_t first=0; … … 506 506 507 507 if (IsEnvDefined(env, prefix, "MinNumberLeds", print)) 508 fM axRadius = GetEnvValue(env, prefix, "MinNumberLeds", fMinNumberLeds);508 fMinNumberLeds = GetEnvValue(env, prefix, "MinNumberLeds", fMinNumberLeds); 509 509 510 510 if (IsEnvDefined(env, prefix, "SizeBox", print)) -
trunk/MagicSoft/Cosy/main/MCosy.cc
r9435 r9439 219 219 if (d.Zd()<fMin.Zd()) 220 220 { 221 gLog << err << "ERROR: Requested Zenith Angle below negative endswitch."<< endl;221 gLog << err << "ERROR: Requested Zenith Angle " << d.Zd()*TMath::RadToDeg() << " below negative endswitch " << fMin.Zd()*TMath::RadToDeg() << endl; 222 222 return kFALSE; 223 223 } … … 225 225 if (d.Zd()>fMax.Zd()) 226 226 { 227 gLog << err << "ERROR: Requested Zenith Angle behind positive endswitch."<< endl;227 gLog << err << "ERROR: Requested Zenith Angle " << d.Zd()*TMath::RadToDeg() << " behind positive endswitch " << fMax.Zd()*TMath::RadToDeg() << endl; 228 228 return kFALSE; 229 229 } … … 231 231 if (d.Az()<fMin.Az()) 232 232 { 233 gLog << err << "ERROR: Requested Azimuth Angle below negative endswitch." << endl; 233 gLog << err << "ERROR: Requested Azimuth Angle " << d.Az()*TMath::RadToDeg() << " below negative endswitch " << fMin.Az()*TMath::RadToDeg() << endl; 234 if (TMath::Abs(d.Zd())<1) 235 gLog << " Remember that there is a small inaccessible region around zenith!" << endl; 236 234 237 return kFALSE; 235 238 } … … 237 240 if (d.Az()>fMax.Az()) 238 241 { 239 gLog << err << "ERROR: Requested Azimuth Angle behind positive endswitch." << endl; 242 gLog << err << "ERROR: Requested Azimuth Angle " << d.Az()*TMath::RadToDeg() << " behind positive endswitch " << fMax.Az()*TMath::RadToDeg() << endl; 243 if (TMath::Abs(d.Zd())<1) 244 gLog << " Remember that there is a small inaccessible region around zenith!" << endl; 240 245 return kFALSE; 241 246 } … … 336 341 337 342 // Default: point.SetPointAcc(0.03, 0.01); 343 // Default: point.SetPointVelocity(0.3); 338 344 point.SetPointAcc(0.03, 0.01); 339 345 point.SetPointVelocity(0.3); 346 347 //point.SetPointAcc(0.09, 0.03); 348 //point.SetPointVelocity(1.0); 340 349 341 350 return point.SetPosition(dst, track); … … 513 522 case WM_STARGTPOINT: 514 523 if (fStarguider) 515 fStarguider->StartTPoint( );524 fStarguider->StartTPoint((char*)mp); 516 525 return 0xca1c; 517 526 518 527 case WM_STARGMODE: 519 528 if (fStarguider) 520 fStarguider->StartStarguider( );529 fStarguider->StartStarguider(*((bool*)mp)); 521 530 return 0xca1c; 522 531 … … 594 603 cout << "Preposition command to " << preps << " received." << endl; 595 604 596 ifstream fin( "prepos.txt");605 ifstream fin(fFilePrepos); 597 606 if (!fin) 598 607 { 599 cout << "ERROR: cannot open prepos.txt."<< endl;608 cout << "ERROR: cannot open " << fFilePrepos << endl; 600 609 return 0xebb1; 601 610 } … … 817 826 { 818 827 tout.Start(999); 819 fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError, armed); 828 fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError, armed, 829 fStarguider ? fStarguider->GetStarguiderMode() : 0); 820 830 } 821 831 … … 876 886 } 877 887 878 // --------------------------------------------------------------------------879 //880 // Disable the synchronization by using a negative CAN Id for id2.881 //882 void MCosy::Constructor(Int_t id1, Int_t id2)883 {884 //885 // Create Nodes886 //887 gLog << inf << "- Setting up network." << endl;888 889 fMac1=new Dkc(id1, "DKC/Az");890 fMac2=new Dkc(id2, "DKC/Zd");891 892 fMac1->SetReport(fOutRep);893 fMac2->SetReport(fOutRep);894 895 gLog << inf << "- Connecting devices to network." << endl;896 897 //898 // Connect the devices to the network899 //900 SetNode(fMac1);901 SetNode(fMac2);902 903 //904 // Create Gui Event timer and Gui905 //906 gLog << inf << "- Initializing GUI Timer." << endl;907 fUpdateGui = new TTimer(this, 100); // 100ms908 909 gLog << all << "- Starting GUI." << endl;910 fWin=new MGCosy(fObservatory, this);911 }912 913 /*914 void MCosy::ConstructorDemo()915 {916 //917 // Create Nodes918 //919 gLog << "- Setting up network." << endl;920 921 //922 // Create Gui Event timer and Gui923 //924 gLog << "- Initializing GUI Timer." << endl;925 fUpdateGui = new TTimer(this, 100); // 100ms926 927 gLog << "- Starting GUI." << endl;928 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1);929 }930 */931 932 888 TString MCosy::GetFileName(const char *path, const char *name, const char *ext) 933 889 { … … 963 919 } 964 920 965 MCosy::MCosy(MEnv &env, MDriveCom *com , const char *pointing)921 MCosy::MCosy(MEnv &env, MDriveCom *com) 966 922 : Network(), fObservatory(MObservatory::kMagic1), fStarguider(NULL), 967 923 fMac1(0), fMac2(0), fStatus(MDriveCom::kStopped), fOutTp(0), fOutRep(0) … … 969 925 const Int_t id1 = env.GetValue("Az_Id", 1); 970 926 const Int_t id2 = env.GetValue("Zd_Id", 3); 927 928 fFilePrepos = env.GetValue("FilePredefinedPositions", "prepos.txt"); 971 929 972 930 TString name = GetFileName("rep", "cosy", "rep"); … … 978 936 *fOutRep << "[Reports]" << endl; 979 937 980 /* 981 gLog << "- Program in "; 982 switch (mode) 983 { 984 case 0: 985 gLog << "<<Standard mode>>" << endl;*/ 986 gLog << all << "Reading pointing model from " << pointing << "..." << endl; 987 if (fBending.Load(pointing)) 988 gLog << all << "Reading pointing model from " << pointing << " successfull." << endl; 989 else 990 gLog << err << "ERROR - Reading pointing model from " << pointing << endl; 991 Constructor(id1, id2);/* 992 break; 993 case 1: 994 gLog << "<<SE mode>>" << endl; 995 fBending.Load("bending.txt"); 996 ConstructorSE(id4, id5, id6); 997 break; 998 default: 999 gLog << "<<Demo mode>>" << endl; 1000 ConstructorDemo(); 1001 } 1002 */ 938 const TString pointing = env.GetValue("PointingModel", "bending.txt"); 939 940 gLog << all << "Reading pointing model from " << pointing << "..." << endl; 941 if (fBending.Load(pointing)) 942 gLog << all << "Reading pointing model from " << pointing << " successfull." << endl; 943 else 944 gLog << err << "ERROR - Reading pointing model from " << pointing << endl; 945 946 // 947 // Create Nodes 948 // 949 gLog << inf << "- Setting up network." << endl; 950 951 fMac1=new Dkc(id1, "DKC/Az"); 952 fMac2=new Dkc(id2, "DKC/Zd"); 953 954 fMac1->SetReport(fOutRep); 955 fMac2->SetReport(fOutRep); 956 957 gLog << inf << "- Connecting devices to network." << endl; 958 959 // 960 // Connect the devices to the network 961 // 962 SetNode(fMac1); 963 SetNode(fMac2); 964 965 // 966 // Create Gui Event timer and Gui 967 // 968 gLog << inf << "- Initializing GUI Timer." << endl; 969 fUpdateGui = new TTimer(this, 100); // 100ms 970 971 gLog << all << "- Starting GUI." << endl; 972 fWin=new MGCosy(fObservatory, fFilePrepos, this); 1003 973 1004 974 gLog.SetOutputGui(fWin->GetLog(), kTRUE); -
trunk/MagicSoft/Cosy/main/MCosy.h
r9435 r9439 91 91 MLog *fOutRep; 92 92 93 TString fFilePrepos; 94 93 95 ZdAz AlignTrackingPos(ZdAz pointing) const; 94 96 Bool_t CheckRange(const ZdAz &d) const; … … 122 124 123 125 public: 124 MCosy(MEnv &env, MDriveCom *com , const char *pointing);126 MCosy(MEnv &env, MDriveCom *com); 125 127 ~MCosy(); 126 128 -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r9435 r9439 1 #undef EXPERT2 1 #undef EXPERT 3 2 … … 307 306 308 307 fGStarg = new MGStarg(this, 235); 309 fGStarg->DrawText("0.75'", "1.50'", "3.00'", "Mispointing [min]");310 fGStarg->DrawHexagon();311 308 fGStarg->Move(530,596+5); 312 309 fList->Add(fGStarg); … … 342 339 343 340 fTPoint = new TGTextButton(this, "TPoint"); 344 fTPoint->Move(4, fMenu->GetDefaultHeight()+785); 341 //fTPoint->Move(4, fMenu->GetDefaultHeight()+785); 342 fTPoint->Move(170, fMenu->GetDefaultHeight()+785); 345 343 fTPoint->AllowStayDown(kTRUE); 346 344 AddFrame(fTPoint); 347 348 fStargTPoint = new TGTextButton(this, "StargTPoint"); 349 fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785); 350 fStargTPoint->AllowStayDown(kTRUE); 351 AddFrame(fStargTPoint); 345 /* 346 fStargTPoint = new TGTextButton(this, "StargTPoint"); 347 fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785); 348 fStargTPoint->AllowStayDown(kTRUE); 349 AddFrame(fStargTPoint); 350 */ 352 351 353 352 fFps = new TGLabel(this, "---fps"); … … 448 447 MapSubwindows(); 449 448 fTPoint->UnmapWindow(); 450 fStargTPoint->UnmapWindow();449 //fStargTPoint->UnmapWindow(); 451 450 fGStarg->UnmapWindow(); 452 451 fGNumStars->UnmapWindow(); … … 479 478 fOutTp(0), 480 479 fOutStargTp(0), 481 fOutRq(0),480 // fOutRq(0), 482 481 fDx((768-kZOOM)/2), 483 482 fDy((512-kZOOM)/2), 484 483 fStatus(MDriveCom::kStandby), 485 484 fRadius(200), 486 fTPointFromCC(0) 485 fTPointFromCC(-1), 486 fFindStarCut(3.0), fFindStarBox(70) 487 487 { 488 488 gLog << warn << " #### FIXME: Make MCaos Thread safe!" << endl; … … 557 557 558 558 fRadius = env.GetValue("Leds.Radius", fRadius); 559 560 fStarguiderW = env.GetValue("Starguider.Width", fStarguiderW); 561 fStarguiderH = env.GetValue("Starguider.Height", fStarguiderH); 562 fStarguiderX = env.GetValue("Starguider.X", fStarguiderX); 563 fStarguiderY = env.GetValue("Starguider.Y", fStarguiderY); 564 565 fSkyOffsetX = env.GetValue("Starguider.SkyOffsetX", fSkyOffsetX); 566 fSkyOffsetY = env.GetValue("Starguider.SkyOffsetY", fSkyOffsetY); 567 568 fFindStarBox = env.GetValue("FindStar.SizeBox", fFindStarBox); 569 fFindStarCut = env.GetValue("FindStar.CleaningLevel", fFindStarCut); 559 570 } 560 571 … … 583 594 delete fOutStargTp; 584 595 585 if (fOutRq)586 delete fOutRq;596 // if (fOutRq) 597 // delete fOutRq; 587 598 588 599 gLog << inf2 << "Camera Display destroyed." << endl; … … 649 660 } 650 661 662 /* 651 663 void MStarguider::ToggleFindStar() 652 664 { 653 665 if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy) 654 666 fTPoint->MapWindow(); 655 667 else 656 668 { … … 659 671 } 660 672 } 661 673 */ 662 674 void MStarguider::ToggleStarguider() 663 675 { … … 671 683 fOperations->EnableEntry(IDM_kStargAnalysis); 672 684 673 fStargTPoint->MapWindow();685 //fStargTPoint->MapWindow(); 674 686 675 687 fPZdAz->MapWindow(); … … 703 715 SwitchOff(fChannel, IDM_kChannel2); 704 716 fChannel->CheckEntry(IDM_kChannel1); 705 706 717 } 707 718 else … … 709 720 fStatus = MDriveCom::kStandby; 710 721 711 fStargTPoint->UnmapWindow();712 fStargTPoint->SetDown(kFALSE);722 //fStargTPoint->UnmapWindow(); 723 //fStargTPoint->SetDown(kFALSE); 713 724 714 725 fPZdAz->UnmapWindow(); … … 772 783 MapSubwindows(); // maps everything, but we don't want that 773 784 fTPoint->UnmapWindow(); 774 fStargTPoint->UnmapWindow();785 //fStargTPoint->UnmapWindow(); 775 786 fGStarg->UnmapWindow(); 776 787 fGNumStars->UnmapWindow(); … … 863 874 //tpoint 864 875 SwitchOff(fDisplay, IDM_kFindStar); 865 ToggleFindStar();866 876 SwitchOff(fDisplay, IDM_kCaosFilter); 867 877 ToggleCaosFilter(); … … 874 884 875 885 //check needed items 876 fDisplay-> CheckEntry(IDM_kStretch);886 fDisplay->UnCheckEntry(IDM_kStretch); 877 887 fDisplay->CheckEntry(IDM_kStargCaosFilter); 878 888 fDisplay->CheckEntry(IDM_kStarguider); 879 889 ToggleStarguider(); 890 891 fTPoint->MapWindow(); 880 892 } 881 893 else … … 885 897 fDisplay->UnCheckEntry(IDM_kStargCaosFilter); 886 898 fDisplay->UnCheckEntry(IDM_kStarguider); 899 fTPoint->UnmapWindow(); 887 900 ToggleStarguider(); 888 901 … … 922 935 923 936 //checking needed items 924 fDisplay-> CheckEntry(IDM_kStretch);937 fDisplay->UnCheckEntry(IDM_kStretch); 925 938 fDisplay->CheckEntry(IDM_kCaosFilter); 926 939 ToggleCaosFilter(); 927 940 fDisplay->CheckEntry(IDM_kFindStar); 928 ToggleFindStar();941 fTPoint->MapWindow(); 929 942 } 930 943 else … … 946 959 ToggleCaosFilter(); 947 960 fDisplay->UnCheckEntry(IDM_kFindStar); 948 ToggleFindStar();961 fTPoint->UnmapWindow(); 949 962 } 950 963 return kTRUE; … … 956 969 case IDM_kFindStar: 957 970 Toggle(fDisplay, IDM_kFindStar); 958 ToggleFindStar();971 //ToggleFindStar(); 959 972 return kTRUE; 960 973 … … 1293 1306 #endif 1294 1307 1308 return fSao->CalcDeltaZdAzFromPix(mx, my)*TMath::RadToDeg(); 1309 /* 1295 1310 AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg; 1296 1311 AltAz pos1 = fSao->CalcAltAzFromPix(768/2+mx, 576/2+my)*kRad2Deg; … … 1298 1313 pos1 -= pos0; 1299 1314 1300 return ZdAz(-pos1.Alt(), pos1.Az()); 1301 } 1302 1303 Int_t MStarguider::CalcTrackingError(Leds &leds, MStarList &stars, 1304 ZdAz &d, MTime &t, double &bright, Int_t &num) 1305 { 1315 ZdAz res2 = ZdAz(-pos1.Alt(), pos1.Az()); 1316 1317 return res1; 1318 */ 1319 } 1320 1321 Int_t MStarguider::CalcTrackingError(const Leds &leds, MStarList &stars, 1322 ZdAz &d, const MTime &t, const double &bright, 1323 Int_t &num, const Ring ¢er, Int_t numleds, Int_t numrings) 1324 { 1325 // Get tracking coordinates 1326 const XY xy = fCRaDec->GetCoordinates(); 1327 1306 1328 num = leds.GetEntries(); 1307 1329 if (num < 3) //was 1 1308 1330 { 1309 1331 gLog << warn << "Sorry, less than 3 detected spot in FOV!" << endl; 1310 fStargTPoint->SetDown(kFALSE); 1332 if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom()) 1333 fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num); // Report 1334 fTPoint->SetDown(kFALSE); 1311 1335 return 0; 1312 1336 } … … 1315 1339 { 1316 1340 gLog << warn << "Sorry, less than 3 stars in FOV!" << endl; 1317 fStargTPoint->SetDown(kFALSE); 1341 if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom()) 1342 fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num); // Report 1343 fTPoint->SetDown(kFALSE); 1318 1344 return 0; 1319 1345 } … … 1375 1401 if (numcor<1) 1376 1402 { 1377 fStargTPoint->SetDown(kFALSE); 1403 fTPoint->SetDown(kFALSE); 1404 if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom()) 1405 fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num, numcor); // Report 1378 1406 return 0; 1379 1407 } … … 1388 1416 1389 1417 // Check StargTPoint data set request 1390 if (!f StargTPoint->IsDown())1418 if (!fDisplay->IsEntryChecked(IDM_kStarguiderMode) || !fTPoint->IsDown()) 1391 1419 return numcor; 1392 f StargTPoint->SetDown(kFALSE);1420 fTPoint->SetDown(kFALSE); 1393 1421 1394 1422 // If no file open: open new file … … 1406 1434 } 1407 1435 1408 // Get tracking coordinates1409 const XY xy = fCRaDec->GetCoordinates();1410 1436 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad()); 1411 1437 … … 1430 1456 1431 1457 // Write real pointing position 1432 //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;1433 1458 *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " "; 1434 1459 1435 1460 // Write system pointing position 1436 //cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl;1437 1461 *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd(); 1438 1462 … … 1440 1464 *fOutStargTp << " " << d.Zd() << " " << d.Az(); 1441 1465 *fOutStargTp << " " << setprecision(11) << t.GetMjd(); 1442 *fOutStargTp << " " << num; 1443 *fOutStargTp << " " << bright; 1466 *fOutStargTp << " " << setprecision(4) << center.GetMag(); 1467 *fOutStargTp << " " << star->GetMag(); 1468 *fOutStargTp << " " << center.GetX() << " " << center.GetY(); 1469 *fOutStargTp << " 0 0"; 1470 *fOutStargTp << " " << numleds << " " << numrings; 1471 *fOutStargTp << " " << num << " " << numcor << " " << bright; 1444 1472 *fOutStargTp << endl; 1445 1473 1474 gLog << all << "Starguider TPoint successfully taken." << endl; 1475 1446 1476 fTimeFromTp.Clear(); 1447 1477 1478 if (!fCosy) 1479 return numcor; 1480 1481 MDriveCom *com = fCosy->GetDriveCom(); 1482 if (!com) 1483 return numcor; 1484 1485 com->SendTPoint(true, 'S', fTPointStarMag, fTPointStarName, za0, cpos, xy, d.Zd(), d.Az(), t, center, Led(), numleds, numrings, num, numcor); // Report 1486 1448 1487 return numcor; 1449 1488 } 1450 1489 1451 void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t) 1452 { 1490 void MStarguider::FindStar(const FilterLed &f, const FilterLed &f2, const Ring ¢er, const MTime &t, Int_t numleds, Int_t numrings) 1491 { 1492 // Get tracking coordinates 1493 const XY xy = fCRaDec->GetCoordinates(); // [h, deg] 1494 1495 if (center.GetX()<=0 && center.GetY()<=0) 1496 { 1497 gLog << warn << "Couldn't determine center of the camera." << endl; 1498 if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom()) 1499 fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings); // Report 1500 return; 1501 } 1502 1453 1503 // Try to find the star 1454 1504 Leds leds; … … 1459 1509 if (!star) 1460 1510 { 1461 if (fTPoint->IsDown()) 1462 { 1463 fTPoint->SetDown(kFALSE); 1464 gLog << warn << "No star found. Couldn't take a tpoint." << endl; 1465 } 1511 gLog << warn << "No star found." << endl; 1512 if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom()) 1513 fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings); // Report 1466 1514 return; 1467 1515 } … … 1470 1518 star->Print(); 1471 1519 f2.MarkPoint(star->GetX(), star->GetY(), 2<<2); 1520 1521 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad()); 1472 1522 1473 1523 // Initialize Star Catalog on the camera plane … … 1478 1528 ac.SetObservatory(*fSao); 1479 1529 ac.SetTime(t); 1480 1481 // Get tracking coordinates1482 const XY xy = fCRaDec->GetCoordinates(); // [h, deg]1483 const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());1484 1485 1530 ac.SetRaDec(rd.Ra(), rd.Dec()); 1486 1531 … … 1500 1545 1501 1546 // Check TPoint data set request 1502 if (!f TPoint->IsDown())1547 if (!fDisplay->IsEntryChecked(IDM_kTpointMode) || !fTPoint->IsDown()) 1503 1548 return; 1504 1505 fTPoint->SetDown(kFALSE);1506 1549 1507 1550 // If no file open: open new file … … 1539 1582 const ZdAz za1 = fCosy->GetSePos()*360; // [deg] 1540 1583 1584 1541 1585 // Write real pointing position 1542 1586 //cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl; … … 1552 1596 *fOutTp << " " << setprecision(4) << center.GetMag(); 1553 1597 *fOutTp << " " << star->GetMag(); 1598 *fOutTp << " " << center.GetX() << " " << center.GetY(); 1599 *fOutTp << " " << star->GetX() << " " << star->GetY(); 1600 *fOutTp << " " << numleds << " " << numrings; 1601 *fOutTp << " 0 0 0"; 1554 1602 *fOutTp << endl; 1603 1604 gLog << all << "TPoint successfully taken." << endl; 1555 1605 /* 1556 1606 MLog &outrep = *fCosy->GetOutRep(); … … 1570 1620 1571 1621 // return zdaz; 1622 1623 if (!fCosy) 1624 return; 1625 1626 MDriveCom *com = fCosy->GetDriveCom(); 1627 if (!com) 1628 return; 1629 1630 com->SendTPoint(true, 'T', fTPointStarMag, fTPointStarName, za0, za1, xy, -dzd, -daz, t, center, *star, numleds, numrings); // Report 1572 1631 } 1573 1632 … … 1624 1683 } 1625 1684 1626 void MStarguider::StartStarguider() 1685 void MStarguider::StartTPoint(char *cmd) 1686 { 1687 fTPointStarName = "Dummy"; 1688 fTPointStarMag = 0; 1689 1690 TString str(cmd); 1691 1692 TObjArray *arr = str.Tokenize(' '); 1693 1694 if (arr->GetEntries()==2) 1695 { 1696 fTPointStarName = (*arr)[0]->GetName(); 1697 fTPointStarMag = atof((*arr)[1]->GetName()); 1698 } 1699 1700 delete arr; 1701 1702 if (fTPointFromCC<0) 1703 fTPointFromCC=0; 1704 } 1705 1706 void MStarguider::StartStarguider(bool on) 1627 1707 { 1628 1708 // 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); 1709 if (on) 1710 { 1711 cout << " * Switching Starguider mode on" << endl; 1712 fMode->UnCheckEntry(IDM_kStarguiderMode); 1713 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0); 1714 } 1715 else 1716 { 1717 cout << " * Switching Starguider mode off" << endl; 1718 fMode->CheckEntry(IDM_kStarguiderMode); 1719 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0); 1720 } 1721 } 1722 1723 Int_t MStarguider::GetStarguiderMode() const 1724 { 1725 return fMode->IsEntryChecked(IDM_kStarguiderMode) ? 1 : 2; 1726 1632 1727 } 1633 1728 1634 1729 Bool_t MStarguider::DoTPoint() 1635 1730 { 1731 if (fTPoint->IsDown() && fTPointFromCC<0) 1732 { 1733 fTPointFromCC = 0; 1734 fTPoint->SetDown(kFALSE); 1735 } 1736 1636 1737 if (fTPointFromCC<0) 1637 1738 return kTRUE; … … 1650 1751 1651 1752 case 2: 1753 case 3: 1652 1754 cout << " * Waiting one frame" << endl; 1653 1755 // Wait one frame 1654 1756 return kFALSE; 1655 1757 1656 case 3:1758 case 4: 1657 1759 cout << " * Taking TPoint" << endl; 1658 1760 fTPoint->SetDown(); // kTRUE 1659 1761 return kTRUE; 1660 1762 1661 case 4:1763 case 5: 1662 1764 if (!fTimeFromTp) // TPoint failed 1663 1765 break; … … 1669 1771 return kFALSE; 1670 1772 1671 case 5: 1773 case 6: 1774 case 7: 1672 1775 cout << " * Waiting one frame" << endl; 1673 1776 // Wait one frame 1674 1777 return kFALSE; 1675 1778 1676 case 6:1779 case 8: 1677 1780 cout << " * Taking Starguider TPoint" << endl; 1678 f StargTPoint->SetDown(); // kTRUE1781 fTPoint->SetDown(); // kTRUE 1679 1782 return kTRUE; 1680 1783 1681 case 7: 1682 cout << " * Send Report" << endl; 1784 // case 9: 1785 // cout << " * Send Report" << endl; 1786 // return kTRUE; 1787 1788 case 9: 1789 cout << " * Switching to TPoint mode" << endl; 1790 // Switch to tpoint mode 1791 fMode->UnCheckEntry(IDM_kTpointMode); 1792 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kTpointMode, 0); 1683 1793 break; 1684 1794 } … … 1686 1796 // Send report 1687 1797 fTPointFromCC = -1; 1688 1798 /* 1689 1799 if (!fCosy) 1690 1800 return kTRUE; … … 1702 1812 //fNumStarsCorrelated = rc; 1703 1813 com->SendTPoint(fNumStarsCorrelated>0); 1704 1814 */ 1705 1815 return kTRUE; 1706 1816 } … … 1736 1846 if (!fWritePictures->IsEntryEnabled(IDM_kStart) && 1737 1847 (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce))) 1738 { 1848 { 1739 1849 1740 1850 if (fFileType->IsEntryChecked(IDM_kPNG)) … … 1752 1862 f.Execute(); 1753 1863 1754 DoTPoint(); 1864 if (!DoTPoint()) 1865 return; 1755 1866 1756 1867 Int_t numleds = 0; … … 1758 1869 1759 1870 // Find Center of Camera for Caos and Tpoints 1760 Ring center(768/2, 576/2); 1871 // Ring center;//(-1, -1); 1872 Ring center(5, 5);//(-1, -1); 1761 1873 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 1762 1874 { … … 1774 1886 1775 1887 // Find Star at Center---for Tpoint Procedure 1776 if (fDisplay->IsEntryChecked(IDM_kFindStar) && 1777 center.GetX()>0 && center.GetY()>0) 1888 if (fDisplay->IsEntryChecked(IDM_kFindStar)) 1778 1889 { 1779 1890 // 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 );1891 f.SetCut(fFindStarCut); 1892 f.SetBox(fFindStarBox); 1893 1894 FindStar(f, f2, center, t, numleds, numrings); 1784 1895 } 1785 1896 … … 1788 1899 1789 1900 // Position corresponding to the camera center (53.2, 293.6) 1790 Ring sgcenter (53.2, 293.6); // Center of camera in SG picture [px]1901 Ring sgcenter;//(-1, -1); // Center of camera in SG picture [px] 1791 1902 1792 1903 // Find Center of Camera in Starfield Camera picture … … 1817 1928 fCZdAz->SetCoordinates(fSao->GetZdAz()); 1818 1929 1819 fSao->SetBox( 230); //Region of interest around center1930 fSao->SetBox(fStarguiderW, fStarguiderH); // 280 Region of interest around center 1820 1931 1821 1932 // If center of camera cannot be determined sgcenter is (0,0) 1822 1933 const Bool_t centerisvalid = sgcenter.GetX()>0 && sgcenter.GetY()>0; 1823 // if (centerisvalid)1824 // skycenter.SetXY(sgcenter.GetX() - 53.2,1825 // sgcenter.GetY() - 293.6);1826 1934 1827 1935 // We determine the ideal starfield using camera sagging info … … 1830 1938 // 53.2 and 293.6 are the "preliminary" camera center 1831 1939 // -9 and 28.5 are the offsets of the pointing position in the sky 1832 const XY off(sgcenter.GetX()- 53.2-9, 1833 sgcenter.GetY()-293.6+28.5); 1834 1835 // we obtain stars in the effective star FOV and draw them. 1836 // coordinates are video frame coords. 1837 MStarList stars; 1838 fSao->CalcStars(stars, 530, 292, TMath::FloorNint(off.X()), TMath::FloorNint(off.Y())); 1839 fSao->DrawStars(stars, cimg); 1840 1841 // Position around which the circles are drawn. 1842 const Ring skycenter(768/2-off.X(), 576/2+off.Y()); 1940 //const XY off(sgcenter.GetX()- 53.2-9, 1941 // sgcenter.GetY()-293.6+28.5); 1942 1943 // Skycenter 1944 const XY off(sgcenter.GetX() + fSkyOffsetX, 1945 sgcenter.GetY() + fSkyOffsetY); 1946 1947 MStarList stars; 1948 if (centerisvalid) 1949 { 1950 // we obtain stars in the effective star FOV and draw them. 1951 // coordinates are video frame coords. 1952 fSao->CalcStars(stars, fStarguiderX, fStarguiderY, off.X(), off.Y()); 1953 fSao->DrawStars(stars, cimg); 1954 } 1843 1955 1844 1956 // There are two corrections to the mispointing … … 1853 1965 1854 1966 Leds spots; 1855 f.SetBox(230);1967 f.SetBox(fStarguiderW, fStarguiderH); // 280 1856 1968 f.SetCut(cut); 1857 1969 1858 1970 double bright; 1859 f.ExecuteAndMark(spots, 530, 292, bright);1971 f.ExecuteAndMark(spots, fStarguiderX, fStarguiderY, bright); 1860 1972 1861 1973 ULong_t color; … … 1878 1990 1879 1991 Int_t numstars = 0; 1880 const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars );1992 const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars, sgcenter, numleds, numrings); 1881 1993 1882 1994 const Bool_t monitoring = brightnessisvalid && centerisvalid && fNumStarsCorrelated>2; … … 1907 2019 if (centerisvalid && fNumStarsCorrelated>2) 1908 2020 { 2021 // Position around which the circles are drawn. 2022 const Ring skycenter(off.X(), off.Y()); 2023 1909 2024 f2.DrawCircle(skycenter, 2.0, 0x0a); 1910 2025 … … 1917 2032 1918 2033 } //CalcStars 2034 2035 if (fTPoint->IsDown()) 2036 fTPoint->SetDown(kFALSE); 1919 2037 1920 2038 // Draw Circles around center of Camera … … 1948 2066 void MStarguider::UpdatePosZoom() 1949 2067 { 1950 MString txt; 2068 MString txt;/* 1951 2069 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1952 2070 { … … 1958 2076 txt.Form("(%d, %d) %.1fd/%.1fd", fDx, fDy, -aa.Alt(), aa.Az()-180); 1959 2077 } 1960 else 2078 else*/ 1961 2079 txt.Form("(%d, %d)", fDx, fDy); 1962 2080 fPosZoom->SetText(txt); -
trunk/MagicSoft/Cosy/main/MStarguider.h
r9435 r9439 98 98 99 99 TGButton *fTPoint; 100 TGButton *fStargTPoint;100 // TGButton *fStargTPoint; 101 101 102 102 ZdAz fPos; … … 121 121 ofstream *fOutTp; 122 122 ofstream *fOutStargTp; 123 ofstream *fOutRq;123 // ofstream *fOutRq; 124 124 125 125 Int_t fDx; … … 135 135 136 136 Int_t fTPointFromCC; 137 138 Int_t fStarguiderW; 139 Int_t fStarguiderH; 140 Int_t fStarguiderX; 141 Int_t fStarguiderY; 142 143 Float_t fSkyOffsetX; // Offset between camera center and sky position 144 Float_t fSkyOffsetY; // Offset between camera center and sky position 145 146 Float_t fFindStarCut; 147 Int_t fFindStarBox; 148 149 TString fTPointStarName; 150 Float_t fTPointStarMag; 137 151 138 152 void Toggle(TGPopupMenu *p, UInt_t id); 139 153 void SwitchOff(TGPopupMenu *p, UInt_t id); 140 154 void ToggleStargAnalysis(); 141 void ToggleFindStar();155 // void ToggleFindStar(); 142 156 void ToggleStarguider(); 143 157 void ToggleCaosFilter(); 144 158 void SetChannel(); 145 Int_t CalcTrackingError( Leds &, MStarList &, ZdAz &, MTime &, double &bright, Int_t &num);159 Int_t CalcTrackingError(const Leds &, MStarList &, ZdAz &, const MTime &, const double &bright, Int_t &num, const Ring ¢er, Int_t numleds, Int_t numrings); 146 160 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag, Int_t &num) const; 147 161 bool Interpolate(const unsigned long n, byte *img) const; 148 void FindStar( FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t);162 void FindStar(const FilterLed &f, const FilterLed &f2, const Ring ¢er, const MTime &t, Int_t numleds, Int_t numrings); 149 163 150 164 void InitGui(Int_t channel); … … 188 202 void Print(Option_t *o) const { } 189 203 190 void StartTPoint() { if (fTPointFromCC<0) fTPointFromCC=0; } 191 void StartStarguider(); 204 void StartTPoint(char *cmd=0);// { if (fTPointFromCC<0) fTPointFromCC=0; } 205 void StartStarguider(bool on); 206 207 Int_t GetStarguiderMode() const; 192 208 193 209 ClassDef(MStarguider, 0) -
trunk/MagicSoft/Cosy/main/MTracking.cc
r9435 r9439 33 33 // Send the new velocities for both axes. 34 34 // 35 fCosy->fMac2->SendSDO(0x300 6, 1, (LWORD_t)(v.Zd()*vrzd)); // SetRpmVelocity [re/min]36 fCosy->fMac1->SendSDO(0x300 6, 1, (LWORD_t)(v.Az()*vraz)); // SetRpmVelocity [re/min]35 fCosy->fMac2->SendSDO(0x3007, (LWORD_t)(v.Zd()*vrzd)); // SetRpmVelocity [re/min] 36 fCosy->fMac1->SendSDO(0x3007, (LWORD_t)(v.Az()*vraz)); // SetRpmVelocity [re/min] 37 37 38 38 // 39 39 // Wait for the objects to be acknoledged. 40 40 // 41 fCosy->fMac2->WaitForSdo(0x300 6, 1, 100);42 fCosy->fMac1->WaitForSdo(0x300 6, 1, 100);41 fCosy->fMac2->WaitForSdo(0x3007, 0, 100); 42 fCosy->fMac1->WaitForSdo(0x3007, 0, 100); 43 43 44 44 // … … 272 272 { 273 273 /* 274 sla.Now(1); 274 // Code for position control mode 275 // Set: S-0-0001 276 // Set: S-0-0002 277 // Set: P-0-0099 278 // Set: P-0-0187 (Spline) 279 // Replace S-0-0258 by S-0-0047 in communication 280 281 sla.Now(); 275 282 const ZdAz pointing = sla.CalcZdAz(fCosy->fRaDec); // [rad] 276 283 ZdAz dest = fCosy->AlignTrackingPos(pointing); // fix ambiguity … … 279 286 break; 280 287 dest *= 1./TMath::TwoPi(); //[rev] 281 fCosy->fMac2->SendSDO(0x6004, 0,(LWORD_t)(dest.Zd()*fCosy->fMac2->GetPosRes()+.5), false);282 fCosy->fMac1->SendSDO(0x6004, 0,(LWORD_t)(dest.Az()*fCosy->fMac1->GetPosRes()+.5), false);283 usleep(10000 0); // 1s288 fCosy->fMac2->SendSDO(0x6004, (LWORD_t)(dest.Zd()*fCosy->fMac2->GetPosRes()+.5), false); 289 fCosy->fMac1->SendSDO(0x6004, (LWORD_t)(dest.Az()*fCosy->fMac1->GetPosRes()+.5), false); 290 usleep(10000); // 10ms 284 291 continue; 285 292 */ -
trunk/MagicSoft/Cosy/prepos_magic2.txt
r9430 r9439 1 93. 7240.0 Park1 93.62 0.0 Park -
trunk/MagicSoft/Cosy/stargleds_magic2.txt
r9430 r9439 1 35 139 0 0 2 90 195 0 0 3 113 271 0 0 4 34 402 0 0 1 91 136 0 0 2 148 192 0 0 3 169 267 0 0 4 91 400 0 0 5 20 420 0 0 -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r9435 r9439 104 104 cout << "Zd/Az: " << zd << "/" << az << " "; 105 105 cout << "Ra/Dec: " << ra/15 << "h/" << dec << " "; 106 cout << "SolRad: " << solar << "W/m²" << endl; 106 //cout << "SolRad: " << solar << "W/m²"; 107 cout << endl; 107 108 108 109 fComStat = kCmdReceived; … … 122 123 return InterpreteReport(str); 123 124 124 const bool rc = InterpreteCmd(cmd, str.Strip(TString::kBoth)); 125 fComStat = rc ? kCmdReceived : kComProblem; 126 return rc; 125 return InterpreteCmd(cmd, str.Strip(TString::kBoth)); 127 126 } 128 127 129 128 bool MCeCoCom::SendRep(const char *cmd, const char *str, bool force) 130 129 { 131 MTime t;132 t.Now();133 130 134 131 UShort_t y1, y2, ms1, ms2; 135 132 Byte_t mon1, mon2, d1, d2, h1, h2, m1, m2, s1, s2; 136 133 134 fT.GetDate(y2, mon2, d2); 135 fT.GetTime(h2, m2, s2, ms2); 136 137 MTime t(-1); 137 138 t.GetDate(y1, mon1, d1); 138 139 t.GetTime(h1, m1, s1, ms1); 139 140 140 fT.GetDate(y2, mon2, d2);141 fT.GetTime(h2, m2, s2, ms2);141 if (t-fT>20) 142 fComStat = kComProblem; 142 143 143 144 const TString msg = … … 152 153 // Send report to CC 153 154 const bool rc = Send(msg.Data(), msg.Length()); 154 fComStat = rc ? kNoCmdReceived : kComProblem;155 155 156 156 // Write report to stream -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
r9432 r9439 19 19 enum ComStatus_t 20 20 { 21 kCmdReceived, 22 kNoCmdReceived, 23 kComProblem 21 kCmdReceived = 1, 22 kComProblem = 2 24 23 }; 25 24 … … 52 51 MCeCoCom(const char *addr, const int tx=7304, const int rx=7404, MLog *out=NULL) 53 52 : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0), 54 fTelescope(1), fComStat(k NoCmdReceived),53 fTelescope(1), fComStat(kComProblem), 55 54 fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1), 56 55 fAlarmCounter(0) -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r9435 r9439 7 7 #include "MString.h" 8 8 #include "Ring.h" 9 #include "Led.h" 10 11 #include "MLog.h" 12 #include "MLogManip.h" 9 13 10 14 using namespace std; … … 45 49 if (!ReadPosition(str, ra, dec)) 46 50 { 47 cout<< "ERROR - Reading position from RADEC" << endl;51 gLog << err << "ERROR - Reading position from RADEC" << endl; 48 52 return false; 49 53 } 50 54 if (!str.IsNull()) 51 55 { 52 cout<< "ERROR - Too many bytes in command RADEC" << endl;53 return false; 54 } 55 56 cout<< "CC-COMMAND " << MTime(-1) << " RADEC " << ra << "h " << dec << "d '" << str << "'" << endl;56 gLog << err << "ERROR - Too many bytes in command RADEC" << endl; 57 return false; 58 } 59 60 gLog << all << "CC-COMMAND " << MTime(-1) << " RADEC " << ra << "h " << dec << "d '" << str << "'" << endl; 57 61 58 62 ra *= 15; // h -> deg … … 72 76 if (!ReadPosition(str, ra, dec)) 73 77 { 74 cout<< "ERROR - Reading position from GRB" << endl;78 gLog << err << "ERROR - Reading position from GRB" << endl; 75 79 return false; 76 80 } 77 81 if (!str.IsNull()) 78 82 { 79 cout<< "ERROR - Too many bytes in command GRB" << endl;80 return false; 81 } 82 83 cout<< "CC-COMMAND " << MTime(-1) << " GRB " << ra << "h " << dec << "d '" << str << "'" << endl;83 gLog << err << "ERROR - Too many bytes in command GRB" << endl; 84 return false; 85 } 86 87 gLog << all << "CC-COMMAND " << MTime(-1) << " GRB " << ra << "h " << dec << "d '" << str << "'" << endl; 84 88 85 89 ra *= 15; // h -> deg … … 99 103 if (!ReadPosition(str, zd, az)) 100 104 { 101 cout<< "ERROR - Reading position from ZDAZ" << endl;105 gLog << err << "ERROR - Reading position from ZDAZ" << endl; 102 106 return false; 103 107 } … … 105 109 if (!str.IsNull()) 106 110 { 107 cout<< "ERROR - Too many bytes in command ZDAZ" << endl;108 return false; 109 } 110 111 cout<< "CC-COMMAND " << MTime(-1) << " ZDAZ " << zd << "deg " << az << "deg" << endl;111 gLog << err << "ERROR - Too many bytes in command ZDAZ" << endl; 112 return false; 113 } 114 115 gLog << all << "CC-COMMAND " << MTime(-1) << " ZDAZ " << zd << "deg " << az << "deg" << endl; 112 116 113 117 ZdAz za(zd, az); … … 125 129 if (str.IsNull()) 126 130 { 127 cout<< "ERROR - No identifier for preposition (PREPS) given." << endl;131 gLog << err << "ERROR - No identifier for preposition (PREPS) given." << endl; 128 132 return false; 129 133 } 130 134 if (str.First(' ')>=0) 131 135 { 132 cout<< "ERROR - PREPS command syntax error (contains whitespaces)." << endl;136 gLog << err << "ERROR - PREPS command syntax error (contains whitespaces)." << endl; 133 137 return false; 134 138 } … … 136 140 str.ToLower(); 137 141 138 cout<< "CC-COMMAND " << MTime(-1) << " PREPS '" << str << "'" << endl;142 gLog << all << "CC-COMMAND " << MTime(-1) << " PREPS '" << str << "'" << endl; 139 143 140 144 //cout << "MDriveCom - TRACK... start." << endl; … … 147 151 bool MDriveCom::CommandTPOINT(TString &str) 148 152 { 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 gLog << all << "CC-COMMAND " << MTime(-1) << " TPOIN " << str << endl; 154 155 TObjArray *arr = str.Tokenize(' '); 156 157 if (arr->GetEntries()!=2) 158 { 159 delete arr; 160 gLog << err << "ERROR - Wrong number of arguments in TPOIN command" << endl; 161 return false; 162 } 163 164 delete arr; 165 166 if (fQueue) 167 fQueue->PostMsg(WM_STARGTPOINT, (void*)str.Data(), str.Length()+1);//, (void*)str.Data(), str.Length()+1); 153 168 154 169 return true; … … 157 172 bool MDriveCom::CommandSTGMD(TString &str) 158 173 { 159 cout << "CC-COMMAND " << MTime(-1) << "STGMD" << endl; 160 161 if (fQueue) 162 fQueue->PostMsg(WM_STARGMODE);//, (void*)str.Data(), str.Length()+1); 174 gLog << all << "CC-COMMAND " << MTime(-1) << " STGMD " << str << endl; 175 176 bool on = str=="ON"; 177 178 if (fQueue) 179 fQueue->PostMsg(WM_STARGMODE, &on, sizeof(bool));//, (void*)str.Data(), str.Length()+1); 163 180 164 181 return true; … … 170 187 if (str.IsNull()) 171 188 { 172 cout<< "ERROR - No identifier for ARM command." << endl;189 gLog << err << "ERROR - No identifier for ARM command." << endl; 173 190 return false; 174 191 } 175 192 if (str.First(' ')>=0) 176 193 { 177 cout<< "ERROR - ARM command syntax error (contains whitespaces)." << endl;194 gLog << err << "ERROR - ARM command syntax error (contains whitespaces)." << endl; 178 195 return false; 179 196 } … … 182 199 if (str!="lock" && str!="unlock") 183 200 { 184 cout<< "ERROR - ARM command syntax error (neither LOCK nor UNLOCK)." << endl;185 return false; 186 } 187 188 cout<< "CC-COMMAND " << MTime(-1) << " ARM '" << str << "'" << endl;201 gLog << err << "ERROR - ARM command syntax error (neither LOCK nor UNLOCK)." << endl; 202 return false; 203 } 204 205 gLog << all << "CC-COMMAND " << MTime(-1) << " ARM '" << str << "'" << endl; 189 206 190 207 bool lock = str=="lock"; … … 200 217 { 201 218 //cout << "MDriveCom - WAIT... start." << endl; 202 cout<< "CC-COMMAND " << MTime(-1) << " WAIT" << endl;219 gLog << all << "CC-COMMAND " << MTime(-1) << " WAIT" << endl; 203 220 if (fQueue) 204 221 fQueue->PostMsg(WM_WAIT); … … 210 227 { 211 228 //cout << "MDriveCom - STOP!... start." << endl; 212 cout<< "CC-COMMAND " << MTime(-1) << " STOP!" << endl;229 gLog << all << "CC-COMMAND " << MTime(-1) << " STOP!" << endl; 213 230 if (fQueue) 214 231 fQueue->PostMsg(WM_STOP); … … 240 257 if (cmd.IsNull() && str.IsNull()) 241 258 { 242 cout<< "CC-COMMAND " << MTime(-1) << " Empty command (single '\\n') received." << endl;243 return false; 244 } 245 246 cout<< "CC-COMMAND " << MTime(-1) << " Syntax error: '" << cmd << "':'" << str << "'" << endl;259 gLog << all << "CC-COMMAND " << MTime(-1) << " Empty command (single '\\n') received." << endl; 260 return false; 261 } 262 263 gLog << err << "CC-COMMAND " << MTime(-1) << " Syntax error: '" << cmd << "':'" << str << "'" << endl; 247 264 return false; 248 265 } … … 258 275 } 259 276 260 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed )277 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed, Int_t stargmd) 261 278 { 262 279 // rd [rad] … … 294 311 str += MString::Format("%08.3f ", er.Az()); 295 312 str += armed ? "1 " : "0 "; 313 str += MString::Format("%d ", stargmd); // Starguider mode: 0=none, 1=starguider, 2=starguider off 296 314 297 315 return SendRep("DRIVE-REPORT", str.Data(), kFALSE); … … 336 354 } 337 355 338 bool MDriveCom::SendTPoint(UInt_t stat) 339 { 340 //const MTime t(-1); 341 356 bool MDriveCom::SendTPoint(bool stat, char type, Float_t mag, const char *name, const AltAz &za0, const ZdAz &za1, 357 const TVector2 &xy, Float_t dzd, Float_t daz, const MTime &t, 358 const Ring ¢er, const Led &star, Int_t numleds, Int_t numrings, 359 Int_t numstars, Int_t numcor, Float_t bright) 360 { 342 361 SetStatus(stat); 343 /* 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 */ 359 return SendRep("TPOINT-REPORT", "", kTRUE); 360 } 362 363 TString str = type; 364 str += MString::Format(" %8.4f ", za0.Az()); 365 str += MString::Format("%8.4f ", za0.Alt()); 366 str += MString::Format("%8.4f ", fmod(za1.Az()+360, 360)); 367 str += MString::Format("%8.4f ", 90-za1.Zd()); 368 str += MString::Format("%8.4f ", xy.X()); 369 str += MString::Format("%8.4f ", xy.Y()); 370 str += MString::Format("%8.4f ", dzd); 371 str += MString::Format("%8.4f ", daz); 372 str += MString::Format("%12.6f ", t.GetMjd()); 373 str += MString::Format("%f ", center.GetMag()); 374 str += MString::Format("%f ", star.GetMag()); 375 str += MString::Format("%f ", center.GetX()); 376 str += MString::Format("%f ", center.GetY()); 377 str += MString::Format("%f ", star.GetX()); 378 str += MString::Format("%f ", star.GetY()); 379 str += numleds; 380 str += " "; 381 str += numrings; 382 str += " "; 383 str += numstars; 384 str += " "; 385 str += numcor; 386 str += " "; 387 str += bright; 388 str += " "; 389 str += mag; 390 str += " "; 391 str += name; 392 393 return SendRep("TPOINT-REPORT", str, kTRUE); 394 } -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
r9435 r9439 7 7 8 8 class RaDec; 9 class AltAz; 9 10 class ZdAz; 10 11 class MsgQueue; 11 12 class Ring; 13 class Led; 12 14 class MLog; 15 class MTime; 16 class TVector2; 13 17 14 18 class MDriveCom : public MCeCoCom … … 49 53 50 54 51 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed );55 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed, Int_t stargmd); 52 56 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); 53 bool SendTPoint(UInt_t stat); 57 // bool SendTPoint(char type); 58 bool SendTPoint(bool stat, char type, Float_t mag, const char *name, const AltAz &za0, const ZdAz &za1, 59 const TVector2 &xy, Float_t dzd, Float_t daz, const MTime &t, 60 const Ring ¢er, const Led &star, Int_t numleds, Int_t numrings, 61 Int_t numstars=0, Int_t numcor=0, Float_t bright=0); 54 62 bool SendStatus(const char *stat); 55 63 }; -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
r9432 r9439 43 43 MTcpIpO::MTcpIpO(const char *addr, Int_t tx) : fPortTx(tx) 44 44 { 45 gLog << inf2 << "- Open send socket to " << addr << ":" << tx << endl; 45 // was "inf2" but nobody knows what the prg is doing if it times out 46 gLog << all << "- Open send socket to " << addr << ":" << tx << endl; 47 46 48 fTxSocket = new TSocket(addr, tx); 49 fTxSocket->SetOption(kNoBlock, 1); 50 51 MTcpIpO::RunThread(); 47 52 } 48 53 49 54 MTcpIpO::~MTcpIpO() 50 55 { 56 CancelThread(); 57 51 58 // Now delete all TCP/IP objects 52 59 delete fTxSocket; … … 55 62 MTcpIpIO::MTcpIpIO(const char *addr, Int_t tx, Int_t rx) : MTcpIpI(rx), MTcpIpO(addr, tx) 56 63 { 57 RunThread();64 MTcpIpI::RunThread(); 58 65 } 59 66 … … 74 81 } 75 82 83 /* 76 84 TString MTcpIpO::GetSocketAddress() const 77 85 { 86 TLockGuard guard(const_cast<TMutex*>(&fMutex)); 78 87 return GetSocketAddress(*fTxSocket); 79 88 } 80 89 */ 81 90 bool MTcpIpO::SendFrame(TSocket &tx, const char *msg, int len) 82 91 { 83 92 if (!tx.IsValid()) 84 {85 //gLog << warn << "WARNING - No transmission to " << GetSocketAddress(tx) << " possible." << endl;86 93 return false; 87 }88 94 89 95 #ifdef DEBUG … … 91 97 #endif 92 98 93 const Int_t l = tx.SendRaw(msg, len); 99 const Int_t l = tx.SendRaw(msg, len, kDontBlock); 100 101 // Frame not sent, EWOULDBLOCK 102 if (l==-4) 103 { 104 gLog << err << "ERROR - Sending to " << GetSocketAddress(tx) << " would block." << endl; 105 /*--->*/ tx.Close(); // ????? 106 return false; 107 } 108 94 109 if (l<0) 95 110 { … … 100 115 if (l!=len) 101 116 { 102 gLog << err << "ERROR - Sent wrong number (" << l << ") ofbytes to " << GetSocketAddress(tx) << endl;117 gLog << err << "ERROR - Could only sent " << l << " out of " << len << " bytes to " << GetSocketAddress(tx) << endl; 103 118 return false; 104 119 } … … 109 124 bool MTcpIpO::SendFrame(const char *addr, int port, const char *msg, int len) 110 125 { 111 // R__LOCKGUARD2(myMutex);112 126 #ifdef DEBUG 113 127 cout << "Connecting to " << addr << ":" << port << endl; … … 117 131 TSocket tx(addr, port); 118 132 return SendFrame(tx, msg, len); 119 /* 120 if (!tx.IsValid()) 121 { 122 gLog << warn << "WARNING - No transmission to " << addr << ":" << port << " possible." << endl; 133 } 134 135 bool MTcpIpO::Send(const char *msg, Int_t len) 136 { 137 const Int_t mtx = fMutex.TryLock(); 138 if (mtx==13) 139 gLog << warn << "MTcpIpO::Send - mutex is already locked by this thread." << endl; 140 141 // If Mutex cannot be locked, i.e. we are currently reopening 142 // the send socket we cannot wait, because we would block the 143 // executing threrad. 144 if (mtx) 123 145 return false; 124 } 125 126 gLog << dbg << "Sending to " << addr << ":" << port << endl; 127 128 const Int_t l = tx.SendRaw(msg, len, kDontBlock); 129 if (l<0) 130 { 131 gLog << err << "ERROR - Sending TCP/IP frame to " << addr << ":" << port << endl; 132 return false; 133 } 134 135 if (l!=len) 136 { 137 gLog << err << "ERROR - Sent wrong number (" << l << ") of bytes to " << addr << ":" << port << endl; 138 return false; 139 } 140 141 #ifdef DEBUG 142 cout << "Tx: " << msg << flush; 143 #endif 144 145 return true; 146 */ 147 } 148 149 bool MTcpIpO::Send(const char *msg, Int_t len) 150 { 151 if (!fTxSocket->IsValid()) 152 { 153 const TInetAddress &a = fTxSocket->GetInetAddress(); 154 if (!a.IsValid()) 155 return false; 146 147 const bool rc = SendFrame(*fTxSocket, msg, len); 148 149 fMutex.UnLock(); 150 151 return rc; 152 } 153 154 Int_t MTcpIpO::Thread() 155 { 156 const TInetAddress &a = fTxSocket->GetInetAddress(); 157 if (!a.IsValid()) 158 { 159 gLog << err << "ERROR: Send socket address invalid." << endl; 160 return 0; 161 } 162 163 Int_t wait = 1000; /// Wait a ms 164 165 while (!IsThreadCanceled()) 166 { 167 if (fTxSocket->IsValid()) 168 { 169 MThread::Sleep(1000); // Wait a ms 170 wait = 1000; 171 continue; 172 } 173 174 156 175 #ifdef DEBUG 157 176 cout << "- Reopen send socket to " << a.GetHostAddress() << ":" << fPortTx << endl; 158 177 #endif 178 179 fMutex.Lock(); 180 159 181 delete fTxSocket; 182 160 183 fTxSocket = new TSocket(a.GetHostAddress(), fPortTx); 161 } 162 163 return SendFrame(*fTxSocket, msg, len); 184 fTxSocket->SetOption(kNoBlock, 1); 185 186 fMutex.UnLock(); 187 188 if (fTxSocket->IsValid()) 189 continue; 190 191 MThread::Sleep(wait); // Wait a ms 192 if (wait<30000000) // 30s 193 wait *= 2; 194 } 195 196 return 1; 164 197 } 165 198 … … 174 207 TString str; 175 208 176 while (! IsThreadCanceled())209 while (!MTcpIpI::IsThreadCanceled()) 177 210 { 178 211 char c; -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h
r9432 r9439 2 2 #define COSY_MTcpIpIO 3 3 4 #ifndef MARS_MThread5 #include " MThread.h"4 #ifndef COSY_MsgQueue 5 #include "msgqueue.h" 6 6 #endif 7 7 #ifndef MARS_MTime 8 8 #include "MTime.h" 9 #endif 10 #ifndef ROOT_TMutex 11 #include <TMutex.h> 9 12 #endif 10 13 … … 22 25 23 26 Bool_t fConnectionEstablished; 27 28 MTime fLast; 24 29 25 30 Bool_t WaitForData(TSocket &sock); … … 39 44 40 45 // A generalized class for sending over tcp/ip 41 class MTcpIpO 46 class MTcpIpO : public MThread 42 47 { 43 48 private: 44 49 TSocket *fTxSocket; 50 TMutex fMutex; 45 51 46 52 Int_t fPortTx; 53 54 Int_t Thread(); 47 55 48 56 public: … … 54 62 static bool SendFrame(const char *addr, int port, const char *msg, int len); 55 63 56 TString GetSocketAddress() const; 57 bool Send(const char *msg, int len); 64 bool Send(const char *msg, int len); 58 65 }; 59 66 -
trunk/MagicSoft/Cosy/videodev/FilterLed.cc
r8869 r9439 247 247 248 248 int FilterLed::GetMeanPosition(const int x, const int y, 249 const int box, float &mx, float &my, unsigned int &sum) const 249 const int boxx, const int boxy, 250 float &mx, float &my, unsigned int &sum) const 250 251 { 251 252 unsigned int sumx=0; … … 253 254 254 255 sum=0; 255 for (int dx=x-box ; dx<x+box+1; dx++)256 for (int dy=y-box ; dy<y+box+1; dy++)256 for (int dx=x-boxx; dx<x+boxx+1; dx++) 257 for (int dy=y-boxy; dy<y+boxy+1; dy++) 257 258 { 258 259 const byte &m = fImg[dy*fW+dx]; … … 269 270 } 270 271 271 int FilterLed::GetMeanPosition(const int x, const int y, const int box ) const272 int FilterLed::GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const 272 273 { 273 274 float mx, my; 274 275 unsigned int sum; 275 return GetMeanPosition(x, y, box , mx, my, sum);276 return GetMeanPosition(x, y, boxx, boxy, mx, my, sum); 276 277 } 277 278 278 279 int FilterLed::GetMeanPositionBox(const int x, const int y, 279 const int box , float &mx,280 float &m y, unsigned int &sum) const280 const int boxx, const int boxy, 281 float &mx, float &my, unsigned int &sum) const 281 282 { 282 283 //------------------------------- 283 284 // Improved algorithm: 284 285 // 1. Look for the largest five-pixel-cross signal inside the box 285 int x0 = TMath::Max(x-box +1, 0);286 int y0 = TMath::Max(y-box +1, 0);287 288 int x1 = TMath::Min(x+box +1-1, fW);289 int y1 = TMath::Min(y+box +1-1, fH);286 int x0 = TMath::Max(x-boxx+1, 0); 287 int y0 = TMath::Max(y-boxy+1, 0); 288 289 int x1 = TMath::Min(x+boxx+1-1, fW); 290 int y1 = TMath::Min(y+boxy+1-1, fH); 290 291 291 292 int maxx=0; … … 330 331 331 332 int FilterLed::GetMeanPositionBox(const int x, const int y, 332 const int box ) const333 const int boxx, const int boxy) const 333 334 { 334 335 float mx, my; 335 336 unsigned int sum; 336 return GetMeanPositionBox(x, y, box , mx, my, sum);337 return GetMeanPositionBox(x, y, boxx, boxy, mx, my, sum); 337 338 } 338 339 … … 374 375 void FilterLed::Execute(Leds &leds, int xc, int yc, double &bright) const 375 376 { 376 const int x0 = TMath::Max(xc-fBox , 0);377 const int y0 = TMath::Max(yc-fBox , 0);378 const int x1 = TMath::Min(xc+fBox , fW);379 const int y1 = TMath::Min(yc+fBox , fH);377 const int x0 = TMath::Max(xc-fBoxX, 0); 378 const int y0 = TMath::Max(yc-fBoxY, 0); 379 const int x1 = TMath::Min(xc+fBoxX, fW); 380 const int y1 = TMath::Min(yc+fBoxY, fH); 380 381 381 382 const int wx = x1-x0; … … 432 433 // Define inner box in which to search the signal 433 434 // 434 const int x0 = TMath::Max(xc-fBox , 0);435 const int y0 = TMath::Max(yc-fBox , 0);436 const int x1 = TMath::Min(xc+fBox , fW);437 const int y1 = TMath::Min(yc+fBox , fH);435 const int x0 = TMath::Max(xc-fBoxX, 0); 436 const int y0 = TMath::Max(yc-fBoxY, 0); 437 const int x1 = TMath::Min(xc+fBoxX, fW); 438 const int y1 = TMath::Min(yc+fBoxY, fH); 438 439 439 440 // … … 444 445 const double sqrt2 = sqrt(2.); 445 446 446 const int xa = TMath::Max(xc- (int)rint(fBox*sqrt2), 0);447 const int ya = TMath::Max(yc- (int)rint(fBox*sqrt2), 0);448 const int xb = TMath::Min(xc+ (int)rint(fBox*sqrt2), fW);449 const int yb = TMath::Min(yc+ (int)rint(fBox*sqrt2), fH);447 const int xa = TMath::Max(xc-TMath::Nint(fBoxX*sqrt2), 0); 448 const int ya = TMath::Max(yc-TMath::Nint(fBoxY*sqrt2), 0); 449 const int xb = TMath::Min(xc+TMath::Nint(fBoxX*sqrt2), fW); 450 const int yb = TMath::Min(yc+TMath::Nint(fBoxY*sqrt2), fH); 450 451 451 452 // … … 518 519 float mx, my; 519 520 unsigned int mag; 520 int pos = box ? GetMeanPositionBox(xc, yc, fBox-1, mx, my, mag) : GetMeanPosition(xc, yc, fBox-1, mx, my, mag); 521 int pos = box ? GetMeanPositionBox(xc, yc, fBoxX-1, fBoxY-1, mx, my, mag) 522 : GetMeanPosition(xc, yc, fBoxX-1, fBoxY-1, mx, my, mag); 521 523 522 524 if (pos<0 || pos>=fW*fH || fImg[pos]<sum+fCut*sdev) -
trunk/MagicSoft/Cosy/videodev/FilterLed.h
r8810 r9439 17 17 int fW; 18 18 int fH; 19 int fBox; 19 int fBoxX; 20 int fBoxY; 20 21 float fCut; 21 22 … … 24 25 25 26 void GetMinMax(const int offset, byte *min, byte *max) const; 26 int GetMeanPosition(const int x, const int y, const int box ) const;27 int GetMeanPosition(const int x, const int y, const int box ,27 int GetMeanPosition(const int x, const int y, const int boxx, const int boxy) const; 28 int GetMeanPosition(const int x, const int y, const int boxx, const int boxy, 28 29 float &mx, float &my, unsigned int &sum) const; 29 30 30 31 int GetMeanPositionBox(const int x, const int y, 31 const int box ) const;32 const int boxx, const int boxy) const; 32 33 int GetMeanPositionBox(const int x, const int y, 33 const int box , float &mx, float &my,34 const int boxx, const int boxy, float &mx, float &my, 34 35 unsigned int &sum) const; 35 36 … … 40 41 public: 41 42 FilterLed(byte *img, int w, int h, double cut=2.5) 42 : fImg(img), fW(w), fH(h), fBox (w>h?w:h), fCut(cut)43 : fImg(img), fW(w), fH(h), fBoxX(w), fBoxY(h), fCut(cut) 43 44 { 44 45 } 45 46 46 FilterLed(byte *img, int w, int h, int box , double cut=2.5)47 : fImg(img), fW(w), fH(h), fBox (box), fCut(cut)47 FilterLed(byte *img, int w, int h, int boxx, int boxy, double cut=2.5) 48 : fImg(img), fW(w), fH(h), fBoxX(boxx), fBoxY(boxy), fCut(cut) 48 49 { 49 50 } 50 51 virtual ~FilterLed() { } 51 52 52 void SetBox(int box) { fBox = box; } 53 void SetBox(int box) { fBoxX = fBoxY = box; } 54 void SetBox(int boxx, int boxy) { fBoxX = boxx; fBoxY = boxy; } 53 55 void SetCut(float cut) { fCut = cut; } 54 56 void FindStar(Leds &leds, int xc, int yc, bool circle=false) const;
Note:
See TracChangeset
for help on using the changeset viewer.