Changeset 1703 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 01/14/03 12:08:46 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/macs.cc
r1702 r1703 48 48 case 0x100a: 49 49 lout << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl; 50 fSoftVersion = val; 51 return; 52 53 case 0x100b: 54 // Do not display, this is used for CheckConnection 55 // lout << "Node ID: " << dec << val << endl; 50 56 return; 51 57 … … 221 227 } 222 228 223 void Macs::InitDevice(Network *net) 224 { 225 lout << "- " << GetNodeName() << ": MAC Init device." << endl; 226 NodeDrv::InitDevice(net); 227 lout << "- " << GetNodeName() << ": MAC Init device...done." << endl; 228 229 // SendSDO(0x4003, (LWORD_t)('E'<<24 | 'X'<<16 | 'I'<<8 'T')); 230 // WaitForSdo(0x4003, 0); 231 232 /* 233 lout << "- Requesting SDO 0x2002 (vel) of " << (int)GetId() << endl; 234 RequestSDO(0x2002); 235 WaitForSdo(0x2002); 236 237 lout << "- Requesting SDO 0x2003 of " << (int)GetId() << endl; 238 RequestSDO(0x2003); 239 WaitForSdo(0x2003); 240 241 lout << "- Requesting SDO 0x2004 of " << (int)GetId() << endl; 242 RequestSDO(0x2004); 243 WaitForSdo(0x2004); 244 */ 229 void Macs::CheckConnection() 230 { 231 RequestSDO(0x100b); 232 WaitForSdo(0x100b); 233 234 // FIXME! Not statically linked! 235 // if (fSoftVersion<0x00000035) 236 // fIsZombie = true; 237 } 238 239 240 void Macs::Init() 241 { 245 242 lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; 246 243 RequestSDO(0x100a); 247 244 WaitForSdo(0x100a); 248 245 249 if (IsZombie()) 250 return; 246 if (fIsZombie) 247 { 248 lout << GetNodeName() << " - InitDevice failed!" << endl; 249 return; 250 } 251 251 252 252 EnableTimeout(kFALSE); … … 259 259 SendSDO(0x3000, string('o', 'n')); 260 260 WaitForSdo(0x3000); 261 262 261 263 262 // SetHome(250000); … … 413 412 // or by a positioning command (POSA, ...) 414 413 // 415 lout << "- " << GetNodeName() << ": Starting Posi stion Sync Mode." << endl;414 lout << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl; 416 415 SendSDO(0x3007, 1, string('s', 'y', 'n', 'c')); 417 416 WaitForSdo(0x3007, 1); … … 547 546 } 548 547 548 // FIXME? Handling of fIsZombie? 549 549 void Macs::HandleError() 550 550 { -
trunk/MagicSoft/Cosy/devdrv/macs.h
r1702 r1703 11 11 private: 12 12 BYTE_t fMacId; 13 14 LWORD_t fSoftVersion; 13 15 14 16 LWORD_t fVelRes; … … 41 43 Bool_t HandleTimer(TTimer *t); 42 44 45 void Init(); 46 //bool Reboot(); 47 48 //bool InitDevice(Network *); 49 50 //void StartDevice(); 51 void StopDevice(); 52 53 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); 54 void HandleSDOOK(WORD_t idx, BYTE_t subidx); 55 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); } 56 57 void HandlePDO1(BYTE_t *data, timeval_t *tv); 58 void HandlePDO2(BYTE_t *data, timeval_t *tv); 59 60 void CheckConnection(); 61 43 62 public: 63 enum 64 { 65 kNoSync = BIT(0), 66 kPosSync = BIT(1), 67 kVelSync = BIT(2) 68 }; 44 69 enum 45 70 { … … 54 79 Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog); 55 80 virtual ~Macs(); 56 57 void InitDevice(Network *);58 59 //void StartDevice();60 void StopDevice();61 62 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv);63 void HandleSDOOK(WORD_t idx, BYTE_t subidx);64 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }65 66 void HandlePDO1(BYTE_t *data, timeval_t *tv);67 void HandlePDO2(BYTE_t *data, timeval_t *tv);68 81 69 82 void SendMsg(BYTE_t data[6]); -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1701 r1703 51 51 } 52 52 case 0x100b: 53 lout << "Node ID: " << dec << val << endl; 53 // Do not display, this is used for CheckConnection 54 // lout << "Node ID: " << dec << val << endl; 54 55 return; 55 56 … … 94 95 void ShaftEncoder::DisplayVal() 95 96 { 97 if (fIsZombie) 98 { 99 fLabel[0]->SetText(new TGString("")); 100 fLabel[1]->SetText(new TGString("")); 101 fLabel[2]->SetText(new TGString("")); 102 fUpdPos = ~fPos; 103 fUpdVel = ~fVel; 104 fUpdAcc = ~fAcc; 105 return; 106 } 107 96 108 char text[21]; 97 109 … … 190 202 } 191 203 192 void ShaftEncoder::InitDevice(Network *net) 193 { 194 NodeDrv::InitDevice(net); 195 204 void ShaftEncoder::Init() 205 { 196 206 //----------------------------------------------------------------------- 197 207 // Start Setup of the Shaft Encoder … … 203 213 lout << "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl; 204 214 RequestSDO(0x1000); 205 if (!WaitForSdo(0x1000)) 206 { 207 lout << " ... failed." << endl; 208 fIsZombie = true; 215 WaitForSdo(0x1000); 216 217 if (fIsZombie) 218 { 219 lout << GetNodeName() << " - Init failed!" << endl; 209 220 return; 210 221 } … … 265 276 } 266 277 278 void ShaftEncoder::CheckConnection() 279 { 280 // Request Node number 281 RequestSDO(0x100b); 282 WaitForSdo(0x100b); 283 } 284 /* 285 bool ShaftEncoder::InitDevice(Network *net) 286 { 287 NodeDrv::InitDevice(net); 288 289 Init(); 290 291 return !fIsZombie; 292 } 293 294 // -------------------------------------------------------------------------- 295 // 296 // This should be called from a master or main thread to get a node out 297 // of the Zombie-Status. 298 // 299 bool ShaftEncoder::Reboot() 300 { 301 fIsZombie = false; 302 303 Init(); 304 305 return !fIsZombie; 306 } 307 */ 308 267 309 void ShaftEncoder::ReqPos() 268 310 { … … 277 319 void ShaftEncoder::SetPreset(LWORD_t pre) 278 320 { 321 lout << "- " << GetNodeName() << ": Setting Preset." << endl; 322 323 SendSDO(0x6003, (LWORD_t)fPos); 324 if (!WaitForSdo(0x6003)) 325 return; 326 279 327 fPos = pre%16384; 280 328 fTurn = pre/16384; 281 282 lout << "- " << GetNodeName() << ": Setting Preset." << endl;283 SendSDO(0x6003, (LWORD_t)fPos);284 WaitForSdo(0x6003);285 329 } 286 330 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r1690 r1703 32 32 void ReqPos(); 33 33 34 void Init(); 35 void CheckConnection(); 36 34 37 public: 35 38 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog); 36 39 virtual ~ShaftEncoder(); 37 40 38 void InitDevice(Network *); 41 //bool InitDevice(Network *); 42 //bool Reboot(); 39 43 40 44 //void StartDevice(); … … 50 54 void HandlePDO2(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); } 51 55 52 LWORDS_t GetPos() { return f Pos+fTurn*fTicks; }56 LWORDS_t GetPos() { return fIsZombie ? 0 : fPos+fTurn*fTicks; } // FIXME? 0? 53 57 LWORD_t GetPhysRes() { return fTicks; } 54 58
Note:
See TracChangeset
for help on using the changeset viewer.