FACT++  1.0
template<class T , class S >
int StateMachineFTM< T, S >::Execute ( )
inlineprivatevirtual

Implements StateMachineAsio< T >.

Definition at line 2038 of file ftmctrl.cc.

References FTM::State::kConfigError1, FTM::State::kConfigError2, ConnectionFTM::kConfigured, FTM::State::kConfigured1, FTM::State::kConfigured2, FTM::State::kConfiguring1, FTM::State::kConfiguring2, ConnectionFTM::kConnected, FTM::State::kConnected, ConnectionFTM::kDisconnected, FTM::State::kDisconnected, ConnectionFTM::kIdle, FTM::State::kIdle, FTM::kRegister, FTM::kStaticData, ConnectionFTM::kTriggerOn, FTM::State::kTriggerOn, and FTM::State::kValid.

2039  {
2040  // If FTM is neither in data taking nor idle,
2041  // leave configuration state
2042  switch (fFTM.GetState())
2043  {
2046  default:
2047  break;
2048  }
2049 
2050  // FIXME: Add timeouts and go to error state
2051  // so that a configuration error can be handled
2052  switch (T::GetCurrentState())
2053  {
2055  // If FTM has received an anwer to the stop_run command
2056  // the counter for the registers has been increased
2057  if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg)
2059 
2060  // If now the state is not idle as expected this means we had
2061  // an error (maybe old events waiting in the queue)
2062  if (fFTM.GetState()!=ConnectionFTM::kIdle &&
2063  fFTM.GetState()!=ConnectionFTM::kConfigured)
2065 
2066  fCounterStat = fFTM.GetCounter(FTM::kStaticData);
2067 
2068  fFTM.CmdSendStatDat(fTargetConfig->second);
2069 
2070  T::Message("Trigger successfully disabled... sending new configuration.");
2071 
2072  // Next state is: wait for the answer to our configuration
2074 
2077  // If FTM has received an anwer to the CmdSendStatDat
2078  // the counter for static data has been increased
2079  if (fFTM.GetCounter(FTM::kStaticData)<=fCounterStat)
2080  break;
2081 
2082  // If now the configuration is not what we expected
2083  // we had an error (maybe old events waiting in the queue?)
2084  if (fFTM.GetState()!=ConnectionFTM::kConfigured)
2086 
2087  // Check configuration again when a new static data block
2088  // will be received
2089  fCounterStat = fFTM.GetCounter(FTM::kStaticData);
2090 
2091  // This is also displayed when the ratecontrol sends its configuration...
2092  if (T::GetCurrentState()==FTM::State::kConfiguring2)
2093  T::Message("Sending new configuration was successfull.");
2094  else
2095  T::Message("Configuration successfully updated.");
2096 
2097  // Next state is: wait for the answer to our configuration
2098  return FTM::State::kConfigured1;
2099 
2100  // This state is set by StartRun [START_TRIGGER]
2102  // No answer to the CmdStartRun received yet... go on waiting
2103  if (fFTM.GetCounter(FTM::kRegister)<=fCounterReg)
2104  return FTM::State::kConfigured2;
2105 
2106  // Answer received and trigger enable acknowledged
2107  if (fFTM.GetState()==ConnectionFTM::kTriggerOn)
2108  return FTM::State::kTriggerOn;
2109 
2110  // If the trigger is not enabled, but the configuration
2111  // has changed go to error state (should never happen)
2112  if (fFTM.GetState()!=ConnectionFTM::kConfigured)
2114 
2115  // Send a new command... the previous one might have gone
2116  // ignored by the ftm because it was just after a
2117  // threshold setting during the configured state
2118  fFTM.CmdStartRun(false);
2119 
2120  // Set counter to wait for answer.
2121  fCounterReg = fFTM.GetCounter(FTM::kRegister);
2122 
2123  // Go on waiting for a proper acknowledge of the trigger enable
2124  return FTM::State::kConfigured2;
2125 
2128  //case FTM::State::kConfigError3:
2129  break;
2130 
2131  default:
2132  switch (fFTM.GetState())
2133  {
2137  default:
2138  throw runtime_error("StateMachineFTM - Execute() - Inavlid state.");
2139  }
2140  }
2141 
2142  return T::GetCurrentState();
2143  }
Static (configuration) data.
Definition: HeadersFTM.h:89
Configs::const_iterator fTargetConfig
Definition: ftmctrl.cc:2012
uint32_t fCounterReg
Definition: ftmctrl.cc:2007
A requested register value.
Definition: HeadersFTM.h:93
uint32_t fCounterStat
Definition: ftmctrl.cc:2008