OpenIndy-Core  0.2.0.43
sensor.h
Go to the documentation of this file.
1 #ifndef SENSOR_H
2 #define SENSOR_H
3 
4 #include <QObject>
5 #include <QPointer>
6 #include <QString>
7 #include <QStringList>
8 #include <QMap>
9 #include <QVariant>
10 #include <QPair>
11 
12 #include "pluginmetadata.h"
13 #include "sensorconfiguration.h"
14 #include "measurementconfig.h"
15 #include "types.h"
16 #include "util.h"
17 #include "reading.h"
18 
19 namespace oi{
20 
25 public:
26  double moveAzimuth;
27  double moveZenith;
28  double moveDistance;
30  double moveX;
31  double moveY;
32  double moveZ;
33  QString action;
34 };
35 
36 class Reading;
37 class MeasurementConfig;
38 class SensorControl;
39 
43 class OI_CORE_EXPORT Sensor : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48  explicit Sensor(QObject *parent = 0);
49 
50  virtual ~Sensor();
51 
55  eSensorError
56  };
57 
58  //############################
59  //sensor initialization method
60  //############################
61 
62  virtual void init();
63 
64  //####################################
65  //get or set general sensor attributes
66  //####################################
67 
68  const SensorConfiguration &getSensorConfiguration() const;
69  void setSensorConfiguration(const SensorConfiguration &sConfig);
70 
71  const QPair<ReadingTypes, QPointer<Reading> > &getLastReading() const;
72 
73  //#########################################################
74  //methods to get or set further information to use a sensor
75  //#########################################################
76 
77  const QList<ReadingTypes> &getSupportedReadingTypes() const;
78  const QList<SensorFunctions> &getSupportedSensorActions() const;
79  const QList<ConnectionTypes> &getSupportedConnectionTypes() const;
80 
81  const PluginMetaData &getMetaData() const;
82 
83  const QMap<QString, int> &getIntegerParameter() const;
84  const QMap<QString, double> &getDoubleParameter() const;
85  const QMultiMap<QString, QString> &getStringParameter() const;
86 
87  const QStringList &getSelfDefinedActions() const;
88 
89  const QMap<QString, double> &getDefaultAccuracy() const;
90 
91  //########################
92  //sensor state and actions
93  //########################
94 
95  virtual bool accept(const SensorFunctions &method, const SensorAttributes &sAttr);
96 
97  virtual bool abortAction();
98 
99  virtual bool connectSensor();
100  virtual bool disconnectSensor();
101 
102  virtual QList<QPointer<Reading> > measure(const MeasurementConfig &mConfig);
103  virtual QVariantMap readingStream(const ReadingTypes &streamFormat);
104 
105  virtual bool getConnectionState();
106  virtual bool getIsReadyForMeasurement();
107  virtual bool getIsBusy();
108  virtual QMap<QString, QString> getSensorStatus();
109 
110  virtual bool doSelfDefinedAction(const QString &action);
111 
112  //#################
113  //save and load XML
114  //#################
115 
116  QDomElement toOpenIndyXML(QDomDocument &xmlDoc) const;
117  bool fromOpenIndyXML(QDomElement &xmlElem);
118 
119 signals:
120 
121  //##############################################
122  //signals to inform OpenIndy about sensor issues
123  //##############################################
124 
125  void sensorMessage(const QString &msg, const MessageTypes &msgType, const MessageDestinations &msgDest = eConsoleMessage);
126  void sensorMessage(const SensorMessage &type, const QString &msg, const MessageTypes &msgType, const MessageDestinations &msgDest = eConsoleMessage);
127 
128 protected:
129 
130  //#########################
131  //general sensor attributes
132  //#########################
133 
135 
136  QPair<ReadingTypes, QPointer<Reading> > lastReading; //the last reading produced by this sensor
137 
138  //###########################
139  //input and output parameters
140  //###########################
141 
142  //meta information about the sensor
143  QList<ReadingTypes> supportedReadingTypes;
144  QList<SensorFunctions> supportedSensorActions;
145  QList<ConnectionTypes> supportedConnectionTypes;
146  QStringList selfDefinedActions;
147  QMap<QString, double> defaultAccuracy;
149 
150  //the needed scalar input parameters including default values
151  QMap<QString, int> integerParameters;
152  QMap<QString, double> doubleParameters;
153  QMultiMap<QString, QString> stringParameters;
154 
155 };
156 
157 }
158 
159 #ifndef STR
160 #define STR(x) #x
161 #endif
162 #ifndef STR2
163 #define STR2(x) STR(x)
164 #endif
165 
166 #ifndef CONCAT
167 #define CONCAT(a, b) a ## b
168 #endif
169 #ifndef CONCAT2
170 #define CONCAT2(a, b) CONCAT(a, b)
171 #endif
172 
173 #define SENSOR_PREFIX de.openIndy.plugin.sensor.v
174 #define Sensor_iidd STR2(CONCAT2(SENSOR_PREFIX, PLUGIN_INTERFACE_VERSION))
175 
176 #endif // SENSOR_H
Definition: pluginmetadata.h:10
QMap< QString, double > defaultAccuracy
Definition: sensor.h:147
QList< ReadingTypes > supportedReadingTypes
Definition: sensor.h:143
double moveY
Definition: sensor.h:31
SensorConfiguration sensorConfiguration
Definition: sensor.h:134
void init()
Definition: util.cpp:53
SensorMessage
Definition: sensor.h:52
ReadingTypes
Definition: types.h:203
QString action
Definition: sensor.h:33
double moveX
Definition: sensor.h:30
Definition: coordinatesystem.h:15
double moveZ
Definition: sensor.h:32
QMap< QString, double > doubleParameters
Definition: sensor.h:152
QMultiMap< QString, QString > stringParameters
Definition: sensor.h:153
The SensorAttributes class.
Definition: sensor.h:24
Definition: types.h:38
MessageDestinations
used to specify where to print a message
Definition: types.h:37
Definition: sensor.h:53
The MeasurementConfig class Contains all the configuration parameters needed to start a measurement...
Definition: measurementconfig.h:15
The SensorConfiguration class.
Definition: sensorconfiguration.h:70
bool moveIsRelative
Definition: sensor.h:29
double moveAzimuth
Definition: sensor.h:26
QPair< ReadingTypes, QPointer< Reading > > lastReading
Definition: sensor.h:136
The Sensor class.
Definition: sensor.h:43
MessageTypes
all types of messages
Definition: types.h:29
QMap< QString, int > integerParameters
Definition: sensor.h:151
QList< SensorFunctions > supportedSensorActions
Definition: sensor.h:144
QStringList selfDefinedActions
Definition: sensor.h:146
Definition: sensor.h:54
double moveDistance
Definition: sensor.h:28
QList< ConnectionTypes > supportedConnectionTypes
Definition: sensor.h:145
SensorFunctions
Definition: types.h:412
The Reading class.
Definition: reading.h:132
PluginMetaData metaData
Definition: sensor.h:148
The SensorControl class A sensor control object belongs to a station and executes all sensor actions ...
Definition: sensorcontrol.h:24
#define OI_CORE_EXPORT
Definition: types.h:11
double moveZenith
Definition: sensor.h:27