FACT++  1.0
template<class T>
int StateMachineFAD< T >::StartConfigure ( const EventImp evt)
inlineprivate

Definition at line 1041 of file fadctrl.cc.

References ConnectionFAD::Cmd(), ConnectionFAD::CmdSetDacValue(), ConnectionFAD::CmdSetRoi(), ConnectionFAD::CmdSetRunNumber(), ConnectionFAD::CmdSetTriggerRate(), Error(), EventImp::Get(), i, kCmdBusyOff, kCmdBusyOn, kCmdContTrigger, kCmdDrsEnable, kCmdDwrite, kCmdResetEventCounter, kCmdSocket, kCmdTriggerLine, FTM::State::kConfiguring1, Agilent::State::kConnected, kNumChannelsPerChip, kNumChips, kNumDac, EventImp::Ptr(), and str.

Referenced by StateMachineFAD< T >::StateMachineFAD().

1042  {
1043  const string name = evt.Ptr<char>(16);
1044 
1045  fTargetConfig = fConfigs.find(name);
1046  if (fTargetConfig==fConfigs.end())
1047  {
1048  T::Error("StartConfigure - Run-type '"+name+"' not found.");
1049  return T::GetCurrentState();
1050  }
1051 
1052  // FIXME: What about an error state?
1053  const uint32_t runno = StartNewRun(evt.Get<int64_t>(), evt.Get<int64_t>(8), *fTargetConfig);
1054  if (runno==0)
1055  return FAD::State::kConnected;
1056 
1057  ostringstream str;
1058  str << "Starting configuration for run " << runno << " (" << name << ")";
1059  T::Message(str.str());
1060 
1061  if (runno>=1000)
1062  T::Warn("Run number exceeds logical maximum of 999 - this is no problem for writing but might give raise to problems in the analysis.");
1063 
1064  const FAD::Configuration &conf = fTargetConfig->second;
1065 
1066  for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++)
1067  {
1068  ConnectionFAD &fad = *it->second;
1069 
1070  fad.Cmd(FAD::kCmdBusyOn, true); // continously on
1071  fad.Cmd(FAD::kCmdTriggerLine, false);
1072  fad.Cmd(FAD::kCmdContTrigger, false);
1073  fad.Cmd(FAD::kCmdSocket, true);
1074  fad.Cmd(FAD::kCmdBusyOff, false); // normal when BusyOn==0
1075 
1076  fad.Cmd(FAD::kCmdDwrite, conf.fDwrite);
1077  fad.Cmd(FAD::kCmdDrsEnable, conf.fDenable);
1078 
1079  for (int i=0; i<FAD::kNumDac; i++)
1080  fad.CmdSetDacValue(i, conf.fDac[i]);
1081 
1082  for (int i=0; i<FAD::kNumChips; i++)
1083  for (int j=0; j<FAD::kNumChannelsPerChip; j++)
1084  fad.CmdSetRoi(i*FAD::kNumChannelsPerChip+j, conf.fRoi[j]);
1085 
1086  fad.CmdSetTriggerRate(conf.fTriggerRate);
1087  fad.CmdSetRunNumber(runno);
1089  fad.Cmd(FAD::kCmdTriggerLine, true);
1090  //fad.Cmd(FAD::kCmdSingleTrigger);
1091  //fad.Cmd(FAD::kCmdTriggerLine, true);
1092  }
1093 
1094  // Now the old run is stopped already. So all other servers can start a new run
1095  // (Note that we might need another step which only checks if the continous trigger
1096  // is wwitched off, too)
1097  const int64_t runs[2] = { runno, runno+1 };
1098  fDimStartRun.Update(runs);
1099 
1101  }
BoardList fBoards
Definition: fadctrl.cc:555
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
Configs fConfigs
Definition: fadctrl.cc:1994
void CmdSetRunNumber(uint32_t num)
Definition: fadctrl.cc:412
bool CmdSetTriggerRate(int32_t val)
Definition: fadctrl.cc:400
bool CmdSetRoi(int8_t addr, uint16_t val)
Definition: fadctrl.cc:452
DimDescribedService fDimStartRun
Definition: fadctrl.cc:1642
uint32_t StartNewRun(int64_t maxtime, int64_t maxevt, const pair< string, FAD::Configuration > &ref)
Configs::const_iterator fTargetConfig
Definition: fadctrl.cc:1995
Error()
Definition: HeadersFTM.h:197
T Get(size_t offset=0) const
Definition: EventImp.h:66
const T * Ptr(size_t offset=0) const
Definition: EventImp.h:74
void Cmd(FAD::Enable cmd, bool on=true)
Definition: fadctrl.cc:371
bool CmdSetDacValue(int8_t addr, uint16_t val)
Definition: fadctrl.cc:429

+ Here is the call graph for this function:

+ Here is the caller graph for this function: