Changeset 9439 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 05/09/09 13:48:12 (15 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/dkc.cc
r9435 r9439 22 22 fStatus(0), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false), 23 23 fReport(NULL),fLabel(NULL),fUpdPos(0) 24 {25 }26 27 Dkc::~Dkc()28 24 { 29 25 } … … 165 161 { 166 162 case 0x1000: 167 if (subidx==1) 168 { 169 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl; 170 fArmed = val==1; 171 } 163 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl; 164 fArmed = val==1; 172 165 return; 173 166 174 167 case 0x1003: 175 168 // FIXME, see Init 176 if (subidx!=2)177 return;178 169 gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << hex << val << dec << endl; 179 170 CheckErrorDKC(val); … … 196 187 197 188 case 0x6004: 198 if (subidx==0) 199 { 200 fPdoPos1 = (LWORDS_t)val; 201 fPdoTime1.Set(tv); 202 fHasChangedPos1 = true; 203 } 204 if (subidx==1) 205 { 206 fPdoPos2 = (LWORDS_t)val; 207 fPdoTime2.Set(tv); 208 fHasChangedPos2 = true; 209 } 189 fPdoPos1 = (LWORDS_t)val; 190 fPdoTime1.Set(tv); 191 fHasChangedPos1 = true; 192 return; 193 194 case 0x6005: 195 fPdoPos2 = (LWORDS_t)val; 196 fPdoTime2.Set(tv); 197 fHasChangedPos2 = true; 210 198 return; 211 199 … … 246 234 { 247 235 case 0x1000: 248 switch (subidx) 249 { 250 case 1: 251 //lout << ddev(MLog::eGui); 252 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl; 253 //lout << edev(MLog::eGui); 254 return; 255 } 256 break; 236 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl; 237 return; 238 239 case 0x1001: 240 gLog << inf2 << "- " << GetNodeName() << ": PDOs requested." << endl; 241 return; 257 242 258 243 case 0x2002: 259 //lout << ddev(MLog::eGui);260 244 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl; 261 //lout << edev(MLog::eGui);262 245 return; 263 246 264 247 case 0x2003: 265 //lout << ddev(MLog::eGui);266 248 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl; 267 //lout << edev(MLog::eGui);268 249 return; 269 250 270 251 case 0x3006: 271 switch (subidx) 272 { 273 case 0: 274 //lout << ddev(MLog::eGui); 275 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl; 276 //lout << edev(MLog::eGui); 277 return; 278 279 case 1: 280 /* 281 lout << ddev(MLog::eGui); 282 lout << "- Velocity set (" << GetNodeName() << ")" << endl; 283 lout << edev(MLog::eGui); 284 */ 285 return; 286 } 287 break; 252 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl; 253 return; 254 255 case 0x3007: 256 //gLog << inf2 << "- Velocity set (" << GetNodeName() << ")" << endl; 257 return; 288 258 289 259 case 0x4000: … … 292 262 293 263 case 0x6000: 294 //lout << ddev(MLog::eGui);295 264 gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl; 296 //lout << edev(MLog::eGui);297 265 return; 298 266 299 267 case 0x6002: 300 //lout << ddev(MLog::eGui); 301 gLog << inf2 << "- " << GetNodeName() << ": Velocitz resolution set." << endl; 302 //lout << edev(MLog::eGui); 268 gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution set." << endl; 303 269 return; 304 270 305 271 case 0x6004: 306 switch (subidx) 307 { 308 case 0: 309 //lout << ddev(MLog::eGui); 310 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 311 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 312 //lout << edev(MLog::eGui); 313 return; 314 315 case 1: 316 //lout << ddev(MLog::eGui); 317 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 318 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 319 //lout << edev(MLog::eGui); 320 return; 321 } 322 break; 323 324 325 } 272 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 273 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 274 return; 275 276 case 0x6005: 277 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 278 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 279 return; 280 } 281 326 282 NodeDrv::HandleSDOOK(idx, subidx, data, tv); 327 283 } … … 348 304 } 349 305 350 void Dkc::StartNode()351 {352 //353 // Switch node from pre-operational state to operational state354 // (This is not CANOpen compatible)355 // After this the MACS will react on real movement commands.356 //357 gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl;358 SendSDO(0x1000, 1, (LWORD_t)1);359 WaitForSdo(0x1000, 1);360 }361 362 306 void Dkc::Arm() 363 307 { 364 StartNode(); 308 gLog << inf2 << "- " << GetNodeName() << ": Arming node." << endl; 309 SendSDO(0x1000, (LWORD_t)1); 310 WaitForSdo(0x1000); 365 311 } 366 312 367 313 void Dkc::Disarm() 368 314 { 369 gLog << inf2 << "- " << GetNodeName() << ": Stopping Node." << endl;370 SendSDO(0x1000, 1,(LWORD_t)0);371 WaitForSdo(0x1000 , 1);315 gLog << inf2 << "- " << GetNodeName() << ": Disarming Node." << endl; 316 SendSDO(0x1000, (LWORD_t)0); 317 WaitForSdo(0x1000); 372 318 } 373 319 … … 385 331 // 386 332 gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl; 387 RequestSDO(0x1003 , 2);388 WaitForSdo(0x1003 , 2);333 RequestSDO(0x1003); 334 WaitForSdo(0x1003); 389 335 390 336 /* … … 404 350 ReqVelMax(); // Init fVelMax 405 351 352 // Request to send all PDOs at least once 353 ReqPDOs(); 354 406 355 #ifdef EXPERT 407 StartNode();356 Arm(); 408 357 #endif 409 358 410 359 gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl; 411 RequestSDO(0x1000 , 1);412 WaitForSdo(0x1000 , 1);360 RequestSDO(0x1000); 361 WaitForSdo(0x1000); 413 362 } 414 363 … … 422 371 } 423 372 373 void Dkc::ReqPDOs() 374 { 375 gLog << inf2 << "- " << GetNodeName() << ": Requesting all PDOs." << endl; 376 377 SendSDO(0x1001, (LWORD_t)1); 378 WaitForSdo(0x1001); 379 } 380 424 381 void Dkc::ReqPos1() 425 382 { 426 383 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 1." << endl; 427 RequestSDO(0x6004 , 0);428 WaitForSdo(0x6004 , 0);384 RequestSDO(0x6004); 385 WaitForSdo(0x6004); 429 386 } 430 387 … … 432 389 { 433 390 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 2." << endl; 434 RequestSDO(0x600 4, 1);435 WaitForSdo(0x600 4, 1);391 RequestSDO(0x6005); 392 WaitForSdo(0x6005); 436 393 } 437 394 … … 460 417 { 461 418 gLog << dbg << "- Setting acceleration to: " << acc << endl; 462 SendSDO(0x2003, 0, acc); // acceleration 463 WaitForSdo(0x2003, 0); 464 } 465 /* 466 void Dkc::SetDeceleration(LWORD_t dec) 467 { 468 gLog << dbg << "- Setting deceleration to: " << dec << endl; 469 SendSDO(0x2003, 1, dec); 470 WaitForSdo(0x2003, 1); 471 } 472 */ 419 SendSDO(0x2003, acc); // acceleration 420 WaitForSdo(0x2003); 421 } 422 473 423 void Dkc::SetRpmMode(BYTE_t mode) 474 424 { … … 476 426 // SetRpmMode(FALSE) stop the motor, but lets the position control unit on 477 427 // 478 SendSDO(0x3006, 0,mode ? string('s','t','r','t') : string('s','t','o','p'));479 WaitForSdo(0x3006 , 0);428 SendSDO(0x3006, mode ? string('s','t','r','t') : string('s','t','o','p')); 429 WaitForSdo(0x3006); 480 430 } 481 431 482 432 void Dkc::SetRpmVelocity(LWORDS_t cvel) 483 433 { 484 SendSDO(0x300 6, 1, (LWORD_t)cvel);485 WaitForSdo(0x300 6, 1);434 SendSDO(0x3007, (LWORD_t)cvel); 435 WaitForSdo(0x3007); 486 436 } 487 437 … … 496 446 497 447 gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORDS_t)pos << " ticks." << endl; 498 SendSDO(0x600 4, 1, (LWORD_t)pos);448 SendSDO(0x6005, (LWORD_t)pos); 499 449 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 500 450 } … … 510 460 511 461 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << (LWORDS_t)pos << " ticks." << endl; 512 SendSDO(0x6004, 0,(LWORD_t)pos);462 SendSDO(0x6004, (LWORD_t)pos); 513 463 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 514 464 } … … 526 476 527 477 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << p << " ticks." << endl; 528 SendSDO(0x6004, 0,p);478 SendSDO(0x6004, p); 529 479 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO 530 }531 532 void Dkc::StartVelSync()533 {534 //535 // The syncronization mode is disabled by a 'MOTOR STOP'536 // or by a positioning command (POSA, ...)537 //538 gLog << inf2 << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;539 SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));540 WaitForSdo(0x3007, 0);541 }542 543 void Dkc::StartPosSync()544 {545 //546 // The syncronization mode is disabled by a 'MOTOR STOP'547 // or by a positioning command (POSA, ...)548 //549 gLog << inf2 << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;550 SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));551 WaitForSdo(0x3007, 1);552 480 } 553 481 -
trunk/MagicSoft/Cosy/devdrv/dkc.h
r9132 r9439 73 73 public: 74 74 Dkc(const BYTE_t nodeid, const char *name=NULL); 75 virtual ~Dkc() ;75 virtual ~Dkc() { } 76 76 77 77 static LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0) … … 84 84 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0); 85 85 86 void ReqPDOs(); 86 87 void ReqPos1(); 87 88 void ReqPos2(); … … 91 92 void ReqVelMax(); 92 93 void SetAcceleration(LWORD_t acc); 93 void SetDeceleration(LWORD_t dec);94 // void SetDeceleration(LWORD_t dec); 94 95 void SetVelocity(LWORD_t vel); 95 96 void SetVelocityRel(Double_t vel); 96 97 void SetRpmMode(BYTE_t mode=TRUE); 97 98 void SetRpmVelocity(LWORDS_t cvel); 98 void SetPDO1On(BYTE_t flag=TRUE);99 100 void StartVelSync();101 void StartPosSync();102 99 103 100 void StartRelPos(LWORDS_t pos); 104 101 void StartAbsPos(LWORDS_t pos); 105 102 void StartAbsPosRev(Double_t pos); 106 107 void StartNode();108 103 109 104 bool IsArmed() const { return fArmed; }
Note:
See TracChangeset
for help on using the changeset viewer.