- Timestamp:
- 12/18/02 20:35:52 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/base/BaseLinkDef.h
r1531 r1691 8 8 #pragma link C++ class MLog; 9 9 #pragma link C++ class MStar+; 10 #pragma link C++ class MGList+; 10 11 11 12 #endif -
trunk/MagicSoft/Cosy/base/Makefile
r1531 r1691 40 40 MLog.cc \ 41 41 MLogManip.cc \ 42 MGList.cc \ 42 43 timer.cc 43 44 44 45 CINTHEADERS = MStar.h \ 46 MGList.h \ 45 47 MLog.h \ 46 48 MLogManip.h -
trunk/MagicSoft/Cosy/catalog/SlaStars.cc
r1275 r1691 40 40 slaMappa(2000.0, mjd, fAmprms); 41 41 slaAoppa(mjd, 0, // mjd, UT1-UTC 42 GetElong(), GetPhi(), 148, // göttingen long, lat, height 42 // GetElong(), GetPhi(), 148, // göttingen long, lat, height 43 GetElong(), GetPhi(), 300, // göttingen long, lat, height 43 44 0, 0, // polar motion x, y-coordinate (radians) 44 273.155, 1013.25, 0.5, // temp, pressure, humidity 45 0.2, 0.0065, // wavelength, tropo lapse rate 45 // 273.155, 1013.25, 0.5, // temp, pressure, humidity 46 273.155+20, 1013.25, 0.5, // temp, pressure, humidity 47 // 0.2, 0.0065, // wavelength, tropo lapse rate 48 0.55, 0.0065, // wavelength, tropo lapse rate 46 49 fAoprms); 47 50 } -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1275 r1691 26 26 typedef struct tm tm_t; 27 27 28 #define GEAR_RATIO_ALT 75.55 // 75.25 VERY IMPORTANT! unit=RE/SE 29 #define GEAR_RATIO_AZ 179.8 // VERY IMPORTANT! unit=RE/SE 30 31 const XY kGearRatio(GEAR_RATIO_ALT, GEAR_RATIO_AZ); 32 const XY kGearRatio2(GEAR_RATIO_ALT*16384.0/360.0, GEAR_RATIO_AZ*16384.0/360.0); 33 34 double Rad2SE(double rad) 28 /* 29 #define GEAR_RATIO_ALT 2475.6 // [U_mot/U_tel(360deg)] 30 #define GEAR_RATIO_AZ 5891.7 // [U_mot/U_tel(360deg)] 31 32 #define RES_RE 500 // [re/U_mot] 33 #define RES_SE 16384 // [se/U_tel(360deg)] 34 */ 35 /* 36 #define GEAR_RATIO_ALT (75.55*16384/1500) // 75.25 VERY IMPORTANT! unit=U_mot/U_tel 37 #define GEAR_RATIO_AZ (179.8*16384/1500) // VERY IMPORTANT! unit=U_mot/U_tel 38 */ 39 40 //const XY kGearRatio (GEAR_RATIO_ALT*RES_RE/RES_SE, GEAR_RATIO_AZ*RES_RE/RES_SE); //[re/se] 41 //const XY kGearRatio2(GEAR_RATIO_ALT*RES_RE/360.0, GEAR_RATIO_AZ*RES_RE/360.0); //[re/deg] 42 43 double MCosy::Rad2SE(double rad) const 35 44 { 36 45 return 16384.0/k2Pi*rad; 37 46 } 38 47 39 double Rad2ZdRE(double rad)48 double MCosy::Rad2ZdRE(double rad) const 40 49 { 41 50 return 16384.0/k2Pi*rad*kGearRatio.X(); 42 51 } 43 52 44 double Rad2AzRE(double rad)53 double MCosy::Rad2AzRE(double rad) const 45 54 { 46 55 return 16384.0/k2Pi*rad*kGearRatio.Y(); 47 56 } 48 57 49 double Deg2ZdRE(double rad)58 double MCosy::Deg2ZdRE(double rad) const 50 59 { 51 60 return rad*kGearRatio2.X(); 52 61 } 53 62 54 double Deg2AzRE(double rad)63 double MCosy::Deg2AzRE(double rad) const 55 64 { 56 65 return rad*kGearRatio2.Y(); … … 72 81 ZdAz dest = dst * kRad2Deg; 73 82 83 if (dest.Zd()>-3 && dest.Zd()<3) 84 dest.Zd(dest.Zd()<0?-3:3); 85 74 86 if (dest.Zd()>-1e-6 && dest.Zd()<1e-6) 75 87 return dst*(16384.0/k2Pi); … … 138 150 // Get the values 139 151 // 140 const int p0 = fZd1 ->GetPos();141 const int p1 = fZd2 ->GetPos();142 const int p2 = fAz ->GetPos();152 const int p0 = fZd1 ? fZd1->GetPos() : 0; 153 const int p1 = fZd2 ? fZd2->GetPos() : 0; 154 const int p2 = fAz ? fAz->GetPos() : 0; 143 155 144 156 const int a0 = p0; //p0>8192?p0-16384:p0; … … 165 177 Bool_t MCosy::RequestRePos() 166 178 { 179 if (!(fMac1 && fMac2)) 180 return kTRUE; 181 167 182 // 168 183 // Send request … … 201 216 ZdAz MCosy::GetRePos() 202 217 { 203 return ZdAz(fMac2->GetPos(), fMac1->GetPos());218 return fMac1 && fMac2 ? ZdAz(fMac2->GetPos(), fMac1->GetPos()) : ZdAz(0,0); 204 219 } 205 220 … … 363 378 // FIXME: Correct by fOffset ? 364 379 380 if (!(fMac1 && fMac2 && fMac3)) 381 { 382 cout << "SetPosition: No MACS!" << endl; 383 return TRUE; 384 } 385 365 386 // 366 387 // Calculate new target position (shortest distance to go) 367 388 // 368 const ZdAz src = GetSePos(); 369 const ZdAz dest = CorrectTarget(src, dst); 389 const ZdAz src = GetSePos();//*TMath::Pi()*2/16384;; 390 391 // 392 // Because we agreed on I don't search for the shortest move 393 // anymore 394 // 395 // const ZdAz dest = CorrectTarget(src, dst); 396 // 397 const ZdAz dest = fBending(dst)*16384/2/TMath::Pi(); 370 398 371 399 lout << "Positioning to Target..." << endl; 372 400 //cout << "Source Zd: " << src.Zd() << "se Az:" << src.Az() << "se" << endl; 373 401 //cout << "Destination Zd: " << Rad2SE(dst.Zd()) << "se Az:" << Rad2SE(dst.Az()) << "se" << endl; 374 //cout << "Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl;402 cout << "Shortest Dest Zd: " << dest.Zd() << "se Az:" << dest.Az() << "se" << endl; 375 403 376 404 for (int i=0; i<10 && !StopWaitingForSDO(); i++) … … 484 512 void MCosy::InitTracking() 485 513 { 514 if (!(fMac1 && fMac2)) 515 return; 516 486 517 // 487 518 // Start revolution mode … … 608 639 InitTracking(); 609 640 641 XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec())); 642 610 643 lout << "Start tracking:"; 611 lout << " Ra: " << Rad2Deg(dst.Ra()) << "\xb0 "; 612 lout << "Dec: " << Rad2Deg(dst.Dec()) << "\xb0" << endl; 644 lout << " Ra: " << xy.X() << "h " << "Dec: " << xy.Y() << "\xb0" << endl; 645 646 ofstream fout("coordinates.txt"); 647 fout << xy; 648 fout.close(); 613 649 614 650 // 615 651 // Initialize Tracker (slalib or starguider) 616 652 // 617 fRaDec = dst; 653 fRaDec = dst; 654 655 if (!(fMac1 && fMac2 && fMac3)) 656 return; 657 618 658 fTracking = kTRUE; 619 659 620 ofstream fout("log/cosy.pos");621 fout << "Tracking:";622 fout << " Ra: " << Rad2Deg(dst.Ra()) << "\x9c ";623 fout << "Dec: " << Rad2Deg(dst.Dec()) << "\x9c" << endl << endl;624 fout << " Mjd/10ms V/re/min/4" << endl;660 //--- ofstream fout("log/cosy.pos"); 661 //--- fout << "Tracking:"; 662 //--- fout << " Ra: " << Rad2Deg(dst.Ra()) << "\x9c "; 663 //--- fout << "Dec: " << Rad2Deg(dst.Dec()) << "\x9c" << endl << endl; 664 //--- fout << " Mjd/10ms V/re/min/4" << endl; 625 665 626 666 // … … 646 686 // 647 687 sla.SetMjd(sla.CalcMjd()+dt/(60*60*24)); 648 dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); // [se] 649 650 ZdAz vcalc = sla.GetApproxVel(dst) * kGearRatio2*4./60.; // [re/min] 688 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 689 dest = CorrectTarget(GetSePos(), dummy); // [se] 651 690 652 691 // … … 676 715 // 677 716 ZdAz vt = v/4; 717 ZdAz vcalc = sla.GetApproxVel(fRaDec) * kGearRatio2*4./60.; // [re/min] 678 718 LimitSpeed(&vt, vcalc); 679 719 vt.Round(); … … 700 740 fVelocity = vt/kGearRatio2*4; 701 741 702 const double mjd = fMac2->GetMjd();703 fout << setprecision(15) << setw(17) << mjd*60.*60.*24. << " ";704 fout << setw(4) << vt.Zd() << " ";705 fout << setw(4) << vt.Az() << endl;742 //--- const double mjd = fMac2->GetMjd(); 743 //--- fout << setprecision(15) << setw(17) << mjd*60.*60.*24. << " "; 744 //--- fout << setw(4) << vt.Zd() << " "; 745 //--- fout << setw(4) << vt.Az() << endl; 706 746 // 707 747 // FIXME? Calculate an accuracy for the tracking system? … … 716 756 // update time 717 757 // 718 //usleep(50000); // 0.05s758 usleep(50000); // 0.05s 719 759 } 720 760 … … 733 773 void MCosy::StopMovement() 734 774 { 775 if (!fMac1 || !fMac2) 776 return; 735 777 // 736 778 // Set status to stopped … … 780 822 case WM_PRESET: 781 823 cout << "WM_Preset: start." << endl; 782 fZd1->SetPreset();783 fZd2->SetPreset();784 fAz->SetPreset();824 if (fZd1) fZd1->SetPreset(); 825 if (fZd2) fZd2->SetPreset(); 826 if (fAz) fAz->SetPreset(); 785 827 cout << "WM_Preset: done. (return 0xaffe)" << endl; 786 828 return (void*)0xaffe; 787 829 788 case WM_ POLARIS:830 case WM_CALIB: 789 831 { 790 cout << "WM_ Polaris: start." << endl;832 cout << "WM_Calib: start." << endl; 791 833 SlaStars sla; 792 834 sla.SetMjd2Now(); 793 835 794 RaDec rd(37.94, 89.2644); 836 RaDec rd = *((RaDec*)mp); 837 838 //RaDec rd(37.94, 89.2644); // POLARIS 839 //RaDec rd(213.915417, 19.1825); // ACTURUS 840 841 cout << "Calibrating to: " << rd.Ra()*24/360 << "h " << rd.Dec() << "°" << endl; 842 795 843 ZdAz za=sla.CalcZdAz(rd*kDeg2Rad)*16384.0/k2Pi; 796 844 … … 800 848 cout << "Got Zd: " << sepos.Zd() << " Az: " << sepos.Az() << endl; 801 849 802 fZd1->SetPreset(za.Zd()); 803 fZd2->SetPreset(-za.Zd()); 804 fAz->SetPreset(za.Az()); 850 if (fZd1) 851 fZd1->SetPreset(za.Zd()); 852 if(fZd2) 853 fZd2->SetPreset(-za.Zd()); 854 if(fAz) 855 fAz->SetPreset(za.Az()); 805 856 806 857 cout << "WM_Polaris: done. (return 0xaffe)" << endl; 807 858 } 808 859 return (void*)0xaffe; 860 861 case WM_TPOINT: 862 { 863 cout << "WM_TPoint: start." << endl; 864 SlaStars sla; 865 sla.SetMjd2Now(); 866 867 RaDec rd = *((RaDec*)mp); 868 cout << "TPoint Star: " << rd.Ra()/15 << "h " << rd.Dec() << "°" << endl; 869 870 AltAz za=sla.CalcAltAz(rd*kDeg2Rad)*kRad2Deg; 871 872 cout << " Alt/Az: " << za.Alt() << "° " << za.Az() << "°" << endl; 873 *tpout << za.Az() << " " << za.Alt() << " "; 874 875 ZdAz sepos = GetSePos()*TMath::Pi()*2/16384;; 876 za.Set(TMath::Pi()/2-sepos.Zd(), sepos.Az()); 877 za *= kRad2Deg; 878 879 cout << " SE-Pos: " << za.Alt() << "° " << za.Az() << "°" << endl; 880 *tpout << fmod(za.Az()+360, 360) << " " << za.Alt() << endl; 881 882 cout << "WM_TPoint: done. (return 0xaffe)" << endl; 883 } 884 return (void*)0xca1b; 809 885 810 886 case WM_POSITION: … … 827 903 return (void*)0x8888; 828 904 905 case WM_NEWTRACK: 906 cout << "WM_NewTrack: START" << endl; 907 fRaDec = *((RaDec*)mp); 908 cout << "WM_NewTrack: done. (return 0x9999)" << endl; 909 return (void*)0x9999; 910 911 case WM_LOADBENDING: 912 cout << "WM_LoadBending: START" << endl; 913 fBending.Load("bending.txt"); 914 cout << "WM_LoadBending: done. (return 0xbe0d)" << endl; 915 return (void*)0xbe0d; 916 917 case WM_CALCALTAZ: 918 { 919 cout << endl; 920 921 SlaStars sla; 922 sla.SetMjd2Now(); 923 924 XY xy = *((XY*)mp); 925 RaDec rd(xy.X()*15., xy.Y()); 926 927 ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad); 928 ZdAz a1 = fBending(a0); 929 ZdAz se = CorrectTarget(GetSePos(), a1); 930 a0 *= kRad2Deg; 931 a1 *= kRad2Deg; 932 ZdAz a2 = a1*16384/360; 933 cout << "Ra/Dec source: " << xy.X() << "h " << xy.Y() << "°" << endl; 934 cout << "Zd/Az source: " << a0.Zd() << "° " << a0.Az() << "°" << endl; 935 cout << "Zd/Az bended: " << a1.Zd() << "° " << a1.Az() << "°" << endl; 936 cout << "SE bended: " << a2.Zd() << " " << a2.Az() << endl; 937 cout << "SE target: " << se.Zd() << " " << se.Az() << endl; 938 } 939 return (void*)0xa17a; 940 829 941 case WM_QUIT: 830 942 cout << "WM_Quit: now." << endl; 831 943 TerminateApp(); 832 944 cout << "WM_Quit: done." << endl; 833 return (void*)0x 9999;945 return (void*)0xaaaa; 834 946 } 835 947 cout << "Unknown Msg" << endl; … … 843 955 } 844 956 957 void MCosy::ReadConfig() 958 { 959 cout << "Reading configuration file..." << flush; 960 TEnv env(".cosyrc"); 961 cout << "done." << endl; 962 963 cout << "Reading gear ratios..." << flush; 964 const Double_t gaz = env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0); 965 const Double_t gzd = env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0); 966 967 Double_t resreaz = 0; 968 if (fMac1) 969 resreaz = fMac1->GetRes(); 970 else 971 if (fMac3) 972 resreaz = fMac3->GetRes(); 973 else 974 resreaz = env.GetValue("Az_ResRE[re/U_mot]", 1500); 975 976 Double_t resrezd = 0; 977 if (fMac2) 978 resrezd = fMac2->GetRes(); 979 else 980 resrezd = env.GetValue("Zd_ResRE[re/U_mot]", 1500); 981 982 Double_t ressezd = 0; 983 if (fZd1) 984 ressezd = fZd1->GetPhysRes(); 985 else 986 if (fZd2) 987 ressezd = fZd2->GetPhysRes(); 988 else 989 ressezd = env.GetValue("Zd_ResSE[se/U_mot]", 16384); 990 991 Double_t resseaz = 0; 992 if (fAz) 993 resseaz = fAz->GetPhysRes(); 994 else 995 resseaz = env.GetValue("Az_ResSE[se/U_mot]", 16384); 996 997 kGearRatio.Set (gzd*resrezd/ressezd, gaz*resreaz/resseaz); //[re/se] 998 kGearRatio2.Set(gzd*resrezd/360.0, gaz*resreaz/360.0); //[re/deg] 999 cout << "done." << endl; 1000 } 1001 845 1002 void MCosy::TalkThread() 846 1003 { 1004 if (!(fMac1 && fMac2 && fMac3)) 1005 return; 1006 1007 fMac1->ReqPos(); 1008 fMac2->ReqPos(); 1009 1010 const int res = fMac3->GetVelRes(); 1011 1012 fMac3->SetVelocity(res); 1013 fMac3->SetAcceleration(res); 1014 fMac3->SetDeceleration(res); 1015 1016 fMac1->EnableTimeout(kTRUE, 500); 1017 fMac2->EnableTimeout(kTRUE, 500); 1018 1019 if (!(fZd1 && fZd2 && fAz)) 1020 return; 1021 1022 /* 847 1023 // 848 1024 // Start the Network … … 872 1048 //cout << "APOS: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 873 1049 874 /* 875 cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < " 876 << Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl; 877 cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < " 878 << env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl; 879 cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < " 880 << Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl; 881 */ 882 1050 //cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < " 1051 //</< Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl; 1052 //cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < " 1053 //<< env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl; 1054 //cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < " 1055 //<< Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl; 883 1056 884 1057 cout << "Setting up software endswitch..." << flush; … … 893 1066 fMac2->EnableTimeout(kTRUE, 500); 894 1067 895 /* 896 fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0))); 897 fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0))); 898 */ 899 // fMac3->StartVelSync(); 900 /* 901 cout << "PostMsg(WM_PRESET)" << endl; 902 void *rc = 903 cout << hex << "WM_PRESET: ret=" << rc << endl; 904 905 RaDec dest = RaDec(45.0, 30.0)*D2PI/360.0; 906 907 cout << "PostMsg(WM_TRACK)" << endl; 908 cout << sizeof(RaDec) << "==" << sizeof(dest) << endl; 909 rc=PostMsg(WM_TRACK, &dest, sizeof(dest)); 910 cout << "DEST killed." << endl; 911 */ 1068 const Double_t gaz = env.GetValue("Az_GearRatio[U_mot/U_tel]"); 1069 const Double_t gzd = env.GetValue("Zd_GearRatio[U_mot/U_tel]"); 1070 1071 const Double_t resreaz = env.GetValue("Az_ResRE[re/U_mot]"); 1072 const Double_t resrezd = env.GetValue("Zd_ResRE[re/U_mot]"); 1073 1074 kGearRatio.Set (gzd*resrezd/RES_SE, gaz*resreaz/RES_SE); //[re/se] 1075 kGearRatio2.Set(gzd*resrezd/360.0, gaz*resreaz/360.0); //[re/deg] 1076 1077 //fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0))); 1078 //fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0))); 1079 // fMac3->StartVelSync(); 1080 1081 //cout << "PostMsg(WM_PRESET)" << endl; 1082 //void *rc = 1083 //cout << hex << "WM_PRESET: ret=" << rc << endl; 1084 1085 //RaDec dest = RaDec(45.0, 30.0)*D2PI/360.0; 1086 1087 //cout << "PostMsg(WM_TRACK)" << endl; 1088 //cout << sizeof(RaDec) << "==" << sizeof(dest) << endl; 1089 //rc=PostMsg(WM_TRACK, &dest, sizeof(dest)); 1090 //cout << "DEST killed." << endl; 1091 912 1092 // AltAz dest = AltAz(45.0, 30.0); 913 1093 // double ra, dec; … … 918 1098 // dest = AltAz(-46.0, 210); 919 1099 // SetPosition(dest); 920 1100 */ 921 1101 SlaStars sla; 922 1102 while (1) … … 928 1108 usleep(1); 929 1109 930 ofstream fout("log/cosy.err");931 fout << "Tracking:";932 fout << " Ra: " << Rad2Deg(fRaDec.Ra()) << "\x9c ";933 fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl;934 fout << " MjdZd/10ms ErrZd/re";935 fout << " MjdAz/10ms ErrAd/re" << endl;1110 //--- ofstream fout("log/cosy.err"); 1111 //--- fout << "Tracking:"; 1112 //--- fout << " Ra: " << Rad2Deg(fRaDec.Ra()) << "\x9c "; 1113 //--- fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl; 1114 //--- fout << " MjdZd/10ms ErrZd/re"; 1115 //--- fout << " MjdAz/10ms ErrAd/re" << endl; 936 1116 937 1117 ZdAz old; … … 1005 1185 { 1006 1186 sla.SetMjd(time.Zd()); 1007 sollzd = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 1187 1188 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1189 sollzd = CorrectTarget(ist, dummy); // [se] 1008 1190 1009 1191 fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight); … … 1013 1195 { 1014 1196 sla.SetMjd(time.Az()); 1015 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se] 1197 1198 ZdAz dummy = fBending(sla.CalcZdAz(fRaDec)); 1199 sollaz = CorrectTarget(ist, dummy); // [se] 1016 1200 1017 1201 fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight); … … 1021 1205 (ist.Az()-sollaz.Az())*kGearRatio.Y()); 1022 1206 1023 fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";1024 fout << setprecision(5) << setw(7) << fTrackingError.Zd() << " ";1025 fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " ";1026 fout << setprecision(5) << setw(7) << fTrackingError.Az() << endl;1207 //--- fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " "; 1208 //--- fout << setprecision(5) << setw(7) << fTrackingError.Zd() << " "; 1209 //--- fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " "; 1210 //--- fout << setprecision(5) << setw(7) << fTrackingError.Az() << endl; 1027 1211 } 1028 1212 1029 fout << endl << endl;1213 //--- fout << endl << endl; 1030 1214 } 1031 1215 } … … 1036 1220 // Update Gui, foremer MTGui. 1037 1221 // 1038 fZd1->DisplayVal();1039 fZd2->DisplayVal();1040 fAz->DisplayVal();1222 if (fZd1) fZd1->DisplayVal(); 1223 if (fZd2) fZd2->DisplayVal(); 1224 if (fAz) fAz->DisplayVal(); 1041 1225 1042 1226 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] … … 1063 1247 Network::Start(); 1064 1248 1249 if (fMac1) 1250 if (fMac1->IsZombieNode()) { delete fMac1; fMac1=NULL; } 1251 if (fMac2) 1252 if (fMac2->IsZombieNode()) { delete fMac2; fMac2=NULL; } 1253 if (fMac3) 1254 if (fMac3->IsZombieNode()) { delete fMac3; fMac3=NULL; } 1255 1256 if (fZd1) 1257 if (fZd1->IsZombieNode()) { delete fZd1; fZd1=NULL; } 1258 else fZd1->SetDisplay(fWin->GetLabel2()); 1259 1260 if (fZd2) 1261 if (fZd2->IsZombieNode()) { delete fZd2; fZd2=NULL; } 1262 else fZd2->SetDisplay(fWin->GetLabel3()); 1263 1264 if (fAz) 1265 if (fAz->IsZombieNode()) { delete fAz; fAz=NULL; } 1266 else fAz->SetDisplay(fWin->GetLabel1()); 1267 1268 ReadConfig(); 1269 1065 1270 lout << "- Starting TX Thread." << endl; 1066 1271 fTTalk = new MTTalk(this); … … 1092 1297 } 1093 1298 1094 MCosy::MCosy(const char *dev, const int baud, MLog &out) 1095 : Network(dev, baud, out), fTracking(kFALSE) 1299 void MCosy::Constructor() 1096 1300 { 1097 1301 // … … 1101 1305 1102 1306 fMac1=new Macs(1, "Mac.1/Az", lout); 1103 fMac2=new Macs(2, "Mac.2/Zd", lout); 1104 fMac3=new Macs(3, "Mac.3/Az-Sync", lout); 1105 1106 fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout); 1107 fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout); 1108 fAz =new ShaftEncoder(6, "SE.6/Az", lout); 1307 fMac3=new Macs(2, "Mac.3/Az-Sync", lout); 1308 fMac2=new Macs(3, "Mac.2/Zd", lout); 1309 1310 fZd1=new ShaftEncoder(5, "SE.5/Zd1", lout); 1311 fZd2=new ShaftEncoder(6, "SE.6/Zd2", lout); 1312 fAz =new ShaftEncoder(7, "SE.7/Az", lout); 1313 1314 lout << "- Connecting devices to network." << endl; 1109 1315 1110 1316 // … … 1132 1338 1133 1339 lout.SetOutputGui(fWin->GetLog(), kTRUE); 1340 } 1341 1342 void MCosy::ConstructorSE() 1343 { 1344 // 1345 // Create Nodes 1346 // 1347 lout << "- Setting up network." << endl; 1348 1349 fZd1=new ShaftEncoder(5, "SE.5/Zd1", lout); 1350 fZd2=new ShaftEncoder(6, "SE.6/Zd2", lout); 1351 fAz =new ShaftEncoder(7, "SE.7/Az", lout); 1352 1353 lout << "- Connecting devices to network." << endl; 1354 1355 // 1356 // Connect the devices to the network 1357 // 1358 SetNode(fZd1); 1359 SetNode(fZd2); 1360 SetNode(fAz); 1361 1362 // 1363 // Create Gui Event timer and Gui 1364 // 1365 lout << "- Initializing GUI Timer." << endl; 1366 fUpdateGui = new TTimer(this, 100); // 100ms 1367 1368 lout << "- Starting GUI." << endl; 1369 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 1370 1371 fAz->SetDisplay(fWin->GetLabel1()); 1372 fZd1->SetDisplay(fWin->GetLabel2()); 1373 fZd2->SetDisplay(fWin->GetLabel3()); 1374 1375 lout.SetOutputGui(fWin->GetLog(), kTRUE); 1376 } 1377 1378 void MCosy::ConstructorDemo() 1379 { 1380 // 1381 // Create Nodes 1382 // 1383 lout << "- Setting up network." << endl; 1384 1385 /* 1386 fMac1=new Macs(1, "Mac.1/Az", lout); 1387 fMac2=new Macs(2, "Mac.2/Zd", lout); 1388 fMac3=new Macs(3, "Mac.3/Az-Sync", lout); 1389 1390 fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout); 1391 fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout); 1392 fAz =new ShaftEncoder(6, "SE.6/Az", lout); 1393 1394 lout << "- Connecting devices to network." << endl; 1395 1396 // 1397 // Connect the devices to the network 1398 // 1399 SetNode(fMac1); 1400 SetNode(fMac2); 1401 SetNode(fMac3); 1402 SetNode(fZd1); 1403 SetNode(fZd2); 1404 SetNode(fAz); 1405 */ 1406 // 1407 // Create Gui Event timer and Gui 1408 // 1409 lout << "- Initializing GUI Timer." << endl; 1410 fUpdateGui = new TTimer(this, 100); // 100ms 1411 1412 lout << "- Starting GUI." << endl; 1413 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 1414 /* 1415 fAz->SetDisplay(fWin->GetLabel1()); 1416 fZd1->SetDisplay(fWin->GetLabel2()); 1417 fZd2->SetDisplay(fWin->GetLabel3()); 1418 */ 1419 lout.SetOutputGui(fWin->GetLog(), kTRUE); 1420 } 1421 1422 MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out) 1423 : Network(dev, baud, out), fTracking(kFALSE) 1424 { 1425 lout << "- Program in "; 1426 switch (mode) 1427 { 1428 case 0: 1429 lout << "<<Stanard mode>>" << endl; 1430 Constructor(); 1431 break; 1432 case 1: 1433 lout << "<<SE mode>>" << endl; 1434 ConstructorSE(); 1435 break; 1436 default: 1437 lout << "<<Demo mode>>" << endl; 1438 ConstructorDemo(); 1439 } 1440 1441 int i=0; 1442 char name[100]; 1443 while (1) 1444 { 1445 sprintf(name, "/home/tbretz/TPoint/tpoint%03d.txt", i++); 1446 cout << "Testing: " << name << endl; 1447 if (gSystem->AccessPathName(name, kFileExists)) 1448 break; 1449 } 1450 1451 Timer time; 1452 time.Now(); 1453 1454 tpout = new ofstream(name); 1455 *tpout << "Magic Model TPOINT data file" << endl; 1456 *tpout << ": ALTAZ" << endl; 1457 *tpout << "49 48 0 "; 1458 *tpout << time.Year() << " " << time.Month() << " " << time.Day() << " "; 1459 *tpout << /*"20 1013.25 300 0.5 0.55 0.0065" <<*/ endl; 1460 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m) 1134 1461 } 1135 1462 … … 1155 1482 MCosy::~MCosy() 1156 1483 { 1484 *tpout << "END" << endl; 1485 delete tpout; 1486 1157 1487 cout << "Deleting GUI timer." << endl; 1158 1488 … … 1161 1491 cout << "Deleting Nodes." << endl; 1162 1492 1163 delete fAz;1164 delete fZd2;1165 delete fZd1;1166 delete fMac1;1167 delete fMac2;1168 delete fMac3;1493 if (fAz) delete fAz; 1494 if (fZd1) delete fZd1; 1495 if (fZd2) delete fZd2; 1496 if (fMac1) delete fMac1; 1497 if (fMac2) delete fMac2; 1498 if (fMac3) delete fMac3; 1169 1499 1170 1500 cout << "Deleting MGCosy." << endl; -
trunk/MagicSoft/Cosy/main/MCosy.h
r1275 r1691 6 6 #include "network.h" 7 7 #include "MThread.h" 8 #include "MBending.h" 8 9 9 10 #define kDEG ((char)0x9c) // Linux 'ø' 10 11 11 #define WM_WAIT WM_NULL 12 #define WM_PRESET 0x1000 13 #define WM_POSITION 0x1001 14 #define WM_TRACK 0x1002 15 #define WM_STOP 0x1003 16 #define WM_POLARIS 0x1004 12 #define WM_WAIT WM_NULL 13 #define WM_PRESET 0x1000 14 #define WM_POSITION 0x1001 15 #define WM_TRACK 0x1002 16 #define WM_STOP 0x1003 17 #define WM_CALIB 0x1004 18 #define WM_TPOINT 0x1005 19 #define WM_NEWTRACK 0x1006 20 #define WM_LOADBENDING 0x1007 21 #define WM_CALCALTAZ 0x1008 17 22 18 23 class ShaftEncoder; … … 75 80 ZdAz fVelocity; // Actual velocity of Tracking 76 81 82 XY kGearRatio; // describing the gear of the system [re/se] 83 XY kGearRatio2; // describing the gear of the system [re/deg] 84 85 MBending fBending; 86 77 87 UInt_t fStatus; 88 89 ofstream *tpout; 90 91 double Rad2SE(double rad) const; 92 double Rad2ZdRE(double rad) const; 93 double Rad2AzRE(double rad) const; 94 double Deg2ZdRE(double rad) const; 95 double Deg2AzRE(double rad) const; 78 96 79 97 void SetStatus(UInt_t stat) { fStatus = stat; } … … 107 125 void WaitForEndMovement(); 108 126 127 void Constructor(); 128 void ConstructorSE(); 129 void ConstructorDemo(); 130 131 void ReadConfig(); 132 109 133 public: 110 MCosy( const char *dev, const int baud, MLog &out=gLog);134 MCosy(int mode, const char *dev, const int baud, MLog &out=gLog); 111 135 ~MCosy(); 112 136 -
trunk/MagicSoft/Cosy/starg.cc
r924 r1691 7 7 8 8 /* ---------------------------------------------------------------------- */ 9 10 9 //extern void InitGui(); 11 10 //VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; 12 11 12 TROOT root("GUI", "GUI test environement"); //, initfuncs); 13 13 14 int main(int argc, char **argv) 14 15 { 15 TROOT root("GUI", "GUI test environement"); //, initfuncs); 16 17 TApplication app("Starguider", &argc, argv); 16 TApplication *app=new TApplication("Starguider", &argc, argv); 18 17 19 18 MGStarguider starg; … … 21 20 starg.Loop(0); 22 21 23 app .Run();22 app->Run(kTRUE); 24 23 25 24 cout << "Exit." << endl; -
trunk/MagicSoft/Cosy/videodev/Makefile
r1111 r1691 33 33 SRCFILES = Camera.cc \ 34 34 Filter.cc \ 35 Filter2.cc \ 35 36 Writer.cc 36 37 -
trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h
r1111 r1691 7 7 #pragma link C++ class Writer+; 8 8 #pragma link C++ class Filter+; 9 #pragma link C++ class Filter2+; 9 10 10 11 #pragma link C++ class Camera+;
Note:
See TracChangeset
for help on using the changeset viewer.