FACT++  1.0
template<class T , class S >
int StateMachineDrive< T, S >::TrackWobble ( const EventImp evt)
inlineprivate

Definition at line 2059 of file drivectrl.cc.

References Source::angles, Error(), EventImp::GetSize(), EventImp::GetUShort(), Source::offset, and EventImp::Ptr().

2060  {
2061  if (evt.GetSize()<2)
2062  {
2063  ostringstream msg;
2064  msg << "TrackWobble - Received event has " << evt.GetSize() << " bytes, but expected at least 3.";
2065  T::Fatal(msg);
2066  return T::kSM_FatalError;
2067  }
2068 
2069  if (evt.GetSize()==2)
2070  {
2071  ostringstream msg;
2072  msg << "TrackWobble - Source name missing.";
2073  T::Error(msg);
2074  return T::GetCurrentState();
2075  }
2076 
2077  const uint16_t wobble = evt.GetUShort();
2078  if (wobble!=1 && wobble!=2)
2079  {
2080  ostringstream msg;
2081  msg << "TrackWobble - Wobble id " << wobble << " undefined, only 1 and 2 allowed.";
2082  T::Error(msg);
2083  return T::GetCurrentState();
2084  }
2085 
2086  const char *ptr = evt.Ptr<char>(2);
2087  const char *last = ptr+evt.GetSize()-2;
2088 
2089  try
2090  {
2091  const sources::const_iterator it = GetSourceFromDB(ptr, last);
2092 
2093  const Source &src = it->second;
2094  return StartTracking(src, src.offset, src.angles[wobble-1]);
2095  }
2096  catch (const uint32_t &e)
2097  {
2098  return e;
2099  }
2100  }
array< double, 2 > angles
Definition: drivectrl.cc:129
uint16_t GetUShort() const
Definition: EventImp.h:92
int StartTracking(const Source &src, double offset, double angle, double period=0)
Definition: drivectrl.cc:1945
Error()
Definition: HeadersFTM.h:197
double offset
Definition: drivectrl.cc:128
const T * Ptr(size_t offset=0) const
Definition: EventImp.h:74
const sources::const_iterator GetSourceFromDB(const char *ptr, const char *last)
Definition: cosyctrl.cc:988
virtual size_t GetSize() const
Definition: EventImp.h:55

+ Here is the call graph for this function: