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

Definition at line 2937 of file drivectrl.cc.

References Source::angles, Local::az, buffer, Source::dec, Error(), Configuration::Get(), Configuration::Has(), i, Time::IsValid(), PointingModel::Load(), Source::offset, Source::ra, Configuration::Vec(), and Local::zd.

2938  {
2939  if (!fSunRise)
2940  return 1;
2941 
2942  fDrive.SetVerbose(!conf.Get<bool>("quiet"));
2943 
2944  fMaxPointingResidual = conf.Get<double>("pointing.max.residual");
2945  fPointingVelocity = conf.Get<double>("pointing.velocity");
2946 
2947  fPointingMin = Encoder(conf.Get<double>("pointing.min.zd"),
2948  conf.Get<double>("pointing.min.az"));
2949  fPointingMax = Encoder(conf.Get<double>("pointing.max.zd"),
2950  conf.Get<double>("pointing.max.az"));
2951 
2952  fParkingPos.zd = conf.Has("parking-pos.zd") ? conf.Get<double>("parking-pos.zd") : 90;
2953  fParkingPos.az = conf.Has("parking-pos.az") ? conf.Get<double>("parking-pos.az") : 0;
2954 
2955  if (!CheckRange(fParkingPos))
2956  return 2;
2957 
2958  fAccPointing = Acceleration(conf.Get<double>("pointing.acceleration.zd"),
2959  conf.Get<double>("pointing.acceleration.az"));
2960  fAccTracking = Acceleration(conf.Get<double>("tracking.acceleration.zd"),
2961  conf.Get<double>("tracking.acceleration.az"));
2962  fAccMax = Acceleration(conf.Get<double>("acceleration.max.zd"),
2963  conf.Get<double>("acceleration.max.az"));
2964 
2965  fWeatherTimeout = conf.Get<uint16_t>("weather-timeout");
2966 
2967  if (fAccPointing>fAccMax)
2968  {
2969  T::Error("Pointing acceleration exceeds maximum acceleration.");
2970  return 3;
2971  }
2972 
2973  if (fAccTracking>fAccMax)
2974  {
2975  T::Error("Tracking acceleration exceeds maximum acceleration.");
2976  return 4;
2977  }
2978 
2979  fDeviationLimit = conf.Get<uint16_t>("deviation-limit");
2980  fDeviationCounter = conf.Get<uint16_t>("deviation-count");
2981  fDeviationMax = conf.Get<uint16_t>("deviation-max");
2982 
2983  const string fname = conf.Get<string>("pointing.model-file");
2984 
2985  try
2986  {
2987  fPointingModel.Load(fname);
2988  }
2989  catch (const exception &e)
2990  {
2991  T::Error(e.what());
2992  return 5;
2993  }
2994 
2995  const vector<string> &vec = conf.Vec<string>("source");
2996 
2997  for (vector<string>::const_iterator it=vec.begin(); it!=vec.end(); it++)
2998  {
2999  istringstream stream(*it);
3000 
3001  string name;
3002 
3003  int i=0;
3004 
3005  Source src;
3006 
3007  string buffer;
3008  while (getline(stream, buffer, ','))
3009  {
3010  istringstream is(buffer);
3011 
3012  switch (i++)
3013  {
3014  case 0: name = buffer; break;
3015  case 1: src.ra = ReadAngle(is); break;
3016  case 2: src.dec = ReadAngle(is); break;
3017  case 3: is >> src.offset; break;
3018  case 4: is >> src.angles[0]; break;
3019  case 5: is >> src.angles[1]; break;
3020  }
3021 
3022  if (is.fail())
3023  break;
3024  }
3025 
3026  if (i==3 || i==6)
3027  {
3028  AddSource(name, src);
3029  continue;
3030  }
3031 
3032  T::Warn("Resource 'source' not correctly formatted: '"+*it+"'");
3033  }
3034 
3035  //fAutoResume = conf.Get<bool>("auto-resume");
3036 
3037  if (conf.Has("source-database"))
3038  {
3039  fDatabase = conf.Get<string>("source-database");
3040  ReadDatabase();
3041  }
3042 
3043  if (fSunRise.IsValid())
3044  {
3045  ostringstream msg;
3046  msg << "Next sun-rise will be at " << fSunRise;
3047  T::Message(msg);
3048  }
3049 
3050  // The possibility to connect should be last, so that
3051  // everything else is already initialized.
3052  SetEndpoint(conf.Get<string>("addr"));
3053 
3054  return -1;
3055  }
double fMaxPointingResidual
Definition: drivectrl.cc:1883
uint16_t fDeviationMax
Definition: drivectrl.cc:1589
array< double, 2 > angles
Definition: drivectrl.cc:129
Encoder fPointingMax
Definition: drivectrl.cc:1585
Encoder fPointingMin
Definition: drivectrl.cc:1584
Acceleration fAccPointing
Definition: drivectrl.cc:1880
int i
Definition: db_dim_client.c:21
T Get(const std::string &var)
double zd
Definition: drivectrl.cc:51
std::vector< T > Vec(const std::string &var)
double fPointingVelocity
Definition: drivectrl.cc:1884
double az
Definition: drivectrl.cc:52
void ReadDatabase(bool print=true)
Definition: cosyctrl.cc:1507
bool Has(const std::string &var)
uint16_t fDeviationLimit
Definition: drivectrl.cc:1587
double dec
Definition: drivectrl.cc:125
bool IsValid() const
Definition: Time.h:90
uint16_t fDeviationCounter
Definition: drivectrl.cc:1588
bool AddSource(const string &name, const Source &src)
Definition: cosyctrl.cc:1497
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
double ra
Definition: drivectrl.cc:124
Acceleration fAccMax
Definition: drivectrl.cc:1882
Acceleration fAccTracking
Definition: drivectrl.cc:1881
PointingModel fPointingModel
Definition: drivectrl.cc:1578
Error()
Definition: HeadersFTM.h:197
bool CheckRange(ZdAz pos)
Definition: drivectrl.cc:1786
double offset
Definition: drivectrl.cc:128
void Load(const string &name)
Definition: drivectrl.cc:197
void SetEndpoint(const string &url)
Definition: cosyctrl.cc:1492
uint16_t fWeatherTimeout
Definition: drivectrl.cc:1574
double ReadAngle(istream &in)
Definition: drivectrl.cc:1774

+ Here is the call graph for this function: