- Timestamp:
- 06/22/13 11:45:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r16732 r16887 127 127 uint16_t fDeviationMax; 128 128 129 vector<double> fDevBuffer; 130 uint64_t fDevCount; 131 129 132 uint64_t fTrackingCounter; 130 133 … … 362 365 363 366 // Calculate absolut deviation on the sky 367 364 368 const double dev = GetDevAbs(zd1, zd1-zd_err, az_err)*3600; 369 370 fDevBuffer[fDevCount++%5] = dev; 371 372 const uint8_t cnt = fDevCount<5 ? fDevCount : 5; 373 const double avgdev = accumulate(fDevBuffer.begin(), fDevBuffer.begin()+cnt, 0)/cnt; 365 374 366 375 // If any other state than tracking or a deviation 367 376 // larger than 60, reset the counter 368 if (fState!=State::kTracking || dev>fDeviationLimit)377 if (fState!=State::kTracking || avgdev>fDeviationLimit) 369 378 fTrackingCounter = 0; 370 379 else … … 377 386 378 387 // Having th state as Tracking will reset the counter 379 if (fState==State::kOnTrack && dev>fDeviationMax)388 if (fState==State::kOnTrack && avgdev>fDeviationMax) 380 389 fState = State::kTracking; 390 391 if (fState!=State::kTracking && avgdev!=State::kOnTrack) 392 fDevCount = 0; 381 393 382 394 // 206 206 ce ce pwr vlt emcy fs | pwr vlt emcy fs … … 624 636 public: 625 637 ConnectionDrive(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 626 fState(-1), fIsVerbose(true), fDeviationLimit(120), fDeviationCounter(5), fDeviationMax(240), fTrackingCounter(0), fKeepAlive(ioservice) 638 fState(-1), fIsVerbose(true), 639 fDeviationLimit(120), fDeviationCounter(5), fDeviationMax(240), 640 fDevBuffer(5), fDevCount(0), 641 fTrackingCounter(0), fKeepAlive(ioservice) 627 642 { 628 643 SetLogStream(&imp); … … 640 655 fDeviationMax = max; 641 656 } 657 642 658 int GetState() const 643 659 { … … 790 806 string fLastCommand; // Last tracking (RADEC) command 791 807 int fAutoResume; // 0: disabled, 1: enables, 2: resuming 808 Time fAutoResumeTime; 792 809 793 810 // Status 0: Error … … 873 890 } 874 891 892 893 T::Info("Resume: "+fLastCommand); 875 894 return SendCommand(fLastCommand, false); 876 895 } … … 1220 1239 }*/ 1221 1240 1222 if (Time()>fSunRise) 1241 const Time now; 1242 1243 1244 if (now>fSunRise) 1223 1245 { 1224 1246 if (T::GetCurrentState()>Drive::State::kLocked) … … 1227 1249 if (T::GetCurrentState()==Drive::State::kLocked) 1228 1250 { 1229 fSunRise = Time().GetNextSunRise();1251 fSunRise = now.GetNextSunRise(); 1230 1252 1231 1253 ostringstream msg; … … 1246 1268 // If auto resume is enabled and the drive is in error, 1247 1269 // resume tracking 1248 if ( fAutoResume==1 &&state==StateMachineImp::kSM_Error)1270 if (state==StateMachineImp::kSM_Error) 1249 1271 { 1250 Resume(); 1251 fAutoResume = 2; 1272 if (fAutoResume==1) 1273 { 1274 Resume(); 1275 fAutoResume = 2; 1276 fAutoResumeTime = now; 1277 } 1278 1279 if (fAutoResume==2 && fAutoResumeTime+boost::posix_time::seconds(5)<now) 1280 { 1281 Resume(); 1282 fAutoResume = 3; 1283 } 1252 1284 } 1253 1254 // If drive got out of the error state, 1255 // enable auto resume again 1256 if (fAutoResume==2 && state!=StateMachineImp::kSM_Error) 1257 fAutoResume = 1; 1285 else 1286 { 1287 // If drive got out of the error state, 1288 // enable auto resume again 1289 if (fAutoResume>1) 1290 fAutoResume = 1; 1291 } 1258 1292 } 1259 1293
Note:
See TracChangeset
for help on using the changeset viewer.