Changeset 910
- Timestamp:
- 08/15/01 12:52:38 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 8 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r808 r910 1 1 -*-*- END -*-*- 2 2001/08/15 - Thomas Bretz: 2 3 4 * .cosyrc: 5 - changed names 6 - added HomeTime 7 8 * MCosy.[h,cc]: 9 - added home time 10 - added MTGui, MTTalk 11 - added reading environment 12 13 * Makefile, Makefile.conf.linux-gnu, Makefile.rules 14 - changed to Mars style 15 16 * Starguider.cc: 17 - changed include timer.g to base/timer.h 18 19 * Starguider.[h,cc]: 20 - renamed Execute to ProcessFrame 21 22 * cosy.cc: 23 - removed unnecessary includes 24 25 * base/MGList.h: 26 - added debug output 27 28 * base/msgqueue.cc: 29 - added comments 30 31 * base/msgqueue.h: 32 - made Break const 33 34 * candrv/canopen.[h,cc]: 35 - made CobId const 36 37 * candrv/network.[h,cc]: 38 - fixed typo 39 - StopReceiver -> VmodIcan::Stop 40 - made HasError const 41 42 * candrv/nodedrv.[h,cc]: 43 - added timeout to WaitForSdo 44 45 * candrv/sdolist.[h,cc]: 46 - made IsPending const 47 48 * candrv/vmodican.[h,cc]: 49 - changed ReceiveThread to new stylish MThread 50 51 * devdrv/macs.[h,cc]: 52 - changed SetHome to use a maximum positioning time 53 - added comments 54 - replaces SetSyncMode by StartPosSync and StartVelSync 55 56 * devdrv/shaftencoder.[h,cc]: 57 - removed gui thread (the update is done by MTGui now) 58 59 * gui/MGCosy.[h,cc]: 60 - some small changed 61 - removed fList->Delete() 62 - added MSkyPosition-Object 63 - gSystem->ExitLoop() replaced by gSystem->Terminate(0) 64 65 * videodev/Camera.[h,cc]: 66 - renamed Execute to ProcessFrame 67 68 69 3 70 2001/05/25 - Thomas Bretz: 4 71 -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r909 r910 793 793 SendCanFrame(cobid, msg); 794 794 } 795 /*796 void VmodIcan::StopReceiver()797 {798 if (!fRxThrd)799 return;800 801 pthread_cancel(*fRxThrd);802 803 delete fRxThrd;804 fRxThrd = NULL;805 lout << "- Receiver Thread stopped." << endl;806 }807 */808 809 /*810 void VmodIcan::StartReceiver()811 {812 **************************************813 * create thread waiting for messages *814 **************************************815 if (fRxThrd)816 {817 cout << "Error: rx thread already started." << endl;818 return;819 }820 821 lout << "- Starting receiving Thread." << endl;822 823 fRxThrd = new pthread_t;824 pthread_create(fRxThrd, NULL, ReceiveThread, this);825 }826 */827 -
trunk/MagicSoft/Cosy/candrv/vmodican.h
r909 r910 10 10 11 11 #include "MThread.h" 12 /*13 class VmodIcanRX : public MThread14 {15 private:16 VmodIcan *fModule;17 12 18 void *Thread();19 20 public:21 MTGui(VmodIcan *mod) : MThread(false), fModule(mod)22 {23 SetPriority(-10);24 Detach();25 }26 };27 */28 13 class VmodIcan : public Log, protected MThread 29 14 { … … 32 17 private: 33 18 int fd; // file descriptor for can module 34 // pthread_t *fRxThrd;35 19 36 20 int Ioctl(int msg, void *arg); … … 71 55 virtual void TerminateApp() { exit(-1); } 72 56 73 //protected:74 // void StartReceiver();75 // void StopReceiver();76 77 57 public: 78 58 VmodIcan(const char *dev, const int baud, ostream &out=cout); -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r808 r910 188 188 } 189 189 190 void Macs::SetHome(LWORDS_t pos )190 void Macs::SetHome(LWORDS_t pos, WORD_t maxtime) 191 191 { 192 192 lout << "- Driving #" << (int)GetId() << " to home position, Offset=" << dec << pos << endl; … … 195 195 196 196 // home also defines the zero point of the system 197 // maximum time allowd for home drive: 25.000ms 197 198 SendSDO(0x3001, string('h','o','m','e')); // home 198 WaitForSdo(0x3001 );199 WaitForSdo(0x3001, 0, maxtime*1000); 199 200 lout << "- Home position of #" << (int)GetId() << " reached. " << endl; 200 201 … … 253 254 } 254 255 255 void Macs::SetSyncMode() 256 { 257 lout << "- Setting Sync Mode #" << (int)GetId() << endl; 258 SendSDO(0x3007, string('S', 'Y', 'N', 'C')); 259 WaitForSdo(0x3007); 256 void Macs::StartVelSync() 257 { 258 // 259 // The syncronization mode is disabled by a 'MOTOR STOP' 260 // or by a positioning command (POSA, ...) 261 // 262 lout << "- Setting Vel Sync Mode #" << (int)GetId() << endl; 263 SendSDO(0x3007, 0, string('S', 'Y', 'N', 'C')); 264 WaitForSdo(0x3007, 0); 265 } 266 267 void Macs::StartPosSync() 268 { 269 // 270 // The syncronization mode is disabled by a 'MOTOR STOP' 271 // or by a positioning command (POSA, ...) 272 // 273 lout << "- Setting Pos Sync Mode #" << (int)GetId() << endl; 274 SendSDO(0x3007, 1, string('S', 'Y', 'N', 'C')); 275 WaitForSdo(0x3007, 1); 260 276 } 261 277 /* -
trunk/MagicSoft/Cosy/devdrv/macs.h
r808 r910 2 2 #define MACS_H 3 3 4 #include "timer.h"5 4 #include "nodedrv.h" 5 #include "base/timer.h" 6 6 7 7 class Macs : public NodeDrv … … 51 51 void ReqAxEnd(); 52 52 void ReqVelRes(); 53 void SetHome(LWORDS_t pos=0 );53 void SetHome(LWORDS_t pos=0, WORD_t maxtime=25); 54 54 void SetAcceleration(LWORD_t acc); 55 55 void SetDeceleration(LWORD_t dec); 56 56 void SetVelocity(LWORD_t vel); 57 57 void SetNoWait(BYTE_t flag=TRUE); 58 void SetSyncMode();59 58 void SetRpmMode(BYTE_t mode=TRUE); 60 59 void SetRpmVelocity(LWORDS_t cvel); … … 64 63 65 64 void EnableEndswitches(bool neg=true, bool pos=true); 65 66 void StartVelSync(); 67 void StartPosSync(); 66 68 67 69 void StartRelPos(LWORDS_t pos); -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r732 r910 18 18 // Show information 19 19 // 20 pthread_create(&fThread, NULL, MapUpdateThread, this);20 // pthread_create(&fThread, NULL, MapUpdateThread, this); 21 21 22 22 } … … 24 24 ShaftEncoder::~ShaftEncoder() 25 25 { 26 pthread_cancel(fThread);26 // pthread_cancel(fThread); 27 27 } 28 28 … … 91 91 cout << endl; 92 92 } 93 93 /* 94 94 void *ShaftEncoder::MapUpdateThread(void *data) 95 95 { … … 106 106 return NULL; 107 107 } 108 108 */ 109 void ShaftEncoder::DisplayVal() 110 { 111 static LWORDS_t pos; // ticks 112 static WORDS_t vel; // ticks per 5ms 113 static WORDS_t acc; // ticks per 25ms^2 114 115 char text[21]; 116 117 if (fPos!=pos) 118 { 119 sprintf(text, "%ld", fPos); 120 fLabel[0]->SetText(new TGString(text)); 121 } 122 123 if (fVel!=vel) 124 { 125 sprintf(text, "%d", fVel); 126 fLabel[1]->SetText(new TGString(text)); 127 } 128 129 if (fAcc!=acc) 130 { 131 sprintf(text, "%d", fAcc); 132 fLabel[2]->SetText(new TGString(text)); 133 } 134 } 135 /* 109 136 void ShaftEncoder::UpdateThread() 110 137 { 138 return; 111 139 // 112 140 // check for a running thread and lock mutex 113 141 // 114 char text[21];115 142 116 143 // … … 122 149 while (1) 123 150 { 124 WaitForNextPdo1(); 151 usleep(40000); 152 //WaitForNextPdo1(); 125 153 126 154 // 127 155 // Update information 128 156 // 129 sprintf(text, "%ld", fPos); 130 fLabel[0]->SetText(new TGString(text)); 131 132 sprintf(text, "%d", fVel); 133 fLabel[1]->SetText(new TGString(text)); 134 135 sprintf(text, "%d", fAcc); 136 fLabel[2]->SetText(new TGString(text)); 157 137 158 138 159 // 139 160 // make updated information visible 140 161 // 141 gSystem->ProcessEvents();142 } 143 } 144 162 //gSystem->ProcessEvents(); ----> MCosy::GuiThread 163 } 164 } 165 */ 145 166 void ShaftEncoder::HandlePDOType0(BYTE_t *data) 146 167 { -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r732 r910 23 23 Timer fTime; 24 24 25 pthread_t fThread; 26 27 static void *MapUpdateThread(void *se); 28 void UpdateThread(); 25 // pthread_t fThread; 26 // static void *MapUpdateThread(void *se); 27 // void UpdateThread(); 29 28 30 29 void HandlePDOType0(BYTE_t *data); … … 58 57 59 58 void SetPreset(LWORD_t pre=0); 59 60 void DisplayVal(); 60 61 }; 61 62 -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r808 r910 10 10 #include <TGLabel.h> // TGLabel 11 11 #include <TGSplitter.h> // TGHorizontal3DLine 12 #include <TApplication.h> // gApplication 12 13 13 14 #include "timer.h" // Timer … … 16 17 #include "MGList.h" 17 18 #include "MGCoordinates.h" 19 #include "MGSkyPosition.h" 18 20 19 21 #include "Slalib.h" … … 149 151 150 152 fCoord = new MGCoordinates(this, kTRUE, 151 153 "Coordinate 1 [\xb0]:", "Coordinate 2 [\xb0]:"); 152 154 fCoord->Move(10, 160); 153 155 fList->Add(fCoord); 154 156 157 fSkyPosition = new MGSkyPosition(this); 158 fSkyPosition->Move(320, 40); 159 fSkyPosition->Resize(200, 200); 160 fList->Add(fSkyPosition); 161 155 162 // 156 163 // Map the window, set up the layout, etc. 157 164 // 158 SetWMSizeHints( 350, 250, 350, 250, 10, 10 ); // set the smallest and biggest size of the Main frame165 SetWMSizeHints(550, 250, 550, 250, 10, 10); // set the smallest and biggest size of the Main frame 159 166 160 167 MapSubwindows(); … … 173 180 MGCosy::~MGCosy() 174 181 { 182 cout << "Deleting MGCosy." << endl; 183 175 184 delete fLayMenuBar; 176 185 delete fLayMenuItem; 177 186 178 fList->Delete(); 187 cout << "Deleting MGCosy::fList" << endl; 188 179 189 delete fList; 190 191 cout << "MGCosy deleted." << endl; 180 192 } 181 193 // ====================================================================== … … 188 200 // window menu item is selected. 189 201 190 gSystem->ExitLoop();202 //gSystem->ExitLoop(); 191 203 // gSystem->DispatchOneEvent(kTRUE); 192 204 193 205 // TGMainFrame::CloseWindow(); 194 // gROOT->GetApplication()->Terminate(0);206 gApplication->Terminate(0); 195 207 } 196 208 … … 270 282 { 271 283 case IDM_EXIT: 284 cout << "Idm_Exit." << endl; 272 285 CloseWindow(); 273 286 return kTRUE; -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r740 r910 26 26 class MGList; 27 27 class MGCoordinates; 28 class MGSkyPosition; 28 29 29 30 class MGCosy : public TGMainFrame … … 44 45 45 46 MGCoordinates *fCoord; 47 MGSkyPosition *fSkyPosition; 46 48 47 49 MsgQueue *fQueue; … … 61 63 TGLabel **GetLabel3() { return fLabel3; } 62 64 65 MGSkyPosition *GetSkyDisplay() { return fSkyPosition; } 66 63 67 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2); 64 68 }; -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r808 r910 187 187 188 188 189 void Camera::Execute(const unsigned long n, 190 byte *img, 191 struct timeval *tm) 189 void Camera::ProcessFrame(const unsigned long n, byte *img, 190 struct timeval *tm) 192 191 { 193 192 cout << "Img: " << n << " " << (void*)img << endl; … … 247 246 if (!StartGrab(i&1)) 248 247 break; 249 Execute(i, (byte*)fImg, &fTime);248 ProcessFrame(i, (byte*)fImg, &fTime); 250 249 i++; 251 250 } … … 254 253 { 255 254 LoopStep(i); 256 Execute(i, (byte*)fImg, &fTime);255 ProcessFrame(i, (byte*)fImg, &fTime); 257 256 i++; 258 257 } 259 258 260 259 LoopStep(i); 261 Execute(i, (byte*)fImg, &fTime);260 ProcessFrame(i, (byte*)fImg, &fTime); 262 261 i++; 263 262 -
trunk/MagicSoft/Cosy/videodev/Camera.h
r808 r910 86 86 // Execution of one frame - this function may be overloaded! 87 87 // 88 virtual void Execute(const unsigned long n,89 byte *img, struct timeval *tm);88 virtual void ProcessFrame(const unsigned long n, 89 byte *img, struct timeval *tm); 90 90 91 91 // -
trunk/MagicSoft/Cosy/videodev/Writer.cc
r808 r910 7 7 #include <png.h> 8 8 9 #include " timer.h"9 #include "base/timer.h" 10 10 11 11 void Writer::Png(const char *fname, const byte *buf, … … 80 80 char text[36]; 81 81 82 Timer time (date);83 sprintf(text, "*** %s ***", time .GetTimeStr());82 Timer timet(date); 83 sprintf(text, "*** %s ***", timet.GetTimeStr()); 84 84 png_write_chunk(fPng, (png_byte*)"UTC", (png_byte*)text, strlen(text)); 85 85 sprintf(text,"*** %s %s %.1f %i ***", tzname[0], tzname[1], 1.0/3600*timezone, daylight);
Note:
See TracChangeset
for help on using the changeset viewer.