Changeset 914 for trunk/MagicSoft/Cosy
- Timestamp:
- 08/23/01 14:41:03 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r913 r914 39 39 - reorganized parts of the existing code 40 40 41 * devdrv/macs.cc: 42 - changed some output from cout to lout 43 41 44 42 45 … … 100 103 101 104 * slalib/Makefile: 102 - added missing files 103 105 - added missing files 104 106 105 107 -
trunk/MagicSoft/Cosy/MCosy.cc
r912 r914 9 9 #include <TSystem.h> 10 10 #include <TApplication.h> 11 #include <TTimer.h> 11 12 12 13 #include "MGCosy.h" … … 151 152 } 152 153 154 ZdAz MCosy::GetRePosPdo() 155 { 156 return ZdAz(fMac2->GetPdoPos(), fMac1->GetPdoPos()); 157 } 158 153 159 int MCosy::SetPosition(const ZdAz &dst) // [rad] 154 160 { 155 // FIXME: CORRECT BY f Offset!!!!!!!!!!161 // FIXME: CORRECT BY fTrackingError !!!!!!!!!! 156 162 157 163 // … … 336 342 dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); 337 343 344 // 345 // Request absolute position of rotary encoder from MACS 346 // 338 347 fMac2->RequestSDO(0x6004); 339 348 fMac1->RequestSDO(0x6004); … … 346 355 347 356 // 348 // Copy f Offsetto a local variable357 // Copy fTrackingError to a local variable 349 358 // 350 359 ZdAz offset = fOffset; … … 402 411 dest0 *= kGearRatio; 403 412 dest0 -= GetRePos()+offset; 404 dest0.Round();413 //dest0.Round(); 405 414 406 415 fAccuracy = dest0/kGearRatio2; // [deg] 416 fVelocity = vt/kGearRatio2; 407 417 408 418 //cout << "Control deviation: "; 409 419 fout << setprecision(15) << setw(15) << mjd*60.*60.*24. << " "; 410 fout << setw(4) << (int)f Offset.Zd() << " ";411 fout << setw(4) << (int)f Offset.Az() << " ";420 fout << setw(4) << (int)fTrackingError.Zd() << " "; 421 fout << setw(4) << (int)fTrackingError.Az() << " "; 412 422 fout << setw(4) << dest0.Zd() << " "; 413 423 fout << setw(4) << dest0.Az() << " "; … … 515 525 return (void*)0xffffffff; 516 526 } 517 527 /* 518 528 void *MTGui::Thread() 519 529 { … … 521 531 return NULL; 522 532 } 523 533 */ 524 534 void *MTTalk::Thread() 525 535 { … … 609 619 usleep(1); 610 620 611 ZdAz sollalt; // [se]612 ZdAz sollaz; // [se]613 621 ZdAz old; 614 615 ZdAz ist=fOffset/kGearRatio; // [se] 616 // 617 // only update fOffset while tracking 618 // 622 ZdAz ist = fTrackingError/kGearRatio; // [se] 623 ZdAz istre = fOffset; // [re] 624 // 625 // only update fTrackingError while tracking 626 // 627 ZdAz sollzd; 628 ZdAz sollaz; 619 629 while (fTracking) 620 630 { 621 usleep(100000/*00*/); // 0.1s 631 // 632 // This is the time constant which defines how fast 633 // you correct for external influences (like wind) 634 // 635 usleep(100000); // 0.1s 622 636 623 637 // 624 638 // Make changes (eg wind) smoother - attenuation of control function 625 639 // 626 627 ZdAz offset(fOffset.Zd()*9.0/10.0+((ist.Zd()-sollalt.Zd())*kGearRatio.X())/10.0, 628 fOffset.Az()*9.0/10.0+((ist.Az()-sollaz.Az()) *kGearRatio.Y())/10.0); 640 fTrackingError.Set((ist.Zd()-sollzd.Zd())*kGearRatio.X(), 641 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 642 643 644 const float weight = 0.3; 645 646 ZdAz offset(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight, 647 fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); 629 648 630 649 fOffset = offset; 631 // f Offset.Zd(((offset.Zd()>1000)||(offset.Zd()<-1000))?0:offset.Zd());632 // f Offset.Az(((offset.Az()>1000)||(offset.Az()<-1000))?0:offset.Az());650 // fTrackingError.Zd(((offset.Zd()>1000)||(offset.Zd()<-1000))?0:offset.Zd()); 651 // fTrackingError.Az(((offset.Az()>1000)||(offset.Az()<-1000))?0:offset.Az()); 633 652 634 653 // … … 644 663 continue; 645 664 646 // 647 // if Alt Shaftencoder changed position 665 istre = GetRePosPdo(); 666 667 // 668 // Get time from last shaftencoder position change (position: ist) 669 // 670 const double tzd = (fAlt1->GetMjd()+fAlt2->GetMjd())/2.0; 671 const double taz = fAz->GetMjd(); 672 673 // 674 // if Shaftencoder changed position 675 // calculate were we should be 648 676 // 649 677 if ((int)ist.Zd() != (int)old.Zd()) 650 678 { 651 // 652 // Get time from last shaftencoder position change 653 // 654 const double t = (fAlt1->GetMjd()+fAlt2->GetMjd())/2.0; 655 656 // 657 // calculate were we should be 658 // 659 sla.SetMjd(t); 660 sollalt = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); 661 662 old.Zd(ist.Zd()); 679 sla.SetMjd(tzd); 680 sollzd = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 663 681 } 664 682 665 //666 // if Alt Shaftencoder changed position667 //668 683 if ((int)ist.Az() != (int)old.Az()) 669 684 { 670 // 671 // Get time from last shaftencoder position change 672 // 673 const double t = fAz->GetMjd(); 674 675 // 676 // calculate were we should be 677 // 678 sla.SetMjd(t); 679 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); 680 681 old.Az(ist.Az()); 685 sla.SetMjd(taz); 686 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 682 687 } 688 689 old = ist; 683 690 } 684 691 } 685 692 } 686 693 /* 687 694 void MCosy::GuiThread(MTGui *t) 688 695 { 696 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 697 698 fAz->SetDisplay(fWin->GetLabel1()); 699 fAlt1->SetDisplay(fWin->GetLabel2()); 700 fAlt2->SetDisplay(fWin->GetLabel3()); 701 689 702 while (!t->HasStopFlag()) 690 703 { … … 698 711 699 712 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] 700 fWin->Update(ist, fAccuracy );713 fWin->Update(ist, fAccuracy, fVelocity, fTrackingError/kGearRatio2); 701 714 702 715 } 716 717 delete fWin; 703 718 cout << "Not running anymore." << endl; 704 719 } 720 */ 721 Bool_t MCosy::HandleTimer(TTimer *t) 722 { 723 // 724 // Update Gui, foremer MTGui. 725 // 726 fAlt1->DisplayVal(); 727 fAlt2->DisplayVal(); 728 fAz->DisplayVal(); 729 730 // gSystem->ProcessEvents(); 731 732 // ZdAz err1 = fTrackingError/kGearRatio2; 733 // ZdAz err2(30./3600., 20./3600.); // = fTrackingError/kGearRatio2; 734 735 ZdAz dummy = fOffset/kGearRatio2/4.; // /4. because using velocity canvas 736 737 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] 738 739 fWin->Update(ist, fTrackingError/kGearRatio2, fVelocity, dummy); 740 741 // cout << fTrackingError.Zd()/kGearRatio2.X()*3600. << " "; 742 // cout << fTrackingError.Az()/kGearRatio2.Y()*3600. << endl; 743 744 return kTRUE; 745 } 746 705 747 706 748 int MCosy::StopWaitingForSDO() const … … 718 760 719 761 lout << "- Starting GUI Thread." << endl; 720 fTGui = new MTGui(this); 762 fUpdateGui->TurnOn(); 763 // fTGui = new MTGui(this); 721 764 } 722 765 723 766 void MCosy::Stop() 724 767 { 725 delete fTGui; 768 cout << "Stopping Gui Timer Events." << endl; 769 fUpdateGui->TurnOff(); 770 // delete fTGui; 726 771 lout << "- GUI Thread stopped." << endl; 727 772 … … 755 800 SetNode(fAz); 756 801 802 // 803 // Create Gui Event timer and Gui 804 // 805 fUpdateGui = new TTimer(this, 100); // 100ms 806 757 807 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 758 808 … … 760 810 fAlt1->SetDisplay(fWin->GetLabel2()); 761 811 fAlt2->SetDisplay(fWin->GetLabel3()); 812 762 813 } 763 814 … … 780 831 MCosy::~MCosy() 781 832 { 833 delete fUpdateGui; 834 782 835 cout << "Deleting Nodes." << endl; 783 836 -
trunk/MagicSoft/Cosy/MCosy.h
r912 r914 21 21 class MCosy; 22 22 23 /* 23 24 class MTGui : public MThread 24 25 { … … 35 36 } 36 37 }; 38 */ 37 39 38 40 class MTTalk : public MThread … … 51 53 } 52 54 }; 53 54 class MCosy : public Network, public MsgQueue 55 class TTimer; 56 class MCosy : public Network, public MsgQueue, public TObject 55 57 { 56 58 friend class MTGui; … … 68 70 MGCosy *fWin; 69 71 70 MTGui *fTGui; 72 TTimer *fUpdateGui; 73 74 //MTGui *fTGui; 71 75 MTTalk *fTTalk; 72 76 73 ZdAz fOffset; // Tracking Offset between SE and calc-pos [re] 74 RaDec fRaDec; // Position to track 75 int fTracking; // Flag for present tracking action 76 ZdAz fAccuracy; // Actual accuracy of Tracking 77 ZdAz fTrackingError; // Tracking Offset between SE and calc-pos [re] 78 ZdAz fOffset; // Offset between se and re coordinate system [re] 79 RaDec fRaDec; // Position to track 80 int fTracking; // Flag for present tracking action 81 ZdAz fAccuracy; // Actual accuracy of Tracking 82 ZdAz fVelocity; // Actual velocity of Tracking 77 83 78 84 ZdAz GetRePos(); 85 ZdAz GetRePosPdo(); 79 86 ZdAz GetSePos(); // [se] 80 87 … … 99 106 void *Proc(int msg, void *mp); 100 107 108 Bool_t HandleTimer(TTimer *t); 109 101 110 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst); 102 111 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0)); -
trunk/MagicSoft/Cosy/Makefile
r912 r914 24 24 CINT = M 25 25 INCLUDES = -I. -Iincl -Ibase -Igui -Idevdrv -Icandrv -Ivideodev -Icatalog 26 LIBS = -lpng -lz -L/usr/X11R6/lib 26 LIBS = -lpng -lz -L/usr/X11R6/lib -lpthread 27 27 28 28 # … … 38 38 # 39 39 SUBDIRS = \ 40 gui 41 candrv 42 devdrv\43 catalog\44 videodev 45 base 40 gui \ 41 candrv \ 42 catalog \ 43 devdrv \ 44 videodev \ 45 base \ 46 46 slalib 47 47 -
trunk/MagicSoft/Cosy/base/coord.h
r732 r914 78 78 public: 79 79 ZdAz(double zd=0, double az=0) : XY(zd, az) {} 80 ZdAz(const ZdAz &c) : XY(c) {} 80 81 81 82 double Zd() const { return fX; }
Note:
See TracChangeset
for help on using the changeset viewer.