FACT++  1.0
template<class T >
void StateMachineSmartFACT::WriteBinaryVec ( const Time tm,
const string &  fname,
const vector< T > &  vec,
double  scale,
double  offset = 0,
const string &  title = "",
const string &  col = "" 
)
inlineprivate

Definition at line 689 of file smartfact.cc.

References i, Time::JavaDate(), StateMachineSmartFACT::Statistics::max, StateMachineSmartFACT::Statistics::med, and StateMachineSmartFACT::Statistics::min.

690  {
691  if (vec.empty())
692  return;
693 
694  ostringstream out;
695  out << tm.JavaDate() << '\n';
696  out << offset << '\n';
697  out << offset+scale << '\n';
698  out << setprecision(3);
699  if (!title.empty())
700  out << title << '\x7f';
701  else
702  {
703  const Statistics stat(vec[0]);
704  out << stat.min << '\n';
705  out << stat.med << '\n';
706  out << stat.max << '\x7f';
707  }
708  if (!col.empty())
709  out << col;
710  for (auto it=vec.cbegin(); it!=vec.cend(); it++)
711  {
712  // The valid range is from 1 to 127
713  // \0 is used to seperate different curves
714  vector<uint8_t> val(it->size());
715  for (uint64_t i=0; i<it->size(); i++)
716  {
717  float range = nearbyint(126*(double(it->at(i))-offset)/scale); // [-2V; 2V]
718  if (range>126)
719  range=126;
720  if (range<0)
721  range=0;
722  val[i] = (uint8_t)range;
723  }
724 
725  const char *ptr = reinterpret_cast<char*>(val.data());
726  out.write(ptr, val.size()*sizeof(uint8_t));
727  out << '\x7f';
728  }
729 
730  ofstream(fPath+"/"+fname+".bin") << out.str();
731  }
uint64_t JavaDate() const
Definition: Time.h:111
int i
Definition: db_dim_client.c:21

+ Here is the call graph for this function: