FACT++  1.0
int ConnectionLid::GetState ( ) const
inline

Definition at line 352 of file lidctrl.cc.

References Time::IsValid(), Lid::State::kClosed, State::kConnected, State::kDisconnected, Lid::State::kInconsistent, kMaxAddr, Lid::State::kOpen, Lid::State::kOvercurrent, Lid::State::kPowerProblem, Lid::State::kUnidentified, Lid::State::kUnknown, and ConnectionLid::Lid::status.

353  {
354  using namespace Lid;
355 
356  // Timeout
357  if (fLastReport.IsValid() && fLastReport+boost::posix_time::seconds(fInterval*2)<Time())
358  return State::kDisconnected;
359 
360  // Unidentified state detected
361  if ((!fLid1.status.empty() && fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown" && fLid1.status!="Overcurrent") ||
362  (!fLid2.status.empty() && fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown" && fLid2.status!="Overcurrent"))
363  return State::kUnidentified;
364 
365  // This is an assumption, but the best we have...
366  if (fLid1.status=="Closed" && fLid2.status=="Power Problem")
367  return State::kClosed;
368  if (fLid2.status=="Closed" && fLid1.status=="Power Problem")
369  return State::kClosed;
370  if (fLid1.status=="Open" && fLid2.status=="Power Problem")
371  return State::kOpen;
372  if (fLid2.status=="Open" && fLid1.status=="Power Problem")
373  return State::kOpen;
374 
375  // Inconsistency
376  if (fLid1.status!=fLid2.status)
377  return State::kInconsistent;
378 
379  // Unknown
380  if (fLid1.status=="Unknown")
381  return State::kUnknown;
382 
383  // Power Problem
384  if (fLid1.status=="Power Problem")
385  return State::kPowerProblem;
386 
387  // Overcurrent
388  if (fLid1.status=="Overcurrent")
389  return State::kOvercurrent;
390 
391  // Closed
392  if (fLid1.status=="Closed")
393  return State::kClosed;
394 
395  // Open
396  if (fLid1.status=="Open")
397  return State::kOpen;
398 
399  return State::kConnected;
400  }
uint16_t fInterval
Definition: lidctrl.cc:82
Time fLastReport
Definition: lidctrl.cc:93
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
bool IsValid() const
Definition: Time.h:90
Definition: HeadersLid.h:4

+ Here is the call graph for this function: