Changeset 8835
- Timestamp:
- 01/24/08 16:38:40 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r8834 r8835 80 80 - changed to new threading classes 81 81 - thread doesn't run detached anymore 82 83 * candrv/nodedrv.[h,cc], devdrv/macs.[h,cc], devdrv/shaftencoder.[h,cc]: 84 - changed from lout to gLog 85 - added maipulators 86 - removed MLog from the constructor 82 87 83 88 -
trunk/MagicSoft/Cosy/candrv/network.cc
r8813 r8835 32 32 #include "network.h" 33 33 34 #include <iostream> // cout35 #include <iomanip> // setw, setfill34 #include "MLog.h" 35 #include "MLogManip.h" 36 36 37 37 ClassImp(Network); … … 46 46 void Network::Start() 47 47 { 48 gLog << "- Starting network." << endl;48 gLog << inf << "- Starting network." << endl; 49 49 50 50 CanOpen::Start(); 51 51 InitNodes(); 52 52 53 gLog << "- Network started." << endl;53 gLog << inf << "- Network started." << endl; 54 54 } 55 55 … … 60 60 void Network::Stop() 61 61 { 62 gLog << "- Stopping network." << endl;62 gLog << inf << "- Stopping network." << endl; 63 63 64 64 StopNodes(); 65 65 CanOpen::Stop(); 66 66 67 gLog << "- Network stopped." << endl;67 gLog << inf << "- Network stopped." << endl; 68 68 } 69 69 … … 77 77 memset(fNodeInitialized, 0, 32*sizeof(*fNodeInitialized)); 78 78 79 gLog << "- Network initialized." << endl;79 gLog << inf << "- Network initialized." << endl; 80 80 } 81 81 … … 115 115 } 116 116 117 cout<< dec << setfill('0');118 cout<< "Network::HandleSDO: Node=" << (int)node << " Cmd=0x" << hex << (int)cmd << ": ";119 cout<< "Sdo=" << idx << "/" << (int)subidx << ": 0x" << setw(8) << data;120 cout<< endl;117 gLog << warn << dec << setfill('0'); 118 gLog << "Network::HandleSDO: Node=" << (int)node << " Cmd=0x" << hex << (int)cmd << ": "; 119 gLog << "Sdo=" << idx << "/" << (int)subidx << ": 0x" << setw(8) << data; 120 gLog << endl; 121 121 } 122 122 … … 129 129 if (!fNodes[node]) 130 130 { 131 cout << "Network::HandlePDO1: Node #" << dec << (int)node << " not found - PDO1: " << hex;131 gLog << err << "ERROR - Network::HandlePDO1: Node #" << dec << (int)node << " not found - PDO1: " << hex; 132 132 for (int i=0; i<8; i++) 133 cout<< " 0x" << (int)data[i];134 cout<< endl;133 gLog << " 0x" << (int)data[i]; 134 gLog << endl; 135 135 return; 136 136 } … … 147 147 if (!fNodes[node]) 148 148 { 149 cout << "Network::HandlePDO2: Node #" << dec << (int)node << " not found - PDO2: " << hex;149 gLog << err << "ERROR - Network::HandlePDO2: Node #" << dec << (int)node << " not found - PDO2: " << hex; 150 150 for (int i=0; i<8; i++) 151 cout<< " 0x" << (int)data[i];152 cout<< endl;151 gLog << " 0x" << (int)data[i]; 152 gLog << endl; 153 153 return; 154 154 } … … 165 165 if (!fNodes[node]) 166 166 { 167 cout << "Network::HandlePDO3: Node #" << dec << (int)node << " not found - PDO3: " << hex;167 gLog << err << "ERROR - Network::HandlePDO3: Node #" << dec << (int)node << " not found - PDO3: " << hex; 168 168 for (int i=0; i<8; i++) 169 cout<< " 0x" << (int)data[i];170 cout<< endl;169 gLog << " 0x" << (int)data[i]; 170 gLog << endl; 171 171 return; 172 172 } … … 183 183 if (!fNodes[node]) 184 184 { 185 cout << "Network::HandlePDO4: Node #" << dec << (int)node << " not found - PDO4: " << hex;185 gLog << err << "ERROR - Network::HandlePDO4: Node #" << dec << (int)node << " not found - PDO4: " << hex; 186 186 for (int i=0; i<8; i++) 187 cout<< " 0x" << (int)data[i];188 cout<< endl;187 gLog << " 0x" << (int)data[i]; 188 gLog << endl; 189 189 return; 190 190 } … … 202 202 if (!fNodes[node]) 203 203 { 204 cout << "Network::HandleNodeguard: Node #" << dec << (int)node << " not found: Nodeguard." << endl;204 gLog << err << "ERROR - Network::HandleNodeguard: Node #" << dec << (int)node << " not found: Nodeguard." << endl; 205 205 return; 206 206 } … … 218 218 if (!fNodes[node]) 219 219 { 220 cout << "Network::HandleEmergency: Node #" << dec << (int)node << " not found: Emergency." << endl;220 gLog << err << "ERROR - Network::HandleEmergency: Node #" << dec << (int)node << " not found: Emergency." << endl; 221 221 return; 222 222 } … … 236 236 if (nodeid>31) 237 237 { 238 cout << "SetNode - Error: Only node Numbers < 32 are allowed"<< endl;238 gLog << err << "ERROR - Network::SetNode: Only node Numbers < 32 are allowed"<< endl; 239 239 return; 240 240 } … … 252 252 if (fNodes[i]) 253 253 { 254 gLog << "- Setting up Node #" << dec << i << " (";254 gLog << inf2 << "- Setting up Node #" << dec << i << " ("; 255 255 gLog << fNodes[i]->GetNodeName() << ")" << endl; 256 256 if (fNodes[i]->InitDevice(this)) 257 257 fNodeInitialized[i] = TRUE; 258 258 else 259 gLog << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl;259 gLog << err << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl; 260 260 } 261 gLog << "- All Nodes setup." << endl;261 gLog << inf << "- All Nodes setup." << endl; 262 262 } 263 263 … … 271 271 if (fNodes[i] && fNodeInitialized[i]) 272 272 { 273 gLog << "- Stopping Node #" << dec << i;273 gLog << inf2 << "- Stopping Node #" << dec << i; 274 274 gLog << " (" << fNodes[i]->GetNodeName() << ")" << endl; 275 275 fNodes[i]->StopDevice(); 276 276 } 277 gLog << "- All Nodes stopped." << endl;277 gLog << inf << "- All Nodes stopped." << endl; 278 278 } 279 279 … … 292 292 continue; 293 293 294 gLog << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName() << "' ";294 gLog << err << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName() << "' "; 295 295 296 296 if (fNodes[i]->GetError() <= 0) … … 362 362 } 363 363 364 if (rc)365 gLog<< "- All Zombies rebooted." << endl;364 // if (rc) 365 // gLog << inf << "- All Zombies rebooted." << endl; 366 366 367 367 return rc; -
trunk/MagicSoft/Cosy/candrv/network.h
r8813 r8835 42 42 bool HasZombie() const; 43 43 44 bool RebootZombies( );44 bool RebootZombies(Int_t max=33); 45 45 void CheckConnections(); 46 46 -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r8823 r8835 52 52 #include "MTime.h" 53 53 #include "network.h" 54 54 55 #include "MLogManip.h" 55 56 … … 65 66 // and the node name. The name is a name for debug output. 66 67 // 67 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name , MLog &out) : Log(out),fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE), fGuard(NULL)68 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name) : fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE), fGuard(NULL) 68 69 { 69 70 if (nodeid>0x1f) 70 71 { 71 cout << "SetNode - Error: Only node Numbers < 32 are allowed"<< endl;72 gLog << err << "ERROR - NodeDrv::NodeDrv: Only node Numbers < 32 are allowed"<< endl; 72 73 return; 73 74 } … … 83 84 } 84 85 85 lout<< "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl;86 gLog << inf2 << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl; 86 87 87 88 } … … 149 150 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, const timeval_t &tv) 150 151 { 151 const Bool_t gui = lout.IsOutputDeviceEnabled(MLog::eGui);152 const Bool_t gui = gLog.IsOutputDeviceEnabled(MLog::eGui); 152 153 153 154 if (gui) 154 lout<< ddev(MLog::eGui);155 156 lout << hex << setfill('0');157 lout<< "Node #" << dec << (int)fId << ": Sdo=" << hex << idx << "/" << (int)subidx << " set.";158 lout<< endl;155 gLog << ddev(MLog::eGui); 156 157 gLog << warn << setfill('0') << "WARNING - Nodedrv::HandleSDOOK: "; 158 gLog << "Node #" << dec << (int)fId << ": Sdo=" << hex << idx << "/" << (int)subidx << " set."; 159 gLog << endl; 159 160 160 161 if (gui) 161 lout<< edev(MLog::eGui);162 gLog << edev(MLog::eGui); 162 163 } 163 164 … … 168 169 void NodeDrv::HandleSDOError(LWORD_t data) 169 170 { 170 lout << "Nodedrv: SDOError: Entry not found in dictionary (data=0x";171 lout<< hex << setfill('0') << setw(4) << data << ")";172 lout<< endl;171 gLog << warn << "WARNING - Nodedrv::HandleSDOError: Entry not found in dictionary (data=0x"; 172 gLog << hex << setfill('0') << setw(4) << data << ")"; 173 gLog << endl; 173 174 } 174 175 … … 179 180 void NodeDrv::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, const timeval_t &tv) 180 181 { 181 cout << "SdoRx: Idx=0x"<< hex << idx << "/" << (int)subidx;182 cout<< ", val=0x" << val << endl;182 gLog << warn << "WARNING - Nodedrv::HandleSDO: Idx=0x"<< hex << idx << "/" << (int)subidx; 183 gLog << ", val=0x" << val << endl; 183 184 } 184 185 … … 426 427 return true; 427 428 428 lout<< " + " << GetNodeName() << ": NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " --> ZOMBIE! " << MTime(-1) << endl;429 gLog << inf2 << " + " << GetNodeName() << ": NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " --> ZOMBIE! " << MTime(-1) << endl; 429 430 if (zombie) 430 431 SetZombie(); … … 555 556 fGuard->RunThread(); 556 557 557 lout<< "- " << GetNodeName() << ": Guarding (" << dec;558 lout<< fLifeTimeFactor << "*" << fGuardTime << "ms) started." << endl;558 gLog << inf << "- " << GetNodeName() << ": Guarding (" << dec; 559 gLog << fLifeTimeFactor << "*" << fGuardTime << "ms) started." << endl; 559 560 } 560 561 … … 563 564 if (fGuard) 564 565 { 565 lout<< "- " << GetNodeName() << ": ERROR - Guarding already started." << endl;566 gLog << err << "- " << GetNodeName() << ": ERROR - Guarding already started." << endl; 566 567 return; 567 568 } … … 581 582 fGuard=NULL; 582 583 583 lout<< "- " << GetNodeName() << ": Guarding stopped." << endl;584 gLog << inf << "- " << GetNodeName() << ": Guarding stopped." << endl; 584 585 } 585 586 … … 601 602 StopGuarding(); 602 603 else 603 lout<< " - " << GetNodeName() << ": Zombie set due to timeout." << endl;604 } 604 gLog << warn << " - " << GetNodeName() << ": Zombie set due to timeout." << endl; 605 } -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r8813 r8835 4 4 #ifndef ROOT_TString 5 5 #include <TString.h> 6 #endif7 8 #ifndef COSY_Log9 #include "log.h"10 6 #endif 11 7 … … 25 21 class NodeGuard; 26 22 27 class NodeDrv : public Log23 class NodeDrv 28 24 { 29 25 private: … … 50 46 51 47 public: 52 NodeDrv(BYTE_t nodeid, const char *name=NULL , MLog &out=gLog);48 NodeDrv(BYTE_t nodeid, const char *name=NULL); 53 49 virtual ~NodeDrv(); 54 50 -
trunk/MagicSoft/Cosy/devdrv/macs.cc
r8811 r8835 1 1 #include "macs.h" 2 2 3 #include <iostream>4 3 #include <sys/time.h> // timeval->tv_sec 5 4 … … 29 28 */ 30 29 31 Macs::Macs(const BYTE_t nodeid, const char *name , MLog &out)32 : NodeDrv(nodeid, name , out), fMacId(2*nodeid+1),30 Macs::Macs(const BYTE_t nodeid, const char *name) 31 : NodeDrv(nodeid, name), fMacId(2*nodeid+1), 33 32 fPos(0), fPdoPos(0), fPosActive(0), fRpmActive(0), 34 33 fStatusPdo3(0xff) … … 53 52 if (subidx!=2) 54 53 return; 55 lout<< "- " << GetNodeName() << ": Error[0]=" << dec << val << endl;54 gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << dec << val << endl; 56 55 SetError(val); 57 56 return; 58 57 59 58 case 0x100a: 60 lout<< "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;59 gLog << inf2 << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl; 61 60 fSoftVersion = val; 62 61 return; … … 68 67 69 68 case 0x100c: 70 lout<< "- " << GetNodeName() << ": Guard time:" << dec << val << endl;69 gLog << inf2 << "- " << GetNodeName() << ": Guard time:" << dec << val << endl; 71 70 return; 72 71 73 72 case 0x100d: 74 lout<< "- " << GetNodeName() << ": Life time factor:" << dec << val << endl;73 gLog << inf2 << "- " << GetNodeName() << ": Life time factor:" << dec << val << endl; 75 74 return; 76 75 77 76 case 0x2002: 78 cout<< GetNodeName() << ": Current velocity: " << dec << val << endl;77 gLog << inf2 << GetNodeName() << ": Current velocity: " << dec << val << endl; 79 78 fVel = val; 80 79 return; … … 123 122 124 123 case 0x6002: 125 lout<< "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl;124 gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl; 126 125 fVelRes = val; 127 126 return; 128 127 129 128 case 0x6501: 130 lout<< "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl;129 gLog << inf2 << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl; 131 130 fRes = val; 132 131 return; 133 132 } 134 cout << "Macs: SDO, idx=0x"<< hex << idx << "/" << (int)subidx; 135 cout << ", val=0x"<<val<<endl; 133 134 NodeDrv::HandleSDO(idx, subidx, val, tv); 135 136 // cout << "Macs: SDO, idx=0x"<< hex << idx << "/" << (int)subidx; 137 // cout << ", val=0x"<<val<<endl; 136 138 } 137 139 … … 154 156 case 1: 155 157 //lout << ddev(MLog::eGui); 156 lout<< "- " << GetNodeName() << ": State of node set." << endl;158 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl; 157 159 //lout << edev(MLog::eGui); 158 160 return; … … 165 167 case 0: 166 168 //lout << ddev(MLog::eGui); 167 lout<< "- " << GetNodeName() << ": Guard time set." << endl;169 gLog << inf2 << "- " << GetNodeName() << ": Guard time set." << endl; 168 170 //lout << edev(MLog::eGui); 169 171 return; … … 176 178 case 0: 177 179 //lout << ddev(MLog::eGui); 178 lout<< "- " << GetNodeName() << ": Life time factor set." << endl;180 gLog << inf2 << "- " << GetNodeName() << ": Life time factor set." << endl; 179 181 //lout << edev(MLog::eGui); 180 182 return; … … 187 189 case 1: 188 190 //lout << ddev(MLog::eGui); 189 lout<< "- " << GetNodeName() << ": Status of PDO1 set." << endl;191 gLog << inf2 << "- " << GetNodeName() << ": Status of PDO1 set." << endl; 190 192 //lout << edev(MLog::eGui); 191 193 return; … … 198 200 case 0: 199 201 //lout << ddev(MLog::eGui); 200 lout<< "- " << GetNodeName() << ": Velocity set." << endl;202 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl; 201 203 //lout << edev(MLog::eGui); 202 204 return; … … 209 211 case 0: 210 212 //lout << ddev(MLog::eGui); 211 lout<< "- " << GetNodeName() << ": Acceleration set." << endl;213 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl; 212 214 //lout << edev(MLog::eGui); 213 215 return; 214 216 case 1: 215 217 //lout << ddev(MLog::eGui); 216 lout<< "- " << GetNodeName() << ": Deceleration set." << endl;218 gLog << inf2 << "- " << GetNodeName() << ": Deceleration set." << endl; 217 219 //lout << edev(MLog::eGui); 218 220 return; … … 225 227 case 0: 226 228 //lout << ddev(MLog::eGui); 227 lout<< "- " << GetNodeName() << ": RPM mode switched." << endl;229 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl; 228 230 //lout << edev(MLog::eGui); 229 231 return; … … 245 247 case 0x6000: 246 248 //lout << ddev(MLog::eGui); 247 lout<< "- " << GetNodeName() << ": Rotation direction set." << endl;249 gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl; 248 250 //lout << edev(MLog::eGui); 249 251 return; … … 251 253 case 0x6002: 252 254 //lout << ddev(MLog::eGui); 253 lout<< "- " << GetNodeName() << ": Velocitz resolution set." << endl;255 gLog << inf2 << "- " << GetNodeName() << ": Velocitz resolution set." << endl; 254 256 //lout << edev(MLog::eGui); 255 257 return; … … 260 262 case 0: 261 263 //lout << ddev(MLog::eGui); 262 lout<< "- " << GetNodeName() << ": Absolute positioning started." << endl;264 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 263 265 //lout << edev(MLog::eGui); 264 266 return; … … 266 268 case 1: 267 269 //lout << ddev(MLog::eGui); 268 lout<< "- " << GetNodeName() << ": Relative positioning started." << endl;270 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 269 271 //lout << edev(MLog::eGui); 270 272 return; … … 277 279 case 0: 278 280 //lout << ddev(MLog::eGui); 279 lout<< "- " << GetNodeName() << ": Absolute positioning started." << endl;281 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl; 280 282 //lout << edev(MLog::eGui); 281 283 return; … … 283 285 case 1: 284 286 //lout << ddev(MLog::eGui); 285 lout<< "- " << GetNodeName() << ": Relative positioning started." << endl;287 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl; 286 288 //lout << edev(MLog::eGui); 287 289 return; … … 296 298 void Macs::ReqVelRes() 297 299 { 298 lout<< "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl;300 gLog << inf2 << "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl; 299 301 RequestSDO(0x6002); 300 302 WaitForSdo(0x6002); … … 303 305 void Macs::ReqRes() 304 306 { 305 lout<< "- " << GetNodeName() << ": Requesting encoder resolution (res, 0x6501)." << endl;307 gLog << inf2 << "- " << GetNodeName() << ": Requesting encoder resolution (res, 0x6501)." << endl; 306 308 RequestSDO(0x6501); 307 309 WaitForSdo(0x6501); … … 310 312 void Macs::SetPDO1On(BYTE_t flag) 311 313 { 312 lout<< "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl;314 gLog << inf2 << "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl; 313 315 SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31); 314 316 WaitForSdo(0x1800, 1); … … 322 324 // After this the MACS will react on real movement commands. 323 325 // 324 lout<< "- " << GetNodeName() << ": Starting Node." << endl;326 gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl; 325 327 SendSDO(0x1000, 1, (LWORD_t)1); 326 328 WaitForSdo(0x1000, 1); … … 339 341 // error list) 340 342 // 341 lout<< "- " << GetNodeName() << ": Requesting Error[0]." << endl;343 gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl; 342 344 RequestSDO(0x1003, 2); 343 345 WaitForSdo(0x1003, 2); 344 346 if (HasError()) 345 347 { 346 lout<< "Macs::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl;348 gLog << err << "Macs::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl; 347 349 SetZombie(); 348 350 } … … 353 355 StopGuarding(); 354 356 355 lout<< "- " << GetNodeName() << ": Requesting Mac Software Version." << endl;357 gLog << inf2 << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl; 356 358 RequestSDO(0x100a); 357 359 WaitForSdo(0x100a); … … 360 362 if (fSoftVersion<0x00000045) // 00.69 361 363 { 362 lout<< GetNodeName() << " - Software Version too old!" << endl;364 gLog << err << GetNodeName() << " - Software Version too old!" << endl; 363 365 SetZombie(); 364 366 return; … … 431 433 void Macs::ReqPos() 432 434 { 433 lout<< "- " << GetNodeName() << ": Requesting Position." << endl;435 gLog << inf2 << "- " << GetNodeName() << ": Requesting Position." << endl; 434 436 RequestSDO(0x6004); 435 437 WaitForSdo(0x6004); … … 438 440 void Macs::ReqVel() 439 441 { 440 lout<< "- " << GetNodeName() << ": Requesting Velocity." << endl;442 gLog << inf2 << "- " << GetNodeName() << ": Requesting Velocity." << endl; 441 443 RequestSDO(0x2002); 442 444 WaitForSdo(0x2002); … … 523 525 // or by a positioning command (POSA, ...) 524 526 // 525 lout<< "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;527 gLog << inf2 << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl; 526 528 SendSDO(0x3007, 0, string('s', 'y', 'n', 'c')); 527 529 WaitForSdo(0x3007, 0); … … 534 536 // or by a positioning command (POSA, ...) 535 537 // 536 lout<< "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;538 gLog << inf2 << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl; 537 539 SendSDO(0x3007, 1, string('s', 'y', 'n', 'c')); 538 540 WaitForSdo(0x3007, 1); … … 591 593 if (!errnum) 592 594 { 593 lout<< "- " << GetNodeName() << ": reports Error occursion." << endl;594 lout<< "Macs::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl;595 gLog << err << "- " << GetNodeName() << ": reports Error occursion." << endl; 596 gLog << "Macs::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl; 595 597 SetZombie(); 596 598 SetError(-1); … … 604 606 if (GetError()>0) 605 607 { 606 lout<< GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl;608 gLog << warn << GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl; 607 609 608 610 // … … 615 617 SetError(errnum); 616 618 617 lout<< GetNodeName() << " reports: ";619 gLog << err << GetNodeName() << " reports: "; 618 620 switch (errnum) 619 621 { 620 622 case 3: 621 lout<< "Axis does not existing." << endl;623 gLog << "Axis does not existing." << endl; 622 624 return; 623 625 case 5: 624 lout<< "Error not cleared (while trying to move axis)" << endl;626 gLog << "Error not cleared (while trying to move axis)" << endl; 625 627 return; 626 628 case 6: … … 630 632 // from reporting this error a thousands of times. 631 633 // 632 lout<< "Home position not the first positioning command." << endl;634 gLog << "Home position not the first positioning command." << endl; 633 635 SetError(0); 634 636 return; 635 637 case 8: 636 lout<< "Control deviation overflow." << endl;638 gLog << "Control deviation overflow." << endl; 637 639 return; 638 640 case 9: 639 lout<< "Zero index not found." << endl;641 gLog << "Zero index not found." << endl; 640 642 return; 641 643 case 10: 642 lout<< "Unknown command, syntax error." << endl;643 lout<< "Please recompile and reload program." << endl;644 gLog << "Unknown command, syntax error." << endl; 645 gLog << "Please recompile and reload program." << endl; 644 646 return; 645 647 case 11: … … 648 650 { 649 651 case -1: 650 lout<< "Negative";652 gLog << "Negative"; 651 653 break; 652 654 case 1: 653 lout<< "Positive";655 gLog << "Positive"; 654 656 break; 655 657 default: 656 lout<< "-unknown-";658 gLog << "-unknown-"; 657 659 } 658 660 switch (errnum) 659 661 { 660 662 case 11: 661 lout<< " software";663 gLog << " software"; 662 664 break; 663 665 case 25: 664 lout<< " hardware";666 gLog << " hardware"; 665 667 break; 666 668 } 667 lout<< " endswitch activated." << endl;669 gLog << " endswitch activated." << endl; 668 670 return; 669 671 case 12: 670 lout<< "Wrong parameter number used in SET command." << endl;672 gLog << "Wrong parameter number used in SET command." << endl; 671 673 return; 672 674 case 14: 673 lout<< " Too many LOOP calls." << endl;675 gLog << " Too many LOOP calls." << endl; 674 676 return; 675 677 case 16: 676 lout<< "Parameter in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;677 lout<< "Please use APOSS to 'Reset' the MACS and reload the parameters." << endl;678 gLog << "Parameter in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl; 679 gLog << "Please use APOSS to 'Reset' the MACS and reload the parameters." << endl; 678 680 return; 679 681 case 17: 680 lout<< "Program in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;681 lout<< "Please use APOSS to delete all Programs restore the programs." << endl;682 gLog << "Program in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl; 683 gLog << "Please use APOSS to delete all Programs restore the programs." << endl; 682 684 return; 683 685 case 18: 684 lout<< "Reset by CPU (reset called by Watch-dog cause of CPU halted)" << endl;685 lout<< "Possible reasons: short under-/overvoltage or shortcut." << endl;686 gLog << "Reset by CPU (reset called by Watch-dog cause of CPU halted)" << endl; 687 gLog << "Possible reasons: short under-/overvoltage or shortcut." << endl; 686 688 return; 687 689 case 19: 688 lout<< "User break (autostart program stopped by user)" << endl;690 gLog << "User break (autostart program stopped by user)" << endl; 689 691 return; 690 692 case 51: 691 lout<< "Too many (>=10) GOSUB calls." << endl;693 gLog << "Too many (>=10) GOSUB calls." << endl; 692 694 return; 693 695 case 52: 694 lout<< "Too many RETURN calls." << endl;696 gLog << "Too many RETURN calls." << endl; 695 697 return; 696 698 case 62: 697 lout<< "Error veryfiing EEPROM after access (Try again savaing parameters or program)" << endl;699 gLog << "Error veryfiing EEPROM after access (Try again savaing parameters or program)" << endl; 698 700 return; 699 701 case 70: 700 lout<< "Error in DIM call (call to DIM doesn't fit existing DIM call)" << endl;702 gLog << "Error in DIM call (call to DIM doesn't fit existing DIM call)" << endl; 701 703 return; 702 704 case 71: 703 lout<< "Array out of bound." << endl;705 gLog << "Array out of bound." << endl; 704 706 return; 705 707 case 79: 706 lout<< "Timeout waiting for index (WAITNDX)." << endl;708 gLog << "Timeout waiting for index (WAITNDX)." << endl; 707 709 return; 708 710 case 84: 709 lout<< "Too many (>12) ON TIME calls." << endl;711 gLog << "Too many (>12) ON TIME calls." << endl; 710 712 return; 711 713 case 87: 712 lout<< "Out of memory for variables - Check APOSS predifined number of" << endl;713 lout<< "variables and try deleting the array by doing a 'Reset' from APOSS." << endl;714 gLog << "Out of memory for variables - Check APOSS predifined number of" << endl; 715 gLog << "variables and try deleting the array by doing a 'Reset' from APOSS." << endl; 714 716 return; 715 717 case 89: 716 lout<< "CAN I/O error (REOPEN=" << dec << errinf << " " << (errinf==0?"OK":"ERR") << ")" << endl;718 gLog << "CAN I/O error (REOPEN=" << dec << errinf << " " << (errinf==0?"OK":"ERR") << ")" << endl; 717 719 return; 718 720 … … 723 725 724 726 default: 725 lout<< "Error Nr. " << errnum << ", " << errinf << endl;727 gLog << "Error Nr. " << errnum << ", " << errinf << endl; 726 728 } 727 729 } … … 737 739 time.Now(); 738 740 739 lout<< time << ": " << GetNodeName() << " - PDO3 = ";741 gLog << inf << time << ": " << GetNodeName() << " - PDO3 = "; 740 742 const Bool_t ready = data[3]&0x01; 741 743 const Bool_t fuse = data[3]&0x02; … … 745 747 const Bool_t rf = data[3]&0x20; 746 748 const Bool_t brake = data[3]&0x40; 747 if (ready) lout<< "DKC-Ready ";748 if (fuse) lout<< "FuseOk ";749 if (emcy) lout<< "EmcyOk ";750 if (vltg) lout<< "OvervoltOk ";751 if (mode) lout<< "SwitchToManualMode ";752 if (rf) lout<< "RF ";753 if (brake) lout<< "BrakeOpen ";754 lout<< endl;749 if (ready) gLog << "DKC-Ready "; 750 if (fuse) gLog << "FuseOk "; 751 if (emcy) gLog << "EmcyOk "; 752 if (vltg) gLog << "OvervoltOk "; 753 if (mode) gLog << "SwitchToManualMode "; 754 if (rf) gLog << "RF "; 755 if (brake) gLog << "BrakeOpen "; 756 gLog << endl; 755 757 756 758 fStatusPdo3 = data[3]; … … 780 782 // we can go on working 'as usual' Eg. Initialize a Display Update 781 783 // 782 cout<< GetNodeName() << " Handling Error #" << dec << GetError() << endl;784 gLog << inf << GetNodeName() << " Handling Error #" << dec << GetError() << endl; 783 785 switch (GetError()) 784 786 { … … 787 789 case 9: // zero idx 788 790 case 84: // ON TIME 789 lout<< "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;791 gLog << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl; 790 792 return; 791 793 792 794 case 11: // software endswitch 793 795 case 25: // hardware endswitch 794 lout<< "- " << GetNodeName() << ": Cannot handle error 'Endswitch!'" << endl;796 gLog << "- " << GetNodeName() << ": Cannot handle error 'Endswitch!'" << endl; 795 797 return; 796 798 … … 805 807 */ 806 808 default: 807 lout<< "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;809 gLog << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl; 808 810 809 811 } … … 850 852 WaitForSdo(0x100d); 851 853 852 lout<< "- " << GetNodeName() << ": Hostguarding started (" << dec;853 lout<< GetLifeTimeFactor() << "*" << GetGuardTime() << "ms)" << endl;854 gLog << inf2 << "- " << GetNodeName() << ": Hostguarding started (" << dec; 855 gLog << GetLifeTimeFactor() << "*" << GetGuardTime() << "ms)" << endl; 854 856 } 855 857 … … 866 868 WaitForSdo(0x100d); 867 869 868 lout<< "- " << GetNodeName() << ": Hostguarding stopped." << endl;869 } 870 870 gLog << inf2 << "- " << GetNodeName() << ": Hostguarding stopped." << endl; 871 } 872 -
trunk/MagicSoft/Cosy/devdrv/macs.h
r8811 r8835 68 68 }; 69 69 70 Macs(const BYTE_t nodeid, const char *name=NULL , MLog &out=gLog);70 Macs(const BYTE_t nodeid, const char *name=NULL); 71 71 virtual ~Macs(); 72 72 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r8820 r8835 1 1 #include "shaftencoder.h" 2 2 3 #include <TGLabel.h> // TGLabel->SetText 4 5 #include "MLog.h" 6 #include "MLogManip.h" 7 8 #include "macs.h" 3 9 #include "network.h" 4 10 5 #include <iostream> // cout6 #include <iomanip> // setw, setfill7 8 #include <TGLabel.h> // TGLabel->SetText9 10 #include "macs.h"11 12 11 ClassImp(ShaftEncoder); 13 12 14 13 using namespace std; 15 14 16 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name , MLog &out)17 : NodeDrv(nodeid, name , out),15 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name) 16 : NodeDrv(nodeid, name), 18 17 fPos(0), fVel(0), fAcc(0), fTurn(0), fTicks(0), 19 18 fDirection(kUndefined), fHysteresisPos(0), fHysteresisNeg(0), … … 40 39 { 41 40 case 0x1000: 42 lout<< "- Model: ";41 gLog << inf2 << "- Model: "; 43 42 switch (val&0xffff) 44 43 { 45 44 case 0x0196: 46 lout<< "Shaft Encoder Type: ";45 gLog << inf2 << "Shaft Encoder Type: "; 47 46 switch ((val>>16)&0xff) 48 47 { 49 48 case 0x01: 50 lout<< "Singleturn" << endl;49 gLog << "Singleturn" << endl; 51 50 return; 52 51 case 0x02: 53 lout<< "Multiturn" << endl;52 gLog << "Multiturn" << endl; 54 53 return; 55 54 default: 56 lout<< "?" << endl;55 gLog << err << "?" << endl; 57 56 SetZombie(); 58 57 return; 59 58 } 60 59 default: 61 lout<< "???" << endl;60 gLog << err << "???" << endl; 62 61 SetZombie(); 63 62 return; … … 69 68 70 69 case 0x100c: 71 lout<< "- Guardtime: " << dec << val << "ms" << endl;70 gLog << inf2 << "- Guardtime: " << dec << val << "ms" << endl; 72 71 return; 73 72 74 73 case 0x100d: 75 lout<< "- Lifetimefactor: " << dec << val << endl;74 gLog << inf2 << "- Lifetimefactor: " << dec << val << endl; 76 75 return; 77 76 78 77 case 0x100e: 79 lout<< "- CobId for guarding: 0x" << hex << val << endl;78 gLog << inf2 << "- CobId for guarding: 0x" << hex << val << endl; 80 79 return; 81 80 82 81 case 0x6000: 83 82 case 0x6500: 84 lout<< "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << " ";85 lout<< "HwTest: " << (val&2 ?"on":"off") << " ";86 lout<< "Scaling: " << (val&4 ?"on":"off") << " ";87 lout<< "Modulo: " << (val&4096?"on":"off") << endl;83 gLog << inf2 << "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << " "; 84 gLog << "HwTest: " << (val&2 ?"on":"off") << " "; 85 gLog << "Scaling: " << (val&4 ?"on":"off") << " "; 86 gLog << "Modulo: " << (val&4096?"on":"off") << endl; 88 87 return; 89 88 90 89 case 0x6001: 91 lout<< "- Logical Ticks/Revolution: " << dec << val << endl;90 gLog << inf2 << "- Logical Ticks/Revolution: " << dec << val << endl; 92 91 return; 93 92 94 93 case 0x6004: 95 lout<< "- Position: " << dec << val << endl;94 gLog << inf2 << "- Position: " << dec << val << endl; 96 95 fPos = val; 97 96 fTurn = 0; … … 107 106 108 107 case 0x6501: 109 lout<< "- Phys. Ticks/Revolution: " << dec << val << endl;108 gLog << inf2 << "- Phys. Ticks/Revolution: " << dec << val << endl; 110 109 fTicks = val; 111 110 return; … … 114 113 //if (val==0) 115 114 // val = 1; // Single Turn = Multiturn with one turn 116 lout<< "- Number of Revolutions: " << dec << val << endl;115 gLog << inf2 << "- Number of Revolutions: " << dec << val << endl; 117 116 fTurns = val; 118 117 return; … … 120 119 121 120 } 122 cout << hex << setfill('0'); 123 cout << "Sdo=" << idx << "/" << (int)subidx << ": 0x" << setw(8) << val; 124 cout << endl; 121 122 NodeDrv::HandleSDO(idx, subidx, val, tv); 123 124 // gLog << err << hex << setfill('0'); 125 // gLog << "Sdo=" << idx << "/" << (int)subidx << ": 0x" << setw(8) << val; 126 // gLog << endl; 125 127 } 126 128 … … 134 136 case 1: 135 137 //lout << ddev(MLog::eGui); 136 lout<< "- " << GetNodeName() << ": PDOs configured." << endl;138 gLog << inf2 << "- " << GetNodeName() << ": PDOs configured." << endl; 137 139 //lout << edev(MLog::eGui); 138 140 return; … … 145 147 case 0: 146 148 //lout << ddev(MLog::eGui); 147 lout<< "- " << GetNodeName() << ": Log.ticks/revolution set." << endl;149 gLog << inf2 << "- " << GetNodeName() << ": Log.ticks/revolution set." << endl; 148 150 //lout << edev(MLog::eGui); 149 151 return; … … 156 158 case 0: 157 159 //lout << ddev(MLog::eGui); 158 lout<< "- " << GetNodeName() << ": Max number of ticks set." << endl;160 gLog << inf2 << "- " << GetNodeName() << ": Max number of ticks set." << endl; 159 161 //lout << edev(MLog::eGui); 160 162 return; … … 167 169 case 0: 168 170 //lout << ddev(MLog::eGui); 169 lout<< "- " << GetNodeName() << ": Preset value set." << endl;171 gLog << inf2 << "- " << GetNodeName() << ": Preset value set." << endl; 170 172 //lout << edev(MLog::eGui); 171 173 return; … … 356 358 // Requesting and checking (FIXME) type of encoder 357 359 // 358 lout<< "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl;360 gLog << inf2 << "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl; 359 361 RequestSDO(0x1000); 360 362 WaitForSdo(0x1000); … … 365 367 // Read physical ticks per revolution 366 368 // 367 lout<< "- " << GetNodeName() << ": Requesting physical ticks/revolution (SDO 0x6501)." << endl;369 gLog << inf2 << "- " << GetNodeName() << ": Requesting physical ticks/revolution (SDO 0x6501)." << endl; 368 370 RequestSDO(0x6501); 369 371 WaitForSdo(0x6501); … … 372 374 // Read number of possible ticks per revolution 373 375 // 374 lout<< "- " << GetNodeName() << ": Requesting possible ticks/revolution (SDO 0x6502)." << endl;376 gLog << inf2 << "- " << GetNodeName() << ": Requesting possible ticks/revolution (SDO 0x6502)." << endl; 375 377 RequestSDO(0x6502); 376 378 WaitForSdo(0x6502); … … 389 391 // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1 390 392 // 391 lout<< "- " << GetNodeName() << ": Configuring log. tick/rev (0x6001)." << endl;393 gLog << inf2 << "- " << GetNodeName() << ": Configuring log. tick/rev (0x6001)." << endl; 392 394 SendSDO(0x6001, fTicks); 393 395 WaitForSdo(0x6001); … … 396 398 // Set maximum number of ticks (ticks * turns) 397 399 // 398 lout<< "- " << GetNodeName() << ": Configuring max number of ticks (0x6002)." << endl;400 gLog << inf2 << "- " << GetNodeName() << ": Configuring max number of ticks (0x6002)." << endl; 399 401 SendSDO(0x6002, (LWORD_t)(fTicks*fTurns)); 400 402 WaitForSdo(0x6002); … … 403 405 // Delete preset Value 404 406 // 405 lout<< "- " << GetNodeName() << ": Delete preset value (0x6003)." << endl;407 gLog << inf2 << "- " << GetNodeName() << ": Delete preset value (0x6003)." << endl; 406 408 SendSDO(0x6003, (LWORD_t)0xffffffff); 407 409 WaitForSdo(0x6003); … … 410 412 // Configure PDOs 411 413 // 412 lout<< "- " << GetNodeName() << ": Configuring PDOs (0x1802)." << endl;414 gLog << inf2 << "- " << GetNodeName() << ": Configuring PDOs (0x1802)." << endl; 413 415 SendSDO(0x1802, 1, (LWORD_t)0x281); 414 416 WaitForSdo(0x1802, 1); … … 417 419 // Request Parameter 418 420 // 419 lout<< "- " << GetNodeName() << ": Requesting SDO 0x6000." << endl;421 gLog << inf2 << "- " << GetNodeName() << ": Requesting SDO 0x6000." << endl; 420 422 RequestSDO(0x6000); 421 423 WaitForSdo(0x6000); … … 423 425 ReqPos(); 424 426 425 lout<< "- " << GetNodeName() << ": Start Node (NMT)." << endl;427 gLog << inf2 << "- " << GetNodeName() << ": Start Node (NMT)." << endl; 426 428 SendNMT(kNMT_START); 427 429 … … 450 452 // Request Position 451 453 // 452 lout<< "- " << GetNodeName() << ": Requesting Position." << endl;454 gLog << inf2 << "- " << GetNodeName() << ": Requesting Position." << endl; 453 455 RequestSDO(0x6004); 454 456 WaitForSdo(0x6004); … … 457 459 void ShaftEncoder::SetPreset(LWORD_t pre) 458 460 { 459 lout<< "- " << GetNodeName() << ": Setting Preset." << endl;461 gLog << inf2 << "- " << GetNodeName() << ": Setting Preset." << endl; 460 462 461 463 SendSDO(0x6003, (LWORD_t)pre); … … 476 478 void ShaftEncoder::StopDevice() 477 479 { 478 lout<< "- " << GetNodeName() << ": Stop Node (NMT)." << endl;480 gLog << inf2 << "- " << GetNodeName() << ": Stop Node (NMT)." << endl; 479 481 SendNMT(kNMT_STOP); 480 482 } -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r8811 r8835 56 56 57 57 public: 58 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL , MLog &out=gLog);58 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL); 59 59 60 60 void StopDevice();
Note:
See TracChangeset
for help on using the changeset viewer.