Changeset 2278
- Timestamp:
- 07/15/03 15:05:21 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 9 added
- 2 deleted
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r2068 r2278 1 1 -*-*- END -*-*- 2 2003/07/15 - Thomas Bretz (La Palma) 3 4 * leds.txt: 5 - new configuration file 6 7 * main/MCaos.[h,cc]: 8 - added 9 10 * main/MStarguider.[h,cc]: 11 - added 12 13 * videodev/PixGetter.[h,cc]: 14 - added 15 16 * videodev/FilterLed.[h,cc]: 17 - added 18 - highly optimized for speed! 19 20 * Makefile.conf.linux: 21 - added -O5 optimization option 22 23 * bending_magic.txt: 24 - changed to newly determined bending correction 25 26 * cosy.cc: 27 - included starguider 28 - do not overwrite log file 29 - added EXPERT mode 30 31 * starg.cc: 32 - changed from MGStarguider to MStarguider 33 - simplified by use of PixGetter 34 35 * aposs/Manual.m: 36 - removed a wrong character 37 38 * base/coord.h: 39 - changed operator<< 40 41 * base/timer.[h,cc]: 42 - const argument for copy constructor 43 - added operator<< 44 45 * candrv/network.[h,cc], candrv/nodedrv.[h,cc]: 46 - added data argument to HandleSDOOK 47 48 * candrv/vmodican.cc: 49 - return from constructor if Module not found 50 51 * caos/Led.[h,cc]: 52 - included TROOT 53 - formated Print-output 54 - Initialize fDx, fDy and fDphi 55 - added AddOffset 56 57 * caos/Leds.[h,cc]: 58 - added Add 59 60 * caos/Ring.[h,cc]: 61 - added constructor 62 - use hypot 63 - devide by n instead of n-1 64 - formated Print-output 65 66 * caos/Rings.[h,cc]: 67 - Do not calculated Center for less than 5 rings 68 - included Radius filter 69 70 * catalog/StarCatalog.cc: 71 - Do not output Alt/Az, fAzCnt, fAltMin, etc. 72 73 * devdrv/macs.[h,cc]: 74 - added data argument to HandleSDOOK 75 - implemented StartNode() and check for initialization 76 - changed minimum MACS software version to 0.69 77 - moved SetNoWait to the MACS software 78 - removed StopMotor 79 80 * devdrv/shaftencoder.[h,cc]: 81 - initialize all values to 0 82 83 * gui/GuiLinkDef.h: 84 - removed MGStarguider 85 86 * gui/MGAccuracy.cc: 87 - small change 88 89 * gui/MGCosy.[h,cc]: 90 - added moving in Zd/Az by buttons while tracking (Experts only) 91 - some changes to the menu bar 92 - removed displaying offsets 93 - changed EXPERT mode 94 95 * gui/MGEmbeddedCanvas.[h,cc]: 96 - changed range argument in constructor to double (problems 97 with the optimization - strange!) 98 99 * gui/MGImage.[h,cc]: 100 - switched from my own code completely to tVirtualX code 101 + requires root 3.05./05! 102 - highly optimized for speed! 103 - at the moment only 32 bit screen depth is supported! 104 105 * gui/MGSkyPosition.[h,cc]: 106 - fixed position of vega 107 - added new bright star 108 - cut displaying position into two. \n not supported by 109 root 3.05/05 110 111 * gui/MGVelocity.[h,cc]: 112 - removed displaying numbers 113 114 * gui/Makefile: 115 - removed MGStarguider 116 117 * main/MCosy.[h,cc]: 118 - added output of time when tracking is started or stopped 119 - added output of time when slewing is started or stopped 120 - removed sign changing limits in LimitSpeed 121 - changed EXPERT mode 122 - added MStarguider support 123 - fixed Calc-Alt/Az 124 - added GetPointingPos 125 - removed fOffset from Update 126 127 * main/MainLinkDef.h, main/Makefile: 128 - added MStarguider 129 130 * main/MStarguider.[h,cc]: 131 - added 132 133 * tpoint/tpointfit.C: 134 - fixed reading of data 135 - removed absolute path 136 137 * videodev/Camera.[h,cc]: 138 - small simplification 139 - derived from new PixGetter 140 141 * videodev/CaosFilter.[h,cc], videodev/Filter.[h,cc]: 142 - optimized, but not used anymore, will be removed soon 143 144 * videodev/Makefile, videodev/VideodevLinkDef.h: 145 - added PixGetter to Makefile 146 - removed Filter 147 - removed Filter2 148 - removed CaosFilter 149 - added FilterLed 150 151 * videodev/PngReader.h: 152 - derived from PixGetter 153 154 155 2 156 2003/05/05 - Thomas Bretz 3 157 -
trunk/MagicSoft/Cosy/Makefile.conf.linux
r1822 r2278 12 12 # compilers 13 13 14 CC 15 CXX 16 F77 17 AR 14 CC = gcc 15 CXX = g++ 16 F77 = f77 17 AR = ar -rc 18 18 # 19 19 # ----->>> settings for compilation … … 21 21 22 22 #-O2 23 OPTIM = -Wall -fno-rtti-fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual -D_REENTRANT24 DEBUG 23 OPTIM = -O5 -Wall -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual -D_REENTRANT 24 DEBUG = -g 25 25 26 MARS_LIB = -Llib $(SUBDIRS:%=-l%)27 INCLUDES 26 MARS_LIB = -Llib $(SUBDIRS:%=-l%) -lX11 -lXpm 27 INCLUDES = -I. $(SUBDIRS:%=-I%) 28 28 29 29 # uncomment this for quiet compilation -
trunk/MagicSoft/Cosy/aposs/Manual.m
r2067 r2278 1 #/* ----------------------------------------------------------------------- */1 /* ----------------------------------------------------------------------- */ 2 2 /* */ 3 3 /* Version: */ -
trunk/MagicSoft/Cosy/base/coord.h
r1760 r2278 74 74 75 75 inline ifstream& operator>>(ifstream &in, XY &xy) { in >> xy.fX; in >> xy.fY; return in; } 76 inline ofstream& operator<<(ofstream &out, XY &xy) { out << xy.fX << " " << xy.fY; return out; }76 inline ofstream& operator<<(ofstream &out, const XY &xy) { out << xy.X() << " " << xy.Y(); return out; } 77 77 78 78 class AltAz : public XY -
trunk/MagicSoft/Cosy/base/timer.cc
r1959 r2278 68 68 } 69 69 70 Timer::Timer( Timer &t)70 Timer::Timer(const Timer &t) 71 71 { 72 72 fMs = t.fMs; … … 124 124 } 125 125 126 Timer::operator double() //[s]126 Timer::operator double() const //[s] 127 127 { 128 128 return fMs+fSecs; … … 142 142 } 143 143 144 ostream &operator<<(ostream &out, Timer &t) 145 { 146 char text[256]; 147 148 sprintf(text, "%d/%02d/%02d %d:%02d:%02d.%01li", 149 t.fYea, t.fMon, t.fDay, t.fHor, t.fMin, t.fSec, (long)(10.0*t.fMs)); 150 151 out << text; 152 return out; 153 } -
trunk/MagicSoft/Cosy/base/timer.h
r1810 r2278 1 #ifndef TIMER_H2 #define TIMER_H1 #ifndef COSY_Timer 2 #define COSY_Timer 3 3 4 4 struct timeval; 5 5 6 class ostream; 7 6 8 class Timer 7 9 { 10 friend ostream &operator<<(ostream &out, Timer &t); 8 11 private: 9 12 double fMs; … … 28 31 Timer(double t); 29 32 Timer(struct timeval *tv); 30 Timer( Timer &t);33 Timer(const Timer &t); 31 34 32 35 void SetTimer(int tv_sec, double tv_usec); … … 54 57 void Print(); 55 58 56 operator double() ; //[s]59 operator double() const; //[s] 57 60 }; 58 61 62 ostream &operator<<(ostream &out, Timer &t); 63 59 64 #endif -
trunk/MagicSoft/Cosy/bending_magic.txt
r1953 r2278 1 MAGIC1 2003/0 3/07 20:40:26.886041 MAGIC1 2003/07/15 13:28:46.783326 2 2 S 00 000000 000000 0000000 3 IA 499.0188249-14 IE - 10.741869-15 CA -0.23939033-16 NPAE 2.3247554-17 AN 0 8 AW -1. 1901258-13 IA 141.81712 -1 4 IE -9.0736584 -1 5 CA 0 -1 6 NPAE 0.14617499 -1 7 AN 0 -1 8 AW -1.5469003 -1 9 9 NRX 0 -1 10 10 NRY 0 -1 … … 15 15 ECEC 0 -1 16 16 ACEC 0 -1 17 MAGIC1 0 -118 MAGIC2 0 -119 17 END -
trunk/MagicSoft/Cosy/candrv/network.cc
r1953 r2278 105 105 106 106 case kSDO_TX_OK: // answer to a SDO_TX message 107 fNodes[node]->HandleSDOOK(idx, subidx, tv);107 fNodes[node]->HandleSDOOK(idx, subidx, data, tv); 108 108 return; 109 109 -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r2019 r2278 144 144 // 145 145 // Print an "SDO idx/subidx set." from this device message. 146 // This output is never redirected to the GUI 147 // 148 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) 146 // This output is never redirected to the GUI. 147 // In standard CANOpen operation data is meaningless (we are using 148 // it in the 'non-standard' CANOpen communication with the MACS) 149 // 150 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv) 149 151 { 150 152 const Bool_t gui = lout.IsOutputDeviceEnabled(MLog::eGui); -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r2019 r2278 69 69 70 70 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 71 virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv);71 virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv); 72 72 virtual void HandleSDOError(LWORD_t data); 73 73 -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r1953 r2278 950 950 cout << "Cannot open device '" << dev << "'... exit." << endl; 951 951 cout << strerror(errno) << endl; 952 return; 952 953 // exit(1); // open module 953 954 } -
trunk/MagicSoft/Cosy/caos/Led.cc
r1802 r2278 2 2 3 3 #include <iostream.h> 4 5 #include <TROOT.h> 4 6 #include <TMath.h> 5 7 … … 16 18 { 17 19 cout << "Led: "; 18 cout << "x=" << fX<< "+-" << fDx << ", ";19 cout << "y=" << fY<< "+-" << fDy << ", ";20 cout << "phi=" << fPhi<< "+-" << fDphi << ", ";20 cout << "x=" << Form("%5.1f", fX) << "+-" << fDx << ", "; 21 cout << "y=" << Form("%5.1f", fY) << "+-" << fDy << ", "; 22 cout << "phi=" << Form("%6.1f", fPhi) << "+-" << fDphi << ", "; 21 23 cout << "mag=" << fMag << endl; 22 24 } -
trunk/MagicSoft/Cosy/caos/Led.h
r1802 r2278 23 23 public: 24 24 Led(Double_t x=0, Double_t y=0, Double_t dx=0, Double_t dy=0, Double_t mag=0) : 25 fX(x), fY(y), f Dx(dx), fDy(dy), fMag(mag)25 fX(x), fY(y), fPhi(0), fDx(dx), fDy(dy), fDphi(-1), fMag(mag) 26 26 { 27 27 } … … 48 48 Double_t GetMag() const { return fMag; } 49 49 50 Bool_t IsSortable() const { return kTRUE; } 50 void AddOffset(Double_t dx, Double_t dy) { fX+=dx; fY+=dy; } 51 52 Bool_t IsSortable() const { return kTRUE; } 51 53 52 54 void CalcPhi(const Ring &ring); -
trunk/MagicSoft/Cosy/caos/Leds.cc
r1802 r2278 12 12 } 13 13 14 void Leds::Add(Double_t x, Double_t y, Double_t dx, Double_t dy, Double_t mag) 15 { 16 Set(GetEntriesFast(), x, y, dx, dy, mag); 17 } 18 14 19 void Leds::Print(Option_t *o=NULL) const 15 20 { -
trunk/MagicSoft/Cosy/caos/Leds.h
r1815 r2278 19 19 // 20 20 21 void Set(Int_t i, Double_t x, Double_t y, Double_t dx, Double_t dy, Double_t mag); 21 void Set(Int_t i, Double_t x, Double_t y, Double_t dx=0, Double_t dy=0, Double_t mag=0); 22 void Add(Double_t x, Double_t y, Double_t dx=0, Double_t dy=0, Double_t mag=0); 22 23 23 24 //nst Led &GetLed(int i) const { return *(Led*)( (*this)[i] ); } -
trunk/MagicSoft/Cosy/caos/Ring.cc
r1882 r2278 9 9 10 10 ClassImp(Ring); 11 12 Ring::Ring() : 13 fX(0), fY(0), fR(0), fPhi(0), fDx(-1), fDy(-1), fDr(-1), fDphi(-1) 14 { 15 } 16 11 17 12 18 bool Ring::CalcCenter(const Leds &leds, Int_t i, Int_t j, Int_t k) … … 53 59 fY = ((m2*(leds(i).GetY() + leds(j).GetY()) +m1*m2*(leds(k).GetX() - leds(i).GetX())-m1*(leds(j).GetY() + leds(k).GetY()))/(m2-m1)/2); 54 60 55 fR = sqrt(sqr(fX-leds(i).GetX())+sqr(fY-leds(i).GetY()));61 fR = hypot(fX-leds(i).GetX(), fY-leds(i).GetY()); 56 62 57 63 return kTRUE; … … 101 107 } 102 108 103 fDx=sqrt(fDx)/ (n-1);104 fDy=sqrt(fDy)/ (n-1);105 fDr=sqrt(fDr)/ (n-1);109 fDx=sqrt(fDx)/n; 110 fDy=sqrt(fDy)/n; 111 fDr=sqrt(fDr)/n; 106 112 } 107 113 … … 109 115 { 110 116 cout << "Ring: "; 111 cout << "x=" << fX << "+-" << fDx<< ", ";112 cout << "y=" << fY << "+-" << fDy<< ", ";113 cout << "r=" << fR << "+-" << fDr<< ", ";114 cout << "phi=" << fPhi << "+-" << fDphi << endl;117 cout << "x=" << Form("%5.1f", fX) << "+-" << Form("%.1f", fDx) << ", "; 118 cout << "y=" << Form("%5.1f", fY) << "+-" << Form("%.1f", fDy) << ", "; 119 cout << "r=" << Form("%5.1f", fR) << "+-" << Form("%.1f", fDr) << ", "; 120 cout << "phi=" << fPhi << "+-" << fDphi << endl; 115 121 } 116 122 -
trunk/MagicSoft/Cosy/caos/Ring.h
r1802 r2278 32 32 33 33 public: 34 Ring(); 34 35 35 36 Double_t GetX() const { return fX; } -
trunk/MagicSoft/Cosy/caos/Rings.cc
r1815 r2278 8 8 ClassImp(Rings); 9 9 10 void Rings::CalcCenters(const Leds &leds )10 void Rings::CalcCenters(const Leds &leds, Float_t min, Float_t max) 11 11 { 12 12 Clear(); 13 13 14 14 int nPoints = leds.GetEntries(); 15 16 if (nPoints<5) 17 return; 15 18 16 19 int n=0; … … 27 30 } 28 31 32 // 33 //filter and remove rings with too big or too small radius 34 // 35 if ((min>=0&&ring.GetR()<min) || (max>=0&&ring.GetR()>max)) 36 { 37 RemoveAt(n); 38 continue; 39 } 40 29 41 n++; 30 42 } … … 33 45 } 34 46 35 void Rings::CalcRings(Leds &leds )47 void Rings::CalcRings(Leds &leds, Float_t min, Float_t max) 36 48 { 37 CalcCenters(leds );49 CalcCenters(leds, min, max); 38 50 39 51 fCenter.InterpolCenters(*this); … … 51 63 { 52 64 cout << "Number of Rings: " << GetEntries() << endl; 53 TClonesArray::Print(); 54 cout << "Center: " << endl; 55 fCenter.Print(); 65 if (GetEntriesFast()>0) 66 { 67 TClonesArray::Print(); 68 cout << "Center: " << endl; 69 fCenter.Print(); 70 } 56 71 } -
trunk/MagicSoft/Cosy/caos/Rings.h
r1815 r2278 17 17 Ring fCenter; 18 18 19 void CalcCenters(const Leds &leds );19 void CalcCenters(const Leds &leds, Float_t min, Float_t max); 20 20 21 21 public: 22 22 Rings() : TClonesArray("Ring", 1) {} 23 23 24 void CalcRings(Leds &leds );24 void CalcRings(Leds &leds, Float_t min=-1, Float_t max=-1); 25 25 26 26 void Print(Option_t *o=NULL) const; -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r1953 r2278 93 93 fAltAz = CalcAltAz(fRaDec); 94 94 95 cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << " ";96 cout << "Az: " << 360.0/D2PI*fAltAz.Az() << endl;95 //cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << " "; 96 //cout << "Az: " << 360.0/D2PI*fAltAz.Az() << endl; 97 97 98 98 CalcRaDecRange(); … … 170 170 fAzCnt++; 171 171 172 cout << "fAzCnt: " << setw(3) << fAzCnt << " " << flush;172 //cout << "fAzCnt: " << setw(3) << fAzCnt << " " << flush; 173 173 174 174 // … … 204 204 } 205 205 206 cout << "fAltMin: " << setw(3) << fAltMin << " ";207 cout << "fAltMax: " << setw(3) << fAltMax << endl;206 //cout << "fAltMin: " << setw(3) << fAltMin << " "; 207 //cout << "fAltMax: " << setw(3) << fAltMax << endl; 208 208 } 209 209 … … 291 291 if (fRa0[x]) 292 292 fRaCnt++; 293 cout << "fRaCnt: " << setw(3) << fRaCnt << " " << flush;293 //cout << "fRaCnt: " << setw(3) << fRaCnt << " " << flush; 294 294 295 295 // … … 323 323 } 324 324 325 cout << "fDecMin: " << setw(3) << fDecMin << " ";326 cout << "fDecMax: " << setw(3) << fDecMax << endl;325 //cout << "fDecMin: " << setw(3) << fDecMin << " "; 326 //cout << "fDecMax: " << setw(3) << fDecMax << endl; 327 327 } 328 328 … … 707 707 } 708 708 709 cout << " " << count+deleted << "-" << deleted << "=" << count << "" << endl;709 cout << "Showing " << count+deleted << "-" << deleted << "=" << count << " stars." << endl; 710 710 } 711 711 -
trunk/MagicSoft/Cosy/cosy.cc
r2019 r2278 11 11 #include "base/timer.h" 12 12 13 #include "Camera.h" 14 #include "PngReader.h" 15 #include "MStarguider.h" 16 17 #define EXPERT 18 13 19 #define clog(txt) \ 14 20 { \ … … 20 26 21 27 TROOT root("Cosy", "Magic Control System"); 28 29 /* ---------------------------------------------------------------------- */ 30 //extern void InitGui(); 31 //VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; 22 32 23 33 int main(int argc, char **argv) … … 37 47 // this must move to MGCosy !!!! (or MApplication) 38 48 // 39 MLog *l = new MLog("log/cosy.log", kTRUE); 49 int i=0; 50 char name[100]; 51 while (1) 52 { 53 sprintf(name, "log/cosy%03d.log", i++); 54 if (gSystem->AccessPathName(name, kFileExists)) 55 break; 56 } 57 58 MLog *l = new MLog(name, kTRUE); 40 59 MLog &lout = *l; 41 60 … … 75 94 76 95 clog("- Starting MCosy."); 96 #ifndef EXPERT 77 97 lout.DisableOutputDevice(MLog::eStdout); 98 #endif 78 99 cosy->Start(); 79 100 101 clog("- Starting Camera."); 102 MStarguider *client=new MStarguider(MObservatory::kMagic1); 103 Camera *cam = new Camera(*client); 104 cam->Loop(0); 105 106 cosy->SetStarguider(client); 107 client->SetCosy(cosy); 108 80 109 clog("- Starting mainloop."); 110 #ifndef EXPERT 81 111 lout.DisableOutputDevice(MLog::eStdout); 112 #endif 82 113 app->Run(kTRUE); 114 115 client->SetCosy(NULL); 116 cosy->SetStarguider(NULL); 117 118 clog("- Stopping starg."); 119 cam->ExitLoop(); 120 delete cam; 121 delete client; 83 122 84 123 clog("- Stopping cosy."); -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r2019 r2278 127 127 } 128 128 129 void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) 130 { 131 // cout << "Node #" << dec << (int)GetId() << ": Sdo=" << hex << idx << "/" << (int)subidx << " set." << endl; 129 void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv) 130 { 131 // cout << "Node #" << dec << (int)GetId() << ": Sdo=" << hex << idx << "/" << (int)subidx << " set." << endl; 132 133 // If a real drive operation is requested from the MACS and 134 // the MACS is not correctly initialized the operation is 135 // rejected. (This is expecially harmfull if the NoWait state 136 // is set incorrectly) 137 if (data) 138 SetZombie(); 139 132 140 switch (idx) 133 141 { … … 201 209 202 210 } 203 NodeDrv::HandleSDOOK(idx, subidx, tv);211 NodeDrv::HandleSDOOK(idx, subidx, data, tv); 204 212 } 205 213 … … 223 231 SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31); 224 232 WaitForSdo(0x1800, 1); 233 } 234 235 void Macs::StartNode() 236 { 237 // 238 // Switch node from pre-operational state to operational state 239 // (This is not CANOpen compatible) 240 // After this the MACS will react on real movement commands. 241 // 242 lout << "- " << GetNodeName() << ": Starting Node." << endl; 243 SendSDO(0x1000, 1, (LWORD_t)1); 244 WaitForSdo(0x1000, 1); 225 245 } 226 246 … … 251 271 StopGuarding(); 252 272 253 273 // ****FIXME*** usleep(2000*GetGuardTime()); 254 274 255 275 lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; … … 257 277 WaitForSdo(0x100a); 258 278 // FIXME! Not statically linked! 259 if (fSoftVersion<0x00000044) // 00.68 279 //if (fSoftVersion<0x00000044) // 00.68 280 if (fSoftVersion<0x00000045) // 00.69 260 281 { 261 282 lout << GetNodeName() << " - Software Version too old!" << endl; … … 269 290 ReqVelRes(); // Init fVelRes 270 291 271 lout << "- " << GetNodeName() << ": Motor on." << endl; 272 SendSDO(0x3000, string('o', 'n')); 273 WaitForSdo(0x3000); 292 /* Should not be necessary anymore. This is done by the MACS itself. 293 lout << "- " << GetNodeName() << ": Motor on." << endl; 294 SendSDO(0x3000, string('o', 'n')); 295 WaitForSdo(0x3000); 296 */ 274 297 275 298 SetPDO1On(FALSE); // this is a workaround for the Macs 276 299 SetPDO1On(TRUE); 277 300 278 SetNoWait(TRUE); 279 280 // StartGuarding(200, 2, kFALSE); // Using PDO1 @ 100ms 281 282 // StartGuarding(250, 4); 283 // StartHostGuarding(); 284 } 285 301 //This is now standard in the MACS 302 //SetNoWait(TRUE); 303 304 // StartGuarding(200, 2, kFALSE); // Using PDO1 @ 100ms 305 // StartGuarding(250, 4); 306 // StartHostGuarding(); 307 308 StartNode(); 309 } 310 /* 286 311 void Macs::StopMotor() 287 312 { … … 292 317 WaitForSdo(0x3000); 293 318 } 294 319 */ 295 320 void Macs::StopDevice() 296 321 { 297 322 //EnableTimeout(kFALSE); 298 323 299 SetNoWait(FALSE); 324 //No need to switch it off. 325 //SetNoWait(FALSE); 300 326 301 327 StopHostGuarding(); … … 402 428 } 403 429 430 /* 404 431 void Macs::SetNoWait(BYTE_t flag) 405 432 { … … 408 435 WaitForSdo(0x3008); 409 436 } 437 */ 410 438 411 439 void Macs::StartVelSync() -
trunk/MagicSoft/Cosy/devdrv/macs.h
r1804 r2278 34 34 35 35 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 36 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv);36 void HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv); 37 37 //void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); } 38 38 … … 84 84 void SetDeceleration(LWORD_t dec); 85 85 void SetVelocity(LWORD_t vel); 86 void SetNoWait(BYTE_t flag=TRUE);86 //void SetNoWait(BYTE_t flag=TRUE); 87 87 void SetRpmMode(BYTE_t mode=TRUE); 88 88 void SetRpmVelocity(LWORDS_t cvel); … … 99 99 void StartAbsPos(LWORDS_t pos); 100 100 101 void StopMotor(); 101 //void StopMotor(); 102 103 void StartNode(); 102 104 103 105 int IsPositioning() const { return fPosActive; } -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1953 r2278 16 16 17 17 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out) 18 : NodeDrv(nodeid, name, out), fLabel(NULL), fPosHasChanged(false) 18 : NodeDrv(nodeid, name, out), fPos(0), fVel(0), fAcc(0), 19 fTurn(0), fLabel(NULL), fPosHasChanged(false) 19 20 { 20 21 } -
trunk/MagicSoft/Cosy/gui/GuiLinkDef.h
r1819 r2278 18 18 19 19 #pragma link C++ class MGCosy+; 20 #pragma link C++ class MGStarguider+;21 20 22 21 #endif -
trunk/MagicSoft/Cosy/gui/MGAccuracy.cc
r1953 r2278 170 170 171 171 MGAccuracy::MGAccuracy(const TGWindow* p, const UInt_t w) 172 : MGEmbeddedCanvas("Accuracy", p, w, 75*4)172 : MGEmbeddedCanvas("Accuracy", p, w, 300) 173 173 { 174 174 DrawCoordinateSystem(); -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r2069 r2278 55 55 kPB_DECp, 56 56 kPB_DECm, 57 kPB_ZDp, 58 kPB_ZDm, 59 kPB_AZp, 60 kPB_AZm, 57 61 kPB_LoadBending, 58 62 kPB_ResetBending, 59 63 kPB_CALIBSE, 60 64 kCB_PredefPos, 65 kCB_StarList, 61 66 62 67 // kLog … … 85 90 TGPopupMenu *logmenu = new TGPopupMenu(gClient->GetRoot()); 86 91 logmenu->AddEntry("&Copy Selected", kLogCopy); 87 logmenu->AddEntry(" Clear all", kLogClear);92 logmenu->AddEntry("&Select All", kLogSelect); 88 93 logmenu->AddSeparator(); 89 logmenu->AddEntry(" Select All", kLogSelect);94 logmenu->AddEntry("Clear &all", kLogClear); 90 95 /* 91 96 logmenu->AddSeparator(); … … 93 98 */ 94 99 logmenu->AddSeparator(); 95 logmenu->AddEntry("Sa ve",kLogSave);96 logmenu->AddEntry("Save a ppend",kLogAppend);100 logmenu->AddEntry("Sa&ve", kLogSave); 101 logmenu->AddEntry("Save a&ppend", kLogAppend); 97 102 logmenu->Associate(this); 98 103 … … 160 165 fList->Add(fLabel2); 161 166 fList->Add(fLabel3); 162 167 /* 163 168 l = new TGLabel(f, "Offset-Zd:"); 164 169 l->Move(x-60, y+102); … … 177 182 fList->Add(fOffsetZd); 178 183 fList->Add(fOffsetAz); 179 184 */ 180 185 l = new TGLabel(f, "Ra (estimated):"); 181 l->Move(x-60, y+142 );186 l->Move(x-60, y+142-20); 182 187 fList->Add(l); 183 188 184 189 l = new TGLabel(f, "Ra (nominal):"); 185 l->Move(x-60, y+159 );190 l->Move(x-60, y+159-20); 186 191 fList->Add(l); 187 192 188 193 l = new TGLabel(f, "Dec (estimated):"); 189 l->Move(x-60, y+182 );194 l->Move(x-60, y+182-20); 190 195 fList->Add(l); 191 196 192 197 l = new TGLabel(f, "Dec (nominal):"); 193 l->Move(x-60, y+199 );198 l->Move(x-60, y+199-20); 194 199 fList->Add(l); 195 200 … … 214 219 fZdSoll->SetTextJustify(kTextRight); 215 220 fAzSoll->SetTextJustify(kTextRight); 216 fRaEst->Move(x+30, y+142 );217 fRaSoll->Move(x+30, y+159 );218 fDecEst->Move(x+30, y+182 );219 fDecSoll->Move(x+30, y+199 );221 fRaEst->Move(x+30, y+142-20); 222 fRaSoll->Move(x+30, y+159-20); 223 fDecEst->Move(x+30, y+182-20); 224 fDecSoll->Move(x+30, y+199-20); 220 225 fZdSoll->Move(x+30, y+222); 221 226 fAzSoll->Move(x+30, y+239); … … 311 316 if (!fin) 312 317 { 313 cout << "ERROR: Predifined posi ionin 'prepos.txt' not found." << endl;318 cout << "ERROR: Predifined positions in 'prepos.txt' not found." << endl; 314 319 return; 315 320 } … … 329 334 } 330 335 331 void MGCosy::CreateTabs(TGTab *fTab) 336 void MGCosy::CreateStarList(TGCompositeFrame *tf1) 337 { 338 /* 339 TGComboBox *box = new TGComboBox(tf1, kCB_StarList); 340 box->Resize(120, 20); 341 box->Associate(this); 342 343 TGLayoutHints *lay = new TGLayoutHints(kLHintsLeft|kLHintsTop, 344 27, 0, 200, 0); 345 tf1->AddFrame(box, lay); 346 347 fList->Add(box); 348 fList->Add(lay); 349 350 ifstream fin("stars.txt"); 351 if (!fin) 352 { 353 cout << "ERROR: Star List 'stars.txt' not found." << endl; 354 return; 355 } 356 357 int i=0; 358 while (1) 359 { 360 TString str; 361 Int_t h, m, s, d, am, as; 362 fin >> h >> m >> s >> d >> am >> as; 363 if (!fin) 364 break; 365 366 box->AddEntry(str, i++); 367 368 fStarList.Add(zd, az); 369 } 370 */ 371 } 372 373 void MGCosy::CreateTabs() 332 374 { 333 375 TGCompositeFrame *tf1 = fTab->AddTab("Position"); 334 376 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 377 TGCompositeFrame *tf4 = fTab->AddTab("Calib"); 335 378 #ifdef EXPERT 336 TGCompositeFrame *tf4 = fTab->AddTab("Calib");337 379 TGCompositeFrame *tf5 = fTab->AddTab("Test SE"); 338 380 TGCompositeFrame *tf6 = fTab->AddTab("Gear"); … … 345 387 346 388 CreatePredefinedPos(tf1); 389 CreateStarList(tf4); 347 390 348 391 fCRaDec = new MGCoordinates(tf2, kETypeRaDec); … … 350 393 fList->Add(fCRaDec); 351 394 352 #ifdef EXPERT353 395 fCCalib = new MGCoordinates(tf4, kETypeRaDec); 354 396 fCCalib->Move(27, 105); 355 397 fList->Add(fCCalib); 356 #endif357 398 358 399 const int x=15; … … 386 427 fList->Add(l3); 387 428 388 #ifdef EXPERT389 429 l1 = new TGLabel(tf4, "Start the calibration using the Start button."); 390 430 l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using"); … … 401 441 fList->Add(l4); 402 442 443 #ifdef EXPERT 403 444 l1 = new TGLabel(tf5, "START starts histograming the differences of"); 404 445 l2 = new TGLabel(tf5, "the two shaftencoders at the elevation axis."); … … 495 536 fList->Add(but); 496 537 */ 538 #ifdef EXPERT 497 539 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 498 but->Resize( 80, 25);499 but->Move( 25, 190);540 but->Resize(50, 25); 541 but->Move(151, 185); 500 542 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 501 543 but->Associate(this); … … 503 545 504 546 but = new TGTextButton(tf4, "Reset", kPB_ResetBending); 505 but->Resize( 80, 25);506 but->Move(2 5, 220);547 but->Resize(50, 25); 548 but->Move(206, 185); 507 549 but->SetToolTipText("Reset bending correction (coefficients=0)"); 508 550 but->Associate(this); 509 551 fList->Add(but); 552 #endif EXPERT 510 553 511 554 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 512 but->Resize( 80, 25);513 but->Move( 25, 250);555 but->Resize(50, 25); 556 but->Move(176/*231*/, 213); 514 557 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 558 but->Associate(this); 559 fList->Add(but); 560 561 but= new TGTextButton(tf4, "Zd -", kPB_ZDm); 562 but->Resize(50, 25); 563 but->Move(25, 210); 564 but->SetToolTipText("Zenith Distance -= 1SE"); 565 but->Associate(this); 566 fList->Add(but); 567 but= new TGTextButton(tf4, "Zd +", kPB_ZDp); 568 but->Resize(50, 25); 569 but->Move(90, 210); 570 but->SetToolTipText("Zenith Distance += 1SE"); 571 but->Associate(this); 572 fList->Add(but); 573 but= new TGTextButton(tf4, "Az +", kPB_AZp); 574 but->Resize(50, 25); 575 but->Move(55, 185); 576 but->SetToolTipText("Azimuth += 1SE"); 577 but->Associate(this); 578 fList->Add(but); 579 but= new TGTextButton(tf4, "Az -", kPB_AZm); 580 but->Resize(50, 25); 581 but->Move(55, 235); 582 but->SetToolTipText("Azimuth -= 1SE"); 515 583 but->Associate(this); 516 584 fList->Add(but); … … 728 796 AddFrame(f2, hints2); 729 797 730 //731 // FIXME!732 //733 798 #ifdef DEBUG 734 799 cout << "MGCosy: Creating Tabs" << endl; 735 800 #endif 736 CreateTabs( fTab);801 CreateTabs(); 737 802 #ifdef DEBUG 738 803 cout << "MGCosy: Creating Label" << endl; … … 871 936 } 872 937 } 873 938 /* 874 939 void MGCosy::UpdateOffset(ZdAz &off) 875 940 { … … 892 957 } 893 958 } 894 959 */ 895 960 void MGCosy::UpdateZdAz(ZdAz &soll) 896 961 { … … 954 1019 } 955 1020 956 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off,RaDec radec,1021 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, /*ZdAz off,*/ RaDec radec, 957 1022 ZdAz soll, UInt_t stat, UInt_t stat2) 958 1023 { … … 962 1027 double mjd = UpdateTime(); 963 1028 fSkyPosition->Update(pos, mjd); 964 fAccuracy->Update(pos, acc); 965 fVelocity->Update(vel); 966 UpdateOffset(off); 1029 //UpdateOffset(off); 967 1030 UpdateRaDec(pos, mjd, radec); 968 1031 UpdateZdAz(soll); … … 991 1054 SetLabelColor(fAvailSe3, stat2&0x20); 992 1055 993 stat&kTracking ? fAccuracy->MapWindow() : fAccuracy->UnmapWindow(); 994 stat&kTracking ? fVelocity->MapWindow() : fVelocity->UnmapWindow(); 1056 if (stat&kTracking) 1057 { 1058 fAccuracy->Update(pos, acc); 1059 fVelocity->Update(vel); 1060 fAccuracy->MapWindow(); 1061 fVelocity->MapWindow(); 1062 } 1063 else 1064 { 1065 fAccuracy->UnmapWindow(); 1066 fVelocity->UnmapWindow(); 1067 } 995 1068 // stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow(); 996 1069 … … 1022 1095 } 1023 1096 1024 void MGCosy::StartTrack( )1097 void MGCosy::StartTrack(bool track) 1025 1098 { 1026 1099 cout << "Start tracking." << endl; 1027 1100 1028 XY xy = fCRaDec->GetCoordinates(); 1029 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø] 1030 1031 cout << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 1101 XY xy0 = fCRaDec->GetCoordinates(); 1102 XY xy1 = track ? xy0 : fCCalib->GetCoordinates(); 1103 1104 RaDec dest0(xy0.X()*15., xy0.Y()); // xy.X() [h]->[ø] 1105 RaDec dest1(xy1.X()*15., xy1.Y()); // xy.X() [h]->[ø] 1106 1107 cout << "TrackPos: " << dest0.Ra() << "h " << dest0.Dec() << "\xb0" << endl; 1108 cout << "CalibPos: " << dest1.Ra() << "h " << dest1.Dec() << "\xb0" << endl; 1109 1110 RaDec dest[2] = { dest0, dest1 }; 1032 1111 1033 1112 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); … … 1036 1115 } 1037 1116 1038 void MGCosy::StartTrackPos( )1117 void MGCosy::StartTrackPos(Long_t mp1) 1039 1118 { 1040 1119 cout << "Start tracking Zd/Az pos." << endl; … … 1043 1122 1044 1123 ZdAz za(xy.X(), xy.Y()); 1124 1125 switch (mp1) 1126 { 1127 case kPB_ZDm: 1128 za.Zd(za.Zd()-360/16384.); 1129 break; 1130 case kPB_ZDp: 1131 za.Zd(za.Zd()+360/16384.); 1132 break; 1133 case kPB_AZm: 1134 za.Az(za.Az()-360/16384.); 1135 break; 1136 case kPB_AZp: 1137 za.Az(za.Az()+360/16384.); 1138 break; 1139 } 1045 1140 1046 1141 cout << za.Zd() << "\xb0 " << za.Az() << "\xb0" << endl; … … 1203 1298 return kTRUE; 1204 1299 case 1: 1205 StartTrack( );1300 StartTrack(true); 1206 1301 return kTRUE; 1207 1302 case 2: 1208 1303 fCRaDec->SetCoordinates(fCCalib->GetCoordinates()); 1304 StartTrack(false); 1209 1305 return kTRUE; 1210 1306 case 3: … … 1261 1357 break; 1262 1358 } 1263 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]1264 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));1265 //fQueue->Proc(WM_NEWTRACK, &dest);1266 1359 fCRaDec->SetCoordinates(xy); 1267 1268 cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 1360 StartTrack(false); 1361 /* 1362 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø] 1363 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 1364 //fQueue->Proc(WM_NEWTRACK, &dest); 1365 */ 1366 //cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 1269 1367 } 1368 return kTRUE; 1369 1370 case kPB_ZDp: 1371 case kPB_ZDm: 1372 case kPB_AZp: 1373 case kPB_AZm: 1374 StartTrackPos(mp1); 1270 1375 return kTRUE; 1271 1376 -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r2069 r2278 50 50 TGLabel *fLabel3; 51 51 52 TGLabel *fOffsetZd;53 TGLabel *fOffsetAz;52 // TGLabel *fOffsetZd; 53 // TGLabel *fOffsetAz; 54 54 55 55 TGLabel *fRaEst; … … 98 98 void CreateMenu(); 99 99 void CreateLabel(TGCompositeFrame *f); 100 void CreateTabs( TGTab *fTab);100 void CreateTabs(); 101 101 void CreatePredefinedPos(TGCompositeFrame *tf1); 102 void CreateStarList(TGCompositeFrame *tf1); 102 103 103 104 void StartPos(); 104 void StartTrack( );105 void StartTrackPos( );105 void StartTrack(bool track); 106 void StartTrackPos(Long_t mp1=0); 106 107 void StartDemo(); 107 108 //void StartCalib(); … … 110 111 void EnableLabel(TGLabel *label, Bool_t stat); 111 112 void SetLabelColor(TGLabel *label, Bool_t col); 112 void UpdateOffset(ZdAz &off);113 //void UpdateOffset(ZdAz &off); 113 114 void UpdateZdAz(ZdAz &off); 114 115 void UpdateRaDec(ZdAz &pos, double mjd, RaDec &radec); … … 127 128 TGTextView *GetLog() const { return fLog; } 128 129 129 void Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off,RaDec radec, ZdAz soll, UInt_t stat, UInt_t stat2);130 void Update(ZdAz pos, ZdAz acc, ZdAz vel, /*ZdAz off,*/ RaDec radec, ZdAz soll, UInt_t stat, UInt_t stat2); 130 131 131 132 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); -
trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc
r1804 r2278 17 17 18 18 MGEmbeddedCanvas::MGEmbeddedCanvas(const char *name, const TGWindow* p, 19 const UInt_t width, Float_t range)19 UInt_t width, Double_t range) 20 20 : TRootEmbeddedCanvas(name, p, width+1, width+1, 0/*kRaisedFrame*/), 21 fModified(kFALSE), fWidth(width), fRange( range), fPix(2.*range/width)21 fModified(kFALSE), fWidth(width), fRange(fabs(range)), fPix(2.*fabs(range)/width) 22 22 { 23 23 #ifdef DEBUG … … 34 34 fCanvas->SetFillColor(39); // s. TAttFill 35 35 #ifdef DEBUG 36 cout << "MGEmbeddedCanvas : fRange=" << fRange<< endl;36 cout << "MGEmbeddedCanvas." << endl; 37 37 #endif 38 if (fRange>0) 39 38 39 fCanvas->Range(-fRange, -fRange, fRange, fRange); 40 40 41 41 fList = new TList; -
trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.h
r1804 r2278 34 34 public: 35 35 MGEmbeddedCanvas(const char *name, const TGWindow* p, 36 const UInt_t width, const Float_t range);36 UInt_t width, Double_t range); 37 37 ~MGEmbeddedCanvas(); 38 38 -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r1690 r2278 12 12 #include <pthread.h> 13 13 14 #include <X11/Xlib.h> 15 14 16 #include <TTimer.h> 15 17 #include <TSystem.h> … … 18 20 19 21 ClassImp(MGImage); 22 /* 23 class MyX11 : public TGX11 24 { 25 public: 26 Display *GetDisplay() { return fDisplay; } 27 Drawable GetRootWin() { return fRootWin; } 28 Drawable GetVisRootWin() { return fVisRootWin; } 29 Int_t GetDepth() { return fDepth; } 30 }; 31 */ 20 32 21 33 MGImage::MGImage(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options, ULong_t back) … … 27 39 28 40 // 29 // Set Color Table (Gray scale)30 //31 const int cols = 0x100+4*4*4;32 33 for (int c=0; c<0x100; c++)34 sprintf(fColors[c], "%02x", c);35 36 //37 // create space for the pixmap buffer, initialize pointer to data area38 //39 fBuffer = new char*[1+cols+fHeight+1];40 fBody = &fBuffer[1+cols];41 42 //43 // fill buffer with header informations44 //45 fBuffer[0] = new char[14];46 sprintf(fBuffer[0], "%3d %3d %3d %1d", fWidth, fHeight, cols, 2);47 48 for (int k=0; k<0x100; k++)49 {50 const int l = k+1;51 fBuffer[l] = new char[13];52 fBuffer[l][0] = fColors[k][0];53 fBuffer[l][1] = fColors[k][1];54 fBuffer[l][2] = '\t';55 fBuffer[l][3] = 'c';56 fBuffer[l][4] = ' ';57 fBuffer[l][5] = '#';58 fBuffer[l][6] = fColors[k][0];59 fBuffer[l][7] = fColors[k][1];60 fBuffer[l][8] = fColors[k][0];61 fBuffer[l][9] = fColors[k][1];62 fBuffer[l][10] = fColors[k][0];63 fBuffer[l][11] = fColors[k][1];64 fBuffer[l][12] = '\0';65 }66 67 for (int b=0; b<4; b++)68 for (int g=0; g<4; g++)69 for (int r=0; r<4; r++)70 {71 const int nr = r+(g<<2)+(b<<4);72 const int l = 0x100+nr+1;73 74 fBuffer[l] = new char[13];75 fBuffer[l][0] = 'f'+nr/8+1;76 fBuffer[l][1] = 'f'+nr%8+1;77 fBuffer[l][2] = '\t';78 fBuffer[l][3] = 'c';79 fBuffer[l][4] = ' ';80 fBuffer[l][5] = '#';81 fBuffer[l][6] = fColors[r*85][0];82 fBuffer[l][7] = fColors[r*85][1];83 fBuffer[l][8] = fColors[g*85][0];84 fBuffer[l][9] = fColors[g*85][1];85 fBuffer[l][10] = fColors[b*85][0];86 fBuffer[l][11] = fColors[b*85][1];87 fBuffer[l][12] = '\0';88 }89 90 //91 // mark end of lines of the data area92 //93 for (UInt_t y=0; y<fHeight; y++)94 {95 fBody[y] = new char[fWidth*2+1];96 fBody[y][fWidth*2] = '\0';97 }98 //99 // mark end of buffer100 //101 fBuffer[1+cols+fHeight] = '\0';102 103 //104 // Create Default Graphic Context (XCreateGC)105 //106 fDefGC = gVirtualX->CreateGC(fId, 0); // GetBckgndGC().GetGC(); //107 108 //109 41 // Creat drawing semaphore 110 42 // … … 112 44 pthread_mutex_init((pthread_mutex_t*)fMuxPixmap, NULL); 113 45 114 //115 // create empty (black) pixmap116 // return (Pixmap_t) XCreatePixmap(fDisplay, (Drawable) id, w, h,117 // DefaultDepth(fDisplay, DefaultScreen(fDisplay)));118 //119 fPixmap = kNone; //@@@gVirtualX->CreatePixmap(fId, fWidth, fHeight);120 121 46 Resize(w, h); 122 47 123 //fTimer=new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 250, kTRUE); 124 // fTimer=new TTimer("printf(\"Timer!\\n\"); gSystem->ProcessEvents();", 250, kTRUE); 125 //fTimer->Start(); 126 } 127 128 void MGImage::Resize(UInt_t w, UInt_t h) 129 { 130 // TGFrame::Resize(w+2*GetBorderWidth(), h+2*GetBorderWidth()); 131 // FIXME: RESIZE THE PIXMAP 132 } 133 134 void MGImage::Resize(TGDimension size) 135 { 136 // TGFrame::Resize(size.fWidth+2*GetBorderWidth(), size.fHeight+2*GetBorderWidth()); 137 // FIXME: RESIZE THE PIXMAP 138 } 139 140 void MGImage::MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h) 141 { 142 // TGFrame::MoveResize(x, y, w+2*GetBorderWidth(), h+2*GetBorderWidth()); 143 // FIXME: RESIZE THE PIXMAP 48 // 49 // create empty pixmap 50 // 51 fPixmap = gVirtualX->CreatePixmap(fId, fWidth, fHeight); 52 fDefGC = gVirtualX->CreateGC(fId, 0); 53 fImage = (XImage*)gVirtualX->CreateImage(fWidth, fHeight); 144 54 } 145 55 146 56 MGImage::~MGImage() 147 57 { 148 //fTimer->Stop();149 //delete fTimer;150 151 58 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap); 152 59 153 cout << "Deleting fBuffer..." << endl;60 cout << "Deleting MGImage..." << endl; 154 61 155 char **b = fBuffer; 156 while (*b) 157 delete[] *b++; 158 delete[] fBuffer; 159 160 cout << "Deleting Pixmap..." << endl; 161 162 if (fPixmap!=kNone) // @@@ 163 { 164 cout << "Delete Pixmap" << endl; 165 gVirtualX->DeletePixmap(fPixmap); // XFreePixmap(fDisplay, (Pixmap) pmap); 166 } 167 168 cout << "Deleting GC..." << endl; 169 170 171 gVirtualX->DeleteGC(fDefGC); // XFreeGC(fDisplay, (GC) gc); 62 gVirtualX->DeletePixmap(fPixmap); 63 gVirtualX->DeleteGC(fDefGC); 64 gVirtualX->DeleteImage((Drawable_t)fImage); 172 65 173 66 pthread_mutex_destroy((pthread_mutex_t*)fMuxPixmap); … … 176 69 } 177 70 178 #include <X11/Xlib.h>179 /*180 #include <X11/Xutil.h>181 #include <X11/Intrinsic.h>182 XImage *fPix=NULL;183 */184 185 71 void MGImage::DoRedraw() 186 72 { 187 // TGFrame::DrawBorder();188 73 pthread_mutex_lock((pthread_mutex_t*)fMuxPixmap); 189 74 190 //=========================== 191 if (TestBit(kNeedRecreate)) 75 if (TestBit(kNeedRedraw)) 192 76 { 193 Pixmap_t mask = kNone; 194 PictureAttributes_t attr; 195 attr.fMask = kNone; 196 197 if (fPixmap!=kNone) 198 gVirtualX->DeletePixmap(fPixmap); 199 200 fPixmap=kNone; 201 202 if (!gVirtualX->CreatePictureFromData(fId, fBuffer, fPixmap, 203 mask, attr)) 204 { 205 cout << "Warning: Error in CreatePictureFromData" << endl; 206 fPixmap=kNone; 207 } 208 ResetBit(kNeedRecreate); 77 gVirtualX->PutImage(fId, fDefGC, (Drawable_t)fImage, 0, 0, 0, 0, fWidth, fHeight); 78 ResetBit(kNeedRedraw); 209 79 } 210 80 211 //===========================212 213 // Copy a drawable (i.e. pixmap) to another drawable (pixmap, window).214 // The graphics context gc will be used and the source will be copied215 // from src_x,src_y,src_x+width,src_y+height to dest_x,dest_y.216 // XCopyArea(fDisplay, src, dest, (GC) gc, src_x, src_y, width, height,217 // dest_x, dest_y);218 if (fPixmap!=kNone) //@@@219 {220 // gVirtualX->DrawString(fId, fDefGC, 20, 20, "HELLO WORLD!", 12);221 // gVirtualX->FillRectangle(fId, fDefGC, 10, 10, 50, 50);222 223 // cout << gVirtualX->IsA()->GetName() << endl;224 gVirtualX->CopyArea(fPixmap, fId, fDefGC,225 0, 0, fWidth, fHeight,226 GetBorderWidth(), GetBorderWidth());227 228 /*229 XCopyArea((Display*)gVirtualX->GetDisplay(), pm, fId,230 (GC)fDefGC, 0, 0, fWidth, fHeight,231 GetBorderWidth(), GetBorderWidth());232 */233 }234 /*235 if (fPix)236 {237 cout << "put" << flush;238 XPutImage((Display*)gVirtualX->GetDisplay(), fId,239 fDefGC, fPix,240 0, 0, GetBorderWidth(), GetBorderWidth(),241 fWidth, fHeight);242 243 cout << "done " << endl;244 }245 */246 81 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 247 82 } 248 83 249 250 //#include <TGClient.h>251 84 void MGImage::DrawImg(const byte *buffer) 252 85 { … … 254 87 return; 255 88 256 for (UInt_t y=0; y<fHeight; y++) 89 char *d = fImage->data; 90 char *e = (char*)(buffer+fWidth*fHeight); 91 char *s = (char*)buffer; 92 93 // FIXME: This loop depends on the screen color depth 94 while (s<e) 257 95 { 258 for (UInt_t x=0; x<fWidth; x++) 259 { 260 const byte col = buffer[y*fWidth+x]; 261 262 fBody[y][x*2] = fColors[col][0]; 263 fBody[y][x*2+1] = fColors[col][1]; 264 } 96 *d++ = *s; 97 *d++ = *s; 98 *d++ = *s++; 99 d++; 265 100 } 266 101 267 /* 268 cout << "CreateImage" << flush; 269 if (!fPix) 270 { 271 Display *dsp = (Display*)gVirtualX->GetDisplay(); 272 Screen *scr = DefaultScreenOfDisplay(dsp); 273 Visual *vis = DefaultVisualOfScreen(scr); 102 SetBit(kNeedRedraw); 274 103 275 cout << vis->visualid << endl;276 cout << vis->c_class << endl;277 cout << vis->bits_per_rgb << endl;278 cout << vis->map_entries << endl;279 Visual visual;280 visual.c_class = StaticGray;281 282 int n;283 XPixmapFormatValues *fmt = XListPixmapFormats(dsp, &n);284 285 cout << "N: " << n << endl;286 for (int i=0; i<n; i++)287 {288 cout << fmt[i].dww.epth << " " << fmt[i].bits_per_pixel << " "289 << fmt[i].scanline_pad << endl;290 }291 292 Colormap colormap = XCreateColormap(dsp, fId, vis, AllocNone);293 294 for (int i=0; i<vis->map_entries; i++)295 {296 XColor color;297 char data[4];298 299 color.flags = DoRed | DoGreen | DoBlue;300 color.pixel = i;301 color.red = (256*i/vis->map_entries) << 8;302 color.green = (256*i/vis->map_entries) << 8;303 color.blue = (256*i/vis->map_entries) << 8;304 305 XAllocColor(dsp, colormap, &color);306 307 cout << color.pixel <<" " << flush;308 }309 fPix = XCreateImage(dsp, vis, 8, ZPixmap, 0,310 buffer, 768, 576, 32, 0);311 312 cout << "Colors" << visual.visualid << flush;313 314 }315 cout << "Done " << (void*)fPix << endl;316 */317 318 /*319 Pixmap_t mask = kNone;320 PictureAttributes_t attr;321 attr.fMask = kNone;322 if (fPixmap!=kNone) // @@@323 gVirtualX->DeletePixmap(fPixmap); // XFreePixmap(fDisplay, (Pixmap) pmap);324 325 // Create a pixture pixmap from data. The picture attributes326 // are used for input and output. Returns kTRUE in case of success,327 // kFALSE otherwise. If mask does not exist it is set to kNone.328 //329 // XpmAttributes xpmattr;330 //331 // MapPictureAttributes(attr, xpmattr);332 //333 // Int_t res = XpmCreatePixmapFromData(fDisplay, id, data, (Pixmap*)&pict,334 // (Pixmap*)&pict_mask, &xpmattr);335 //336 // MapPictureAttributes(attr, xpmattr, kFALSE);337 // XpmFreeAttributes(&xpmattr);338 //339 // if (res == XpmSuccess || res == XpmColorError)340 // return kTRUE;341 //342 // if (pict) {343 // XFreePixmap(fDisplay, (Pixmap)pict);344 // pict = kNone;345 // }346 // if (pict_mask) {347 // XFreePixmap(fDisplay, (Pixmap)pict_mask);348 // pict_mask = kNone;349 // }350 // return kFALSE;351 fPixmap=kNone;352 if (!gVirtualX->CreatePictureFromData(fId, fBuffer, fPixmap,353 mask, attr))354 {355 cout << "Warning: Error in CreatePictureFromData" << endl;356 fPixmap=kNone;357 }358 */359 SetBit(kNeedRecreate);360 104 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 361 //gClient->NeedRedraw(this);362 //fTimer->Start(10, kTRUE);363 //gVirtualX->UpdateWindow(1);364 // ((TGX11*)gVirtualX)->Sync(1);365 //new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 1, kFALSE);366 // DoRedraw();367 105 } 368 106 … … 372 110 return; 373 111 374 for (UInt_t y=0; y<fHeight; y++) 112 char *d = fImage->data; 113 char *e = (char*)(gbuf+fWidth*fHeight); 114 char *s1 = (char*)gbuf; 115 char *s2 = (char*)cbuf; 116 117 // FROM libAfterImage: 118 // ------------------- 119 //#define ALPHA_TRANSPARENT 0x00 120 //#define ALPHA_SEMI_TRANSPARENT 0x7F 121 //#define ALPHA_SOLID 0xFF 122 // * Lowermost 8 bits - Blue channel 123 // * bits 8 to 15 - Green channel 124 // * bits 16 to 23 - Red channel 125 // * bits 24 to 31 - Alpha channel 126 //#define ARGB32_White 0xFFFFFFFF 127 //#define ARGB32_Black 0xFF000000 128 129 // FIXME: This loop depends on the screen color depth 130 while (s1<e) 375 131 { 376 for (UInt_t x=0; x<fWidth; x++)132 if (*s2) 377 133 { 378 const byte ccol = cbuf[y*fWidth+x];379 380 if (ccol)381 {382 fBody[y][x*2] = 'f'+ccol/8+1;383 fBody[y][x*2+1] = 'f'+ccol%8+1;384 }385 else386 {387 const byte gcol = gbuf[y*fWidth+x];388 fBody[y][x*2] = fColors[gcol][0];389 fBody[y][x*2+1] = fColors[gcol][1];390 }134 *d++ = ((*s2>>4)&0x3)*85; 135 *d++ = ((*s2>>2)&0x3)*85; 136 *d++ = ((*s2++ )&0x3)*85; 137 d++; 138 s1++; 139 } 140 else 141 { 142 *d++ = *s1; 143 *d++ = *s1; 144 *d++ = *s1++; 145 d++; 146 s2++; 391 147 } 392 148 } 393 /*394 Pixmap_t mask = kNone;395 PictureAttributes_t attr;396 attr.fMask = kNone;397 149 398 if (fPixmap!=kNone) 399 gVirtualX->DeletePixmap(fPixmap); 150 SetBit(kNeedRedraw); 400 151 401 fPixmap=kNone;402 403 if (!gVirtualX->CreatePictureFromData(fId, fBuffer, fPixmap,404 mask, attr))405 {406 cout << "Warning: Error in CreatePictureFromData" << endl;407 fPixmap=kNone;408 }409 */410 SetBit(kNeedRecreate);411 152 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 412 //gClient->NeedRedraw(this);413 //fTimer->Start(10, kTRUE);414 //gVirtualX->UpdateWindow(1);415 // ((TGX11*)gVirtualX)->Sync(1);416 //new TTimer(Form("gClient->ProcessEventsFor((TGWindow*)0x%p);", this), 1, kFALSE);417 // DoRedraw();418 153 } 419 -
trunk/MagicSoft/Cosy/gui/MGImage.h
r1690 r2278 8 8 // Version: V1.0 (1-8-2000) 9 9 10 #ifndef ROOT_TGFrame 10 11 #include <TGFrame.h> 12 #endif 13 #ifndef ROOT_TGX11 14 #include <TGX11.h> 15 #endif 11 16 12 17 class TTimer; … … 16 21 class MGImage : public TGFrame 17 22 { 18 char fColors[0x100][3]; 19 20 char **fBuffer; 21 char **fBody; 23 XImage *fImage; 22 24 23 25 GContext_t fDefGC; … … 31 33 TTimer *fTimer; 32 34 33 enum { kNeedRe create= BIT(17) };35 enum { kNeedRedraw = BIT(17) }; 34 36 35 37 public: … … 38 40 39 41 void DoRedraw(); 40 41 void Resize(UInt_t w, UInt_t h);42 void Resize(TGDimension size);43 void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);44 42 45 43 void DrawImg(const byte *buffer); -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1804 r2278 69 69 InitArc(fSaturn, 1001, kYellow/*17*/, 16); 70 70 71 for (int i=0; i<1 3; i++)71 for (int i=0; i<14; i++) 72 72 { 73 73 fStars[i] = new TArc(0, 0, 1); … … 110 110 } 111 111 112 static const RaDec stars[1 3] =112 static const RaDec stars[14] = 113 113 { 114 114 // 32349 Sirius -1.44 1.45 2.64 0.009 A0m 115 (RaDec(Slalib::Hms2Rad( 6, 45, 0), Slalib::Dms2Rad(-16, 42,0))),115 (RaDec(Slalib::Hms2Rad( 6, 45, 0), Slalib::Dms2Rad(-16, 42, 0))), 116 116 // 30438 Canopus -0.62 -5.53 95.88 0.164 F0Ib 117 (RaDec(Slalib::Hms2Rad( 6, 23, 0), Slalib::Dms2Rad(-52, 41,0))),117 (RaDec(Slalib::Hms2Rad( 6, 23, 0), Slalib::Dms2Rad(-52, 41, 0))), 118 118 // 69673 Arcturus -0.05 -0.31 11.25 1.239 K2IIIp 119 (RaDec(Slalib::Hms2Rad( 14, 15, 0), Slalib::Dms2Rad( 19, 10, 0))), 120 (RaDec(Slalib::Hms2Rad( 01, 37, 6), Slalib::Dms2Rad(-57, 14, 0))), 121 (RaDec(Slalib::Hms2Rad( 12, 26, 6), Slalib::Dms2Rad(-63, 06, 0))), 122 (RaDec(Slalib::Hms2Rad( 13, 25, 2), Slalib::Dms2Rad(-11, 10, 0))), 123 (RaDec(Slalib::Hms2Rad( 5, 14, 0), Slalib::Dms2Rad(- 8, 12, 5))), 124 (RaDec(Slalib::Hms2Rad( 19, 50, 0), Slalib::Dms2Rad(- 8, 52, 6))), 125 (RaDec(Slalib::Hms2Rad( 18, 37, 0), Slalib::Dms2Rad( 38, 47, 0))), 126 (RaDec(Slalib::Hms2Rad( 5, 16, 0), Slalib::Dms2Rad( 46, 00, 0))), 127 (RaDec(Slalib::Hms2Rad( 7, 39, 0), Slalib::Dms2Rad( 5, 14, 0))), 128 (RaDec(Slalib::Hms2Rad( 5, 55, 0), Slalib::Dms2Rad( 7, 24, 0))), 129 (RaDec(Slalib::Hms2Rad( 19, 50, 0), Slalib::Dms2Rad( 8, 52, 0))) 119 (RaDec(Slalib::Hms2Rad( 14, 15, 0), Slalib::Dms2Rad( 19, 10, 0))), 120 // Vega 0.03 121 (RaDec(Slalib::Hms2Rad( 18, 37, 0), Slalib::Dms2Rad( 38, 47, 0))), 122 // Altair 0.77 123 (RaDec(Slalib::Hms2Rad( 19, 50, 0), Slalib::Dms2Rad( 8, 52, 6))), 124 // Antares 0.96 125 (RaDec(Slalib::Hms2Rad( 16, 29, 25), Slalib::Dms2Rad(-26, 25, 55))), 126 // Spica 0.98 127 (RaDec(Slalib::Hms2Rad( 13, 25, 13), Slalib::Dms2Rad(-11, 9, 41))), 128 // Deneb 1.25 129 (RaDec(Slalib::Hms2Rad( 20, 41, 26), Slalib::Dms2Rad( 45, 16, 49))), 130 (RaDec(Slalib::Hms2Rad( 1, 37, 6), Slalib::Dms2Rad(-57, 14, 0))), 131 (RaDec(Slalib::Hms2Rad( 12, 26, 6), Slalib::Dms2Rad(-63, 06, 0))), 132 (RaDec(Slalib::Hms2Rad( 5, 14, 0), Slalib::Dms2Rad(- 8, 12, 5))), 133 (RaDec(Slalib::Hms2Rad( 5, 16, 0), Slalib::Dms2Rad( 46, 00, 0))), 134 (RaDec(Slalib::Hms2Rad( 7, 39, 0), Slalib::Dms2Rad( 5, 14, 0))), 135 (RaDec(Slalib::Hms2Rad( 5, 55, 0), Slalib::Dms2Rad( 7, 24, 0))) 130 136 }; 131 137 132 138 void MGSkyPosition::UpdateStars() 133 139 { 134 for (int i=0; i<1 3; i++)140 for (int i=0; i<14; i++) 135 141 SetDot(fStars[i], stars[i], 0); 136 142 } … … 138 144 void MGSkyPosition::InitText() 139 145 { 140 fText = new TText(105, 105, ""); 141 //fText->SetFillStyle(4000); // transparent 142 fText->SetTextAlign(33); // right, top 143 fText->SetTextColor(10); // white 144 fText->Draw(); 145 146 fList->Add(fText); 146 fText1 = new TText(-105, 105, ""); 147 fText2 = new TText(105, 105, ""); 148 149 fText1->SetTextAlign(13); // left, top 150 fText2->SetTextAlign(33); // right, top 151 152 fText1->SetTextColor(10); // white 153 fText2->SetTextColor(10); // white 154 155 fText1->Draw(); 156 fText2->Draw(); 157 158 fList->Add(fText1); 159 fList->Add(fText2); 147 160 } 148 161 … … 339 352 340 353 char txt[100]; 341 sprintf(txt, "Zd=%s%d\xb0%02.1f'\nAz=%s%d\xb0%02.1f'", 342 x<0?"-":"", abs(xd), xm, y<0?"-":"", abs(yd), ym); 343 344 fText->SetText(fText->GetX(), fText->GetY(), txt); 354 sprintf(txt, "Zd=%s%d\xb0%02.1f'", x<0?"-":"", abs(xd), xm); 355 fText1->SetText(fText1->GetX(), fText1->GetY(), txt); 356 357 sprintf(txt, "Az=%s%d\xb0%02.1f'", y<0?"-":"", abs(yd), ym); 358 fText2->SetText(fText2->GetX(), fText2->GetY(), txt); 345 359 346 360 SetModified(); … … 379 393 return false; 380 394 381 x= -100;382 y= 395 x= 100; 396 y=-100; 383 397 } 384 398 -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r1804 r2278 35 35 TArc *fSaturn; 36 36 37 TArc *fStars[1 3];37 TArc *fStars[14]; 38 38 39 39 TArc *fSaturnRing; … … 47 47 TLine *fSunL[4]; 48 48 49 TText *fText; 49 TText *fText1; 50 TText *fText2; 50 51 51 52 SlaStars *fSlaStar; -
trunk/MagicSoft/Cosy/gui/MGVelocity.cc
r1702 r2278 24 24 void MGVelocity::DrawCoordinateSystem() 25 25 { 26 /*27 TArc arc;28 arc.SetFillStyle(4000); // transparent29 arc.SetFillColor(39);30 arc.SetLineColor(3); // green31 arc.SetLineStyle(2); // dashed (s. TAttLine)32 arc.DrawArc(0, 0, 20);33 34 arc.SetLineColor(5); // yellow35 arc.DrawArc(0, 0, 40);36 37 arc.SetLineColor(2); // red38 arc.DrawArc(0, 0, 60);39 */40 //41 // FIXME? Use TAxis?42 //43 /*44 TLine line;45 line.SetLineColor(13);46 line.SetLineStyle(3); // dotted (s. TAttLine)47 line.DrawLine(-30., -65., -30., 65.);48 line.DrawLine(-65., -30., 65., -30.);49 line.DrawLine( 30., -65., 30., 65.);50 line.DrawLine( -6., 30., 65., 30.);51 52 line.DrawLine(-15., -65., -15., 65.);53 line.DrawLine(-65., -15., 65., -15.);54 line.DrawLine( 15., -65., 15., 65.);55 line.DrawLine(-65., 15., 65., 15.);56 57 line.DrawLine(-45., -65., -45., 65.);58 line.DrawLine(-65., -45., 65., -45.);59 line.DrawLine( 45., -65., 45., 65.);60 line.DrawLine(-65., 45., 65., 45.);61 62 line.SetLineColor(12);63 line.SetLineStyle(2); // dashed (s. TAttLine)64 line.DrawLine(-60., -65., -60., 65.);65 line.DrawLine(-65., -60., 65., -60.);66 line.DrawLine( 60., -65., 60., 65.);67 line.DrawLine(-65., 60., 65., 60.);68 69 line.SetLineColor(1); // black70 line.SetLineStyle(1); // solid (s. TAttLine)71 line.DrawLine(-65., 0, 65., 0);72 line.DrawLine( 0, -65., 0, 65.);73 74 line.DrawLine(-1., 60., 1., 60.);75 line.DrawLine(-1., -60., 1., -60.);76 line.DrawLine(-1., 30., 1., 30.);77 line.DrawLine(-1., -30., 1., -30.);78 79 line.DrawLine( 60., -1., 60., 1.);80 line.DrawLine(-60., -1., -60., 1.);81 line.DrawLine( 30., -1., 30., 1.);82 line.DrawLine(-30., -1., -30., 1.);83 84 TText text;85 text.SetTextAlign(22); // centered, centered (s.TAttText)86 text.DrawText(60., 5., "vAz['/min]");87 text.DrawText(0, 70., "vZd['/min]");88 89 text.SetTextAlign(23); // centered, centered (s.TAttText)90 text.DrawText(-60., -2., "-1'");91 text.DrawText( 60., -2., "1'");92 text.DrawText(-30., -2., "-.5'");93 text.DrawText( 30., -2., ".5'");94 95 text.SetTextAlign(32); // centered, centered (s.TAttText)96 text.DrawText(-2., -60., "-1'");97 text.DrawText(-2., 60., "1'");98 text.DrawText(-2., -30., "-.5'");99 text.DrawText(-2., 30., ".5'");100 */101 26 TWbox box; 102 27 box.DrawWbox(-145, 145, -35, 120, 18, 2, 1); … … 130 55 void MGVelocity::InitVelocity() 131 56 { 132 /*133 fLin1 = new TLine(0, 0, 0, 0);134 fLin2 = new TLine(0, 0, 0, 0);135 136 fLin1->SetLineColor(10); // white (s. TAttFill)137 fLin2->SetLineColor(10); // white138 fLin1->SetLineStyle(1); // solid (s. TAttLine)139 fLin2->SetLineStyle(1);140 141 fLin1->Draw();142 fLin2->Draw();143 144 fList->Add(fLin1);145 fList->Add(fLin2);146 */147 57 fArrow = new TArrow(0, 0, 0, 0, 0.01); 148 58 fArrowX = new TArrow(0, 0, 0, 0, 0.01); … … 170 80 fText->Draw(); 171 81 fList->Add(fText); 172 173 fTextVel = new TText(2*70, 2*70, "");174 fTextVel->SetTextAlign(33); // right, top175 fTextVel->SetTextColor(10); // white176 fTextVel->Draw();177 fList->Add(fTextVel);178 82 } 179 83 … … 255 159 fArrowAvg->SetX2(avgx); 256 160 fArrowAvg->SetY2(avgy); 257 258 // cout << avgx << " " << avgy << endl;259 161 260 162 if ((fabs(avgx)>/*40.*/110. || fabs(avgy)>/*40.*/110.)) … … 274 176 } 275 177 276 void MGVelocity::UpdateVelText(Float_t vx, Float_t vy)277 {278 static int X = ~0;279 static int Y = ~0;280 281 vx /= 60.; //['/min]282 vy /= 60.; //['/min]283 284 int fx = (int)/*floor*/(vx*10.);285 int fy = (int)/*floor*/(vy*10.);286 287 if (X==fx && Y==fy)288 return;289 290 X = fx;291 Y = fy;292 293 char txt[100];294 sprintf(txt, "Zd=%.1f'\nAz=%.1f'",295 vy, vx);296 297 fTextVel->SetText(fTextVel->GetX(), fTextVel->GetY(), txt);298 }299 300 178 void MGVelocity::Update(ZdAz &zdaz) 301 179 { … … 303 181 // calculate actual time for planet positions 304 182 // 305 // static int X = 0xaffe;306 // static int Y = 0xaffe;307 308 183 float vx = zdaz.Az()*3600.; // ["/min] 309 184 float vy = zdaz.Zd()*3600.; // ["/min] 310 185 311 UpdateVelText(vx, vy);312 313 186 int pixx = (int)(vx*fScale/fPix); 314 187 int pixy = (int)(vy*fScale/fPix); … … 328 201 return; 329 202 330 // cout << fScale << ": " << pixx << " " << pixy;331 // cout << fScale << ": " << (int)rc << (int)((int)fOld->X()==pixx) << (int)((int)fOld->Y()==pixy) << " ";332 // cout << zdaz.Az()*3600. << " " << zdaz.Zd()*3600. << endl;333 334 203 vx *= fScale; 335 204 vy *= fScale; -
trunk/MagicSoft/Cosy/gui/MGVelocity.h
r1111 r2278 31 31 32 32 TText *fText; 33 TText *fTextVel;33 // TText *fTextVel; 34 34 35 35 XY *fOld; … … 44 44 void DrawCoordinateSystem(); 45 45 void UpdateText(); 46 void UpdateVelText(Float_t x, Float_t y);46 //void UpdateVelText(Float_t x, Float_t y); 47 47 48 48 public: -
trunk/MagicSoft/Cosy/gui/Makefile
r1819 r2278 32 32 .SUFFIXES: .c .cc .cxx .h .hxx .o 33 33 34 SRCFILES = MGCoordinate.cc \ 34 SRCFILES = MGCosy.cc \ 35 MGCoordinate.cc \ 35 36 MGCoordinates.cc \ 36 MGCosy.cc \37 37 MGImage.cc \ 38 38 MGEmbeddedCanvas.cc \ 39 39 MGAccuracy.cc \ 40 40 MGVelocity.cc \ 41 MGStarguider.cc \42 41 MGSkyPosition.cc \ 43 MGMenu.cc 44 42 MGMenu.cc 43 45 44 SRCS = $(SRCFILES) 46 45 HEADERS = $(SRCFILES:.cc=.h) -
trunk/MagicSoft/Cosy/main/MCosy.cc
r2019 r2278 18 18 19 19 #include "MGCosy.h" 20 #include "MStarguider.h" 20 21 #include "SlaStars.h" 21 22 … … 330 331 { 331 332 // FIXME, what when waiting times out (Zombie) 333 if (!fMac1 || !fMac2) 334 return; 332 335 333 336 while ((fMac1->IsPositioning() || fMac2->IsPositioning()) && … … 428 431 const ZdAz d = dst*kRad2Deg; 429 432 430 lout << "Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl; 433 Timer t; 434 t.Now(); 435 lout << t << " - Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl; 431 436 432 437 if (!CheckRange(d)) … … 504 509 if (!cdzd && !cdaz) 505 510 { 506 lout << "Positioning done in " << i << (i==1?" step.":" steps.") << endl; 511 t.Now(); 512 lout << t << " - Positioning done in " << i << (i==1?" step.":" steps.") << endl; 507 513 SetStatus(MCosy::kStopped); 508 514 return TRUE; … … 577 583 // repositioning (relative) 578 584 // 579 lout << "Do Relative Positioning Done" << endl; 585 586 lout << "Do Relative Positioning..." << endl; 580 587 DoRelPos(rd, cdzd, cdaz); 581 582 588 lout << "Relative Positioning Done" << endl; 583 589 } … … 588 594 SetStatus(MCosy::kStopped); 589 595 590 lout << "Warning: Requested position not reached (i=" << i << ")" << endl; 596 t.Now(); 597 lout << t << " - Warning: Requested position not reached (i=" << i << ")" << endl; 591 598 return FALSE; 592 599 } … … 692 699 // is 25% of the |v| 693 700 // 694 const Float_t limit = 0.25;701 //const Float_t limit = 0.25; 695 702 696 703 // … … 721 728 } 722 729 */ 723 730 /* 724 731 if (sgn(vt->Az()) != sgn(vcalc.Az()) 725 732 && fabs(vt->Az()) < limit*fabs(vcalc.Az()) … … 729 736 vt->Az(0); 730 737 } 731 else 738 else*/ 732 739 if (fabs(vt->Az()) > maxtrack*vraz) 733 740 { … … 735 742 vt->Az(maxtrack*vraz*sgn(vcalc.Az())); 736 743 } 737 744 /* 738 745 if (sgn(vt->Zd()) != sgn(vcalc.Zd()) 739 746 && fabs(vt->Zd()) < limit*fabs(vcalc.Zd()) … … 744 751 } 745 752 else 746 if (fabs(vt->Zd()) > maxtrack*vrzd)753 */ if (fabs(vt->Zd()) > maxtrack*vrzd) 747 754 { 748 755 lout << "Warning: Altitude speed limit (" << maxtrack*100 << "%) exceeded... limited." << endl; … … 880 887 XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec())); 881 888 882 lout << "Start tracking:"; 889 sla.Now(); 890 lout << sla << " - Start tracking:"; 883 891 lout << " Ra: " << xy.X() << "h " << "Dec: " << xy.Y() << "\xb0" << endl; 884 #ifdef EXPERT892 /*#ifdef EXPERT 885 893 ofstream fout("coordinates.txt"); 886 894 fout << xy; 887 895 fout.close(); 888 896 #endif 889 //897 */ // 890 898 // Initialize Tracker (slalib or starguider) 891 899 // … … 1014 1022 } 1015 1023 1024 sla.Now(); 1025 1016 1026 fBackground = kBgdNone; 1017 1027 StopMovement(); 1018 lout << "Tracking stopped." << endl; 1028 1029 lout << sla << " - Tracking stopped." << endl; 1019 1030 } 1020 1031 … … 1037 1048 // 1038 1049 cout << "Stopping movement (dec=30%)..." << endl; 1050 if (fMac1 && fMac2) 1051 { 1039 1052 #ifdef EXPERT 1040 fMac1->SetDeceleration(0.5*fMac1->GetVelRes());1041 fMac2->SetDeceleration(0.5*fMac2->GetVelRes());1053 fMac1->SetDeceleration(0.5*fMac1->GetVelRes()); 1054 fMac2->SetDeceleration(0.5*fMac2->GetVelRes()); 1042 1055 #else 1043 fMac1->SetDeceleration(0.3*fMac1->GetVelRes());1044 fMac2->SetDeceleration(0.3*fMac2->GetVelRes());1056 fMac1->SetDeceleration(0.3*fMac1->GetVelRes()); 1057 fMac2->SetDeceleration(0.3*fMac2->GetVelRes()); 1045 1058 #endif 1046 fMac1->SetRpmMode(FALSE); 1047 fMac2->SetRpmMode(FALSE); 1059 fMac1->SetRpmMode(FALSE); 1060 fMac2->SetRpmMode(FALSE); 1061 } 1048 1062 1049 1063 /* … … 1201 1215 return (void*)0xaffe; 1202 1216 */ 1203 #ifdef EXPERT1204 1217 case WM_TPOINT: 1205 1218 { … … 1222 1235 cout << " SE-Pos: " << za.Alt() << "° " << za.Az() << "°" << endl; 1223 1236 *tpout << fmod(za.Az()+360, 360) << " " << za.Alt() << " "; 1237 1238 if (fStarguider) 1239 { 1240 XY tp = fStarguider->GetCoordinates(); 1241 *tpout << 90-tp.X() << " " << tp.Y() << " "; 1242 } 1243 1224 1244 *tpout << rd.Ra()/15 << " " << rd.Dec() << " " << setprecision(11) << sla.GetMjd() << endl; 1225 1245 … … 1227 1247 } 1228 1248 return (void*)0xca1b; 1229 #endif1230 1249 1231 1250 case WM_TRACKPOS: … … 1283 1302 cout << "WM_Track: START" << endl; 1284 1303 { 1304 RaDec dest = ((RaDec*)mp)[0]; 1305 if (fStarguider) 1306 fStarguider->SetPointingPosition(((RaDec*)mp)[1]); 1285 1307 if (!CheckNetwork()) 1286 1308 return (void*)0xebb0; 1287 1288 RaDec dest = *((RaDec*)mp);1289 1309 TrackPosition(dest*kDeg2Rad); 1290 1310 } … … 1352 1372 RaDec rd(xy.X()*15., xy.Y()); // [deg] 1353 1373 1354 const ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad); 1355 1356 ZdAz a1; 1357 AlignTrackingPos(a0, a1); 1358 a1 *= 180/TMath::Pi(); 1359 1360 const ZdAz a2 = a1*16384/360; 1361 const ZdAz se = a0*16384/360; 1374 ZdAz a1 = sla.CalcZdAz(rd*kDeg2Rad); // [rad] 1375 const ZdAz a0 = a1*kRad2Deg; // [deg] 1362 1376 1363 1377 cout << "Ra/Dec source: " << xy.X() << "h " << xy.Y() << "°" << endl; 1364 1378 cout << "Zd/Az target: " << a0.Zd() << "° " << a0.Az() << "°" << endl; 1379 1380 if (fZd1 && fZd2 && fAz) 1381 AlignTrackingPos(a0, a1); 1382 1383 a1 = fBending(a1)*kRad2Deg; 1384 1385 const ZdAz a2 = a1*16384/360; 1386 1365 1387 cout << "Zd/Az bended: " << a1.Zd() << "° " << a1.Az() << "°" << endl; 1366 cout << "SE target: " << se.Zd() << " " << se.Az() << endl;1367 1388 cout << "SE bended: " << a2.Zd() << " " << a2.Az() << endl; 1368 1389 } … … 1781 1802 } 1782 1803 1804 ZdAz MCosy::GetPointingPos() const 1805 { 1806 // GetPointingPos [deg] 1807 const ZdAz seist = GetSePos()*2*TMath::Pi()/16384; // [se] 1808 return fBending.CorrectBack(seist)*180/TMath::Pi(); 1809 } 1810 1783 1811 Bool_t MCosy::HandleTimer(TTimer *t) 1784 1812 { … … 1793 1821 fAz->DisplayVal(); 1794 1822 1795 ZdAz seist = GetSePos()*2*TMath::Pi()/16384; // [se] 1796 ZdAz bendist = fBending.CorrectBack(seist); 1823 ZdAz bendist = GetPointingPos(); 1797 1824 1798 1825 Byte_t avail = 0; … … 1810 1837 lout.UpdateGui(); 1811 1838 1812 fWin->Update(bendist *(360.0/2/TMath::Pi()), fTrackingError,1813 f Velocity, fOffset, fRaDec, fZdAzSoll, fStatus, avail);1839 fWin->Update(bendist, fTrackingError, fVelocity, /*fOffset,*/ 1840 fRaDec, fZdAzSoll, fStatus, avail); 1814 1841 1815 1842 const Bool_t trigger = fTriggerDisplay; … … 2076 2103 2077 2104 MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out) 2078 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), f Zd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone)2105 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fStarguider(NULL), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone), fStatus(kStopped) 2079 2106 { 2080 2107 TEnv env(".cosyrc"); … … 2109 2136 fZd2->SetDisplay(fWin->GetLabel3()); 2110 2137 fAz->SetDisplay(fWin->GetLabel1()); 2111 #ifdef EXPERT 2138 2112 2139 int i=0; 2113 2140 char name[100]; … … 2130 2157 *tpout << time.Year() << " " << time.Month() << " " << time.Day() << " "; 2131 2158 *tpout << /*"20 1013.25 300 0.5 0.55 0.0065" <<*/ endl; 2132 #endif2133 2159 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m) 2134 2160 } … … 2156 2182 MCosy::~MCosy() 2157 2183 { 2158 #ifdef EXPERT2159 2184 *tpout << "END" << endl; 2185 //streampos size = tpout.tellp(); 2160 2186 delete tpout; 2161 #endif2162 2187 2163 2188 cout << "Deleting GUI timer." << endl; -
trunk/MagicSoft/Cosy/main/MCosy.h
r2019 r2278 36 36 class MCosy; 37 37 class TH1; 38 class MStarguider; 38 39 39 40 class MTTalk : public MThread … … 71 72 const MObservatory::LocationName_t fObservatory; 72 73 74 MStarguider *fStarguider; 75 73 76 ShaftEncoder *fZd1; 74 77 ShaftEncoder *fZd2; … … 187 190 Bool_t HandleTimer(TTimer *t); 188 191 192 ZdAz GetPointingPos(void) const; 193 void SetStarguider(MStarguider *s) { fStarguider = s; } 194 189 195 // static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst); 190 196 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0)); -
trunk/MagicSoft/Cosy/main/MainLinkDef.h
r1393 r2278 6 6 7 7 #pragma link C++ class MCosy; 8 #pragma link C++ class MStarguider+; 8 9 9 10 #pragma link C++ class MBending; -
trunk/MagicSoft/Cosy/main/Makefile
r1758 r2278 21 21 22 22 INCLUDES = -I. -I../base -I.. -I../gui -I../catalog -I../devdrv \ 23 -I../candrv -I../incl -I../videodev 23 -I../candrv -I../incl -I../videodev -I../caos 24 24 25 25 # @code … … 32 32 .SUFFIXES: .c .cc .cxx .h .hxx .o 33 33 34 SRCFILES = MCosy.cc \ 35 MBending.cc 34 SRCFILES = MBending.cc \ 35 MStarguider.cc \ 36 MCaos.cc \ 37 MCosy.cc 36 38 37 39 SRCS = $(SRCFILES) -
trunk/MagicSoft/Cosy/starg.cc
r1819 r2278 6 6 #include "Camera.h" 7 7 #include "PngReader.h" 8 #include "M GStarguider.h"8 #include "MStarguider.h" 9 9 10 10 /* ---------------------------------------------------------------------- */ … … 27 27 } 28 28 29 PixClient *client=new MGStarguider(MObservatory::kMagic1); 29 PixClient *client=new MStarguider(MObservatory::kMagic1); 30 PixGetter *get; 30 31 31 32 if (dummy) 32 33 { 33 34 cout << " --> Starting in dummy-mode. <--" << endl; 34 PngReader *read=new PngReader(*client); 35 app->Run(kTRUE); 36 read->ExitLoop(); 37 delete read; 38 // delete client; 35 get=new PngReader(*client); 39 36 } 40 37 else 41 38 { 42 39 cout << " --> Starting in real-mode. <--" << endl; 43 //PixClient *client=new MGStarguider(MObservatory::kMagic1); 44 Camera *cam = new Camera(*client); 45 cam->Loop(0); 46 app->Run(kTRUE); 47 cam->ExitLoop(); 48 delete cam; 49 // delete client; 40 get = new Camera(*client); 41 ((Camera*)get)->Loop(0); 50 42 } 51 43 44 app->Run(kTRUE); 45 get->ExitLoop(); 46 47 delete get; 52 48 delete client; 53 54 49 55 50 cout << "Application end...." << endl; -
trunk/MagicSoft/Cosy/tpoint/tpointfit.C
r1819 r2278 105 105 fin >> v[3]; 106 106 107 Double_t dummy; 108 fin>>dummy; 109 fin>>dummy; 110 fin>>dummy; 111 107 112 set.fStarAz = v[0]*TMath::Pi()/180; 108 113 set.fStarEl = v[1]*TMath::Pi()/180; … … 311 316 gzd.SetTitle(" \\Delta Zd vs. Zd "); 312 317 313 ifstream fin(" /home/tbretz/pc4/results/tpoint3.txt");318 ifstream fin("tpoint.txt"); 314 319 315 320 while (fin && fin.get()!='\n'); -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r1802 r2278 47 47 void Camera::SigInit() 48 48 { 49 return; 49 50 struct sigaction act, old; 50 51 … … 215 216 while (img < end) 216 217 { 217 *beg = *img; 218 218 *beg++ = *img; 219 219 img += depth; 220 beg++;221 220 } 222 221 } -
trunk/MagicSoft/Cosy/videodev/Camera.h
r1802 r2278 14 14 #endif 15 15 16 #include "PixGetter.h" 16 17 #include "PixClient.h" 17 18 18 class Camera 19 class Camera : public PixGetter 19 20 { 20 21 private: -
trunk/MagicSoft/Cosy/videodev/CaosFilter.cc
r1810 r2278 28 28 } 29 29 30 float CaosFilter::Mean(const byte *buffer, const int offset, int *min, int *max) 31 { 32 double mean = 0.0; 33 34 *min = 0xff; 35 *max = 0x00; 30 void CaosFilter::GetStat(const byte *buffer, const int offset, double *mean, double *sdev) 31 { 32 double sum = 0; 33 double sq = 0; 34 35 byte *s = (byte*)buffer; 36 const byte *e0 = s+768*576; 36 37 37 38 // 38 39 // calculate mean value 39 40 // 40 for (int x=offset; x<768-offset; x++) 41 for (int y=offset; y<576-offset; y++) 42 { 43 byte val = buffer[y*768+x]; 44 45 mean += val; 46 47 if (val>*max) 48 *max = val; 49 50 if (val<*min) 51 *min = val; 52 } 53 54 mean /= (768-2*offset)*(576-2*offset); 55 56 return mean; 41 while (s<e0) 42 { 43 const byte *e = s+576-offset; 44 s += offset; 45 46 while (s<e) 47 { 48 sum += *s; 49 sq += *s * *s; 50 s++; 51 } 52 53 s+=offset; 54 } 55 56 const Int_t sz = (768-2*offset)*(576-2*offset); 57 58 sum /= sz; 59 sq /= sz; 60 61 *mean = sum; 62 *sdev = sqrt(sq-sum*sum); 57 63 } 58 64 … … 80 86 return (int)my*768 + (int)mx; 81 87 } 82 83 float CaosFilter::SDev(const byte *buffer, const int offset, const double mean)84 {85 //86 // calculate sigma87 //88 double sdev=0.0;89 90 for (int x=offset; x<768-offset; x++)91 for (int y=offset; y<576-offset; y++)92 {93 const float val = mean - buffer[y*768+x];94 95 sdev += val*val;96 }97 98 sdev /= (768-2*offset)*(576-2*offset)-1;99 100 return sqrt(sdev);101 }102 103 88 104 89 int CaosFilter::GetMeanPosition(const byte *bitmap, const int x, const int y, … … 389 374 const int offset = 10; 390 375 391 int max; 392 int min; 393 394 const float mean = Mean(img, offset, &min, &max); 395 const float sdev = SDev(img, offset, mean); 396 397 const float cut = mean + 2.5*sdev; 376 double mean, sdev; 377 GetStat(img, offset, &mean, &sdev); 378 379 const byte max = mean+2.5*sdev>254 ? 254 : (byte)(mean+2.5*sdev); 398 380 399 381 // 400 382 // clean image from noise 401 383 // 402 for (int x=0; x<768; x++) 403 for (int y=0; y<576; y++) 404 { 405 if (img[y*768+x]>cut) 406 continue; 407 408 // 409 // FIXME: Create LOOKUP Table! 410 // 411 412 img[y*768+x] = 0; 413 } 384 const byte *e = img+768*576; 385 byte *i = img; 386 while (i<e) 387 { 388 if (*i<=max) 389 *i = 0; 390 i++; 391 } 414 392 415 393 // … … 511 489 const int offset = 10; 512 490 513 int max; 514 int min; 515 516 const float mean = Mean(img, offset, &min, &max); 517 const float sdev = SDev(img, offset, mean); 518 519 const float cut = mean + 2.5*sdev; 491 double mean, sdev; 492 GetStat(img, offset, &mean, &sdev); 493 494 const byte cut = mean+2.5*sdev>254 ? 254 : (byte)(mean + 2.5*sdev); 520 495 521 496 // 522 497 // clean image from noise 523 498 // 524 for (int x=0; x<768; x++) 525 for (int y=0; y<576; y++) 526 { 527 if (img[y*768+x]>cut) 528 continue; 529 530 // 531 // FIXME: Create LOOKUP Table! 532 // 533 534 img[y*768+x] = 0; 535 } 499 const byte *e = img+768*576; 500 byte *i = img; 501 while (i<e) 502 { 503 if (*i<=cut) 504 *i = 0; 505 i++; 506 } 536 507 537 508 // -
trunk/MagicSoft/Cosy/videodev/CaosFilter.h
r1810 r2278 19 19 byte *buffer, const int col); 20 20 21 static float Mean(const byte *buffer, const int offset, 22 int *min, int *max); 23 24 static float SDev(const byte *buffer, const int offset, 25 const double mean); 21 static void GetStat(const byte *buffer, const int offset, 22 double *mean, double *sdev); 26 23 27 24 static int GetMeanPosition(const byte *bitmap, -
trunk/MagicSoft/Cosy/videodev/Filter.cc
r2019 r2278 24 24 } 25 25 26 float Filter::Mean(const byte *buffer, const int offset , int *min, int *max)26 float Filter::Mean(const byte *buffer, const int offset) 27 27 { 28 28 double mean = 0.0; 29 29 30 *min = 0xff;31 *max = 0x00;30 byte *s = (byte*)buffer; 31 const byte *e0 = s+768*576; 32 32 33 33 // 34 34 // calculate mean value 35 35 // 36 for (int x=offset; x<768-offset; x++)37 for (int y=offset; y<576-offset; y++)38 {39 byte val = buffer[y*768+x];36 while (s<e0) 37 { 38 const byte *e = s+576-offset; 39 s += offset; 40 40 41 mean += val; 41 while (s<e) 42 mean += *s++; 42 43 43 if (val>*max)44 *max = val;44 s+=offset; 45 } 45 46 46 if (val<*min) 47 *min = val; 48 } 47 return mean / ((768-2*offset)*(576-2*offset)); 48 } 49 49 50 mean /= (768-2*offset)*(576-2*offset);51 52 return mean;53 }54 50 55 51 float Filter::SDev(const byte *buffer, const int offset, const double mean) … … 101 97 const int offset = 10; 102 98 103 int max; 104 int min; 105 106 const float mean = Mean(img, offset, &min, &max); 99 const float mean = Mean(img, offset); 107 100 const float sdev = SDev(img, offset, mean); 108 101 109 const float cut = mean + 2.5*sdev;102 const byte cut = mean+2.5*sdev>254 ? 254 : (byte)(mean + 2.5*sdev); 110 103 111 104 // 112 105 // clean image from noise 113 106 // 114 for (int x=0; x<768; x++) 115 for (int y=0; y<576; y++) 116 { 117 if (img[y*768+x]>cut) 118 continue; 119 120 // 121 // FIXME: Create LOOKUP Table! 122 // 123 124 img[y*768+x] = 0; 125 } 107 const byte *e = img+768*576; 108 byte *i = img; 109 while (i<e) 110 { 111 if (*i<=cut) 112 *i = 0; 113 i++; 114 } 126 115 127 116 // … … 203 192 } 204 193 205 void Filter::Stretch(byte *img)206 {207 const int offset = 25;208 209 int max;210 int min;211 212 /*const float mean =*/Mean(img, offset, &min, &max);213 214 const byte diff = max-min;215 216 for (int x=0; x<768; x++)217 for (int y=0; y<576; y++)218 {219 byte &b = img[y*768+x];220 221 if (b<min)222 {223 b=0;224 continue;225 }226 if (b>max)227 {228 b=max;229 continue;230 }231 b -= min;232 b *= 255/diff;233 }234 } -
trunk/MagicSoft/Cosy/videodev/Filter.h
r1959 r2278 17 17 byte *buffer, const int col); 18 18 19 static float Mean(const byte *buffer, const int offset, 20 int *min, int *max); 19 static float Mean(const byte *buffer, const int offset); 21 20 22 21 static float SDev(const byte *buffer, const int offset, … … 29 28 public: 30 29 static void Execute(byte *img); 31 static void Stretch(byte *img);32 30 33 31 ClassDef(Filter, 0) -
trunk/MagicSoft/Cosy/videodev/Makefile
r1802 r2278 34 34 PngReader.cc \ 35 35 PixClient.cc \ 36 Filter.cc \ 37 Filter2.cc \ 38 CaosFilter.cc \ 36 PixGetter.cc \ 37 FilterLed.cc \ 39 38 Writer.cc 40 39 -
trunk/MagicSoft/Cosy/videodev/PngReader.h
r1803 r2278 14 14 #endif 15 15 16 #include "PixGetter.h" 17 16 18 class PixClient; 17 19 18 20 typedef unsigned char byte; 19 21 20 class PngReader 22 class PngReader : public PixGetter 21 23 { 22 24 private: -
trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h
r1802 r2278 6 6 7 7 #pragma link C++ class Writer+; 8 #pragma link C++ class Filter+; 9 #pragma link C++ class Filter2+; 10 #pragma link C++ class CaosFilter+; 8 //#pragma link C++ class Filter+; 9 //#pragma link C++ class Filter2+; 10 #pragma link C++ class FilterLed+; 11 //#pragma link C++ class CaosFilter+; 11 12 12 13 #pragma link C++ class Camera+;
Note:
See TracChangeset
for help on using the changeset viewer.