Jpp  16.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
JDATABASE::JAHRSCalibration_t Struct Reference

Auxiliary class to map module identifier to AHRS calibration. More...

#include <JAHRSCalibration_t.hh>

Inheritance diagram for JDATABASE::JAHRSCalibration_t:
std::map< int, JAHRSCalibration > JLANG::JObjectStreamIO< T >

Public Member Functions

 JAHRSCalibration_t ()
 Default constructor. More...
 
 JAHRSCalibration_t (const int id, const int option)
 Constructor. More...
 
 JAHRSCalibration_t (const JDetectorIntegration_t &detector, const int option)
 Constructor. More...
 
 JAHRSCalibration_t (const char *file_name)
 Constructor. More...
 
void configure (const JDetectorIntegration_t &detector, const int option)
 Configure. More...
 
bool has (int id) const
 Check availability of AHRS calibration for given module identifier. More...
 
const JAHRSCalibrationget (int id) const
 Get AHRS calibration for given module identifier. More...
 
void load (const char *file_name)
 Load from input file. More...
 
void store (const char *file_name) const
 Store to output file. More...
 

Friends

std::istream & operator>> (std::istream &in, JAHRSCalibration_t &calibration)
 Read AHRS calibration from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JAHRSCalibration_t &calibration)
 Write AHRS calibration to output stream. More...
 

Detailed Description

Auxiliary class to map module identifier to AHRS calibration.

Definition at line 36 of file JAHRSCalibration_t.hh.

Constructor & Destructor Documentation

JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( )
inline

Default constructor.

Definition at line 43 of file JAHRSCalibration_t.hh.

44  {}
JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const int  id,
const int  option 
)
inline

Constructor.

Parameters
iddetector identifier
optionoption

Definition at line 53 of file JAHRSCalibration_t.hh.

54  {
55  using namespace std;
56  using namespace JPP;
57 
59 
60  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
61 
62  rs >> detector;
63 
64  detector.configure(getDetector(id));
65 
66  this->configure(detector, option);
67  }
void configure(const JDetectorIntegration_t &detector, const int option)
Configure.
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:365
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
do set_variable DETECTOR_TXT $WORKDIR detector
JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const JDetectorIntegration_t detector,
const int  option 
)
inline

Constructor.

Parameters
detectordetector integration
optionoption

Definition at line 76 of file JAHRSCalibration_t.hh.

77  {
78  this->configure(detector, option);
79  }
void configure(const JDetectorIntegration_t &detector, const int option)
Configure.
JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const char *  file_name)
inline

Constructor.

Parameters
file_nameinput file

Definition at line 87 of file JAHRSCalibration_t.hh.

88  {
89  load(file_name);
90  }
void load(const char *file_name)
Load from input file.

Member Function Documentation

void JDATABASE::JAHRSCalibration_t::configure ( const JDetectorIntegration_t detector,
const int  option 
)
inline

Configure.

The latest valid AHRS calibration data to the identifier of the parent module.
In this, the time order and validity of the AHRS calibration data are defined by AHRSComparator and JAHRSValidity, respectively.
The option corresponds to the maximal difference between latest version and latest valid version.

Parameters
detectordetector integration
optionoption

Definition at line 103 of file JAHRSCalibration_t.hh.

104  {
105  using namespace std;
106  using namespace JPP;
107 
109 
112 
113  this->clear();
114 
115  vector<JAHRSCalibration> calibration;
116 
117  ResultSet& rs = getResultSet(getTable<JAHRSCalibration>());
118 
119  rs >> calibration;
120 
121  rs.Close();
122 
123 
124  sort(calibration.begin(), calibration.end(), binary_negate<JAHRSCalibrationComparator>(JAHRSCalibrationComparator()));
125 
126 
127  for (vector<JAHRSCalibration>::const_iterator p = calibration.begin(); p != calibration.end(); ) {
128 
130 
131  for (++q; q != calibration.end() && q->SERIALNUMBER == p->SERIALNUMBER; ++q) {}
132 
133  const JAHRSCalibration& calibration = *p;
134  const JUPI_t upi = getUPI(PBS::AHRS, calibration.SERIALNUMBER);
135 
136  const JDetectorIntegration_t::range_type r1 = detector.find(upi);
137 
138  if (distance(r1.first, r1.second) == 1) {
139 
140  const int id = getCLBID(detector[r1.first->second].container.getUPI());
141 
142  for (vector<JAHRSCalibration>::const_iterator i = p; i != q; ++i) {
143 
144  if (is_valid(*i) && distance(p,i) <= option) {
145 
146  this->insert(make_pair(id, calibration));
147 
148  break;
149  }
150  }
151  }
152 
153  p = q;
154  }
155  }
static void initialise(JHelper_t &helper, const Args &...args)
Initialise.
Definition: JDBToolkit.hh:327
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JUPIHelper & getUPI()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:459
Universal product identifier (UPI).
Definition: JUPI_t.hh:29
Auxiliary data structure for sorting of AHRS calibrations.
bool is_valid(const json &js)
Check validity of JSon data.
JCLBIDHelper & getCLBID()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:413
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
Auxiliary data structure to check validity of AHRS calibration data.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:432
static const JPBS_t AHRS(3, 4, 3, 4)
PBS of compass
bool JDATABASE::JAHRSCalibration_t::has ( int  id) const
inline

Check availability of AHRS calibration for given module identifier.

Parameters
idmodule identifier
Returns
true if AHRS calibration available; else false

Definition at line 164 of file JAHRSCalibration_t.hh.

165  {
166  return (this->find(id) != this->end());
167  }
const JAHRSCalibration& JDATABASE::JAHRSCalibration_t::get ( int  id) const
inline

Get AHRS calibration for given module identifier.

Parameters
idmodule identifier
Returns
AHRS calibration

Definition at line 176 of file JAHRSCalibration_t.hh.

177  {
178  const_iterator i = this->find(id);
179 
180  if (i != this->end())
181  return i->second;
182  else
183  THROW(JValueOutOfRange, "Invalid module identifier " << id);
184  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
template<class T>
void JLANG::JObjectStreamIO< T >::load ( const char *  file_name)
inlineinherited

Load from input file.

Parameters
file_namefile name

Definition at line 30 of file JObjectStreamIO.hh.

31  {
32  JLANG::load<std::ifstream>(file_name, static_cast<T&>(*this));
33  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T>
void JLANG::JObjectStreamIO< T >::store ( const char *  file_name) const
inlineinherited

Store to output file.

Parameters
file_namefile name

Definition at line 41 of file JObjectStreamIO.hh.

42  {
43  JLANG::store<std::ofstream>(file_name, static_cast<const T&>(*this));
44  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JAHRSCalibration_t calibration 
)
friend

Read AHRS calibration from input stream.

Parameters
ininput stream
calibrationAHRS calibration
Returns
input stream

Definition at line 194 of file JAHRSCalibration_t.hh.

195  {
196  int id;
197  JAHRSCalibration buffer;
198 
199  while (in >> id >> buffer) {
200  calibration[id] = buffer;
201  }
202 
203  return in;
204  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
std::ostream& operator<< ( std::ostream &  out,
const JAHRSCalibration_t calibration 
)
friend

Write AHRS calibration to output stream.

Parameters
outoutput stream
calibrationAHRS calibration
Returns
output stream

Definition at line 214 of file JAHRSCalibration_t.hh.

215  {
216  using namespace std;
217 
218  for (JAHRSCalibration_t::const_iterator i = calibration.begin(); i != calibration.end(); ++i) {
219  out << i->first << ' ' << i->second << endl;
220  }
221 
222  return out;
223  }

The documentation for this struct was generated from the following file: