OpenIndy-Core  0.2.0.43
reading.h
Go to the documentation of this file.
1 #ifndef READING_H
2 #define READING_H
3 
4 #include <QObject>
5 #include <QDateTime>
6 #include <QtCore/qmath.h>
7 #include <QtXml>
8 #include <QPointer>
9 
10 #include "element.h"
11 #include "measurementconfig.h"
12 #include "oivec.h"
13 #include "oimat.h"
14 #include "types.h"
15 #include "util.h"
16 
17 class ProjectExchanger;
18 
19 namespace oi{
20 
21 using namespace math;
22 
23 class Sensor;
24 class Observation;
25 class CoordinateSystem;
26 
27 //###########################
28 //definition of reading types
29 //###########################
30 
35 public:
36  ReadingPolar() : azimuth(0.0), zenith(0.0), distance(0.0),
37  sigmaAzimuth(0.0), sigmaZenith(0.0), sigmaDistance(0.0), isValid(false){}
38 
39  double azimuth;
40  double zenith;
41  double distance;
42  double sigmaAzimuth;
43  double sigmaZenith;
44  double sigmaDistance;
45  bool isValid;
46 };
47 
52 public:
53  ReadingDirection() : azimuth(0.0), zenith(0.0), sigmaAzimuth(0.0),
54  sigmaZenith(0.0), isValid(false){}
55 
56  double azimuth;
57  double zenith;
58  double sigmaAzimuth;
59  double sigmaZenith;
60  bool isValid;
61 };
62 
67 public:
68  ReadingDistance() : distance(0.0), sigmaDistance(0.0), isValid(false){}
69 
70  double distance;
71  double sigmaDistance;
72  bool isValid;
73 };
74 
79 public:
80  ReadingCartesian() : xyz(3), sigmaXyz(3), isValid(false){}
81 
84  bool isValid;
85 };
86 
91 public:
92  ReadingTemperature() : temperature(0.0), sigmaTemperature(0.0), isValid(false){}
93 
94  double temperature;
96  bool isValid;
97 };
98 
103 public:
104  ReadingUndefined() : isValid(false){}
105 
106  QMap<QString,double> values;
107  QMap<QString,double> sigmaValues;
108  bool isValid;
109 };
110 
115 public:
116  double RX;
117  double RY;
118  double RZ;
119  double sigmaRX;
120  double sigmaRY;
121  double sigmaRZ;
122  bool isValid;
123 };
124 
125 //########################
126 //the reading class itself
127 //########################
128 
133 {
134  friend class Station;
135  friend class CoordinateSystem;
136  friend class Observation;
137  friend class ProjectExchanger;
138  Q_OBJECT
139 
140 private:
141  explicit Reading(QObject *parent = 0);
142 
143 public:
144  explicit Reading(const ReadingPolar &reading, QObject *parent = 0);
145  explicit Reading(const ReadingCartesian &reading, QObject *parent = 0);
146  explicit Reading(const ReadingDirection &reading, QObject *parent = 0);
147  explicit Reading(const ReadingDistance &reading, QObject *parent = 0);
148  explicit Reading(const ReadingTemperature &reading, QObject *parent = 0);
149  explicit Reading(const ReadingLevel &reading, QObject *parent = 0);
150  explicit Reading(const ReadingUndefined &reading, QObject *parent = 0);
151 
152  Reading(const Reading &copy, QObject *parent = 0);
153 
154  Reading &operator=(const Reading &copy);
155 
156  ~Reading();
157 
158  //###########################
159  //get reading type and values
160  //###########################
161 
162  const ReadingTypes &getTypeOfReading() const;
163 
164  const ReadingPolar &getPolarReading() const;
165  const ReadingCartesian &getCartesianReading() const;
166  const ReadingDirection &getDirectionReading() const;
167  const ReadingDistance &getDistanceReading() const;
168  const ReadingTemperature &getTemperatureReading() const;
169  const ReadingLevel &getLevelReading() const;
170  const ReadingUndefined &getUndefinedReading() const;
171 
172  //##############################
173  //set polar reading (simulation)
174  //##############################
175 
176  void setPolarReading(const ReadingPolar &rPolar);
177 
178  //################################
179  //make and restore reading backups
180  //################################
181 
182  void makeBackup();
183  void restoreBackup();
184 
185  //############################################
186  //convert between polar and cartesian readings
187  //############################################
188 
189  static OiVec toCartesian(const double &azimuth, const double &zenith, const double &distance);
190  static OiVec toPolar(const double &x, const double &y, const double &z);
191 
192  //#########################################
193  //get general information about the reading
194  //#########################################
195 
196  const MeasurementConfig &getMeasurementConfig();
197  void setMeasurementConfig(const MeasurementConfig &mConfig);
198 
199  const QDateTime &getMeasuredAt() const;
200  void setMeasuredAt(const QDateTime &measuredAt);
201 
202  const SensorFaces &getFace() const;
203  void setSensorFace(const SensorFaces &face);
204 
205  //#################################################
206  //get and set references to sensor and observations
207  //#################################################
208 
209  const QPointer<Sensor> &getSensor() const;
210  void setSensor(const QPointer<Sensor> &sensor);
211 
212  const QPointer<Observation> &getObservation() const;
213  void setObservation(const QPointer<Observation> &observation);
214 
215  //###############
216  //display methods
217  //###############
218 
219  QString getDisplayId() const;
220  QString getDisplayType() const;
221  QString getDisplayTime() const;
222  QString getDisplaySensor() const;
223  QString getDisplayIsFrontside() const;
224  QString getDisplayAzimuth(const UnitType &type, const int &digits) const;
225  QString getDisplayZenith(const UnitType &type, const int &digits) const;
226  QString getDisplayDistance(const UnitType &type, const int &digits) const;
227  QString getDisplayX(const UnitType &type, const int &digits) const;
228  QString getDisplayY(const UnitType &type, const int &digits) const;
229  QString getDisplayZ(const UnitType &type, const int &digits) const;
230  QString getDisplayRX(const UnitType &type, const int &digits) const;
231  QString getDisplayRY(const UnitType &type, const int &digits) const;
232  QString getDisplayRZ(const UnitType &type, const int &digits) const;
233  QString getDisplayTemperature(const UnitType &type, const int &digits) const;
234  QString getDisplaySigmaAzimuth(const UnitType &type, const int &digits) const;
235  QString getDisplaySigmaZenith(const UnitType &type, const int &digits) const;
236  QString getDisplaySigmaDistance(const UnitType &type, const int &digits) const;
237  QString getDisplaySigmaX(const UnitType &type, const int &digits) const;
238  QString getDisplaySigmaY(const UnitType &type, const int &digits) const;
239  QString getDisplaySigmaZ(const UnitType &type, const int &digits) const;
240  QString getDisplaySigmaRX(const UnitType &type, const int &digits) const;
241  QString getDisplaySigmaRY(const UnitType &type, const int &digits) const;
242  QString getDisplaySigmaRZ(const UnitType &type, const int &digits) const;
243  QString getDisplaySigmaTemperature(const UnitType &type, const int &digits) const;
244 
245  //#################
246  //save and load XML
247  //#################
248 
249  QDomElement toOpenIndyXML(QDomDocument &xmlDoc) const;
250  bool fromOpenIndyXML(QDomElement &xmlElem);
251 
252 private:
253 
254  //#######################
255  //reading type and values
256  //#######################
257 
258  ReadingTypes typeOfReading;
259 
260  ReadingPolar rPolar;
261  ReadingCartesian rCartesian;
262  ReadingDirection rDirection;
263  ReadingDistance rDistance;
264  ReadingTemperature rTemperature;
265  ReadingLevel rLevel;
266  ReadingUndefined rUndefined;
267 
268  //###################################
269  //backup readings used for simulation
270  //###################################
271 
272  ReadingPolar backupPolar;
273  ReadingCartesian backupCartesian;
274  ReadingDirection backupDirection;
275  ReadingDistance backupDistance;
276  ReadingTemperature backupTemperature;
277  ReadingLevel backupLevel;
278  ReadingUndefined backupUndefined;
279 
280  //##########################
281  //general reading attributes
282  //##########################
283 
284  QDateTime measuredAt;
285  MeasurementConfig mConfig; //the configuration that the sensor used to produce this reading
286  SensorFaces face;
287 
288  //####################################
289  //references to sensor and observation
290  //####################################
291 
292  QPointer<Sensor> sensor;
293  QPointer<Observation> observation;
294 
295  //################
296  //helper variables
297  //################
298 
299  bool hasBackup; //true if a backup was made using makeBackup
300 
301 private:
302 
303  //##############
304  //helper methods
305  //##############
306 
307  void toCartesian();
308  void toPolar();
309 
310  OiVec errorPropagationPolarToCartesian();
311 
312 };
313 
314 }
315 
316 Q_DECLARE_METATYPE( oi::Reading* )
317 
318 #endif // READING_H
double sigmaTemperature
Definition: reading.h:95
ReadingPolar()
Definition: reading.h:36
ReadingCartesian()
Definition: reading.h:80
The ReadingPolar class.
Definition: reading.h:34
The ReadingDistance class.
Definition: reading.h:66
double azimuth
Definition: reading.h:56
ReadingTemperature()
Definition: reading.h:92
The Element class.
Definition: element.h:17
bool isValid
Definition: reading.h:45
ReadingTypes
Definition: types.h:203
The Observation class.
Definition: observation.h:27
bool isValid
Definition: reading.h:60
bool isValid
Definition: reading.h:122
ReadingDirection()
Definition: reading.h:53
double sigmaZenith
Definition: reading.h:43
double zenith
Definition: reading.h:57
double distance
Definition: reading.h:70
The OiVec class.
Definition: oivec.h:22
Definition: coordinatesystem.h:15
bool isValid
Definition: reading.h:84
QMap< QString, double > sigmaValues
Definition: reading.h:107
double RX
Definition: reading.h:116
bool isValid
Definition: reading.h:72
double RZ
Definition: reading.h:118
bool isValid
Definition: reading.h:96
double distance
Definition: reading.h:41
double sigmaAzimuth
Definition: reading.h:42
The MeasurementConfig class Contains all the configuration parameters needed to start a measurement...
Definition: measurementconfig.h:15
double azimuth
Definition: reading.h:39
QMap< QString, double > values
Definition: reading.h:106
The Station class.
Definition: station.h:23
The ReadingTemperature class.
Definition: reading.h:90
double sigmaZenith
Definition: reading.h:59
double sigmaRZ
Definition: reading.h:121
bool isValid
Definition: reading.h:108
ReadingDistance()
Definition: reading.h:68
double sigmaAzimuth
Definition: reading.h:58
double zenith
Definition: reading.h:40
double temperature
Definition: reading.h:94
double sigmaRY
Definition: reading.h:120
The CoordinateSystem class.
Definition: coordinatesystem.h:25
ReadingUndefined()
Definition: reading.h:104
SensorFaces
Definition: types.h:398
The ReadingUndefined class.
Definition: reading.h:102
OiVec sigmaXyz
Definition: reading.h:83
The ReadingLevel class.
Definition: reading.h:114
double sigmaDistance
Definition: reading.h:44
UnitType
Definition: types.h:354
The Reading class.
Definition: reading.h:132
double sigmaDistance
Definition: reading.h:71
OiVec xyz
Definition: reading.h:82
#define OI_CORE_EXPORT
Definition: types.h:11
double sigmaRX
Definition: reading.h:119
The ReadingDirection class.
Definition: reading.h:51
double RY
Definition: reading.h:117
The ReadingCartesian class.
Definition: reading.h:78