Changeset 1953 for trunk/MagicSoft/Cosy
- Timestamp:
- 04/12/03 19:06:27 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 2 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1882 r1953 1 1 -*-*- END -*-*- 2 2003/04/12 - Thomas Bretz 3 4 * prepos_magic.txt: 5 - added 6 7 * bend.cc: 8 - added 9 10 * Makefile: 11 - bend added 12 13 * bending_magic.txt: 14 - new bending 15 16 * cosy.cc: 17 - fixed typo 18 - disable console output 19 20 * testse.cc: 21 - accept commandline options 22 23 * base/MThread.cc, base/msgqueue.cc: 24 - added DEBUG-stuff 25 26 * candrv/network.cc: 27 - fixed wrong handling of SDO messages with less than 4 bytes 28 29 * candrv/nodedrv.cc: 30 - do not switch timer off if it isn't switched on 31 32 * candrv/vmodican.cc: 33 - added EXPERT mode 34 35 * catalog/SlaStars.h: 36 - added CalcAltAz/ZdAz with mjd 37 38 * catalog/StarCatalog.[h,cc]: 39 - included rotation angle 40 41 * devdrv/macs.cc: 42 - added request for present error code 43 - added #71 error message 44 45 * devdrv/shaftencoder.[h,cc]: 46 - fixes to support multiturn encoders correctly 47 - removed velocity and acceleration from gui 48 49 * gui/MGAccuracy.cc: 50 - mega mini change 51 52 * gui/MGCosy.[h,cc]: 53 - added EXPERT mode 54 - added TrackPos 55 - removed shaftencoder label for velocity and acceleration 56 - commented out MAC3 57 - fixed reading of predefined positions 58 - commented out everything related to the demo mode 59 - changed some displayed text 60 61 * gui/MGStarguider.[h,cc]: 62 - added support for rotation angle 63 64 * main/MBending.h: 65 - added constructor with filename 66 67 * main/MCosy.[h,cc]: 68 - for gear display both axis 69 - some more output in WaitForEndMovement 70 - added CheckRange 71 - added AlignTrackingPos 72 - changed timing in tracking procedure from 3s/50ms to 5s/1s 73 - added TrackPos 74 - replaced some code by AlignTrackingPos 75 - commented out CALIB and PRESET 76 77 * slalib/oapqk.c: 78 - fixed a bug checking validity of arguments for atan2 79 80 * videodev/Writer.cc: 81 - fixed names 82 83 84 2 85 2003/03/31 - Daniela Dorner: 3 86 -
trunk/MagicSoft/Cosy/Makefile
r1803 r1953 20 20 # 21 21 22 PROGRAMS = testse starg cosy 22 PROGRAMS = testse starg cosy bend 23 23 SOLIB = cosy.so 24 24 CINT = M -
trunk/MagicSoft/Cosy/base/MThread.cc
r1275 r1953 5 5 #include <pthread.h> 6 6 #include <sys/resource.h> // PRIO_PROCESS 7 8 #undef DEBUG 7 9 8 10 // ---------------------------------------------------------------------- … … 14 16 MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL) 15 17 { 18 #ifdef DEBUG 19 cout << "MThread::MThread" << endl; 20 #endif 16 21 if (!start) 17 22 return; … … 29 34 MThread::~MThread() 30 35 { 36 #ifdef DEBUG 31 37 cout << "~MThread::MThread" << endl; 38 #endif 32 39 Stop(); 33 40 } … … 122 129 void MThread::Stop() 123 130 { 131 #ifdef DEBUG 124 132 cout << "MThread::Stop: fThread=" << fThread << ", fIsRunning=" << (int)fIsRunning << endl; 133 #endif 134 125 135 if (!fThread || !fIsRunning) 126 136 return; … … 128 138 if (fIsDetached) 129 139 { 140 #ifdef DEBUG 130 141 cout << "Stopping detached thread..." << flush; 142 #endif 131 143 pthread_cancel(*fThread); 132 144 fIsRunning = false; … … 134 146 else 135 147 { 148 #ifdef DEBUG 136 149 cout << "Stopping thread..." << flush; 150 #endif 137 151 fStop = true; 138 152 pthread_join(*fThread, &fReturn); 139 153 } 154 #ifdef DEBUG 140 155 cout << "done." << endl; 156 #endif 141 157 142 158 delete fThread; 143 159 fThread = NULL; 144 160 161 #ifdef DEBUG 145 162 cout << "MThread::Stop() done." << endl; 163 #endif 146 164 } -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r1727 r1953 6 6 #include <sys/resource.h> // PRIO_PROCESS 7 7 8 #undef DEBUG 9 8 10 // -------------------------------------------------------------------------- 9 11 // … … 22 24 MsgQueue::~MsgQueue() 23 25 { 26 #ifdef DEBUG 24 27 cout << "~MsgQueue::MsgQueue" << endl; 28 #endif 25 29 pthread_cancel(fThread); 26 30 delete (unsigned char*)fMp; … … 89 93 pthread_mutex_unlock(&fMuxMsg); 90 94 95 #ifdef DEBUG 91 96 cout << "MsgQueue::Thread: Processing Msg 0x" << hex << fMsg << endl; 97 #endif 92 98 // --- bool quit = fMsg==WM_QUIT; 93 99 fRc=Proc(fMsg, fMp); 100 #ifdef DEBUG 94 101 cout << "MsgQueue::PostMsg: Msg 0x" << hex << fMsg << " processed (rc=" << fRc << ")" << endl; 102 #endif 95 103 96 104 // --- if (quit) … … 119 127 // stopped and the messages are processed serialized 120 128 // 129 #ifdef DEBUG 121 130 cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush; 131 #endif 122 132 pthread_mutex_lock(&fMuxMsg); 133 #ifdef DEBUG 123 134 cout << "done." << endl; 135 #endif 124 136 125 137 // … … 134 146 { 135 147 pthread_mutex_unlock(&fMuxMsg); 148 #ifdef DEBUG 136 149 cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl; 150 #endif 137 151 return NULL; 138 152 } 139 153 /**** NEW 20/01/2003 ****/ 154 #ifdef DEBUG 140 155 cout << "MsgQueue::PostMsg: ---> Break <---" << endl; 156 #endif 141 157 fBreak = 1; 142 158 … … 156 172 // Start Proc() 157 173 // 174 #ifdef DEBUG 158 175 cout << "MsgQueue::PostMsg: Releasing MsgQueue mutex..." << flush; 176 #endif 159 177 fStart = 1; 160 178 pthread_mutex_unlock(&fMuxMsg); 179 #ifdef DEBUG 161 180 cout << "done." << endl; 181 #endif 162 182 163 183 /* … … 175 195 // usleep(1); 176 196 197 #ifdef DEBUG 177 198 cout << "MsgQueue::PostMsg: Returning rc = " << hex << rc << endl; 199 #endif 178 200 return rc; 179 201 } -
trunk/MagicSoft/Cosy/bending_magic.txt
r1806 r1953 1 MAGIC1 2003/03/0 2 21:59:35.6202391 MAGIC1 2003/03/07 20:40:26.88604 2 2 S 00 000000 000000 0000000 3 IA -49.372136-14 IE 1.8923836-15 CA -0. 84914789-16 NPAE -2.142261-17 AN 0 .90833138-18 AW 0.93094796-19 NRX 24.647251-110 NRY 1.4925634-13 IA 499.0188249 -1 4 IE -10.741869 -1 5 CA -0.23939033 -1 6 NPAE 2.3247554 -1 7 AN 0 -1 8 AW -1.1901258 -1 9 NRX 0 -1 10 NRY 0 -1 11 11 CRX 0 -1 12 12 CRY 0 -1 13 ECES 15.454204-114 ACES 0 .090104657-115 ECEC -4.7751393-116 ACEC -0.082728729-117 MAGIC1 0 .1424389-113 ECES 0 -1 14 ACES 0 -1 15 ECEC 0 -1 16 ACEC 0 -1 17 MAGIC1 0 -1 18 18 MAGIC2 0 -1 19 19 END -
trunk/MagicSoft/Cosy/candrv/network.cc
r1727 r1953 97 97 98 98 case kSDO_TX3: // answer to 0x40 with 2 bytes of data 99 fNodes[node]->HandleSDO(idx, subidx, data >>16, tv);99 fNodes[node]->HandleSDO(idx, subidx, data&0xffff, tv); 100 100 return; 101 101 102 102 case kSDO_TX1: // answer to 0x40 with 1 byte of data 103 fNodes[node]->HandleSDO(idx, subidx, data >>24, tv);103 fNodes[node]->HandleSDO(idx, subidx, data&0xff, tv); 104 104 return; 105 105 -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r1804 r1953 526 526 void NodeDrv::StopGuarding() 527 527 { 528 if (!fTimerOn) 529 return; 530 528 531 fTimeout->TurnOff(); 529 532 fTimerOn = kFALSE; -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r1804 r1953 880 880 881 881 while (!Send(&msg)); 882 882 #ifdef EXPERT 883 883 lout << "- CobId 0x" << hex << setfill('0') << setw(3) << cobid << " enabled." << endl; 884 #endif 884 885 } 885 886 -
trunk/MagicSoft/Cosy/catalog/SlaStars.h
r1758 r1953 40 40 ZdAz CalcZdAz (const RaDec &radec) const; 41 41 42 AltAz CalcAltAz(const RaDec &radec, double mjd) 43 { SetMjd(mjd); return CalcAltAz(radec); } 44 ZdAz CalcZdAz (const RaDec &radec, double mjd) 45 { SetMjd(mjd); return CalcZdAz(radec); } 46 42 47 AltAz CalcAltAzFast(const RaDec &radec) const; 43 48 ZdAz CalcZdAzFast (const RaDec &radec) const; -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r1803 r1953 14 14 ClassImp(StarCatalog); 15 15 16 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fEntries(0) 16 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fEntries(0), fSinAngle(0), fCosAngle(1) 17 17 { 18 18 // p = pointer to MainFrame (not owner) … … 505 505 // Align alt/az[pix] 506 506 // 507 const int xx = 767-(int)((fWidth-dx+DPI)/fPixSize); 508 const int yy = (int)((fHeight+dy)/fPixSize); 507 const int xx = (int)(((dx-DPI)*fCosAngle - dy*fSinAngle + fWidth)/fPixSize); 508 const int yy = (int)(((dx-DPI)*fSinAngle + dy*fCosAngle + fHeight)/fPixSize); 509 //const int xx = 767-(int)((fWidth-dx+DPI)/fPixSize); 510 //const int yy = (int)((fHeight+dy)/fPixSize); 509 511 510 512 // … … 685 687 686 688 // 687 // Align a lt/az[pix]688 // 689 const float xx = 768.0 - (fWidth -dx+DPI)/fPixSize;690 const float yy = (fHeight+dy)/fPixSize;689 // Align and rotate alt/az[pix] 690 // 691 float xx = ((dx-DPI)*fCosAngle - dy*fSinAngle + fWidth)/fPixSize; 692 float yy = ((dx-DPI)*fSinAngle + dy*fCosAngle + fHeight)/fPixSize; 691 693 692 694 // … … 710 712 AltAz StarCatalog::CalcAltAzFromPix(Double_t pixx, Double_t pixy) const 711 713 { 712 Double_t dx = (pixx-768.0)*fPixSize + fWidth+DPI; 713 Double_t dy = pixy*fPixSize - fHeight; 714 pixx *= fPixSize; 715 pixy *= fPixSize; 716 717 const double dx = (pixx-fWidth)*fCosAngle + (pixy-fHeight)*fSinAngle; 718 const double dy = -(pixx-fWidth)*fSinAngle + (pixy-fHeight)*fCosAngle; 719 720 //const double dx = (pixx-768.0)*fPixSize + fWidth+DPI; 721 //const double dy = pixy*fPixSize - fHeight; 714 722 715 723 double ha, dec; -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r1803 r1953 28 28 double fWidth; // size of display 29 29 double fHeight; // 30 double fSinAngle; 31 double fCosAngle; 30 32 31 33 float fLimitMag; // [M] limiting magnitude for display … … 87 89 void SetPixSize(const double pixsize); 88 90 void SetLimitMag(const float mag) { fLimitMag = mag; } 91 void SetRotationAngle(const float angle) { fSinAngle = sin(angle/kRad2Deg); fCosAngle = cos(angle/kRad2Deg); } 89 92 90 93 double GetPixSize() const; -
trunk/MagicSoft/Cosy/cosy.cc
r1727 r1953 25 25 gLog << "==================================================" << endl; 26 26 gLog << " Cosy V0.1 " << endl; 27 gLog << " Magic Drive Control System Softw ware" << endl;27 gLog << " Magic Drive Control System Software " << endl; 28 28 gLog << " Compiled on <" << __DATE__ << ">" << endl; 29 29 gLog << " Using ROOT v" << ROOTVER << endl; … … 39 39 MLog *l = new MLog("log/cosy.log", kTRUE); 40 40 MLog &lout = *l; 41 lout.EnableOutputDevice(MLog::eStdout);42 41 43 42 clog("Starting Cosy at " << time.GetTimeStr() << " ..."); … … 76 75 77 76 clog("- Starting MCosy."); 77 lout.DisableOutputDevice(MLog::eStdout); 78 78 cosy->Start(); 79 79 -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r1804 r1953 46 46 switch (idx) 47 47 { 48 case 0x1003: 49 // FIXME, see Init 50 if (subidx!=2) 51 return; 52 lout << "- " << GetNodeName() << ": Error[0]=" << dec << val << endl; 53 SetError(val); 54 return; 55 48 56 case 0x100a: 49 57 lout << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl; … … 221 229 } 222 230 223 224 231 void Macs::Init() 225 232 { 233 // 234 // Request current error status (FIXME: is the first entry in the 235 // error list) 236 // 237 lout << "- " << GetNodeName() << ": Requesting Error[0]." << endl; 238 RequestSDO(0x1003, 2); 239 WaitForSdo(0x1003, 2); 226 240 if (HasError()) 227 241 { … … 238 252 RequestSDO(0x100a); 239 253 WaitForSdo(0x100a); 240 241 254 if (IsZombieNode()) 242 { 243 lout << GetNodeName() << " - InitDevice failed!" << endl; 244 return; 245 } 255 return; 246 256 247 257 // FIXME! Not statically linked! … … 538 548 return; 539 549 550 case 71: 551 lout << "Array out of bound." << endl; 552 return; 553 540 554 case 84: 541 555 lout << "Too many (>12) ON TIME calls." << endl; -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1804 r1953 40 40 default: 41 41 lout << "?" << endl; 42 SetZombie(); 42 43 return; 43 44 } 44 45 default: 45 46 lout << "???" << endl; 47 SetZombie(); 46 48 return; 47 49 } … … 88 90 89 91 case 0x6502: 90 if (val==0)91 val = 1; // Single Turn = Multiturn with one turn92 lout << "- Possible Turns: " << dec << val << endl;92 //if (val==0) 93 // val = 1; // Single Turn = Multiturn with one turn 94 lout << "- Number of Revolutions: " << dec << val << endl; 93 95 fTurns = val; 94 96 return; … … 105 107 if (IsZombieNode()) 106 108 { 107 fLabel[0]->SetText(new TGString("")); 108 fLabel[1]->SetText(new TGString("")); 109 fLabel[2]->SetText(new TGString("")); 109 fLabel->SetText(new TGString("")); 110 110 fUpdPos = ~fPos; 111 fUpdVel = ~fVel;112 fUpdAcc = ~fAcc;113 111 return; 114 112 } … … 116 114 char text[21]; 117 115 118 if (fPos!=fUpdPos && fLabel [0])116 if (fPos!=fUpdPos && fLabel) 119 117 { 120 118 sprintf(text, "%ld", fPos); 121 fLabel [0]->SetText(new TGString(text));119 fLabel->SetText(new TGString(text)); 122 120 fUpdPos = fPos; 123 }124 125 if (fVel!=fUpdVel && fLabel[1])126 {127 sprintf(text, "%d", fVel);128 fLabel[1]->SetText(new TGString(text));129 fUpdVel = fVel;130 }131 132 if (fAcc!=fUpdAcc && fLabel[2])133 {134 sprintf(text, "%d", fAcc);135 fLabel[2]->SetText(new TGString(text));136 fUpdAcc = fAcc;137 121 } 138 122 } … … 183 167 fAcc = data[6] | (data[7]<<8); 184 168 185 const int uplim = 9*fTicks/10;186 const int dnlim = 1*fTicks/10;169 const int dnlim = fTicks/10; 170 const int uplim = fTurns*fTicks-dnlim; 187 171 188 172 int turn = fTurn; … … 199 183 fPos = pos; 200 184 fTurn = turn; 201 202 //fout << dec << (int)GetId() << " " << turn << " " << pos << endl;203 185 204 186 fTime.SetTimer(tv); … … 230 212 RequestSDO(0x1000); 231 213 WaitForSdo(0x1000); 232 233 214 if (IsZombieNode()) 234 { 235 lout << GetNodeName() << " - Init failed!" << endl; 236 return; 237 } 215 return; 238 216 239 217 // -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r1727 r1953 17 17 WORD_t fTurns; // Number of possible turns 18 18 19 TGLabel **fLabel; //19 TGLabel *fLabel; // 20 20 LWORDS_t fUpdPos; // ticks 21 WORDS_t fUpdVel; // ticks per 5ms22 WORDS_t fUpdAcc; // ticks per 25ms^221 // WORDS_t fUpdVel; // ticks per 5ms 22 // WORDS_t fUpdAcc; // ticks per 25ms^2 23 23 24 24 bool fPosHasChanged; //! … … 40 40 void StopDevice(); 41 41 42 void SetDisplay(TGLabel * *label) { fLabel = label; }42 void SetDisplay(TGLabel *label) { fLabel = label; } 43 43 44 44 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r1819 r1953 246 246 // 247 247 // calculate actual time for planet positions 248 // acc [deg] 248 249 // 249 250 static int X = ~0; -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1793 r1953 32 32 33 33 #undef DEBUG 34 #define EXPERT 34 35 35 36 ClassImp(MGCosy); … … 44 45 kPB_TRACK, 45 46 kPB_STOP, 46 kPB_ HOME,47 kPB_TRACKPOS, 47 48 kPB_CALCALTAZ, 48 49 kPB_TPOINT, … … 126 127 fList->Add(l); 127 128 128 fLabel1 = new TGLabel*[3]; 129 fLabel1[0] = new TGLabel(f, "00000"); // Max: 16384 130 fLabel1[1] = new TGLabel(f, "000"); // Max: 256 131 fLabel1[2] = new TGLabel(f, "000"); // Max: 256 132 fLabel1[0]->SetTextJustify(kTextRight); 133 fLabel1[1]->SetTextJustify(kTextRight); 134 fLabel1[2]->SetTextJustify(kTextRight); 135 fLabel1[0]->Move(x, y+40); 136 fLabel1[1]->Move(x+43, y+40); 137 fLabel1[2]->Move(x+70, y+40); 138 fList->Add(fLabel1[0]); 139 fList->Add(fLabel1[1]); 140 fList->Add(fLabel1[2]); 141 //f->AddFrame(fLabel1[0]); 142 //f->AddFrame(fLabel1[1]); 143 //f->AddFrame(fLabel1[2]); 144 145 fLabel2 = new TGLabel*[3]; 146 fLabel2[0] = new TGLabel(f, "00000"); 147 fLabel2[1] = new TGLabel(f, "000"); 148 fLabel2[2] = new TGLabel(f, "000"); 149 fLabel2[0]->SetTextJustify(kTextRight); 150 fLabel2[1]->SetTextJustify(kTextRight); 151 fLabel2[2]->SetTextJustify(kTextRight); 152 fLabel2[0]->Move(x, y+57); 153 fLabel2[1]->Move(x+43, y+57); 154 fLabel2[2]->Move(x+70, y+57); 155 fList->Add(fLabel2[0]); 156 fList->Add(fLabel2[1]); 157 fList->Add(fLabel2[2]); 158 //f->AddFrame(fLabel2[0]); 159 //f->AddFrame(fLabel2[1]); 160 //f->AddFrame(fLabel2[2]); 161 162 fLabel3 = new TGLabel*[3]; 163 fLabel3[0] = new TGLabel(f, "00000"); 164 fLabel3[1] = new TGLabel(f, "000"); 165 fLabel3[2] = new TGLabel(f, "000"); 166 fLabel3[0]->SetTextJustify(kTextRight); 167 fLabel3[1]->SetTextJustify(kTextRight); 168 fLabel3[2]->SetTextJustify(kTextRight); 169 fLabel3[0]->Move(x, y+74); 170 fLabel3[1]->Move(x+43, y+74); 171 fLabel3[2]->Move(x+70, y+74); 172 fList->Add(fLabel3[0]); 173 fList->Add(fLabel3[1]); 174 fList->Add(fLabel3[2]); 175 //f->AddFrame(fLabel3[0]); 176 //f->AddFrame(fLabel3[1]); 177 //f->AddFrame(fLabel3[2]); 129 fLabel1 = new TGLabel(f, "00000"); // Max: 16384 130 fLabel2 = new TGLabel(f, "00000"); 131 fLabel3 = new TGLabel(f, "00000"); 132 fLabel1->SetTextJustify(kTextRight); 133 fLabel2->SetTextJustify(kTextRight); 134 fLabel3->SetTextJustify(kTextRight); 135 fLabel1->Move(x, y+40); 136 fLabel2->Move(x, y+57); 137 fLabel3->Move(x, y+74); 138 fList->Add(fLabel1); 139 fList->Add(fLabel2); 140 fList->Add(fLabel3); 178 141 179 142 l = new TGLabel(f, "Offset-Zd:"); … … 250 213 fAvailMac1 = new TGLabel(f, "- MAC1 -"); 251 214 fAvailMac2 = new TGLabel(f, "- MAC2 -"); 252 fAvailMac3 = new TGLabel(f, "- MAC3 -");215 //fAvailMac3 = new TGLabel(f, "- MAC3 -"); 253 216 fAvailSe1 = new TGLabel(f, "-SE/Zd1-"); 254 217 fAvailSe2 = new TGLabel(f, "-SE/Zd2-"); … … 261 224 fAvailMac1->SetBackgroundColor(color); 262 225 fAvailMac2->SetBackgroundColor(color); 263 fAvailMac3->SetBackgroundColor(color);226 //fAvailMac3->SetBackgroundColor(color); 264 227 fAvailSe1->SetBackgroundColor(color); 265 228 fAvailSe2->SetBackgroundColor(color); … … 281 244 fAvailMac1->Move(10, 25+120); 282 245 fAvailMac2->Move(10, 25+140); 283 fAvailMac3->Move(10, 25+160);246 //fAvailMac3->Move(10, 25+160); 284 247 fAvailSe1->Move(10, 25+180); 285 248 fAvailSe2->Move(10, 25+200); … … 293 256 fAvailMac1->Resize(60, 20); 294 257 fAvailMac2->Resize(60, 20); 295 fAvailMac3->Resize(60, 20);258 //fAvailMac3->Resize(60, 20); 296 259 fAvailSe1->Resize(60, 20); 297 260 fAvailSe2->Resize(60, 20); … … 305 268 fList->Add(fAvailMac1); 306 269 fList->Add(fAvailMac2); 307 fList->Add(fAvailMac3);270 //fList->Add(fAvailMac3); 308 271 fList->Add(fAvailSe1); 309 272 fList->Add(fAvailSe2); … … 332 295 333 296 int i=0; 334 while ( !fin.eof())297 while (1) 335 298 { 336 299 TString str; 337 300 Double_t zd, az; 338 301 fin >> str >> zd >> az; 302 if (!fin) 303 break; 339 304 box->AddEntry(str, i++); 340 305 … … 347 312 TGCompositeFrame *tf1 = fTab->AddTab("Position"); 348 313 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 314 #ifdef EXPERT 349 315 TGCompositeFrame *tf4 = fTab->AddTab("Calib"); 350 316 TGCompositeFrame *tf5 = fTab->AddTab("Test SE"); 351 317 TGCompositeFrame *tf6 = fTab->AddTab("Gear"); 352 /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo"); 318 #endif 319 /*TGCompositeFrame *tf3 =*/// fTab->AddTab("Demo"); 353 320 354 321 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 362 329 fList->Add(fCRaDec); 363 330 331 #ifdef EXPERT 364 332 fCCalib = new MGCoordinates(tf4, kETypeRaDec); 365 333 fCCalib->Move(27, 105); 366 334 fList->Add(fCCalib); 335 #endif 367 336 368 337 const int x=15; … … 372 341 TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in"); 373 342 TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates"); 374 TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates , which means that the");375 TGLabel *l4 = new TGLabel(tf1, " coordinates are corrected for the bending of");376 TGLabel *l5 = new TGLabel(tf1, " the telescope.");343 TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates. Enter the coordinates"); 344 TGLabel *l4 = new TGLabel(tf1, "manually or choose a predefined position"); 345 TGLabel *l5 = new TGLabel(tf1, "from the combobox below."); 377 346 l1->Move(x, y); 378 347 l2->Move(x, y+h); … … 396 365 fList->Add(l3); 397 366 367 #ifdef EXPERT 398 368 l1 = new TGLabel(tf4, "Start the calibration using the Start button."); 399 369 l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using"); 400 l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset"); 401 l4 = new TGLabel(tf4, "use the Calib SE button."); 370 l3 = new TGLabel(tf4, "the TPoint button."); 371 //l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset"); 372 //l4 = new TGLabel(tf4, "use the Calib SE button."); 402 373 l1->Move(x, y); 403 374 l2->Move(x, y+h); … … 425 396 l1->Move(x, y); 426 397 fList->Add(l1); 398 #endif 427 399 428 400 // … … 465 437 fList->Add(but); 466 438 467 but = new TGTextButton(tf1, " Home", kPB_HOME);468 but->Resize( 80, 25);469 but->Move( 160, 197);470 but->SetToolTipText(" Initiate Home Drive.");439 but = new TGTextButton(tf1, "Move'n'Track", kPB_TRACKPOS); 440 but->Resize(100, 25); 441 but->Move(25, 242); 442 but->SetToolTipText("Move telescope to a Zd/Az position and start tracking."); 471 443 but->Associate(this); 472 444 fList->Add(but); 473 445 446 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 447 but->Resize(80, 25); 448 but->Move(165, 197); 449 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 450 but->Associate(this); 451 fList->Add(but); 452 453 #ifdef EXPERT 474 454 but = new TGTextButton(tf5, "Display", kPB_DISPLAY1); 475 455 but->Resize(80, 25); … … 486 466 fList->Add(but); 487 467 488 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 489 but->Resize(80, 25); 490 but->Move(165, 197); 491 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 492 but->Associate(this); 493 fList->Add(but); 494 495 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 496 but->Resize(80, 25); 497 but->Move(25, 190); 498 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 499 but->Associate(this); 500 fList->Add(but); 501 468 /* 502 469 but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE); 503 470 but->Resize(80, 25); … … 506 473 but->Associate(this); 507 474 fList->Add(but); 508 475 */ 509 476 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 510 477 but->Resize(80, 25); 511 but->Move(25, 220);478 but->Move(25, 190); 512 479 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 513 480 but->Associate(this); … … 516 483 but = new TGTextButton(tf4, "Reset", kPB_ResetBending); 517 484 but->Resize(80, 25); 518 but->Move(25, 2 50);485 but->Move(25, 220); 519 486 but->SetToolTipText("Reset bending correction (coefficients=0)"); 520 487 but->Associate(this); 521 488 fList->Add(but); 489 490 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 491 but->Resize(80, 25); 492 but->Move(25, 250); 493 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 494 but->Associate(this); 495 fList->Add(but); 496 #endif 522 497 523 498 ULong_t color; … … 958 933 ZdAz soll, UInt_t stat, UInt_t stat2) 959 934 { 935 // acc [rad] 936 acc *= kRad2Deg; // [deg] 937 960 938 double mjd = UpdateTime(); 961 939 fSkyPosition->Update(pos, mjd); … … 984 962 SetLabelColor(fAvailMac1, stat2&0x01); 985 963 SetLabelColor(fAvailMac2, stat2&0x02); 986 SetLabelColor(fAvailMac3, stat2&0x04);964 //SetLabelColor(fAvailMac3, stat2&0x04); 987 965 SetLabelColor(fAvailSe1, stat2&0x08); 988 966 SetLabelColor(fAvailSe2, stat2&0x10); … … 1033 1011 } 1034 1012 1013 void MGCosy::StartTrackPos() 1014 { 1015 cout << "Start tracking Zd/Az pos." << endl; 1016 1017 const XY &xy = fCZdAz->GetCoordinates(); 1018 1019 ZdAz za(xy.X(), xy.Y()); 1020 1021 cout << za.Zd() << "\xb0 " << za.Az() << "\xb0" << endl; 1022 1023 fQueue->PostMsg(WM_TRACKPOS, &za, sizeof(za)); 1024 1025 cout << "PostMsg (WM_TrackPos) returned." << endl; 1026 } 1027 1035 1028 void MGCosy::StartPos() 1036 1029 { … … 1050 1043 // ************************** For demo purpose ********************** 1051 1044 // 1045 /* 1052 1046 #include <TRandom.h> 1053 1047 class MDemo : public MThread … … 1068 1062 Timer tm; 1069 1063 tm.Now(); 1070 /* 1071 Float_t h = 2.+tm.H()+(10.7+tm.M())/60.; 1072 RaDec dest(h*15, 129.7); 1073 1074 cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl; 1075 1076 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 1064 1065 //fQueue->PostMsg(WM_STOP, 0, 0); 1066 1067 ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90); 1068 1069 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; 1070 1071 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 1077 1072 1078 1073 int i = 0; 1079 while (!HasStopFlag() && i++<60) // 2.5min 1080 usleep(1000000); 1081 if (HasStopFlag()) 1082 break; 1083 */ 1084 1085 //fQueue->PostMsg(WM_STOP, 0, 0); 1086 1087 ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90); 1088 1089 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; 1090 1091 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 1092 1093 int i = 0; 1094 while (!HasStopFlag() && i++<5/*5*/) // 30s 1074 while (!HasStopFlag() && i++<5) // 30s 1095 1075 usleep(1000000); 1096 1076 if (HasStopFlag()) … … 1099 1079 //ZdAz dest2(5, 30); 1100 1080 //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2)); 1101 /*1102 i = 0;1103 while (!HasStopFlag() && i++<30) // 30s1104 usleep(1000000);1105 */1106 1081 //if (HasStopFlag()) 1107 1082 // break; … … 1129 1104 demo.Stop(); 1130 1105 } 1131 1106 */ 1107 /* 1132 1108 void MGCosy::StartCalib() 1133 1109 { … … 1141 1117 cout << "PostMsg (WM_Calib) returned." << endl; 1142 1118 } 1143 1119 */ 1144 1120 void MGCosy::StartTPoint() 1145 1121 { … … 1213 1189 fQueue->Proc(WM_GEAR, (void*)1); 1214 1190 return kTRUE; 1191 /* 1215 1192 case 5: 1216 1193 StartDemo(); 1217 1194 return kTRUE; 1195 */ 1218 1196 } 1219 1197 return kTRUE; … … 1221 1199 case kPB_STOP: 1222 1200 cout << "Sending stop movement msg." << endl; 1223 StopDemo();1201 //StopDemo(); 1224 1202 fQueue->PostMsg(WM_STOP, 0, 0); 1225 1203 if (fTab->GetCurrent()==3) … … 1270 1248 StartTPoint(); 1271 1249 return kTRUE; 1250 /* 1272 1251 case kPB_CALIBSE: 1273 1252 StartCalib(); 1274 1253 return kTRUE; 1254 */ 1275 1255 case kPB_LoadBending: 1276 1256 fQueue->Proc(WM_LOADBENDING, NULL); … … 1279 1259 fQueue->Proc(WM_RESETBENDING, NULL); 1280 1260 return kTRUE; 1261 /* 1281 1262 case kPB_HOME: 1282 1263 fQueue->PostMsg(WM_HOME, 0, 0); 1264 return kTRUE; 1265 */ 1266 case kPB_TRACKPOS: 1267 StartTrackPos(); 1283 1268 return kTRUE; 1284 1269 case kPB_DISPLAY1: -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1760 r1953 49 49 MGList *fList; 50 50 51 TGLabel **fLabel1;52 TGLabel **fLabel2;53 TGLabel **fLabel3;51 TGLabel *fLabel1; 52 TGLabel *fLabel2; 53 TGLabel *fLabel3; 54 54 55 55 TGLabel *fOffsetZd; … … 104 104 void StartPos(); 105 105 void StartTrack(); 106 void StartTrackPos(); 106 107 void StartDemo(); 107 void StartCalib();108 //void StartCalib(); 108 109 void StartTPoint(); 109 110 … … 121 122 void CloseWindow(); 122 123 123 TGLabel * *GetLabel1() const { return fLabel1; }124 TGLabel * *GetLabel2() const { return fLabel2; }125 TGLabel * *GetLabel3() const { return fLabel3; }124 TGLabel *GetLabel1() const { return fLabel1; } 125 TGLabel *GetLabel2() const { return fLabel2; } 126 TGLabel *GetLabel3() const { return fLabel3; } 126 127 127 128 TGListBox *GetLog() const { return fLog; } -
trunk/MagicSoft/Cosy/gui/MGStarguider.cc
r1819 r1953 74 74 IDM_kLimMag9, 75 75 IDM_kPixSize, 76 IDM_kAngle, 76 77 IDM_kInterpol125, 77 78 IDM_kInterpol25, … … 217 218 fWriteType->AddEntry("&Once", IDM_kOnce); 218 219 fWriteType->AddEntry("&Continous", IDM_kContinous); 220 fWriteType->CheckEntry(IDM_kOnce); 219 221 fWriteType->Associate(this); 220 222 fList->Add(fWriteType); … … 334 336 l = new TGLabel(this, "arcsec/pix"); 335 337 l->SetTextJustify(kTextLeft); 336 l->Move(605, fMenu->GetDefaultHeight()+619); 338 l->Move(605, fMenu->GetDefaultHeight()+619+13); 339 AddFrame(l); 340 fList->Add(l); 341 342 l = new TGLabel(this, "deg"); 343 l->SetTextJustify(kTextLeft); 344 l->Move(605, fMenu->GetDefaultHeight()+619-10); 337 345 AddFrame(l); 338 346 fList->Add(l); … … 347 355 348 356 fSao->SetPixSize(pixsize/3600); 357 fSao->SetRotationAngle(0); 349 358 350 359 TString txt; … … 353 362 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 354 363 fPixSize->SetAlignment(kTextCenterX); 355 fPixSize->Move(547, fMenu->GetDefaultHeight()+617 );364 fPixSize->Move(547, fMenu->GetDefaultHeight()+617+13); 356 365 AddFrame(fPixSize); 357 366 fList->Add(fPixSize); 367 368 fAngle = new TGTextEntry(this, " 0", IDM_kAngle); 369 fAngle->SetAlignment(kTextCenterX); 370 fAngle->Move(547, fMenu->GetDefaultHeight()+617-10); 371 AddFrame(fAngle); 372 fList->Add(fAngle); 358 373 359 374 // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this); … … 582 597 case kC_TEXTENTRY: 583 598 if (GET_SUBMSG(msg)==kTE_ENTER) 584 { 585 const Float_t pixsize = atof(fPixSize->GetText()); 586 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 587 fSao->SetPixSize(pixsize/3600); 588 } 599 switch (mp1) 600 { 601 case IDM_kPixSize: 602 { 603 const Float_t pixsize = atof(fPixSize->GetText()); 604 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 605 fSao->SetPixSize(pixsize/3600); 606 return kTRUE; 607 } 608 case IDM_kAngle: 609 { 610 const Float_t angle = atof(fAngle->GetText()); 611 cout << "Rotation Angle changed to " << angle << "deg" << endl; 612 fSao->SetRotationAngle(angle); 613 return kTRUE; 614 } 615 } 589 616 return kTRUE; 590 617 … … 896 923 AltAz pos1 = fSao->CalcAltAzFromPix(768/2+g.GetMean(1), 576/2+g.GetMean(2))*kRad2Deg; 897 924 925 ofstream fout1("pointingpos.txt"); 926 fout1 << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl; 927 898 928 pos1 -= pos0; 899 929 900 ofstream fout("tracking_error.txt"); 901 fout << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl; 902 fout.close(); 930 ofstream fout2("tracking_error.txt"); 931 fout2 << setprecision(10) << fSao->GetMjd()-52000 << " " << -pos1.Alt() << " " << pos1.Az() << endl; 903 932 904 933 return ZdAz(-pos1.Alt(), pos1.Az()); … … 1172 1201 fDy = dy; 1173 1202 1174 cout << "New coordinates for zoom: " << fDx << " " << fDy << endl; 1203 fSao->Now(); 1204 AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg; 1205 1206 cout << "New coordinates for zoom - x, y : " << fDx << " " << fDy << endl; 1207 cout << "New coordinates for zoom - Alt, az: " << aa.Alt() << " " << aa.Az() << endl; 1175 1208 1176 1209 return kTRUE; -
trunk/MagicSoft/Cosy/gui/MGStarguider.h
r1819 r1953 89 89 90 90 TGTextEntry *fPixSize; 91 TGTextEntry *fAngle; 91 92 92 93 StarCatalog *fSao; -
trunk/MagicSoft/Cosy/main/MBending.h
r1805 r1953 1 1 #ifndef COSY_MBending 2 2 #define COSY_MBending 3 4 #include <TROOT.h>5 6 #include <fstream.h>7 3 8 4 #include "coord.h" … … 53 49 public: 54 50 MBending() { Clear(); } 51 MBending(const char *name) { Clear(); Load(name); } 55 52 56 53 void Load(const char *name); -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1819 r1953 13 13 14 14 #include <TH2.h> 15 #include <TH3.h> 15 16 #include <TProfile.h> 16 17 #include <TCanvas.h> … … 76 77 } 77 78 79 /* 78 80 ZdAz MCosy::CorrectTarget(const ZdAz &src, const ZdAz &dst) 79 81 { … … 145 147 return ret*(16384.0/360.0); 146 148 } 149 */ 147 150 148 151 // -------------------------------------------------------------------------- … … 329 332 { 330 333 // FIXME, what when waiting times out (Zombie) 334 331 335 while ((fMac1->IsPositioning() || fMac2->IsPositioning()) && 332 !(Break() || HasError() ) && !HasZombie())336 !(Break() || HasError() || HasZombie())) 333 337 usleep(1); 334 338 335 339 if (Break() || HasError() || HasZombie()) 336 lout << "WaitForEndMovement aborted..." << endl; 340 { 341 lout << "WaitForEndMovement aborted... "; 342 if (Break()) 343 lout << "Break signal." << endl; 344 if (HasError()) 345 lout << "Network has error." << endl; 346 if (HasZombie()) 347 lout << "Network has zombie." << endl; 348 } 337 349 } 338 350 … … 382 394 } 383 395 396 Bool_t MCosy::CheckRange(const ZdAz &d) const 397 { 398 // d [deg] 399 400 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd()) 401 { 402 lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg) not "; 403 lout << "inside allowed range." << endl; 404 return kFALSE; 405 } 406 407 if (d.Az()<fMin.Az() || d.Az()>fMax.Az()) 408 { 409 lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg) not "; 410 lout << "inside allowed range." << endl; 411 return kFALSE; 412 } 413 414 return kTRUE; 415 } 416 384 417 // -------------------------------------------------------------------------- 385 418 // … … 396 429 { 397 430 // FIXME: Correct by fOffset ? 398 /*399 ZdAz400 401 if (dst.Az()<-TMath::Pi()/2)402 dst.Az(dst.Az() + TMath::Pi()*2);403 404 if (dst.Az()>3*TMath::Pi()/2)405 dst.Az(dst.Az() -TMath::Pi()*2);406 */407 // track=kFALSE;408 409 // const ZdAz d1 = track ? CorrectTarget(src, dst) : dst*16384/TMath::Pi()/2; // [se]410 431 411 432 const ZdAz d = dst*kRad2Deg; … … 413 434 lout << "Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl; 414 435 415 if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd()) 416 { 417 lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg) not "; 418 lout << "inside allowed range." << endl; 436 if (!CheckRange(d)) 419 437 return kFALSE; 420 }421 422 if (d.Az()<fMin.Az() || d.Az()>fMax.Az())423 {424 lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg) not ";425 lout << "inside allowed range." << endl;426 return kFALSE;427 }428 438 429 439 // … … 520 530 cout << "Estimated1: " << 16384*dx + dk << endl; 521 531 cout << "Estimated2: " << (16384*dx + dk)/1.085949688 << endl; 532 cout << "Estimated3: " << rd.Zd()*432 << endl; 522 533 // =========================================== 523 534 … … 775 786 } 776 787 788 Bool_t MCosy::AlignTrackingPos(ZdAz pointing, ZdAz &za) 789 { 790 // pointing [deg] 791 792 if (pointing.Zd()<0) 793 { 794 pointing.Zd(-pointing.Zd()); 795 pointing.Az(pointing.Az()+180); 796 } 797 798 const ZdAz se = GetSePos()*360/16384; // [deg] 799 const ZdAz unbendedse = fBending.CorrectBack(se); // ist pointing 800 801 do 802 { 803 const Double_t d = unbendedse.Az() - pointing.Az(); 804 if (d>-180 && d<=180) 805 break; 806 807 pointing.Az(pointing.Az()+TMath::Sign(360., -d)); 808 } while (1); 809 /* 810 while (pointing.Az()<fMin.Az()) 811 pointing.Az(pointing.Az() + 360); 812 813 while (pointing.Az()>fMax.Az()) 814 pointing.Az(pointing.Az() - 360); 815 */ 816 const Bool_t rc = CheckRange(pointing); 817 za = fBending(pointing/kRad2Deg); // [rad] 818 819 if (!rc) 820 lout << "Error: Aligned position out of Range." << endl; 821 822 return rc; 823 } 824 777 825 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad] 778 826 { … … 787 835 ZdAz dest = sla.CalcZdAz(dst); 788 836 837 // FIXME: Determin tracking start point by star culmination 789 838 if (dest.Az()<-TMath::Pi()/2) 839 { 840 lout << "Adding 360deg to Azimuth " << dest.Az()*kRad2Deg << endl; 790 841 dest.Az(dest.Az() + TMath::Pi()*2); 842 } 791 843 792 844 if (dest.Az()>3*TMath::Pi()/2) 845 { 846 lout << "Substracting 360deg to Azimuth " << dest.Az()*kRad2Deg << endl; 793 847 dest.Az(dest.Az() -TMath::Pi()*2); 848 } 794 849 795 850 if (!SetPosition(dest, kTRUE)) … … 849 904 // 850 905 // *OLD*const float dt = 1; // 1 second 851 const float dt = 3; // 2 second852 while (!(Break() || HasError() ) && !HasZombie())906 const float dt = 5;//3; // 2 second 907 while (!(Break() || HasError() || HasZombie())) 853 908 { 854 909 // … … 860 915 // Request theoretical Position for a time in the future (To+dt) from CPU 861 916 // 862 sla.SetMjd(sla.GetMjd()+dt/(60*60*24)); 917 const Double_t mjd = sla.GetMjd()+dt/(60*60*24); 918 const ZdAz pointing = sla.CalcZdAz(fRaDec, mjd)*kRad2Deg; // soll pointing [deg] 919 920 ZdAz dest; 921 if (!AlignTrackingPos(pointing, dest)) 922 break; 923 924 dest *= 16384/TMath::Pi()/2; // [se] 925 926 /* 863 927 ZdAz dummy1 = sla.CalcZdAz(fRaDec); 864 928 … … 868 932 dummy1.Az(dummy1.Az() -TMath::Pi()*2); 869 933 934 if (!CheckRange(dummy1*kRad2Deg)) 935 { 936 lout << "Error: Tracking position out of Range." << endl; 937 break; 938 } 939 870 940 ZdAz dummy = fBending(dummy1); 871 941 dest = CorrectTarget(GetSePos(), dummy); // [se] 872 873 const ZdAz d = dest*360./16384; // [deg] 942 */ 943 944 //*LP* const ZdAz d = dest*360./16384; // [deg] 874 945 dest *= kGearRatio; // [re] 875 946 876 ZdAz min = fBending(fMin/kRad2Deg)*kRad2Deg; 877 ZdAz max = fBending(fMax/kRad2Deg)*kRad2Deg; 878 879 /* 880 if (d.Zd()<min.Zd() || d.Az()<min.Az()) 881 { 882 lout << "ERROR: Calculated position for T+dt not inside allowed range." << endl; 883 lout << "< " << d.Zd() << " " << min.Zd() << " " << d.Az() << " " << min.Az() << endl; 884 break; 885 } 886 if (d.Zd()>max.Zd() || d.Az()>max.Az()) 887 { 888 lout << "ERROR: Calculated position for T+dt not inside allowed range." << endl; 889 lout << "> " << d.Zd() << " " << max.Zd() << " " << d.Az() << " " << max.Az() << endl; 890 break; 891 } 892 */ 947 //*LP* ZdAz min = fBending(fMin/kRad2Deg)*kRad2Deg; 948 //*LP* ZdAz max = fBending(fMax/kRad2Deg)*kRad2Deg; 949 893 950 ZdAz vcalc = sla.GetApproxVel(fRaDec) * kGearRatio2*4./60.; // [re/min] 894 951 … … 963 1020 // (This is important on fast machines >500MHz) 964 1021 // 965 usleep( 50000); // 0.25s1022 usleep(1000000); // 1s 966 1023 //usleep(50000); // 0.05s 967 1024 } … … 989 1046 // set deceleration to 50% 990 1047 // 991 cout << "Stopping movement (dec= 20%)..." << endl;1048 cout << "Stopping movement (dec=30%)..." << endl; 992 1049 993 1050 fMac1->SetDeceleration(0.3*fMac1->GetVelRes()); … … 1103 1160 StopMovement(); 1104 1161 return NULL; 1105 1162 /* 1106 1163 case WM_PRESET: 1107 1164 cout << "WM_Preset: start." << endl; … … 1113 1170 cout << "WM_Preset: done. (return 0xaffe)" << endl; 1114 1171 return (void*)0xaffe; 1115 1172 */ 1173 /* 1116 1174 case WM_CALIB: 1117 1175 { … … 1126 1184 1127 1185 //RaDec rd(37.94, 89.2644); // POLARIS 1128 //RaDec rd(213.915417, 19.1825); // A CTURUS1186 //RaDec rd(213.915417, 19.1825); // ARCTURUS 1129 1187 1130 1188 cout << "Calibrating to: " << rd.Ra()*24/360 << "h " << rd.Dec() << "°" << endl; … … 1144 1202 } 1145 1203 return (void*)0xaffe; 1204 */ 1146 1205 1147 1206 case WM_TPOINT: … … 1170 1229 } 1171 1230 return (void*)0xca1b; 1231 1232 case WM_TRACKPOS: 1233 cout << "WM_TrackPosition: start." << endl; 1234 { 1235 if (!CheckNetwork()) 1236 return (void*)0xebb0; 1237 1238 ZdAz dest = *((ZdAz*)mp) * kDeg2Rad; 1239 //if (!SetPosition(dest)) 1240 // return (void*)0x1234; 1241 1242 SlaStars sla(fObservatory); 1243 sla.Now(); 1244 1245 RaDec rd = sla.CalcRaDec(dest); 1246 cout << dest.Zd()*180/3.1415 << " " << dest.Az()*180/3.1415 << endl; 1247 cout << rd.Ra()*12/3.1415 << " " << rd.Dec()*180/3.1415 << endl; 1248 TrackPosition(rd); 1249 } 1250 cout << "WM_TrackPosition: done. (return 0xabcd)" << endl; 1251 return (void*)0xabcd; 1172 1252 1173 1253 case WM_POSITION: … … 1273 1353 RaDec rd(xy.X()*15., xy.Y()); // [deg] 1274 1354 1275 ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad); 1276 ZdAz a1 = fBending(a0); 1277 ZdAz se = CorrectTarget(GetSePos(), a1); 1278 a0 *= kRad2Deg; 1279 a1 *= kRad2Deg; 1280 ZdAz a2 = a1*16384/360; 1355 const ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad); 1356 1357 ZdAz a1; 1358 AlignTrackingPos(a0, a1); 1359 a1 *= 180/TMath::Pi(); 1360 1361 const ZdAz a2 = a1*16384/360; 1362 const ZdAz se = a0*16384/360; 1363 1281 1364 cout << "Ra/Dec source: " << xy.X() << "h " << xy.Y() << "°" << endl; 1282 cout << "Zd/Az source: " << a0.Zd() << "° " << a0.Az() << "°" << endl;1365 cout << "Zd/Az target: " << a0.Zd() << "° " << a0.Az() << "°" << endl; 1283 1366 cout << "Zd/Az bended: " << a1.Zd() << "° " << a1.Az() << "°" << endl; 1367 cout << "SE target: " << se.Zd() << " " << se.Az() << endl; 1284 1368 cout << "SE bended: " << a2.Zd() << " " << a2.Az() << endl; 1285 cout << "SE target: " << se.Zd() << " " << se.Az() << endl;1286 1369 } 1287 1370 return (void*)0xa17a; … … 1401 1484 1402 1485 SlaStars sla(fObservatory); 1486 sla.Now(); 1403 1487 1404 1488 ZdAz old; 1405 ZdAz ist; 1406 1407 ZdAz sollzd; 1408 ZdAz sollaz; 1409 1410 ZdAz istre = -fOffset; // [re] 1489 ZdAz ist = GetSePos(); // [se] 1490 1491 // ZdAz istre = -fOffset; // [re] 1411 1492 ZdAz time; 1493 1494 ZdAz sollzd = sla.CalcZdAz(fRaDec); // [rad] 1495 ZdAz sollaz = sollzd; // [rad] 1412 1496 1413 1497 // … … 1456 1540 continue; 1457 1541 */ 1458 istre = GetRePosPdo();1542 ZdAz istre = GetRePosPdo(); 1459 1543 1460 1544 // … … 1479 1563 if (phca1 || phca2 /*(int)ist.Zd() != (int)old.Zd()*/) 1480 1564 { 1481 s la.SetMjd(time.Zd());1482 1565 sollzd = sla.CalcZdAz(fRaDec, time.Zd()); // [rad] 1566 /* 1483 1567 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1484 1568 sollzd = CorrectTarget(ist, dummy); // [se] 1485 1569 */ 1486 1570 fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight); 1487 1571 } … … 1489 1573 if (phcaz /*(int)ist.Az() != (int)old.Az()*/) 1490 1574 { 1491 s la.SetMjd(time.Az());1492 1575 sollaz = sla.CalcZdAz(fRaDec, time.Az()); // [rad] 1576 /* 1493 1577 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1494 1578 sollaz = CorrectTarget(ist, dummy); // [se] 1495 1579 */ 1496 1580 fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 1497 1581 } 1498 1582 1499 ZdAz soll(sollzd.Zd(), sollaz.Az()); // [se] 1583 ZdAz soll(sollzd.Zd(), sollaz.Az()); // [rad] 1584 1585 AlignTrackingPos(soll*360/16384, fZdAzSoll); 1586 /* 1500 1587 fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384); 1501 1588 1502 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(), 1503 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 1589 // FIXME? 1590 if (fZdAzSoll.Az()<-TMath::Pi()/2) 1591 fZdAzSoll.Az(fZdAzSoll.Az() + TMath::Pi()*2); 1592 if (fZdAzSoll.Az()>3*TMath::Pi()/2) 1593 fZdAzSoll.Az(fZdAzSoll.Az() -TMath::Pi()*2); 1594 1595 // FIXME? 1596 while (ist.Az()>3*16384/4/2) 1597 ist.Az(ist.Az() - 16384); 1598 while (soll.Az()>3*16384/4/2) 1599 soll.Az(soll.Az() - 16384); 1600 while (ist.Az()<-16384/4) 1601 ist.Az(ist.Az() + 16384); 1602 while (soll.Az()<-16384/4) 1603 soll.Az(soll.Az() + 16384); 1604 */ 1605 ist *= TMath::Pi()*2/16384; 1606 fTrackingError.Set(ist.Zd()-fZdAzSoll.Zd(), ist.Az()-fZdAzSoll.Az()); 1504 1607 1505 1608 //--- fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " "; … … 1586 1689 } 1587 1690 1588 // fHist = new TH2F("Gear", "Gear Ratio Re/Se", 1589 // 201, fMin.Zd(), fMax.Zd(), 61, 349.5, 500.5); 1590 fHist = new TH2F("Gear", "Gear Ratio Re/Se", 1591 201, fMin.Az(), fMax.Az(), 61, 419.5, 570.5); 1592 fHist->SetXTitle("ZA [\\circ]"); 1593 fHist->SetYTitle("Re/Se"); 1691 fHist = new TH3F("Gear", "Gear Ratio Re/Se", 1692 (int)((fMax.Zd()-fMin.Zd())/2.5+1), fMin.Zd(), fMax.Zd(), 1693 (int)((fMax.Az()-fMin.Az())/2.5+1), fMin.Az(), fMax.Az(), 1694 61, 349.5, 500.5); 1695 1696 fHist->SetXTitle("Zd [\\circ]"); 1697 fHist->SetYTitle("Az [\\circ]"); 1698 fHist->SetZTitle("Re/Se"); 1594 1699 1595 1700 lout << "Starting Gear determination..." << endl; … … 1614 1719 ZdAz dre = re-re0; 1615 1720 1616 if (fabs(dse.Zd())*144>16384) // Each 2.5deg 1721 if (fabs(dse.Zd())*144>16384) // Each 2.5deg (144) 1617 1722 { 1618 1723 se0.Zd(se.Zd()); … … 1620 1725 1621 1726 ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg; 1622 fHist->Fill(bend.Zd(), dre.Zd()/dse.Zd());1727 ((TH3*)fHist)->Fill(bend.Zd(), bend.Az(), dre.Zd()/dse.Zd()); 1623 1728 } 1624 1729 1625 if (fabs(dse.Az())*144>16384) // Each 2.5deg 1730 if (fabs(dse.Az())*144>16384) // Each 2.5deg (144) 1626 1731 { 1627 1732 se0.Az(se.Az()); … … 1629 1734 1630 1735 ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg; 1631 fHist->Fill(bend.Az(), dre.Az()/dse.Az()); 1632 1633 cout << bend.Az() << ": " << dre.Az()/dse.Az() << endl; 1736 ((TH3*)fHist)->Fill(bend.Az(), bend.Az(), dre.Az()/dse.Az()); 1634 1737 } 1635 1636 /*1637 const Double_t pos[3] = {1638 (fZd1->GetPos()+8192)%16384,1639 (fZd2->GetPos()+8192)%16384,1640 fAz->GetPos() };1641 1642 //1643 // Estimate Offset from the first ten positions1644 //1645 if (cnt++<10)1646 {1647 offset += pos[0]+pos[1];1648 continue;1649 }1650 if (cnt==11)1651 {1652 offset /= 10;1653 cnt++;1654 }1655 1656 Double_t apos = (pos[0]-pos[1])/2 * TMath::Pi()*2 / 16384;1657 1658 ZdAz bend = fBending.CorrectBack(ZdAz(apos, pos[2]))*kRad2Deg;1659 fHistTestSe->Fill(bend.Zd(), pos[0]+pos[1]-offset);1660 */1661 1738 } 1662 1739 lout << "Gear Test Stopped... displaying Histogram." << endl; … … 1748 1825 lout.UpdateGui(); 1749 1826 1750 fWin->Update(bendist*(360.0/2/TMath::Pi()), fTrackingError /kGearRatio2,1827 fWin->Update(bendist*(360.0/2/TMath::Pi()), fTrackingError, 1751 1828 fVelocity, fOffset, fRaDec, fZdAzSoll, fStatus, avail); 1752 1753 /*1754 cout << (int)(fMac1->GetStatus()&Macs::kOutOfControl) << " ";1755 cout << (int)(fMac2->GetStatus()&Macs::kOutOfControl) << " ";1756 cout << (int)(fMac3->GetStatus()&Macs::kOutOfControl) << endl;1757 */1758 1829 1759 1830 const Bool_t trigger = fTriggerDisplay; … … 1773 1844 lout << "Displaying histogram..." << endl; 1774 1845 1775 TH2F &hist = * fHist;1846 TH2F &hist = *(TH2F*)fHist; 1776 1847 1777 1848 if (del) … … 1796 1867 TH1F p2("spread", "Spread of the differences", hist.GetNbinsX(), hist.GetBinLowEdge(1), 1797 1868 hist.GetBinLowEdge(hist.GetNbinsX()+1)); 1798 p2.SetXTitle("Z A[\\circ]");1869 p2.SetXTitle("Zd [\\circ]"); 1799 1870 for (int i=0; i<hist.GetNbinsX(); i++) 1800 1871 p2.SetBinError(i, p->GetBinError(i)); … … 1811 1882 lout << "Displaying histogram..." << endl; 1812 1883 1813 TH 2F &hist = *fHist;1884 TH3F &hist = *(TH3F*)fHist; 1814 1885 1815 1886 if (del) … … 1820 1891 1821 1892 TCanvas *c=new TCanvas("c1", "", 1000, 1000); 1822 c->Divide(1,2); 1893 c->Divide(2,2); 1894 1895 // ---------- 1823 1896 1824 1897 c->cd(1); 1825 TH2 *h=(TH2*)hist.DrawCopy(); 1826 1827 TProfile *p = h->ProfileX("_pfx", -1, 9999, "s"); 1828 p->SetLineColor(kBlue); 1829 p->Draw("same"); 1830 p->SetBit(kCanDelete); 1898 TH2D &h1=*(TH2D*)hist.Project3D("zx"); // Zd 1899 h1.SetTitle(" Gear Ratio Zenith Distance [re/se] "); 1900 h1.SetXTitle("Zd [\\circ]"); 1901 h1.Draw(); 1902 h1.SetBit(kCanDelete); 1903 1904 TProfile *p1 = h1.ProfileX("_pfx", -1, 9999, "s"); 1905 p1->SetLineColor(kBlue); 1906 p1->Draw("same"); 1907 p1->SetBit(kCanDelete); 1908 1909 // ---------- 1831 1910 1832 1911 c->cd(2); 1833 1834 TH1F p2("spread", "Spread of the gear [16384/1500/4*U/U]", hist.GetNbinsX(), hist.GetBinLowEdge(1), 1835 hist.GetBinLowEdge(hist.GetNbinsX()+1)); 1836 p2.SetXTitle("ZA [\\circ]"); 1837 for (int i=0; i<hist.GetNbinsX(); i++) 1838 p2.SetBinError(i, p->GetBinError(i)); 1839 p2.SetLineColor(kRed); 1840 p2.SetStats(0); 1841 p2.DrawCopy(); 1912 TH2D &h2=*(TH2D*)hist.Project3D("zy"); // Az 1913 h2.SetTitle(" Gear Ratio Azimuth [re/se] "); 1914 h2.SetXTitle("Zd [\\circ]"); 1915 h2.Draw(); 1916 h2.SetBit(kCanDelete); 1917 1918 TProfile *p2 = h2.ProfileX("_pfx", -1, 9999, "s"); 1919 p2->SetLineColor(kBlue); 1920 p2->Draw("same"); 1921 p2->SetBit(kCanDelete); 1922 1923 // ---------- 1924 1925 c->cd(3); 1926 1927 TAxis &axe1 = *h1.GetXaxis(); 1928 1929 TH1F f1("spreadzd", " Spread Zenith Distance ", 1930 axe1.GetNbins(), axe1.GetXmin(), axe1.GetXmax()); 1931 f1.SetXTitle("Zd [\\circ]"); 1932 for (int i=0; i<axe1.GetNbins(); i++) 1933 f1.SetBinError(i, p1->GetBinError(i)); 1934 f1.SetLineColor(kRed); 1935 f1.SetStats(0); 1936 f1.DrawCopy(); 1937 1938 c->cd(4); 1939 1940 // ---------- 1941 1942 TAxis &axe2 = *h2.GetXaxis(); 1943 1944 TH1F f2("spreadaz", " Spread Azimuth ", 1945 axe2.GetNbins(), axe2.GetXmin(), axe2.GetXmax()); 1946 f2.SetXTitle("Az [\\circ]"); 1947 for (int i=0; i<axe2.GetNbins(); i++) 1948 f2.SetBinError(i, p2->GetBinError(i)); 1949 f2.SetLineColor(kRed); 1950 f2.SetStats(0); 1951 f2.DrawCopy(); 1952 1953 // ---------- 1842 1954 1843 1955 if (del) -
trunk/MagicSoft/Cosy/main/MCosy.h
r1817 r1953 15 15 16 16 #define WM_WAIT WM_NULL 17 #define WM_PRESET 0x100017 //#define WM_PRESET 0x1000 18 18 #define WM_POSITION 0x1001 19 19 #define WM_TRACK 0x1002 20 20 #define WM_STOP 0x1003 21 #define WM_CALIB 0x100421 //#define WM_CALIB 0x1004 22 22 #define WM_TPOINT 0x1005 23 23 #define WM_NEWTRACK 0x1006 … … 29 29 #define WM_GEAR 0x100c 30 30 #define WM_DISPLAY 0x100d 31 #define WM_TRACKPOS 0x100e 31 32 32 33 class ShaftEncoder; … … 34 35 class MGCosy; 35 36 class MCosy; 36 class TH 2F;37 class TH1; 37 38 38 39 class MTTalk : public MThread … … 96 97 BackgroundAction_t fBackground; // Flag for present backgroundthread 97 98 98 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re]99 ZdAz fTrackingError; // [rad] Tracking Offset between SE and calc-pos 99 100 ZdAz fOffset; // Offset between se and re coordinate system [re] 100 ZdAz fZdAzSoll; // Soll position when moving101 ZdAz fZdAzSoll; // [rad] Soll position when moving 101 102 RaDec fRaDec; // Position to track 102 103 ZdAz fAccuracy; // Actual accuracy of Tracking … … 105 106 ZdAz fMax; 106 107 107 TH 2F*fHist;108 TH1 *fHist; 108 109 Bool_t fTriggerDisplay; 109 110 … … 116 117 117 118 ofstream *tpout; 119 120 Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za); 121 Bool_t CheckRange(const ZdAz &d) const; 118 122 119 123 double Rad2SE(double rad) const; … … 182 186 Bool_t HandleTimer(TTimer *t); 183 187 184 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst);188 // static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst); 185 189 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0)); 186 190 -
trunk/MagicSoft/Cosy/testse.cc
r1742 r1953 1 1 #include <iostream.h> 2 /*#include <iomanip.h>3 #include <fstream.h>4 5 #include <TROOT.h>6 #include <TSystem.h>7 #include <TApplication.h>8 9 */10 2 11 3 #include "network.h" … … 21 13 // gLog.EnableOutputDevice(MLog::eStdout); 22 14 23 cout << "Creating Network..." << endl; 24 const int baud = 500; 15 cout << endl; 16 cout << "Usage: testse [nodeid [[speed]" << endl; 17 cout << endl; 18 const int baud = argc>2 ? atoi(argv[2]) : 500; 19 cout << "Creating Network (" << baud << "bps)..." << endl; 25 20 Network net("/dev/dpm_00", baud); 26 21 27 cout << "Creating SE..." << endl; 28 const int nodeid = 6; 22 const int nodeid = argc>1 ? atoi(argv[1]) : 16; 23 24 cout << "Creating SE #" << nodeid << "..." << endl; 29 25 ShaftEncoder se(nodeid, "SE/Zd1"); 30 26 -
trunk/MagicSoft/Cosy/videodev/Writer.cc
r1816 r1953 14 14 struct timeval *date) 15 15 { 16 Timer t(date); 17 TString mjd; 18 mjd += t.GetMjd()-52000; 19 mjd = mjd.Strip(TString::kBoth); 20 if (mjd.Length()<10) 21 mjd.Append('0', 10-mjd.Length()); 22 16 23 TString name = fname; 17 18 Timer t(date);19 20 24 name += "_"; 21 name += t.GetMjd()-52000;25 name += mjd; 22 26 name += ".png"; 23 27
Note:
See TracChangeset
for help on using the changeset viewer.