Changeset 7614 for trunk/MagicSoft/Cosy/main/MStarguider.cc
- Timestamp:
- 03/19/06 18:39:35 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/main/MStarguider.cc
r7338 r7614 1 # defineEXPERT1 #undef EXPERT 2 2 3 3 #include "MStarguider.h" … … 104 104 IDM_kCaosWriteStop, 105 105 IDM_kResetHistograms, 106 IDM_kStargHistograms,107 106 IDM_kStargAnalysis, 108 107 IDM_kStargCaosFilter, 109 IDM_kStargLEDFilter,110 108 IDM_kStargFindStar, 111 IDM_kTPointAna, 112 IDM_kRoqueLampAna 109 IDM_kRoqueLampAna, 110 IDM_kStarguiderMode, 111 IDM_kTpointMode 113 112 114 113 }; … … 147 146 fChannel->AddEntry("TPoint Camera", IDM_kChannel2); 148 147 fChannel->AddEntry("Read from File", IDM_kChannel3); 149 if (channel<0) { 150 fChannel->CheckEntry(IDM_kChannel3); 151 } else { 152 fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2); 153 } 148 if (channel<0) 149 fChannel->CheckEntry(IDM_kChannel3); 150 else 151 fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2); 154 152 fChannel->Associate(this); 155 153 fList->Add(fChannel); … … 161 159 fDisplay->AddEntry("&Filter", IDM_kFilter); 162 160 fDisplay->AddEntry("Find &Star", IDM_kFindStar); 163 fDisplay->AddEntry("C&aos Filter", 161 fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter); 164 162 fDisplay->AddEntry("SAO &Catalog", IDM_kCatalog); 165 163 fDisplay->AddEntry("Stretch", IDM_kStretch); 166 164 fDisplay->AddSeparator(); 167 fDisplay->AddEntry("Starguider", IDM_kStarguider); 168 fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter); 169 fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar); 170 fDisplay->AddEntry("Starguider Analysis", IDM_kStargAnalysis); 165 fDisplay->AddEntry("Starguider", IDM_kStarguider); 166 fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter); 167 fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar); 171 168 fDisplay->AddSeparator(); 172 169 if (channel>=0) 173 170 fDisplay->AddPopup("&Input", fChannel); 174 fDisplay->DisableEntry(IDM_kStargAnalysis);175 171 fDisplay->DisableEntry(IDM_kStargFindStar); 176 172 fDisplay->CheckEntry(IDM_kStretch); … … 178 174 fList->Add(fDisplay); 179 175 176 fMode = new MGPopupMenu(p); 177 fMode->AddEntry("Starguider", IDM_kStarguiderMode); 178 fMode->AddEntry("Tpoint", IDM_kTpointMode); 179 fMode->Associate(this); 180 fList->Add(fMode); 180 181 181 182 fOperations = new MGPopupMenu(p); 182 fOperations->AddEntry("TPoint Analysis", IDM_kTPointAna);183 183 fOperations->AddEntry("Roque Lamp Analysis", IDM_kRoqueLampAna); 184 fOperations->AddEntry("Starguider Analysis", IDM_kStargAnalysis); 185 fOperations->DisableEntry(IDM_kStargAnalysis); 184 186 fOperations->Associate(this); 185 187 fList->Add(fOperations); … … 298 300 fMenu = new MGMenuBar(this, 0, 0, kHorizontalFrame); 299 301 fMenu->AddPopup("&Display", fDisplay, NULL); 302 fMenu->AddPopup("&Mode", fMode, NULL); 300 303 fMenu->AddPopup("&WritePics", fWritePictures, NULL); 301 304 fMenu->AddPopup("&Setup", fSetup, NULL); … … 355 358 AddFrame(fTPoint); 356 359 fList->Add(fTPoint); 360 361 fStargTPoint = new TGTextButton(this, "StargTPoint"); 362 fStargTPoint->Move(240+12+20, fMenu->GetDefaultHeight()+785); 363 fStargTPoint->AllowStayDown(kTRUE); 364 AddFrame(fStargTPoint); 365 fList->Add(fStargTPoint); 357 366 358 367 fFps = new TGLabel(this, "---fps"); … … 458 467 MapSubwindows(); 459 468 fTPoint->UnmapWindow(); 469 fStargTPoint->UnmapWindow(); 460 470 fGStarg->UnmapWindow(); 461 471 fPZdAz->UnmapWindow(); … … 479 489 fCosy(NULL), 480 490 fOutTp(0), 491 fOutStargTp(0), 481 492 fOutRq(0), 482 493 fDx((768-kZOOM)/2), … … 509 520 510 521 fTime.Now(); 522 523 fTimeFromTp.Set(1970,1,1); 524 fAltAzOffsetFromTp = AltAz(-1000,-1000); 511 525 512 526 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); … … 538 552 delete fStargHistograms; 539 553 delete fSao; 540 delete fRaDec; 554 delete fRaDec; 555 delete fTPoint;// 556 delete fStargTPoint;// 541 557 542 558 if (fOutTp) 543 559 delete fOutTp; 560 561 if (fOutStargTp) 562 delete fOutStargTp; 544 563 545 564 if (fOutRq) … … 569 588 else 570 589 p->CheckEntry(id); 590 } 591 592 void MStarguider::ToggleStargAnalysis() 593 { 594 if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 595 fStargHistograms->OpenFile(); 596 else 597 fStargHistograms->CloseFile(); 598 } 599 600 void MStarguider::ToggleFindStar() 601 { 602 if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy) 603 fTPoint->MapWindow(); 604 else 605 { 606 fTPoint->UnmapWindow(); 607 fTPoint->SetDown(kFALSE); 608 } 609 } 610 611 void MStarguider::ToggleStarguider() 612 { 613 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 614 { 615 fLastBright = 0xff; 616 617 if (!fChannel->IsEntryEnabled(IDM_kChannel1)) 618 fChannel->EnableEntry(IDM_kChannel1); 619 if (fDisplay->IsEntryEnabled(IDM_kFindStar)) 620 fDisplay->DisableEntry(IDM_kFindStar); 621 if (fDisplay->IsEntryEnabled(IDM_kCaosFilter)) 622 fDisplay->DisableEntry(IDM_kCaosFilter); 623 if (!fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 624 fOperations->EnableEntry(IDM_kStargAnalysis); 625 626 fStargTPoint->MapWindow(); 627 628 fPZdAz->MapWindow(); 629 fDZdAz->MapWindow(); 630 fSkyBright->MapWindow(); 631 632 fSao->SetLimitMag(8.3); 633 fIntRate = 125; 634 635 if (!fDisplay->IsEntryChecked(IDM_kCatalog)) 636 fDisplay->CheckEntry(IDM_kCatalog); 637 fGStarg->MapWindow(); 638 639 const Int_t ch0 = 640 fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 641 const Int_t ch1 = 0; 642 643 if (ch0!=ch1) 644 { 645 delete fGetter; 646 usleep(150000); // FIX: Device or resource busy. 647 if (fChannel->IsEntryChecked(IDM_kChannel3)) 648 fGetter=new PngReader(*this); 649 else 650 { 651 fGetter = new Camera(*this, ch1); 652 ((Camera*)fGetter)->Loop(0); 653 } 654 } 655 656 if (fChannel->IsEntryChecked(IDM_kChannel2)) 657 fChannel->UnCheckEntry(IDM_kChannel2); 658 if (fChannel->IsEntryEnabled(IDM_kChannel2)) 659 fChannel->DisableEntry(IDM_kChannel2); 660 if (!fChannel->IsEntryChecked(IDM_kChannel1)) 661 fChannel->CheckEntry(IDM_kChannel1); 662 663 } 664 else 665 { 666 667 fStatus = MDriveCom::kStandby; 668 669 fStargTPoint->UnmapWindow(); 670 fStargTPoint->SetDown(kFALSE); 671 672 fPZdAz->UnmapWindow(); 673 fDZdAz->UnmapWindow(); 674 fSkyBright->UnmapWindow(); 675 fGStarg->UnmapWindow(); 676 if (!fChannel->IsEntryEnabled(IDM_kChannel2)) 677 fChannel->EnableEntry(IDM_kChannel2); 678 if (!fDisplay->IsEntryEnabled(IDM_kFindStar)) 679 fDisplay->EnableEntry(IDM_kFindStar); 680 if (!fDisplay->IsEntryEnabled(IDM_kCaosFilter)) 681 fDisplay->EnableEntry(IDM_kCaosFilter); 682 if (fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 683 fOperations->DisableEntry(IDM_kStargAnalysis); 684 } 685 gSystem->Unlink("tracking_error.txt"); 686 } 687 688 void MStarguider::ToggleCaosFilter() 689 { 690 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 691 { 692 if (!fMode->IsEntryChecked(IDM_kStarguiderMode) 693 && !fMode->IsEntryChecked(IDM_kTpointMode)) 694 fMenu->AddPopup("&CaOs", fCaOs, NULL); 695 } 696 else 697 { 698 if (fCaosWrite->IsEntryChecked(IDM_kCaosPrintLeds)) 699 fCaosWrite->UnCheckEntry(IDM_kCaosPrintLeds); 700 if (fCaosWrite->IsEntryChecked(IDM_kCaosPrintRings)) 701 fCaosWrite->UnCheckEntry(IDM_kCaosPrintRings); 702 if (fCaosAnalyse->IsEntryEnabled(IDM_kCaosAnalStop)) 703 { 704 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop); 705 fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart); 706 fCaos->DeleteHistograms(); 707 } 708 if (fCaosWrite->IsEntryEnabled(IDM_kCaosWriteStop)) 709 { 710 fCaosWrite->DisableEntry(IDM_kCaosWriteStop); 711 fCaosWrite->EnableEntry(IDM_kCaosWriteStart); 712 fCaos->CloseFile(); 713 } 714 fMenu->RemovePopup("CaOs"); 715 } 716 fMenu->Resize(fMenu->GetDefaultSize()); 717 MapSubwindows(); // maps everything, but we don't want that 718 fTPoint->UnmapWindow(); 719 fStargTPoint->UnmapWindow(); 720 fGStarg->UnmapWindow(); 721 fPZdAz->UnmapWindow(); 722 fDZdAz->UnmapWindow(); 723 fSZdAz->UnmapWindow(); 724 fSkyBright->UnmapWindow(); 725 MapWindow(); 571 726 } 572 727 … … 616 771 Toggle(fOperations, IDM_kRoqueLampAna); 617 772 // if (!fDisplay->IsEntryChecked(IDM_kCatalog)) 618 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) { 619 fDisplay->CheckEntry(IDM_kStargCaosFilter); 620 } 621 else { 622 fDisplay->UnCheckEntry(IDM_kStargCaosFilter); 623 } 773 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 774 fDisplay->CheckEntry(IDM_kStargCaosFilter); 775 else 776 fDisplay->UnCheckEntry(IDM_kStargCaosFilter); 624 777 625 778 return kTRUE; 626 779 627 628 780 case IDM_kStargFindStar: 629 781 Toggle(fDisplay, IDM_kStargFindStar); 630 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) { 631 fSZdAz->MapWindow(); 632 } else { 633 fSZdAz->UnmapWindow(); 634 } 782 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) 783 fSZdAz->MapWindow(); 784 else 785 fSZdAz->UnmapWindow(); 635 786 return kTRUE; 636 787 637 788 case IDM_kStarguider: 638 789 Toggle(fDisplay, IDM_kStarguider); 639 640 if (fDisplay->IsEntryChecked(IDM_kStarguider)) { 641 642 fLastBright = 0xff; 643 644 fDisplay->DisableEntry(IDM_kFindStar); 645 fDisplay->EnableEntry(IDM_kStargAnalysis); 646 647 fPZdAz->MapWindow(); 648 fDZdAz->MapWindow(); 649 fSkyBright->MapWindow(); 650 651 fSao->SetLimitMag(8.3); 652 fIntRate = 125; 653 654 fDisplay->CheckEntry(IDM_kCatalog); 655 fGStarg->MapWindow(); 656 657 const Int_t ch0 = 658 fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 659 const Int_t ch1 = 0; 660 661 if (ch0!=ch1) 662 { 663 delete fGetter; 664 usleep(150000); // FIX: Device or resource busy. 665 if (fChannel->IsEntryChecked(IDM_kChannel3)) { 666 fGetter=new PngReader(*this); 667 } else { 668 fGetter = new Camera(*this, ch1); 669 ((Camera*)fGetter)->Loop(0); 670 } 671 } 672 673 fChannel->CheckEntry(IDM_kChannel1); 674 fChannel->UnCheckEntry(IDM_kChannel2); 675 fChannel->DisableEntry(IDM_kChannel2); 676 677 } else { 678 679 fStatus = MDriveCom::kStandby; 680 681 fPZdAz->UnmapWindow(); 682 fDZdAz->UnmapWindow(); 683 fSkyBright->UnmapWindow(); 684 fGStarg->UnmapWindow(); 685 fChannel->EnableEntry(IDM_kChannel2); 686 fDisplay->EnableEntry(IDM_kFindStar); 687 fDisplay->DisableEntry(IDM_kStargAnalysis); 688 } 689 690 gSystem->Unlink("tracking_error.txt"); 691 790 ToggleStarguider(); 692 791 return kTRUE; 693 792 694 793 case IDM_kStargAnalysis: 695 Toggle(fDisplay, IDM_kStargAnalysis); 696 if (fDisplay->IsEntryChecked(IDM_kStargAnalysis)) { 697 fStargHistograms->OpenFile(); 698 } else { 699 fStargHistograms->CloseFile(); 700 } 701 702 return kTRUE; 703 704 case IDM_kStargHistograms: 705 Toggle(fDisplay, IDM_kStargHistograms); 706 return kTRUE; 707 708 case IDM_kStargLEDFilter: 709 Toggle(fDisplay, IDM_kStargLEDFilter); 794 Toggle(fOperations, IDM_kStargAnalysis); 795 ToggleStargAnalysis(); 796 return kTRUE; 797 798 case IDM_kStarguiderMode: 799 Toggle(fMode, IDM_kStarguiderMode); 800 801 if (fMode->IsEntryChecked(IDM_kStarguiderMode)) 802 { 803 804 //uncheck not needed items 805 //general 806 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) 807 fDisplay->UnCheckEntry(IDM_kStargFindStar); 808 809 if (fDisplay->IsEntryChecked(IDM_kFilter)) 810 fDisplay->UnCheckEntry(IDM_kFilter); 811 if (fDisplay->IsEntryEnabled(IDM_kFilter)) 812 fDisplay->DisableEntry(IDM_kFilter); 813 814 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 815 fOperations->UnCheckEntry(IDM_kRoqueLampAna); 816 if (fOperations->IsEntryEnabled(IDM_kRoqueLampAna)) 817 fOperations->DisableEntry(IDM_kRoqueLampAna); 818 819 if (fChannel->IsEntryChecked(IDM_kChannel3)) 820 fChannel->UnCheckEntry(IDM_kChannel3); 821 if (fChannel->IsEntryEnabled(IDM_kChannel3)) 822 fChannel->DisableEntry(IDM_kChannel3); 823 824 //tpoint 825 if (fDisplay->IsEntryChecked(IDM_kFindStar)) 826 fDisplay->UnCheckEntry(IDM_kFindStar); 827 ToggleFindStar(); 828 829 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 830 fDisplay->UnCheckEntry(IDM_kCaosFilter); 831 ToggleCaosFilter(); 832 833 if (fMode->IsEntryChecked(IDM_kTpointMode)) 834 fMode->UnCheckEntry(IDM_kTpointMode); 835 836 //enable starguider items 837 // if (!fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 838 // fOperations->EnableEntry(IDM_kStargAnalysis); 839 if (!fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) 840 fDisplay->EnableEntry(IDM_kStargCaosFilter); 841 if (!fDisplay->IsEntryEnabled(IDM_kStarguider)) 842 fDisplay->EnableEntry(IDM_kStarguider); 843 if (!fDisplay->IsEntryEnabled(IDM_kCatalog)) 844 fDisplay->EnableEntry(IDM_kCatalog); 845 846 //check needed items 847 if (!fDisplay->IsEntryChecked(IDM_kStretch)) 848 fDisplay->CheckEntry(IDM_kStretch); 849 850 if (!fDisplay->IsEntryChecked(IDM_kStarguider)) 851 fDisplay->CheckEntry(IDM_kStarguider); 852 ToggleStarguider(); 853 854 if (!fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 855 fDisplay->CheckEntry(IDM_kStargCaosFilter); 856 857 // if (!fOperations->IsEntryChecked(IDM_kStargAnalysis)) 858 // fOperations->CheckEntry(IDM_kStargAnalysis); 859 // ToggleStargAnalysis(); 860 if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 861 fOperations->UnCheckEntry(IDM_kStargAnalysis); 862 if (fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 863 fOperations->DisableEntry(IDM_kStargAnalysis); 864 865 866 } 867 else 868 { 869 //uncheck starguider items 870 // if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 871 // fOperations->UnCheckEntry(IDM_kStargAnalysis); 872 // ToggleStargAnalysis(); 873 874 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 875 fDisplay->UnCheckEntry(IDM_kStargCaosFilter); 876 877 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 878 fDisplay->UnCheckEntry(IDM_kStarguider); 879 ToggleStarguider(); 880 881 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 882 fDisplay->UnCheckEntry(IDM_kCatalog); 883 884 if (!fChannel->IsEntryEnabled(IDM_kChannel3)) 885 fChannel->EnableEntry(IDM_kChannel3); 886 887 if (!fOperations->IsEntryEnabled(IDM_kRoqueLampAna)) 888 fOperations->EnableEntry(IDM_kRoqueLampAna); 889 890 if (!fDisplay->IsEntryEnabled(IDM_kFilter)) 891 fDisplay->EnableEntry(IDM_kFilter); 892 893 } 894 return kTRUE; 895 896 case IDM_kTpointMode: 897 Toggle(fMode, IDM_kTpointMode); 898 899 if (fMode->IsEntryChecked(IDM_kTpointMode)) 900 { 901 //unchecking not needed items 902 //general 903 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) 904 fDisplay->UnCheckEntry(IDM_kStargFindStar); 905 906 if (fDisplay->IsEntryChecked(IDM_kFilter)) 907 fDisplay->UnCheckEntry(IDM_kFilter); 908 if (fDisplay->IsEntryEnabled(IDM_kFilter)) 909 fDisplay->DisableEntry(IDM_kFilter); 910 911 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 912 fOperations->UnCheckEntry(IDM_kRoqueLampAna); 913 if (fOperations->IsEntryEnabled(IDM_kRoqueLampAna)) 914 fOperations->DisableEntry(IDM_kRoqueLampAna); 915 916 if (fChannel->IsEntryChecked(IDM_kChannel3)) 917 fChannel->UnCheckEntry(IDM_kChannel3); 918 if (fChannel->IsEntryEnabled(IDM_kChannel3)) 919 fChannel->DisableEntry(IDM_kChannel3); 920 921 //from starguider 922 if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 923 fOperations->UnCheckEntry(IDM_kStargAnalysis); 924 ToggleStargAnalysis(); 925 if (fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 926 fOperations->DisableEntry(IDM_kStargAnalysis); 927 928 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 929 fDisplay->UnCheckEntry(IDM_kStargCaosFilter); 930 if (fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) 931 fDisplay->DisableEntry(IDM_kStargCaosFilter); 932 933 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 934 fDisplay->UnCheckEntry(IDM_kStarguider); 935 ToggleStarguider(); 936 if (fDisplay->IsEntryEnabled(IDM_kStarguider)) 937 fDisplay->DisableEntry(IDM_kStarguider); 938 939 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 940 fDisplay->UnCheckEntry(IDM_kCatalog); 941 if (fDisplay->IsEntryEnabled(IDM_kCatalog)) 942 fDisplay->DisableEntry(IDM_kCatalog); 943 944 if (fMode->IsEntryChecked(IDM_kStarguiderMode)) 945 fMode->UnCheckEntry(IDM_kStarguiderMode); 946 947 //switch camera 948 const Int_t ch0 = 949 fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 950 const Int_t ch1 = 1; 951 952 if (ch0!=ch1) 953 { 954 delete fGetter; 955 usleep(150000); // FIX: Device or resource busy. 956 fGetter = new Camera(*this, ch1); 957 ((Camera*)fGetter)->Loop(0); 958 } 959 960 if (fChannel->IsEntryChecked(IDM_kChannel1)) 961 fChannel->UnCheckEntry(IDM_kChannel1); 962 if (fChannel->IsEntryEnabled(IDM_kChannel1)) 963 fChannel->DisableEntry(IDM_kChannel1); 964 if (!fChannel->IsEntryChecked(IDM_kChannel2)) 965 fChannel->CheckEntry(IDM_kChannel2); 966 967 //checking needed items 968 if (!fDisplay->IsEntryChecked(IDM_kStretch)) 969 fDisplay->CheckEntry(IDM_kStretch); 970 971 if (!fDisplay->IsEntryChecked(IDM_kCaosFilter)) 972 fDisplay->CheckEntry(IDM_kCaosFilter); 973 ToggleCaosFilter(); 974 975 if (!fDisplay->IsEntryChecked(IDM_kFindStar)) 976 fDisplay->CheckEntry(IDM_kFindStar); 977 ToggleFindStar(); 978 979 } 980 else 981 { 982 //enable starguider items 983 if (!fOperations->IsEntryEnabled(IDM_kStargAnalysis)) 984 fOperations->EnableEntry(IDM_kStargAnalysis); 985 if (!fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) 986 fDisplay->EnableEntry(IDM_kStargCaosFilter); 987 if (!fDisplay->IsEntryEnabled(IDM_kStarguider)) 988 fDisplay->EnableEntry(IDM_kStarguider); 989 if (!fDisplay->IsEntryEnabled(IDM_kCatalog)) 990 fDisplay->EnableEntry(IDM_kCatalog); 991 992 if (!fDisplay->IsEntryEnabled(IDM_kFilter)) 993 fDisplay->EnableEntry(IDM_kFilter); 994 if (!fOperations->IsEntryEnabled(IDM_kRoqueLampAna)) 995 fOperations->EnableEntry(IDM_kRoqueLampAna); 996 if (!fChannel->IsEntryEnabled(IDM_kChannel3)) 997 fChannel->EnableEntry(IDM_kChannel3); 998 999 if (fDisplay->IsEntryChecked(IDM_kFindStar)) 1000 fDisplay->UnCheckEntry(IDM_kFindStar); 1001 ToggleFindStar(); 1002 1003 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 1004 fDisplay->UnCheckEntry(IDM_kCaosFilter); 1005 ToggleCaosFilter(); 1006 1007 if (!fChannel->IsEntryEnabled(IDM_kChannel1)) 1008 fChannel->EnableEntry(IDM_kChannel1); 1009 1010 } 710 1011 return kTRUE; 711 1012 … … 727 1028 case IDM_kFindStar: 728 1029 Toggle(fDisplay, IDM_kFindStar); 729 if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy) 730 fTPoint->MapWindow(); 731 else 732 { 733 fTPoint->UnmapWindow(); 734 fTPoint->SetDown(kFALSE); 735 } 1030 ToggleFindStar(); 736 1031 return kTRUE; 737 1032 … … 744 1039 // fCaos->OpenFile(); 745 1040 Toggle(fDisplay, IDM_kCaosFilter); 746 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) { 747 fMenu->AddPopup("&CaOs", fCaOs, NULL); 748 } 749 else 750 { 751 if(fCaosWrite->IsEntryChecked(IDM_kCaosPrintLeds)) 752 fCaosWrite->UnCheckEntry(IDM_kCaosPrintLeds); 753 if(fCaosWrite->IsEntryChecked(IDM_kCaosPrintRings)) 754 fCaosWrite->UnCheckEntry(IDM_kCaosPrintRings); 755 if(fCaosAnalyse->IsEntryEnabled(IDM_kCaosAnalStop)) 756 { 757 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop); 758 fCaosAnalyse->EnableEntry(IDM_kCaosAnalStart); 759 fCaos->DeleteHistograms(); 760 } 761 if(fCaosWrite->IsEntryEnabled(IDM_kCaosWriteStop)) 762 { 763 fCaosWrite->DisableEntry(IDM_kCaosWriteStop); 764 fCaosWrite->EnableEntry(IDM_kCaosWriteStart); 765 fCaos->CloseFile(); 766 } 767 fMenu->RemovePopup("CaOs"); 768 } 769 fMenu->Resize(fMenu->GetDefaultSize()); 770 MapSubwindows(); // maps everything, but we don't want that 771 fTPoint->UnmapWindow(); 772 fGStarg->UnmapWindow(); 773 fPZdAz->UnmapWindow(); 774 fDZdAz->UnmapWindow(); 775 fSZdAz->UnmapWindow(); 776 fSkyBright->UnmapWindow(); 777 MapWindow(); 1041 ToggleCaosFilter(); 778 1042 return kTRUE; 779 1043 780 1044 case IDM_kStargCaosFilter: 781 1045 Toggle(fDisplay, IDM_kStargCaosFilter); 782 if (fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) { 783 fDisplay->EnableEntry(IDM_kStargFindStar); 784 } else { 785 fDisplay->DisableEntry(IDM_kStargFindStar); 786 } 787 return kTRUE; 1046 if (fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) 1047 fDisplay->EnableEntry(IDM_kStargFindStar); 1048 else 1049 fDisplay->DisableEntry(IDM_kStargFindStar); 1050 return kTRUE; 788 1051 789 1052 case IDM_kCaosPrintLeds: … … 899 1162 usleep(150000); // FIX: Device or resource busy. 900 1163 if (fChannel->IsEntryChecked(IDM_kChannel3)) 901 902 903 904 905 906 1164 fGetter=new PngReader(*this); 1165 else 1166 { 1167 fGetter = new Camera(*this, ch1); 1168 ((Camera*)fGetter)->Loop(0); 1169 } 907 1170 } 908 1171 return kTRUE; … … 988 1251 // chose a bit coarser binning to enhance excess 989 1252 // important: chose binning symmetrical around (0|0)! 990 TH2F h("Hist", "dX/dY", 49, -768/2-8, 768/2+8, 37, -576/2-8, 576/2+8); // 3 1253 // TH2F h("Hist", "dX/dY", 49, -576/2-8, 576/2+8, 37, -576/2-8, 576/2+8); // 3 1254 // reduced range in which histogram is filled, made bins a bit smaller 1255 // 72pix equivalent to 0.6deg 1256 TH2F h("Hist", "dX/dY", 7, -72, 72, 7, -72, 72); 991 1257 992 1258 // TH1F hmag("HistMag", "Mag", 19, 0, 100); … … 1010 1276 1011 1277 const double xmax = h.GetXaxis()->GetBinCenter(mx); 1012 const double dx = h.GetXaxis()->GetBinWidth(mx) ;1278 const double dx = h.GetXaxis()->GetBinWidth(mx)/2; 1013 1279 1014 1280 const double ymax = h.GetYaxis()->GetBinCenter(my); 1015 const double dy = h.GetYaxis()->GetBinWidth(my) ;1281 const double dy = h.GetYaxis()->GetBinWidth(my)/2; 1016 1282 1017 1283 #ifdef EXPERT … … 1069 1335 // } 1070 1336 1337 //deleting histogram and graph 1338 h.Delete(); 1339 g.Delete(); 1071 1340 return ZdAz(-pos1.Alt(), pos1.Az()); 1072 1341 } 1073 1342 1074 bool MStarguider::CalcTrackingError(Leds &leds, MStarList &stars, ZdAz &d, MTime &t )1343 bool MStarguider::CalcTrackingError(Leds &leds, MStarList &stars, ZdAz &d, MTime &t, double &bright) 1075 1344 { 1076 1345 const Int_t max = leds.GetEntries(); 1077 if (stars.GetRealEntries() < 3) 1078 { 1079 cout << "Sorry, less than 3 stars in FOV!" << endl; 1080 return kFALSE; 1081 } 1082 if (max < 3) //was 1 1083 { 1084 cout << "Sorry, less than 3 detected spot in FOV!" << endl; 1085 return kFALSE; 1086 } 1346 if (stars.GetRealEntries() < 3) 1347 { 1348 cout << "Sorry, less than 3 stars in FOV!" << endl; 1349 if (fStargTPoint->IsDown()) 1350 fStargTPoint->SetDown(kFALSE); 1351 return kFALSE; 1352 } 1353 if (max < 3) //was 1 1354 { 1355 cout << "Sorry, less than 3 detected spot in FOV!" << endl; 1356 if (fStargTPoint->IsDown()) 1357 fStargTPoint->SetDown(kFALSE); 1358 return kFALSE; 1359 } 1087 1360 1088 1361 stars.Sort(); // Sort by magnitude … … 1122 1395 mag.AddAt(spot->GetMag()/star->GetMag(), idx); 1123 1396 #ifdef EXPERT 1124 if (fout) { 1125 fout << spot->GetX() << " " 1126 << spot->GetY() << " " 1127 << spot->GetMag() << " " 1128 << star->GetX() << " " 1129 << star->GetY() << " " 1130 << star->GetMag() << " "; 1397 if (fout) 1398 { 1399 fout << spot->GetX() << " " 1400 << spot->GetY() << " " 1401 << spot->GetMag() << " " 1402 << star->GetX() << " " 1403 << star->GetY() << " " 1404 << star->GetMag() << " "; 1131 1405 fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl; 1132 1406 } 1133 1407 #endif 1134 1408 } 1135 } 1409 } 1136 1410 1137 1411 d = TrackingError(x, y, mag); … … 1154 1428 fPZdAz->SetCoordinates(cpos); 1155 1429 1156 return kTRUE; 1430 1431 // Check StargTPoint data set request 1432 if (!fStargTPoint->IsDown()) 1433 return kTRUE; 1434 fStargTPoint->SetDown(kFALSE); 1435 1436 // If no file open: open new file 1437 if (!fOutStargTp) 1438 { 1439 // open tpoint file 1440 const TString name = MCosy::GetFileName("tpoint/starg_%s.txt"); 1441 cout << "TPoint-Starg File ********* " << name << " ********** " << endl; 1442 1443 fOutStargTp = new ofstream(name); 1444 *fOutStargTp << "Magic Model STARGTPOINT data file" << endl; 1445 *fOutStargTp << ": ALTAZ" << endl; 1446 *fOutStargTp << "49 48 0 "; 1447 *fOutStargTp << t << endl; 1448 } 1449 1450 // Get tracking coordinates 1451 const XY xy = fCRaDec->GetCoordinates(); 1452 const RaDec rd(xy.X()*TMath::DegToRad()*15, xy.Y()*TMath::DegToRad()); 1453 1454 // From the star position in the camera we calculate the Alt/Az 1455 // position we are currently tracking (real pointing position) 1456 fSao->SetMjd(t.GetMjd()); 1457 AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg; 1458 1459 //correction with offset from last tpoint measurement 1460 za0 -= fAltAzOffsetFromTp; 1461 MTime t2 = fTimeFromTp; 1462 1463 //if the difference between the tpoint and the starguider tpoint 1464 //is too big, the starguider tpoint is not stored 1465 cout << " mjd difference: " << t.GetMjd()-t2.GetMjd() << endl; 1466 // cout << "t: " << setprecision(11) << t.GetMjd() << endl; 1467 // cout << "t2: " << setprecision(11) << t2.GetMjd() << endl; 1468 if ((t.GetMjd()-t2.GetMjd())>0.001) //1min20sec 1469 { 1470 cout << "time difference between tpoint and starguider-tpoint > " << 1471 t.GetMjd()-t2.GetMjd() << "s => starguider tpoint hasn't been stored. Please repeat whole procedure. " << endl; 1472 return kTRUE; 1473 } 1474 1475 1476 // Write real pointing position 1477 cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl; 1478 *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " "; 1479 1480 // Write system pointing position 1481 cout << " SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl; 1482 *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd(); 1483 1484 *fOutStargTp << " " << xy.X() << " " << xy.Y(); 1485 *fOutStargTp << " " << d.Zd() << " " << d.Az(); 1486 *fOutStargTp << " " << setprecision(11) << t.GetMjd(); 1487 *fOutStargTp << " " << max; 1488 *fOutStargTp << " " << bright; 1489 *fOutStargTp << endl; 1490 1491 1492 1493 1494 1495 1496 fTimeFromTp.Set(1970,1,1); 1497 1498 return kTRUE; 1157 1499 1158 1500 } … … 1212 1554 Led *star = (Led*)leds.At(0); 1213 1555 if (!star) 1556 { 1557 if (fTPoint->IsDown()) 1558 { 1559 fTPoint->SetDown(kFALSE); 1560 cout << "No star found. Couldn't take a tpoint." << endl; 1561 } 1214 1562 return ZdAz(.0,.0); 1563 } 1215 1564 1216 1565 cout << "Found star @ " << flush; … … 1236 1585 Double_t y = center.GetY()-star->GetY(); 1237 1586 1587 #ifdef EXPERT 1238 1588 cout << "STAR-Offset: " << MTime(-1) << " dx=" << x << "pix dy=" << y << "pix" << endl; 1589 #endif 1239 1590 1240 1591 // Convert from Pixel to millimeter (1pix=2.9mm) … … 1250 1601 ac.GetDiffZdAz(x, y, dzd, daz); 1251 1602 1603 #ifdef EXPERT 1252 1604 cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl; 1605 #endif 1253 1606 1254 1607 ZdAz zdaz(dzd,daz); … … 1265 1618 // open tpoint file 1266 1619 // 1267 const TString name = MCosy::GetFileName("tpoint/ starg_%s.txt");1620 const TString name = MCosy::GetFileName("tpoint/tpoint_%s.txt"); 1268 1621 cout << "TPoint-Starg File ********* " << name << " ********** " << endl; 1269 1622 … … 1286 1639 //ZdAz za0 = fSao->GetZdAz(); 1287 1640 za0 -= AltAz(-dzd, daz); 1641 fAltAzOffsetFromTp = AltAz(-dzd, daz); 1642 fTimeFromTp=t; 1643 1288 1644 1289 1645 // From the Shaftencoders we get the current 'pointing' position … … 1388 1744 if (fFileType->IsEntryChecked(IDM_kPNG)) 1389 1745 Writer::Png("pix/file", img, tm, fCRaDec->GetCoordinates()); 1390 1746 1391 1747 if (fFileType->IsEntryChecked(IDM_kPPM)) 1392 1748 Writer::Ppm("pix/file", img, tm, fCRaDec->GetCoordinates()); … … 1419 1775 pos = fCosy->GetPointingPos(); 1420 1776 center = fCaos->Run(img, printl, printr, pos, t, 50, 3.0); 1421 1422 1777 cout << "Caos Filter Camera center position: " << center.GetX() << " " << center.GetY() << endl; 1423 1778 … … 1453 1808 1454 1809 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 1455 { 1810 { 1456 1811 ZdAz pos; 1457 1812 if (fCosy) 1458 1813 pos = fCosy->GetPointingPos(); 1459 sgcenter = 1460 1461 1814 sgcenter = 1815 fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 30, 3.0); // [px] 1816 const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px] 1462 1817 1463 1818 // BE CAREFULL: This transformation is WRONG. It is just … … 1473 1828 << sgcenter.GetY()-293.6<< "pix" << endl; 1474 1829 #endif 1475 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) { 1476 star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg] 1830 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) 1831 { 1832 star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg] 1477 1833 #ifdef EXPERT 1478 cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az=" 1479 << star.Az()*60 << "'" << endl; 1834 cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az=" 1835 << star.Az()*60 << "'" << endl; 1480 1836 #endif 1481 1482 1837 fSZdAz->SetCoordinates(star); // Misspointing found from Camera 1838 } 1483 1839 } 1484 1840 1485 1841 // Find Roque Lamp 1486 1842 1487 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) { 1488 1489 XY roquelamp(0,0); 1490 1491 Double_t imageclean = 1.5; 1492 Double_t boxradius = 60; 1843 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1844 { 1845 1846 XY roquelamp(0,0); 1847 1848 Double_t imageclean = 1.5; 1849 Double_t boxradius = 60; 1493 1850 Double_t scalefactor = 1; 1494 1851 XY searchcenter(768/2-1,576/2+25); … … 1496 1853 roquelamp = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter); 1497 1854 1498 if (fOutRq) { 1499 ZdAz pos = fCosy->GetPointingPos(); 1500 1501 *fOutRq << "RoqueLampDirect: " << MTime(-1) << " " 1502 << pos.Zd() << " " << pos.Az() << " " 1503 << roquelamp.X() << " " << roquelamp.Y() << endl; 1504 } 1505 1506 cout << "Starguider Camera Center: " << sgcenter.GetX() << "," << sgcenter.GetY() << endl; 1855 if (fOutRq) 1856 { 1857 ZdAz pos = fCosy->GetPointingPos(); 1858 1859 *fOutRq << "RoqueLampDirect: " << MTime(-1) << " " 1860 << pos.Zd() << " " << pos.Az() << " " 1861 << roquelamp.X() << " " << roquelamp.Y() << endl; 1862 } 1863 1864 cout << "Starguider Camera Center: " << sgcenter.GetX() << "," << sgcenter.GetY() << endl; 1507 1865 cout << ">=>=>=> Roque Lamp found at: >=>=>=> (" << roquelamp.X() << "," 1508 1866 << roquelamp.Y() << ") <=<=<=<" << endl; … … 1512 1870 // Find Spot on Camera Center in Starguider camera 1513 1871 1514 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) {1515 1516 1517 1518 1872 if (fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1873 { 1874 XY cameraspot(0,0); 1875 1876 Double_t imageclean = 5; 1519 1877 Double_t boxradius = 60; 1520 1878 Double_t scalefactor = 1; … … 1524 1882 cameraspot = FindRoqueLamp(f, f2, sgcenter, t, imageclean, boxradius, searchcenter); 1525 1883 1526 if (fOutRq) { 1527 ZdAz pos = fCosy->GetPointingPos(); 1528 1529 *fOutRq << "RoqueLampReflected: " << MTime(-1) << " " 1530 << pos.Zd() << " " << pos.Az() << " " 1531 << cameraspot.X() << " " << cameraspot.Y() << endl; 1532 } 1533 1534 cout << ">>>>> Spot on Magic camera found at: >>>>> (" << cameraspot.X() << "," 1884 if (fOutRq) 1885 { 1886 ZdAz pos = fCosy->GetPointingPos(); 1887 1888 *fOutRq << "RoqueLampReflected: " << MTime(-1) << " " 1889 << pos.Zd() << " " << pos.Az() << " " 1890 << cameraspot.X() << " " << cameraspot.Y() << endl; 1891 } 1892 1893 cout << ">>>>> Spot on Magic camera found at: >>>>> (" << cameraspot.X() << "," 1535 1894 << cameraspot.Y() << ") <<<<<" << endl; 1536 1895 1537 1896 f2.DrawCircle(sgcenter, 5.0, 0x0fa); 1538 1897 f2.DrawCircle(sgcenter, 115.0, 0x0fa); 1539 1540 1898 } 1541 1899 … … 1556 1914 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1557 1915 { 1558 1559 1916 MTime time(*tm); 1917 1560 1918 XY xy = fCRaDec->GetCoordinates(); 1561 1919 fRaDec->Set(xy.X()*360/24, xy.Y()); … … 1570 1928 fSao->SetBox(230); // Region of interest around center 1571 1929 1572 1930 // very careful: If center of camera cannot be determined 1573 1931 // sgcenter jumps to (0,0) 1574 1932 double sgcenteroffsetX = 0.0; 1575 1933 double sgcenteroffsetY = 0.0; 1576 if ((double)sgcenter.GetX() > 0.0 && (double)sgcenter.GetY() > 0.0) { 1577 sgcenteroffsetX = sgcenter.GetX()-53.2; 1578 sgcenteroffsetY = sgcenter.GetY()-293.6; 1579 } 1934 if ((double)sgcenter.GetX() > 0.0 && (double)sgcenter.GetY() > 0.0) 1935 { 1936 //Please never change this offsets!!! 1937 sgcenteroffsetX = sgcenter.GetX()-53.2; 1938 sgcenteroffsetY = sgcenter.GetY()-293.6; 1939 } 1580 1940 1581 1941 // we obtain stars in the effective star FOV and draw them. … … 1600 1960 1601 1961 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 1602 1962 { 1603 1963 Leds spots; 1604 1964 f.SetBox(230); … … 1612 1972 ULong_t color; 1613 1973 gClient->GetColorByName("Green", color); 1614 if (bright> 60) gClient->GetColorByName("Yellow", color); 1615 if (bright> 85) gClient->GetColorByName("Orange", color); 1616 if (bright> 95) gClient->GetColorByName("Red", color); 1974 if (bright> 60) 1975 gClient->GetColorByName("Yellow", color); 1976 if (bright> 85) 1977 gClient->GetColorByName("Orange", color); 1978 if (bright> 95) 1979 gClient->GetColorByName("Red", color); 1617 1980 fSkyBright->SetBackgroundColor(color); 1618 1619 bool rc = CalcTrackingError(spots, stars, fD, t); 1620 1621 if (rc && (bright <= 1.75* fLastBright) && (bright < 110)) { 1622 fStatus = MDriveCom::kMonitoring; 1623 } else { 1624 fStatus = MDriveCom::kError; 1625 } 1626 1981 1982 bool rc = CalcTrackingError(spots, stars, fD, t, bright); 1983 1984 if (rc && (bright <= 1.75* fLastBright) && (bright < 110)) 1985 fStatus = MDriveCom::kMonitoring; 1986 else 1987 fStatus = MDriveCom::kError; 1988 1627 1989 if (fCosy) 1628 1990 fPos = fCosy->GetPointingPos(); 1629 1991 1630 if (f Display->IsEntryChecked(IDM_kStargAnalysis))1631 fStargHistograms->Fill(spots, stars, fD,1632 1633 1992 if (fOperations->IsEntryChecked(IDM_kStargAnalysis)) 1993 fStargHistograms->Fill(spots, stars, fD, 1994 fSao->GetZdAz(), sgcenter, sgcenterzdaz, 1995 star, bright, fPos, t); 1634 1996 1635 1997 fLastBright = bright; 1636 1998 1637 if (fCosy) { 1999 if (fCosy) 2000 { 1638 2001 MDriveCom &com = *fCosy->GetDriveCom(); 1639 2002 com.SendStargReport(fStatus, fD, fSao->GetZdAz(), sgcenter, spots.GetEntries(), bright, time.GetMjd(), 0, 0); // Report 1640 2003 } 1641 2004 1642 2005 } //kStarguider 1643 2006 1644 2007 f2.DrawCircle(skycenter, 2.0, 0x0a); … … 1666 2029 { 1667 2030 f2.DrawCircle(sgcenter, 0x0a); 1668 f2.DrawCircle(sgcenter, 5.0, 1669 2031 f2.DrawCircle(sgcenter, 5.0, 2032 fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0); 1670 2033 } 1671 2034 … … 1682 2045 fDisplay->IsEntryChecked(IDM_kCatalog) || 1683 2046 fDisplay->IsEntryChecked(IDM_kFindStar) || 1684 fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 2047 fOperations->IsEntryChecked(IDM_kRoqueLampAna)) 1685 2048 fImage->DrawColImg(img, cimg); 1686 2049 else … … 1694 2057 { 1695 2058 // FIXME: Necessary? 1696 2059 fSao->Now(); 1697 2060 AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg; 1698 2061 if (aa.Az()<0)
Note:
See TracChangeset
for help on using the changeset viewer.