Changeset 8833
- Timestamp:
- 01/24/08 14:05:28 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r8832 r8833 71 71 * videodev/VideodevLinkDef.h: 72 72 - removed Camkera from dictionary 73 74 * main/MCosy.[h,cc]: 75 - replaced kDeg2Rad and kRad2Deg by TMath 76 - replaced lout by gLog 77 - made a few changes for the new coordinate classes 78 - added cancel points to thread where possible 79 - changed to new threading classes 80 - thread doesn't run detached anymore 81 73 82 74 83 -
trunk/MagicSoft/Cosy/main/MCosy.cc
r8376 r8833 4 4 #include <fstream> 5 5 6 #include <TROOT.h>7 6 #include <TEnv.h> 8 #include <T System.h>7 #include <TTimer.h> 9 8 #include <TApplication.h> 10 #include <TTimer.h>11 9 12 10 #include <TH2.h> … … 14 12 #include <TProfile.h> 15 13 #include <TCanvas.h> 14 15 #include "MLogManip.h" 16 16 17 17 #include "MGCosy.h" … … 23 23 #include "MTracking.h" 24 24 25 #include "slalib/slalib.h" // FIXME: REMOVE26 27 25 #include "macs.h" 28 26 #include "shaftencoder.h" … … 56 54 57 55 ZdAz source = src * 360.0/16384.0; 58 ZdAz dest = dst * kRad2Deg;56 ZdAz dest = dst * TMath::RadToDeg(); 59 57 60 58 if (dest.Zd()>-3 && dest.Zd()<3) … … 207 205 208 206 MTime t(-1); 209 lout<< t << " - MCosy::WaitForEndMovement aborted...";207 gLog << t << " - MCosy::WaitForEndMovement aborted..."; 210 208 if (Break()) 211 lout<< " Break signal...";209 gLog << " Break signal..."; 212 210 if (HasError()) 213 lout<< " Network has error...";211 gLog << " Network has error..."; 214 212 if (HasZombie()) 215 lout<< " Network has zombie...";216 lout<< endl;213 gLog << " Network has zombie..."; 214 gLog << endl; 217 215 } 218 216 … … 272 270 if (d.Zd()<fMin.Zd()) 273 271 { 274 lout<< "ERROR: Requested Zenith Angle below negative endswitch." << endl;272 gLog << "ERROR: Requested Zenith Angle below negative endswitch." << endl; 275 273 return kFALSE; 276 274 } … … 278 276 if (d.Zd()>fMax.Zd()) 279 277 { 280 lout<< "ERROR: Requested Zenith Angle behind positive endswitch." << endl;278 gLog << "ERROR: Requested Zenith Angle behind positive endswitch." << endl; 281 279 return kFALSE; 282 280 } … … 284 282 if (d.Az()<fMin.Az()) 285 283 { 286 lout<< "ERROR: Requested Azimuth Angle below negative endswitch." << endl;284 gLog << "ERROR: Requested Azimuth Angle below negative endswitch." << endl; 287 285 return kFALSE; 288 286 } … … 290 288 if (d.Az()>fMax.Az()) 291 289 { 292 lout<< "ERROR: Requested Azimuth Angle behind positive endswitch." << endl;290 gLog << "ERROR: Requested Azimuth Angle behind positive endswitch." << endl; 293 291 return kFALSE; 294 292 } … … 303 301 // AlignTrackingPos [deg] 304 302 305 pointing *= kRad2Deg;303 pointing *= TMath::RadToDeg(); 306 304 307 305 if (pointing.Zd()<0) … … 309 307 pointing.Zd(-pointing.Zd()); 310 308 pointing.Az(pointing.Az()+180); 311 // lout<< "ZD=-ZD Az+=180" << endl;309 //gLog << "ZD=-ZD Az+=180" << endl; 312 310 } 313 311 314 312 const ZdAz se = GetSePos()*TMath::TwoPi()/kResSE; // [rad] 315 const ZdAz unbendedse = fBending.CorrectBack(se)* kRad2Deg; // ist pointing316 317 // lout<< "Unbended: " << unbendedse.Zd() << " " << unbendedse.Az() << endl;313 const ZdAz unbendedse = fBending.CorrectBack(se)*TMath::RadToDeg(); // ist pointing 314 315 //gLog << "Unbended: " << unbendedse.Zd() << " " << unbendedse.Az() << endl; 318 316 319 317 do … … 323 321 break; 324 322 325 // lout<< "AZ += " << TMath::Sign(360., d) << endl;323 //gLog << "AZ += " << TMath::Sign(360., d) << endl; 326 324 327 325 pointing.Az(pointing.Az()+TMath::Sign(360., d)); 328 326 } while (1); 329 327 330 return pointing/ kRad2Deg;328 return pointing/TMath::RadToDeg(); 331 329 /* 332 330 const Bool_t rc = CheckRange(pointing); 333 za = pointing/ kRad2Deg; // [rad]331 za = pointing/TMath::RadToDeg(); // [rad] 334 332 335 333 if (!rc) 336 lout<< "Error: Aligned position out of Range." << endl;334 gLog << "Error: Aligned position out of Range." << endl; 337 335 338 336 return rc;*/ … … 353 351 return -1; 354 352 355 ZdAz point=AlignTrackingPos(ZdAz(zd, az)/ kRad2Deg);353 ZdAz point=AlignTrackingPos(ZdAz(zd, az)/TMath::RadToDeg()); 356 354 /* 357 355 if (!AlignTrackingPos(ZdAz(zd, az), point)) … … 363 361 // FIXME: Check Range missing! 364 362 365 const ZdAz diff = (dest-point)* kRad2Deg;363 const ZdAz diff = (dest-point)*TMath::RadToDeg(); 366 364 367 365 if (diff.Zd()>5 || diff.Az()>5) … … 392 390 int MCosy::SetPosition(const ZdAz &dst, Bool_t track) // [rad] 393 391 { 394 M Pointing point(this, lout);392 MSlewing point(this); 395 393 396 394 //#ifdef EXPERT … … 434 432 void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad] 435 433 { 436 MTracking track(this , lout);434 MTracking track(this); 437 435 track.SetOut(fOutRep); 438 436 //#ifdef EXPERT … … 459 457 void MCosy::TrackPositionGRB(const RaDec &dst) // ra, dec [rad] 460 458 { 461 MTracking track(this , lout);459 MTracking track(this); 462 460 track.SetOut(fOutRep); 463 461 //#ifdef EXPERT … … 563 561 } 564 562 565 void *MCosy::Proc(int msg, void *mp)563 Int_t MCosy::Proc(int msg, void *mp) 566 564 { 567 565 switch (msg) … … 569 567 case WM_WAIT: 570 568 cout << "Wait for execution of Proc(WM_*, ): done." << endl; 571 return NULL;569 return 0; 572 570 573 571 case WM_STOP: 574 572 //cout << "MCosy::Proc: Stop." << endl; 575 573 if (!CheckNetwork()) 576 return (void*)0xebb0;574 return 0xebb0; 577 575 StopMovement(); 578 return NULL;576 return 0; 579 577 /* 580 578 case WM_PRESET: … … 605 603 cout << "Calibrating to: " << rd.Ra()*24/360 << "h " << rd.Dec() << "°" << endl; 606 604 607 ZdAz za=sla.CalcZdAz(rd* kDeg2Rad)*16384.0/k2Pi;605 ZdAz za=sla.CalcZdAz(rd*TMath::DegToRad())*16384.0/k2Pi; 608 606 609 607 cout << "Calc Zd: " << za.Zd() << " Az: " << za.Az() << endl; … … 629 627 cout << "TPoint Star: " << rd.Ra()/15 << "h " << rd.Dec() << "°" << endl; 630 628 631 AltAz za=sla.CalcAltAz(rd* kDeg2Rad)*kRad2Deg;629 AltAz za=sla.CalcAltAz(rd*TMath::DegToRad())*TMath::RadToDeg(); 632 630 633 631 if (!fOutTp) … … 653 651 ZdAz sepos = GetSePos()*TMath::TwoPi()/kResSE; 654 652 za.Set(TMath::Pi()/2-sepos.Zd(), sepos.Az()); 655 za *= kRad2Deg;653 za *= TMath::RadToDeg(); 656 654 657 655 cout << " SE-Pos: " << za.Alt() << "° " << za.Az() << "°" << endl; … … 668 666 //cout << "WM_TPoint: done. (return 0xaffe)" << endl; 669 667 } 670 return (void*)0xca1b;668 return 0xca1b; 671 669 672 670 case WM_TRACKPOS: … … 674 672 { 675 673 if (!CheckNetwork()) 676 return (void*)0xebb0;677 678 ZdAz dest = *((ZdAz*)mp) * kDeg2Rad;674 return 0xebb0; 675 676 ZdAz dest = *((ZdAz*)mp) * TMath::DegToRad(); 679 677 if (!SetPosition(dest, kTRUE)) 680 return (void*)0x1234;678 return 0x1234; 681 679 682 680 SlaStars sla(fObservatory); … … 687 685 } 688 686 //cout << "WM_TrackPosition: done. (return 0xabcd)" << endl; 689 return (void*)0xabcd;687 return 0xabcd; 690 688 /* 691 689 case WM_ARM: … … 716 714 { 717 715 if (!CheckNetwork()) 718 return (void*)0xebb0;716 return 0xebb0; 719 717 720 718 ZdAz dest = *((ZdAz*)mp); 721 SetPosition(dest* kDeg2Rad);719 SetPosition(dest*TMath::DegToRad()); 722 720 } 723 721 //cout << "WM_Position: done. (return 0x7777)" << endl; 724 return (void*)0x7777;722 return 0x7777; 725 723 726 724 case WM_POSITION1: … … 728 726 { 729 727 if (!CheckNetwork()) 730 return (void*)0xebb0;728 return 0xebb0; 731 729 732 730 ZdAz dest = *((ZdAz*)mp); 733 SetPosition(dest* kDeg2Rad, kTRUE);731 SetPosition(dest*TMath::DegToRad(), kTRUE); 734 732 } 735 733 //cout << "WM_Position: done. (return 0x7777)" << endl; 736 return (void*)0x7777;734 return 0x7777; 737 735 738 736 case WM_PREPS: … … 740 738 { 741 739 if (!CheckNetwork()) 742 return (void*)0xebb0;740 return 0xebb0; 743 741 744 742 const char *preps = (const char*)mp; … … 749 747 { 750 748 cout << "ERROR: cannot open prepos.txt." << endl; 751 return (void*)0xebb1;749 return 0xebb1; 752 750 } 753 751 … … 767 765 { 768 766 ZdAz dest(zd, az); 769 SetPosition(dest* kDeg2Rad);770 return (void*)0x7979;767 SetPosition(dest*TMath::DegToRad()); 768 return 0x7979; 771 769 } 772 770 cout << "ERROR - Requested preposition not found in file..." << endl; … … 774 772 } 775 773 //cout << "WM_Track: done. (return 0x8888)" << endl; 776 return (void*)0x7878;774 return 0x7878; 777 775 778 776 case WM_TESTSE: … … 780 778 fBackground = mp ? kBgdSeTest : kBgdNone; 781 779 //cout << "WM_TestSe: done. (return 0x1e51)" << endl; 782 return (void*)0x1e51;780 return 0x1e51; 783 781 784 782 case WM_GEAR: … … 786 784 fBackground = mp ? kBgdGear : kBgdNone; 787 785 //cout << "WM_Gear: done. (return 0xfeaf)" << endl; 788 return (void*)0xfeaf;786 return 0xfeaf; 789 787 790 788 case WM_DISPLAY: … … 792 790 fTriggerDisplay = kTRUE; 793 791 //cout << "WM_Disply: done. (return 0xd1e1)" << endl; 794 return (void*)0xd1e1;792 return 0xd1e1; 795 793 796 794 case WM_TRACK: … … 802 800 fStarguider->SetPointingPosition(((RaDec*)mp)[1]); 803 801 if (!CheckNetwork()) 804 return (void*)0xebb0;802 return 0xebb0; 805 803 806 804 if (msg==WM_TRACK) 807 TrackPosition(dest* kDeg2Rad);805 TrackPosition(dest*TMath::DegToRad()); 808 806 else 809 TrackPositionGRB(dest* kDeg2Rad);807 TrackPositionGRB(dest*TMath::DegToRad()); 810 808 } 811 809 //cout << "WM_Track/GRB: done. (return 0x8888)" << endl; 812 return (void*)0x8888;810 return 0x8888; 813 811 814 812 case WM_NEWTRACK: … … 816 814 fRaDec = *((RaDec*)mp); 817 815 //cout << "WM_NewTrack: done. (return 0x9999)" << endl; 818 return (void*)0x9999;816 return 0x9999; 819 817 820 818 case WM_LOADBENDING: … … 822 820 fBending.Load("bending.txt"); 823 821 //cout << "WM_LoadBending: done. (return 0xbe0d)" << endl; 824 return (void*)0xbe0d;822 return 0xbe0d; 825 823 826 824 case WM_RESETBENDING: … … 828 826 fBending.Reset(); 829 827 //cout << "WM_ResetBending: done. (return 0xbe0e)" << endl; 830 return (void*)0xbe0e;828 return 0xbe0e; 831 829 832 830 case WM_HOME: 833 831 //cout << "WM_Home: START" << endl; 834 832 if (!CheckNetwork()) 835 return (void*)0xebb0;833 return 0xebb0; 836 834 else 837 835 { … … 846 844 fMac2->SetHome(250000, env.GetValue("Zd_MaxTime2ReachHome[s]", 100)); 847 845 848 lout<< "SETHOME DONE" << endl;846 gLog << "SETHOME DONE" << endl; 849 847 850 848 SetStatus(HasError() ? MDriveCom::kError : MDriveCom::kStopped); … … 860 858 } 861 859 //cout << "WM_Home: done. (return 0x403e)" << endl; 862 return (void*)0x403e;860 return 0x403e; 863 861 864 862 case WM_CALCALTAZ: … … 872 870 RaDec rd(xy.X()*15., xy.Y()); // [deg] 873 871 874 ZdAz a1 = sla.CalcZdAz(rd* kDeg2Rad); // [rad]872 ZdAz a1 = sla.CalcZdAz(rd*TMath::DegToRad()); // [rad] 875 873 876 874 cout << "Ra/Dec source: " << xy.X() << "h " << xy.Y() << "°" << endl; 877 cout << "Zd/Az target: " << a1.Zd()* kRad2Deg << "° " << a1.Az()*kRad2Deg<< "°" << endl;875 cout << "Zd/Az target: " << a1.Zd()*TMath::RadToDeg() << "° " << a1.Az()*TMath::RadToDeg() << "°" << endl; 878 876 879 877 if (fZd1 && fZd2 && fAz) … … 882 880 a1 = fBending(a1); 883 881 CheckRange(a1); 884 a1 *= kRad2Deg;882 a1 *= TMath::RadToDeg(); 885 883 886 884 const ZdAz a2 = a1*kResSE/360; … … 889 887 cout << "SE bended: " << a2.Zd() << " " << a2.Az() << endl; 890 888 } 891 return (void*)0xa17a;889 return 0xa17a; 892 890 893 891 case WM_ENDSWITCH: 894 892 { 895 893 ZdAz pos = GetSePos()*TMath::TwoPi()/kResSE; 896 pos = fBending.SubtractOffsets(pos)* kRad2Deg;894 pos = fBending.SubtractOffsets(pos)*TMath::RadToDeg(); 897 895 898 896 cout << "Endswitch Position: Zd=" << pos.Zd() << "° Az="; … … 900 898 } 901 899 902 return (void*)0x1010;900 return 0x1010; 903 901 904 902 case WM_QUIT: … … 906 904 if (!CheckNetwork()) 907 905 { 908 lout<< "ERROR: Cannot shutdown CANbus network." << endl;909 return (void*)0xebb0;906 gLog << "ERROR: Cannot shutdown CANbus network." << endl; 907 return 0xebb0; 910 908 } 911 909 TerminateApp(); 912 910 cout << "WM_Quit: done." << endl; 913 return (void*)0xaaaa;911 return 0xaaaa; 914 912 } 915 913 cout << "MCosy::Proc: Unknown message 0x" << msg << endl; 916 return (void*)0xffffffff;917 } 918 919 void *MTTalk::Thread()914 return 0xffffffff; 915 } 916 917 Int_t MTTalk::Thread() 920 918 { 921 919 fCosy->TalkThread(); 922 return NULL;920 return 0; 923 921 } 924 922 … … 942 940 cout << " * Max: " << zmax << "deg " << amax << "deg" << endl; 943 941 944 fMin = fBending.AddOffsets(fMin/ kRad2Deg);945 fMax = fBending.AddOffsets(fMax/ kRad2Deg);946 947 cout << " * Min': " << fMin.Zd()* kRad2Deg << "deg " << fMin.Az()*kRad2Deg<< "deg" << endl;948 cout << " * Max': " << fMax.Zd()* kRad2Deg << "deg " << fMax.Az()*kRad2Deg<< "deg" << endl;942 fMin = fBending.AddOffsets(fMin/TMath::RadToDeg()); 943 fMax = fBending.AddOffsets(fMax/TMath::RadToDeg()); 944 945 cout << " * Min': " << fMin.Zd()*TMath::RadToDeg() << "deg " << fMin.Az()*TMath::RadToDeg() << "deg" << endl; 946 cout << " * Max': " << fMax.Zd()*TMath::RadToDeg() << "deg " << fMax.Az()*TMath::RadToDeg() << "deg" << endl; 949 947 950 948 cout << "Reading gear ratios..." << flush; 951 kGear.X(env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0)); 952 kGear.Y(env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0)); 953 949 // kGear.X(env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0)); 950 // kGear.Y(env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0)); 951 kGear.Set(env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0), 952 env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0)); 953 954 Bool_t mac1 = fMac1 && !fMac1->IsZombieNode(); 955 Bool_t mac2 = fMac2 && !fMac2->IsZombieNode(); 956 Bool_t mac3 = fMac3 && !fMac3->IsZombieNode(); 957 958 Bool_t zd1 = fZd1 && !fZd1->IsZombieNode(); 959 Bool_t zd2 = fZd2 && !fZd2->IsZombieNode(); 960 Bool_t az = fAz && !fAz->IsZombieNode(); 961 962 Double_t x = 0; 963 Double_t y = 0; 964 y = mac1 ? fMac1->GetRes() : (mac3 ? fMac3->GetRes() : env.GetValue("Az_ResRE[re/U_mot]", 1500)); 965 x = mac2 ? fMac2->GetRes() : env.GetValue("Zd_ResRE[re/U_mot]", 1500); 966 kResRE.Set(x,y); 967 968 x = zd1 ? fZd1->GetPhysRes() : (zd2 ? fZd2->GetPhysRes() : env.GetValue("Zd_ResSE[se/U_mot]", 16384)); 969 y = az ? fAz->GetPhysRes() : env.GetValue("Az_ResSE[se/U_mot]", 16384); 970 kResSE.Set(x,y); 971 972 /* 954 973 kResRE.Y(0); 955 974 if (fMac1 && !fMac1->IsZombieNode()) 956 975 kResRE.Y(fMac1->GetRes()); 957 976 else 977 y = fMac3 && !fMac3->IsZombieNode() ? fMac3->GetRes() : env.GetValue("Az_ResRE[re/U_mot]", 1500); 958 978 if (fMac3 && !fMac3->IsZombieNode()) 959 979 kResRE.Y(fMac3->GetRes()); … … 981 1001 else 982 1002 kResSE.Y(env.GetValue("Az_ResSE[se/U_mot]", 16384)); 1003 */ 983 1004 984 1005 // believing the Macs manual '*4' shouldn't be necessary, but it is. … … 986 1007 // Calculating speeds we have to convert back to qc 987 1008 kResRE *= 4; 988 kGearTot = kResRE*kGear; 1009 kGearTot = Mul(kResRE, kGear); 1010 // kGearTot = kResRE*kGear; 989 1011 990 1012 cout << "done." << endl; … … 1000 1022 if (!fMac3) 1001 1023 { 1002 lout<< "Unable to Init Sync! Mac3 not available." << endl;1024 gLog << "Unable to Init Sync! Mac3 not available." << endl; 1003 1025 return; 1004 1026 } … … 1019 1041 if (fHist) 1020 1042 { 1021 lout<< "You are much too fast... try again." << endl;1043 gLog << "You are much too fast... try again." << endl; 1022 1044 return; 1023 1045 } … … 1032 1054 int cnt = 0; 1033 1055 1034 lout<< "Starting Shaftencoder Test..." << endl;1056 gLog << "Starting Shaftencoder Test..." << endl; 1035 1057 1036 1058 while (fBackground==kBgdSeTest) … … 1041 1063 while (!fZd1->PosHasChanged() && !fZd2->PosHasChanged() && 1042 1064 fBackground==kBgdSeTest) 1065 { 1043 1066 usleep(1); 1067 TThread::CancelPoint(); 1068 } 1044 1069 1045 1070 const Double_t pos[3] = { … … 1064 1089 Double_t apos = (pos[0]-pos[1])/2 * TMath::TwoPi() / kResSE.X(); 1065 1090 1066 ZdAz bend = fBending.CorrectBack(ZdAz(apos, pos[2]))* kRad2Deg;1091 ZdAz bend = fBending.CorrectBack(ZdAz(apos, pos[2]))*TMath::RadToDeg(); 1067 1092 fHist->Fill(bend.Zd(), pos[0]+pos[1]-offset); 1068 1093 } 1069 1094 1070 lout<< "Shaftencoder Test Stopped... displaying Histogram." << endl;1095 gLog << "Shaftencoder Test Stopped... displaying Histogram." << endl; 1071 1096 1072 1097 fBackground=kBgdSeTestDispl; … … 1080 1105 if (fHist) 1081 1106 { 1082 lout<< "You are much too fast... try again." << endl;1107 gLog << "You are much too fast... try again." << endl; 1083 1108 return; 1084 1109 } … … 1093 1118 fHist->SetZTitle("Re/Se"); 1094 1119 1095 lout<< "Starting Gear determination..." << endl;1120 gLog << "Starting Gear determination..." << endl; 1096 1121 1097 1122 ZdAz se0 = GetSePos(); … … 1106 1131 while (!fZd1->PosHasChanged() && !fZd2->PosHasChanged() && 1107 1132 !fAz->PosHasChanged() && fBackground==kBgdGear) 1133 { 1108 1134 usleep(1); 1135 TThread::CancelPoint(); 1136 } 1109 1137 1110 1138 ZdAz se = GetSePos(); … … 1121 1149 se -= dse/2; 1122 1150 1123 ZdAz bend = fBending.CorrectBack(se*TMath::TwoPi()/kResSE)* kRad2Deg;1151 ZdAz bend = fBending.CorrectBack(se*TMath::TwoPi()/kResSE)*TMath::RadToDeg(); 1124 1152 ((TH3*)fHist)->Fill(bend.Zd(), bend.Az(), dre.Zd()/dse.Zd()); 1125 1153 } … … 1132 1160 se -= dse/2; 1133 1161 1134 ZdAz bend = fBending.CorrectBack(se*TMath::TwoPi()/kResSE)* kRad2Deg;1162 ZdAz bend = fBending.CorrectBack(se*TMath::TwoPi()/kResSE)*TMath::RadToDeg(); 1135 1163 ((TH3*)fHist)->Fill(bend.Az(), bend.Az(), dre.Az()/dse.Az()); 1136 1164 } 1137 1165 } 1138 lout<< "Gear Test Stopped... displaying Histogram." << endl;1166 gLog << "Gear Test Stopped... displaying Histogram." << endl; 1139 1167 1140 1168 fBackground=kBgdGearDispl; … … 1170 1198 // 1171 1199 while (fBackground==kBgdNone) 1200 { 1172 1201 usleep(1); 1202 TThread::CancelPoint(); 1203 } 1173 1204 1174 1205 switch (fBackground) … … 1213 1244 if (rc) 1214 1245 { 1215 lout<< "* GUI update skipped due to locked mutex." << endl;1246 gLog << "* GUI update skipped due to locked mutex." << endl; 1216 1247 return kTRUE; 1217 1248 } … … 1251 1282 fRaDec, fZdAzSoll, fStatus, avail); 1252 1283 1253 lout.UpdateGui();1284 gLog.UpdateGui(); 1254 1285 1255 1286 const Bool_t trigger = fTriggerDisplay; … … 1270 1301 void MCosy::DisplayHistTestSe(Bool_t del) 1271 1302 { 1272 lout<< "Displaying histogram..." << endl;1303 gLog << "Displaying histogram..." << endl; 1273 1304 1274 1305 TH2F &hist = *(TH2F*)fHist; … … 1308 1339 void MCosy::DisplayHistGear(Bool_t del) 1309 1340 { 1310 lout<< "Displaying histogram..." << endl;1341 gLog << "Displaying histogram..." << endl; 1311 1342 1312 1343 TH3F &hist = *(TH3F*)fHist; … … 1402 1433 ReadConfig(); 1403 1434 1404 lout<< "- Starting TX Thread." << endl;1435 gLog << "- Starting TX Thread." << endl; 1405 1436 fTTalk = new MTTalk(this); 1406 1437 1407 lout<< "- Starting GUI update." << endl;1438 gLog << "- Starting GUI update." << endl; 1408 1439 fUpdateGui->TurnOn(); 1409 1440 } … … 1419 1450 void MCosy::Stop() 1420 1451 { 1421 lout<< "- Stopping GUI update." << endl;1452 gLog << inf << "- Stopping GUI update." << endl; 1422 1453 fUpdateGui->TurnOff(); 1423 lout << "- GUI Update stopped." << endl; 1424 1454 gLog << inf << "- GUI Update stopped." << endl; 1455 1456 gLog << inf << "- Stopping TX Thread." << endl; 1425 1457 delete fTTalk; 1426 lout << "- TX Thread stopped." << endl; 1427 1458 gLog << inf << "- TX Thread stopped." << endl; 1459 1460 gLog << inf << "- Stopping CAN network." << endl; 1428 1461 Network::Stop(); 1462 gLog << inf << "- CAN network stopped." << endl; 1463 1464 gLog << inf << "- Stopping message queue." << endl; 1465 CancelThread(); 1466 gLog << inf << "- Message queue stopped." << endl; 1429 1467 } 1430 1468 … … 1439 1477 // Create Nodes 1440 1478 // 1441 lout<< "- Setting up network." << endl;1442 1443 fMac1=new Macs(id1, "Mac/Az", lout);1444 fMac2=new Macs(id3, "Mac/Zd", lout);1479 gLog << "- Setting up network." << endl; 1480 1481 fMac1=new Macs(id1, "Mac/Az", gLog); 1482 fMac2=new Macs(id3, "Mac/Zd", gLog); 1445 1483 if (id2>=0) 1446 fMac3=new Macs(id2, "Mac/Az-Sync", lout);1447 1448 fZd1=new ShaftEncoder(id4, "SE/Zd1", lout);1449 fZd2=new ShaftEncoder(id5, "SE/Zd2", lout);1450 fAz =new ShaftEncoder(id6, "SE/Az", lout);1484 fMac3=new Macs(id2, "Mac/Az-Sync", gLog); 1485 1486 fZd1=new ShaftEncoder(id4, "SE/Zd1", gLog); 1487 fZd2=new ShaftEncoder(id5, "SE/Zd2", gLog); 1488 fAz =new ShaftEncoder(id6, "SE/Az", gLog); 1451 1489 1452 1490 fZd1->SetReport(fOutRep); … … 1458 1496 fZd2->SetMotor(fMac2); 1459 1497 1460 lout<< "- Connecting devices to network." << endl;1498 gLog << "- Connecting devices to network." << endl; 1461 1499 1462 1500 // … … 1474 1512 // Create Gui Event timer and Gui 1475 1513 // 1476 lout<< "- Initializing GUI Timer." << endl;1514 gLog << "- Initializing GUI Timer." << endl; 1477 1515 fUpdateGui = new TTimer(this, 100); // 100ms 1478 1516 1479 lout<< "- Starting GUI." << endl;1517 gLog << "- Starting GUI." << endl; 1480 1518 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1481 1519 } … … 1486 1524 // Create Nodes 1487 1525 // 1488 lout<< "- Setting up network." << endl;1489 1490 fZd1=new ShaftEncoder(id4, "SE/Zd1", lout);1491 fZd2=new ShaftEncoder(id5, "SE/Zd2", lout);1492 fAz =new ShaftEncoder(id6, "SE/Az", lout);1493 1494 lout<< "- Connecting devices to network." << endl;1526 gLog << "- Setting up network." << endl; 1527 1528 fZd1=new ShaftEncoder(id4, "SE/Zd1", gLog); 1529 fZd2=new ShaftEncoder(id5, "SE/Zd2", gLog); 1530 fAz =new ShaftEncoder(id6, "SE/Az", gLog); 1531 1532 gLog << "- Connecting devices to network." << endl; 1495 1533 1496 1534 // … … 1504 1542 // Create Gui Event timer and Gui 1505 1543 // 1506 lout<< "- Initializing GUI Timer." << endl;1544 gLog << "- Initializing GUI Timer." << endl; 1507 1545 fUpdateGui = new TTimer(this, 100); // 100ms 1508 1546 1509 lout<< "- Starting GUI." << endl;1547 gLog << "- Starting GUI." << endl; 1510 1548 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1511 1549 } … … 1516 1554 // Create Nodes 1517 1555 // 1518 lout<< "- Setting up network." << endl;1556 gLog << "- Setting up network." << endl; 1519 1557 1520 1558 // 1521 1559 // Create Gui Event timer and Gui 1522 1560 // 1523 lout<< "- Initializing GUI Timer." << endl;1561 gLog << "- Initializing GUI Timer." << endl; 1524 1562 fUpdateGui = new TTimer(this, 100); // 100ms 1525 1563 1526 lout<< "- Starting GUI." << endl;1564 gLog << "- Starting GUI." << endl; 1527 1565 fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1); 1528 1566 } … … 1562 1600 } 1563 1601 1564 MCosy::MCosy(/*int mode,*/ const char *dev, const int baud, MLog &out) 1565 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fStarguider(NULL), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone), fStatus(MDriveCom::kStopped), fOutTp(0), fOutRep(0) 1602 MCosy::MCosy() 1603 : Network(), fObservatory(MObservatory::kMagic1), fStarguider(NULL), 1604 fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), 1605 fBackground(kBgdNone), fTriggerDisplay(kFALSE), fStatus(MDriveCom::kStopped), 1606 fOutTp(0), fOutRep(0) 1566 1607 { 1567 1608 TEnv env(".cosyrc"); … … 1582 1623 1583 1624 /* 1584 lout<< "- Program in ";1625 gLog << "- Program in "; 1585 1626 switch (mode) 1586 1627 { 1587 1628 case 0: 1588 lout<< "<<Standard mode>>" << endl;*/1629 gLog << "<<Standard mode>>" << endl;*/ 1589 1630 fBending.Load("bending.txt"); 1590 1631 Constructor(id1, id2, id3, id4, id5, id6);/* 1591 1632 break; 1592 1633 case 1: 1593 lout<< "<<SE mode>>" << endl;1634 gLog << "<<SE mode>>" << endl; 1594 1635 fBending.Load("bending.txt"); 1595 1636 ConstructorSE(id4, id5, id6); 1596 1637 break; 1597 1638 default: 1598 lout<< "<<Demo mode>>" << endl;1639 gLog << "<<Demo mode>>" << endl; 1599 1640 ConstructorDemo(); 1600 1641 } 1601 1642 */ 1602 lout.SetOutputGui(fWin->GetLog(), kTRUE);1643 gLog.SetOutputGui(fWin->GetLog(), kTRUE); 1603 1644 1604 1645 fZd1->SetDisplay(fWin->GetLabel2()); … … 1606 1647 fAz->SetDisplay(fWin->GetLabel1()); 1607 1648 1608 fCom = new MDriveCom(this, *fOutRep);1609 fCom->Start();1649 fCom = new MDriveCom(this, fOutRep); 1650 // fCom->Start(); 1610 1651 } 1611 1652 … … 1623 1664 */ 1624 1665 1625 lout.DisableOutputDevice(MLog::eGui);1666 gLog.DisableOutputDevice(MLog::eGui); 1626 1667 // FIXME: WHY DOES THIS CRASH THE APPLICATIOn WHILE TRAKING? 1627 // lout.SetOutputGui(NULL, kFALSE);1668 // gLog.SetOutputGui(NULL, kFALSE); 1628 1669 1629 1670 gApplication->Terminate(0); … … 1632 1673 MCosy::~MCosy() 1633 1674 { 1675 cout << "Deleting GUI timer." << endl; 1676 // FIXME: Wait until last Update was finished!!! 1677 delete fUpdateGui; 1678 1679 //fMutexGui.Lock(); 1680 1681 // Now the files can safely be closed 1682 cout << "Closing output files." << endl; 1634 1683 if (fOutTp) 1635 1684 { … … 1639 1688 delete fOutRep; 1640 1689 1641 cout << "Deleting GUI timer." << endl; 1642 1643 delete fUpdateGui; 1690 cout << "Deleting CC communication." << endl; 1644 1691 delete fCom; 1645 1692 1646 1693 cout << "Deleting Nodes." << endl; 1647 1648 1694 fZd1->SetReport(0); 1649 1695 fZd2->SetReport(0); … … 1660 1706 cout << "Deleting MGCosy." << endl; 1661 1707 1662 lout.DisableOutputDevice(MLog::eGui);1708 gLog.DisableOutputDevice(MLog::eGui); 1663 1709 1664 1710 delete fWin; -
trunk/MagicSoft/Cosy/main/MCosy.h
r7788 r8833 2 2 #define COSY_MCosy 3 3 4 #include "coord.h"4 //#include "coord.h" 5 5 #include "msgqueue.h" 6 #include "MPointing.h" 7 8 #ifndef MARS_MThread 9 #define COSY_MThread 6 10 #include "MThread.h" 7 # include "MBending.h"11 #endif 8 12 9 13 #ifndef COSY_Network … … 49 53 class MDriveCom; 50 54 51 class MTTalk : public M Thread55 class MTTalk : public MyThreadX 52 56 { 53 57 private: 54 58 MCosy *fCosy; 55 59 56 void *Thread();60 Int_t Thread(); 57 61 58 62 public: 59 MTTalk(MCosy *cosy) : M Thread(false), fCosy(cosy)60 { 61 SetPriority(10);62 Detach();63 Start();63 MTTalk(MCosy *cosy) : MyThreadX("MTTalk"), fCosy(cosy) 64 { 65 //SetPriority(10); 66 //Detach(); 67 RunThread(); 64 68 } 65 ~MTTalk() { std::cout << "~MTTalk::MTTalk" << std::endl; } 69 ~MTTalk() 70 { 71 std::cout << "~MTTalk::CancelThread" << std::endl; 72 CancelThread(); 73 std::cout << "~MTTalk::MTTalk" << std::endl; 74 } 66 75 }; 67 76 … … 70 79 { 71 80 friend class MTTalk; 72 friend class M Pointing;81 friend class MSlewing; 73 82 friend class MTracking; 74 83 … … 125 134 XY kGearTot; // describing the resolution of the system [re/U_tel] 126 135 127 M Bending fBending;136 MPointing fBending; 128 137 129 138 UInt_t fStatus; … … 176 185 177 186 public: 178 MCosy( /*int mode,*/ const char *dev, const int baud, MLog &out=gLog);187 MCosy(); 179 188 ~MCosy(); 180 189 … … 182 191 void Stop(); 183 192 184 void *Proc(int msg, void *mp);193 Int_t Proc(int msg, void *mp); 185 194 186 195 Bool_t HandleTimer(TTimer *t);
Note:
See TracChangeset
for help on using the changeset viewer.