Changeset 4104 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 05/20/04 04:42:48 (20 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/macs.cc
r2615 r4104 382 382 //SetNoWait(TRUE); 383 383 384 StartGuarding(400, 1, kFALSE); // Using PDO1 @ 100ms384 //StartGuarding(400, 1, kFALSE); // Using PDO1 @ 100ms 385 385 //StartGuarding(250, 4); 386 386 //StartHostGuarding(); -
trunk/MagicSoft/Cosy/devdrv/macs.h
r4076 r4104 1 #ifndef MACS_H2 #define MACS_H1 #ifndef COSY_Macs 2 #define COSY_Macs 3 3 4 #ifndef COSY_NodeDrv 4 5 #include "nodedrv.h" 6 #endif 7 8 #ifndef MARS_MTime 5 9 #include "MTime.h" 10 #endif 6 11 7 12 class Macs : public NodeDrv … … 119 124 120 125 Double_t GetPosTime() const { return fPosTime; } 126 Double_t GetMjd() const { return fPosTime.GetMjd(); } 127 Double_t GetPdoMjd() const { return fPdoTime.GetMjd(); } 121 128 122 129 ClassDef(Macs, 0) -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r4076 r4104 8 8 #include <TGLabel.h> // TGLabel->SetText 9 9 10 #include "macs.h" 11 10 12 ClassImp(ShaftEncoder); 11 13 … … 14 16 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out) 15 17 : NodeDrv(nodeid, name, out), fPos(0), fVel(0), fAcc(0), 16 fTurn(0), fLabel(NULL), fPosHasChanged(false), fReport(NULL) 17 { 18 } 19 18 fTurn(0), fLabel(NULL), fPosHasChanged(false), fReport(NULL),/*fTwin(0), 19 fIsUpdated(kFALSE),*/ fMotor(0), fOffset(0) 20 { 21 } 22 /* 23 void ShaftEncoder::CheckTwin(Int_t diff) const 24 { 25 if (!fTwin) 26 return; 27 28 if (fTwin->fIsUpdated) 29 fTwin->fIsUpdated = kFALSE; 30 else 31 fTwin->fOffset += diff; 32 } 33 */ 20 34 void ShaftEncoder::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv) 21 35 { … … 79 93 fPos = val; 80 94 fTurn = 0; 95 fOffset = fMotor ? fMotor->GetPdoPos() : 0; 96 //fIsUpdated=kTRUE; 97 //fOffset = 0; 81 98 return; 82 99 … … 154 171 void ShaftEncoder::DisplayVal() 155 172 { 173 const LWORDS_t pos = GetPos(); 156 174 if (IsZombieNode()) 157 175 { 158 176 fLabel->SetText(new TGString("")); 159 fUpdPos = ~ fPos;177 fUpdPos = ~pos; 160 178 return; 161 179 } 162 180 163 181 char text[21]; 164 165 if (fPos!=fUpdPos && fLabel) 166 { 167 sprintf(text, "%ld", fPos); 182 if (pos!=fUpdPos && fLabel) 183 { 184 sprintf(text, "%ld", pos); 168 185 fLabel->SetText(new TGString(text)); 169 fUpdPos = fPos;186 fUpdPos = pos; 170 187 } 171 188 } … … 177 194 // 178 195 LWORDS_t pos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 179 if (pos==fPos) 180 return; 196 197 //if (pos==fPos) 198 // return; 181 199 182 200 fPos = pos; 201 fOffset = fMotor ? fMotor->GetPdoPos() : 0; 183 202 fTime.Set(*tv); 184 203 fPosHasChanged = true; 185 204 205 //CheckTwin(fPos-pos); 206 //fIsUpdated=kTRUE; 207 186 208 if (fReport) 187 209 { 188 fReport->Lock( );210 fReport->Lock("ShaftEncoder::HandlePDOType0"); 189 211 *fReport << "SE-REPORT " << (int)GetId() << " " << fTime << " PDO0 " << pos << " " << GetNodeName() << endl; 190 fReport->UnLock( );212 fReport->UnLock("ShaftEncoder::HandlePDOType0"); 191 213 } 192 214 } … … 200 222 BYTE_t flag = data[4]; 201 223 202 if (fPos==pos) 203 return; 204 224 //if (fPos==pos) 225 // return; 226 227 //CheckTwin(fPos-pos); 205 228 fPos=pos; 229 fOffset = fMotor ? fMotor->GetPdoPos() : 0; 206 230 fTime.Set(*tv); 207 231 fPosHasChanged=true; 232 //fIsUpdated=kTRUE; 233 //fOffset = 0; 208 234 209 235 flag=flag; … … 211 237 if (fReport) 212 238 { 213 fReport->Lock( );239 fReport->Lock("ShaftEncoder::HandlePDOType1"); 214 240 *fReport << "SE-REPORT " << (int)GetId() << " " << fTime << " PDO1 " << pos << " " << (int)flag << " " << GetNodeName() << endl; 215 fReport->UnLock( );241 fReport->UnLock("ShaftEncoder::HandlePDOType1"); 216 242 } 217 243 } … … 241 267 turn--; 242 268 243 if (fPos==pos && fTurn==fTurn) 244 return; 269 //if (fPos==pos && fTurn==fTurn) 270 // return; 271 272 //CheckTwin(fPos-pos); 245 273 246 274 fPos = pos; 247 275 fTurn = turn; 248 276 277 fOffset = fMotor ? fMotor->GetPdoPos() : 0; 249 278 fTime.Set(*tv); 250 279 fPosHasChanged=true; 280 //fIsUpdated=kTRUE; 281 //fOffset = 0; 282 251 283 252 284 if (fReport) 253 285 { 254 fReport->Lock( );286 fReport->Lock("ShaftEncoder::HandlePDOType2"); 255 287 *fReport << "SE-REPORT " << (int)GetId() << " " << fTime << " PDO2 " << pos << " " << fVel << " " << fAcc << " " << GetNodeName() << endl; 256 fReport->UnLock( );288 fReport->UnLock("ShaftEncoder::HandlePDOType2"); 257 289 } 258 290 } … … 383 415 fPos = pre%16384; 384 416 fTurn = pre/16384; 417 418 fOffset = fMotor ? fMotor->GetPdoPos() : 0; 385 419 } 386 420 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r4076 r4104 1 #ifndef SHAFTENCODER_H2 #define SHAFTENCODER_H1 #ifndef COSY_ShafTEncoder 2 #define COSY_ShafTEncoder 3 3 4 #ifndef COSY_NodeDrv 4 5 #include "nodedrv.h" 6 #endif 7 8 #ifndef MARS_MTime 5 9 #include "MTime.h" 10 #endif 6 11 12 class Macs; 7 13 class TGLabel; 8 14 … … 19 25 TGLabel *fLabel; // 20 26 LWORDS_t fUpdPos; // ticks 21 // WORDS_t fUpdVel; // ticks per 5ms22 // WORDS_t fUpdAcc; // ticks per 25ms^223 27 24 28 bool fPosHasChanged; //! … … 26 30 MTime fTime; 27 31 MLog *fReport; 32 33 Macs *fMotor; 34 Int_t fOffset; 28 35 29 36 void HandlePDOType0(BYTE_t *data, timeval_t *tv); … … 35 42 void Init(); 36 43 void CheckConnection(); 44 // void CheckTwin(Int_t diff) const; 37 45 38 46 public: … … 42 50 43 51 void SetDisplay(TGLabel *label) { fLabel = label; } 52 void SetMotor(Macs *m) { fMotor = m; } 53 //void SetTwin(ShaftEncoder *se) { fTwin = se; } 44 54 45 55 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv); … … 52 62 void HandlePDO2(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); } 53 63 54 LWORDS_t GetPos() { return IsZombieNode() ? 0 : fPos+fTurn*fTicks; } // FIXME? 0? 55 LWORD_t GetPhysRes() { return fTicks; } 64 LWORDS_t GetPos() const { return IsZombieNode() ? 0 : fPos+fTurn*fTicks; } // FIXME? 0? 65 LWORD_t GetPhysRes() const { return fTicks; } 66 Int_t GetOffset() const { return fOffset; } 67 void SetOffset(Int_t off) { fOffset = off; } 56 68 57 69 double GetMjd();
Note:
See TracChangeset
for help on using the changeset viewer.