FACT++  1.0
template<class T>
int StateMachineFAD< T >::EvalOptions ( Configuration conf)
inline

Definition at line 2019 of file fadctrl.cc.

References zofits::DefaultMaxMemory(), zofits::DefaultMaxNumTiles(), zofits::DefaultNumRowsPerTile(), zofits::DefaultNumThreads(), Error(), Configuration::Get(), Configuration::GetDef(), Configuration::Has(), i, kMaxDacValue, kMaxRoiValue, kNumChannelsPerChip, kNumDac, kRed, str, and Configuration::Vec().

2020  {
2021  // ---------- General setup ---------
2022  fIsVerbose = !conf.Get<bool>("quiet");
2023  fIsHexOutput = conf.Get<bool>("hex-out");
2024  fIsDataOutput = conf.Get<bool>("data-out");
2025  fDebugTx = conf.Get<bool>("debug-tx");
2026 
2027  // --------- Setup compression of FITS files -----------
2028  if (conf.Has("zfits.num-threads"))
2029  zofits::DefaultNumThreads(conf.Get<int32_t>("zfits.num-threads"));
2030  if (conf.Has("zfits.max-mem"))
2031  zofits::DefaultMaxMemory(conf.Get<uint32_t>("zfits.max-mem")*1000);
2032  if (conf.Has("zfits.num-tiles"))
2033  zofits::DefaultMaxNumTiles(conf.Get<uint32_t>("zfits.num-tiles"));
2034  if (conf.Has("zfits.num-rows"))
2035  zofits::DefaultNumRowsPerTile(conf.Get<uint32_t>("zfits.num-rows"));
2036 
2037  // ---------- Setup event builder ---------
2038  SetMaxMemory(conf.Get<unsigned int>("max-mem"));
2039  SetEventTimeout(conf.Get<uint16_t>("event-timeout"));
2040 
2041  if (!InitRunNumber(conf.Get<string>("destination-folder")))
2042  return 1;
2043 
2044  // ---------- Setup run types ---------
2045  const vector<string> types = conf.Vec<string>("run-type");
2046  if (types.size()==0)
2047  T::Warn("No run-types defined.");
2048  else
2049  T::Message("Defining run-types");
2050  for (vector<string>::const_iterator it=types.begin();
2051  it!=types.end(); it++)
2052  {
2053  T::Message(" -> "+ *it);
2054 
2055  if (fConfigs.count(*it)>0)
2056  {
2057  T::Error("Run-type "+*it+" defined twice.");
2058  return 2;
2059  }
2060 
2061  FAD::Configuration target;
2062 
2063  if (!CheckConfigVal<bool>(conf, true, "enable-drs.", *it) ||
2064  !CheckConfigVal<bool>(conf, true, "enable-dwrite.", *it) ||
2065  !CheckConfigVal<bool>(conf, true, "enable-continous-trigger.", *it))
2066  return 3;
2067 
2068  target.fDenable = conf.GetDef<bool>("enable-drs.", *it);
2069  target.fDwrite = conf.GetDef<bool>("enable-dwrite.", *it);
2070  target.fContinousTrigger = conf.GetDef<bool>("enable-continous-trigger.", *it);
2071 
2072  target.fTriggerRate = 0;
2073  //if (target.fContinousTrigger)
2074  {
2075  if (!CheckConfigVal<uint16_t>(conf, 0xffff, "trigger-rate.", *it))
2076  return 4;
2077 
2078  target.fTriggerRate = conf.GetDef<uint16_t>("trigger-rate.", *it);
2079  }
2080 
2081  for (int i=0; i<FAD::kNumChannelsPerChip; i++)
2082  {
2083  ostringstream str;
2084  str << "roi-ch" << i << '.';
2085 
2086  if (!CheckConfigVal<uint16_t>(conf, FAD::kMaxRoiValue, "roi.", *it) &&
2087  !CheckConfigVal<uint16_t>(conf, FAD::kMaxRoiValue, str.str(), *it))
2088  return 5;
2089 
2090  target.fRoi[i] = conf.HasDef(str.str(), *it) ?
2091  conf.GetDef<uint16_t>(str.str(), *it) :
2092  conf.GetDef<uint16_t>("roi.", *it);
2093  }
2094 
2095  for (int i=0; i<FAD::kNumDac; i++)
2096  {
2097  ostringstream str;
2098  str << "dac-" << i << '.';
2099 
2100  if (!CheckConfigVal<uint16_t>(conf, FAD::kMaxDacValue, "dac.", *it) &&
2101  !CheckConfigVal<uint16_t>(conf, FAD::kMaxDacValue, str.str(), *it))
2102  return 6;
2103 
2104  target.fDac[i] = conf.HasDef(str.str(), *it) ?
2105  conf.GetDef<uint16_t>(str.str(), *it) :
2106  conf.GetDef<uint16_t>("dac.", *it);
2107  }
2108 
2109  fConfigs[*it] = target;
2110  }
2111 
2112  // FIXME: Add a check about unsused configurations
2113 
2114  // ---------- Setup board addresses for fake-fad ---------
2115 
2116  if (conf.Has("debug-addr"))
2117  {
2118  const string addr = conf.Get<string>("debug-addr");
2119  const int num = conf.Get<unsigned int>("debug-num");
2120 
2121  const tcp::endpoint endpoint = GetEndpoint(addr);
2122  if (endpoint==tcp::endpoint())
2123  return 7;
2124 
2125  for (int i=0; i<num; i++)
2126  AddEndpoint(tcp::endpoint(endpoint.address(), endpoint.port()+8*i));
2127 
2128  if (conf.Get<bool>("start"))
2129  StartConnection();
2130  return -1;
2131  }
2132 
2133  // ---------- Setup board addresses for the real camera ---------
2134 
2135  if (conf.Has("base-addr"))
2136  {
2137  string base = conf.Get<string>("base-addr");
2138 
2139  if (base=="def" || base =="default")
2140  base = "10.0.128.128:31919";
2141 
2142  const tcp::endpoint endpoint = GetEndpoint(base);
2143  if (endpoint==tcp::endpoint())
2144  return 8;
2145 
2146  const ba::ip::address_v4::bytes_type ip = endpoint.address().to_v4().to_bytes();
2147 
2148  if (ip[2]>250 || ip[3]>244)
2149  {
2150  T::Out() << kRed << "EvalConfiguration - IP address given by --base-addr out-of-range." << endl;
2151  return 9;
2152  }
2153 
2154  for (int crate=0; crate<4; crate++)
2155  for (int board=0; board<10; board++)
2156  {
2157  ba::ip::address_v4::bytes_type target = endpoint.address().to_v4().to_bytes();
2158  target[2] += crate;
2159  target[3] += board;
2160 
2161  AddEndpoint(tcp::endpoint(ba::ip::address_v4(target), endpoint.port()));
2162  }
2163 
2164  if (conf.Get<bool>("start"))
2165  StartConnection();
2166  return -1;
2167 
2168  }
2169 
2170  // ---------- Setup board addresses one by one ---------
2171 
2172  if (conf.Has("addr"))
2173  {
2174  const vector<string> addrs = conf.Vec<string>("addr");
2175  for (vector<string>::const_iterator i=addrs.begin(); i<addrs.end(); i++)
2176  {
2177  const tcp::endpoint endpoint = GetEndpoint(*i);
2178  if (endpoint==tcp::endpoint())
2179  return 10;
2180 
2181  AddEndpoint(endpoint);
2182  }
2183 
2184  if (conf.Get<bool>("start"))
2185  StartConnection();
2186  return -1;
2187  }
2188  return -1;
2189  }
int StartConnection()
Definition: fadctrl.cc:1276
bool fIsDataOutput
Definition: fadctrl.cc:559
void SetMaxMemory(unsigned int mb) const
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
T Get(const std::string &var)
Set color Red.
Definition: WindowLog.h:17
void AddEndpoint(const tcp::endpoint &addr)
Definition: fadctrl.cc:1614
Configs fConfigs
Definition: fadctrl.cc:1994
bool fIsHexOutput
Definition: fadctrl.cc:558
static uint32_t DefaultMaxMemory(const uint32_t &_n=0)
Definition: zofits.h:93
std::vector< T > Vec(const std::string &var)
static uint32_t DefaultMaxNumTiles(const uint32_t &_n=0)
Definition: zofits.h:94
static uint32_t DefaultNumThreads(const uint32_t &_n=-2)
static setter for the default number of threads to use. -1 means all available physical cores ...
Definition: zofits.h:92
bool Has(const std::string &var)
T GetDef(const std::string &var, const S &val)
void SetEventTimeout(uint16_t to) const
static uint32_t DefaultNumRowsPerTile(const uint32_t &_n=0)
Definition: zofits.h:95
bool InitRunNumber(const string &path="")
Error()
Definition: HeadersFTM.h:197
tcp::endpoint GetEndpoint(const string &base)
Definition: fadctrl.cc:1966

+ Here is the call graph for this function: