Changeset 8859 for trunk/MagicSoft
- Timestamp:
- 02/08/08 22:49:30 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r8856 r8859 1 1 -*-*- END -*-*- 2 3 2008/02/08 Thomas Bretz (La Palma) 4 5 * videodev/PngReader.[h,cc]: 6 - changed to use MThread 7 8 * videodev/MVideo.cc: 9 - improved error out 10 11 * videodev/Camera.[h,cc]: 12 - removed old obsolete code 13 - fixed capture loop for more than 2 buffers 14 15 * main/MStarguider.cc: 16 - removed obsolete call to Camera->Loop() 17 18 * main/MCosy.h: 19 - removed some obsolete comments 20 21 2 22 3 23 2008/02/05 Thomas Bretz (La Palma) -
trunk/MagicSoft/Cosy/main/MCosy.h
r8843 r8859 63 63 MTTalk(MCosy *cosy) : MThread("MTTalk"), fCosy(cosy) 64 64 { 65 //SetPriority(10);66 //Detach();67 65 RunThread(); 68 66 } -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r8856 r8859 544 544 545 545 if (channel<0) 546 fGetter =new PngReader(*this);546 fGetter = new PngReader(*this); 547 547 else 548 {549 548 fGetter = new Camera(*this, channel); 550 ((Camera*)fGetter)->Loop(0);551 }552 549 } 553 550 -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r8856 r8859 51 51 } 52 52 53 void Camera::ExitLoop()54 {55 CancelThread();56 57 // Some information58 //cout << fNumFrame-1 << "frames processed." << endl;59 //cout << fNumSkipped << "frames skipped." << endl;60 }61 62 53 void Camera::ProcessFrame(char *img) 63 54 { … … 98 89 { 99 90 fNumSkipped = 0; 100 fNumFrame = 1;91 fNumFrame = 0; 101 92 102 93 if (!fVideo->IsOpen()) … … 108 99 //Print(); 109 100 110 for (int f= 0; f<fVideo->GetNumBuffers()-1; f++)101 for (int f=1; f<fVideo->GetNumBuffers(); f++) 111 102 if (!fVideo->CaptureStart(f)) 112 103 return kFALSE; … … 161 152 } 162 153 163 void Camera::Loop(unsigned long nof)164 {165 }154 //void Camera::Loop(unsigned long nof) 155 //{ 156 //} 166 157 167 158 void Camera::SetChannel(int chan) -
trunk/MagicSoft/Cosy/videodev/Camera.h
r8843 r8859 40 40 virtual ~Camera(); 41 41 42 // 43 // Starts, stops the execution 44 // 45 void Loop(const unsigned long nof=0); 46 void ExitLoop(); 47 //int IsRunning() const; 42 void SetChannel(int); 48 43 49 void SetChannel(int);44 void ExitLoop() { CancelThread(); } 50 45 51 46 //ClassDef(Camera, 0) -
trunk/MagicSoft/Cosy/videodev/MVideo.cc
r8856 r8859 263 263 fCaps.maxheight, fCaps.maxwidth, // height, width 264 264 VIDEO_PALETTE_RGB24 // palette 265 //768, 576,266 //VIDEO_PALETTE_RGB555 // palette267 265 }; 268 266 … … 274 272 275 273 // if (errno == EAGAIN) 276 gLog << err << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl; 274 gLog << err; 275 gLog << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl; 276 gLog << " Maybe your card doesn't support VIDEO_PALETTE_RGB24." << endl; 277 277 278 278 return kFALSE; -
trunk/MagicSoft/Cosy/videodev/PngReader.cc
r8378 r8859 113 113 { 114 114 cout << "Starting thread..." << flush; 115 pthread_create(&fThread, NULL, MapThread, this);115 RunThread(); 116 116 cout << "done." << endl; 117 117 … … 121 121 { 122 122 cout << "Stopping thread..." << flush; 123 pthread_cancel(fThread);123 CancelThread(); 124 124 cout << "done." << endl; 125 125 } 126 126 127 void *PngReader::MapThread(void *arg)127 Int_t PngReader::Thread() 128 128 { 129 PngReader *cam = (PngReader*)arg;129 Sleep(3000000); 130 130 131 // setpriority(PRIO_PROCESS, 0, 10);132 pthread_detach(pthread_self());133 134 cam->Thread();135 136 return 0;137 }138 139 void PngReader::Thread()140 {141 fIsRunning = 1;142 usleep(3000000);143 131 int i=0; 144 132 145 133 gettimeofday(&fTime, NULL); 146 134 147 while ( !fStop)135 while (1) 148 136 { 149 137 // if (i<536) 150 138 // { 151 139 GetImg(i); 140 141 TThread::CancelPoint(); 142 152 143 fClient.ProcessFrame(i++, (byte*)fImg, &fTime); 153 144 // usleep(10000); … … 155 146 // else exit(); 156 147 fTime.tv_sec += 1; 157 usleep(1000);148 Sleep(1000); 158 149 } 159 150 160 161 fIsRunning = 0; 151 return 0; 162 152 } 163 153 -
trunk/MagicSoft/Cosy/videodev/PngReader.h
r2278 r8859 1 #ifndef PngReader_H2 #define PngReader_H1 #ifndef COSY_PngReader 2 #define COSY_PngReader 3 3 4 #ifdef __CINT__ 5 typedef unsigned long int pthread_t; 6 struct pthread_mutex_t; 7 struct pthread_cond_t; 8 struct timeval; 9 #else 10 #include <TROOT.h> 11 #include <pthread.h> 12 #include <unistd.h> 13 #include <sys/time.h> 4 #ifndef MARS_MThread 5 #include "MThread.h" 14 6 #endif 15 7 8 #ifndef COSY_PixGetter 16 9 #include "PixGetter.h" 10 #endif 17 11 18 12 class PixClient; 19 13 20 typedef unsigned char byte; 21 22 class PngReader : public PixGetter 14 class PngReader : public PixGetter, public MThread 23 15 { 24 16 private: … … 30 22 static const int gfDepth = 3; 31 23 32 int fStop;33 int fIsRunning;34 35 24 // 36 25 // Thread interface … … 40 29 char fImg[gfCols*gfRows]; 41 30 struct timeval fTime; 42 43 pthread_t fThread;44 31 45 32 PixClient &fClient; … … 53 40 // Execution thread which processes the pictures 54 41 // 55 void Thread(); 56 static void *MapThread(void *arg); 42 Int_t Thread(); 57 43 58 44 public: … … 60 46 virtual ~PngReader(); 61 47 62 // 63 // Starts, stops the execution 64 // 65 void ExitLoop() 66 { 67 fStop = 1; 68 while (IsRunning()) 69 usleep(1); 70 } 71 72 // 73 // flag if the execution is running or not 74 // 75 int IsRunning() const { return fIsRunning; } 48 void ExitLoop() { CancelThread(); } 76 49 77 50 ClassDef(PngReader, 0)
Note:
See TracChangeset
for help on using the changeset viewer.