MNE-CPP  beta 1.0
newrealtimesamplearray.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef NEWREALTIMESAMPLEARRAY_H
37 #define NEWREALTIMESAMPLEARRAY_H
38 
39 //*************************************************************************************************************
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "xmeas_global.h"
45 #include "newmeasurement.h"
46 
47 
48 //*************************************************************************************************************
49 //=============================================================================================================
50 // Qt INCLUDES
51 //=============================================================================================================
52 
53 #include <QSharedPointer>
54 #include <QVector>
55 #include <QMutex>
56 #include <QMutexLocker>
57 
58 
59 //*************************************************************************************************************
60 //=============================================================================================================
61 // DEFINE NAMESPACE XMEASLIB
62 //=============================================================================================================
63 
64 namespace XMEASLIB
65 {
66 
67 
68 //*************************************************************************************************************
69 //=============================================================================================================
70 // USED NAMESPACES
71 //=============================================================================================================
72 
73 //using namespace IOBuffer;
74 
75 
76 //=========================================================================================================
83 {
84  Q_OBJECT
85 public:
86  typedef QSharedPointer<NewRealTimeSampleArray> SPtr;
87  typedef QSharedPointer<const NewRealTimeSampleArray> ConstSPtr;
89  //=========================================================================================================
95  NewRealTimeSampleArray(QObject *parent = 0);
96 
97  //=========================================================================================================
101  virtual ~NewRealTimeSampleArray();
102 
103  //=========================================================================================================
107  void clear();
108 
109  //=========================================================================================================
115  inline void setMinValue(double minValue);
116 
117  //=========================================================================================================
123  inline double getMinValue() const;
124 
125  //=========================================================================================================
131  inline void setMaxValue(double maxValue);
132 
133  //=========================================================================================================
139  inline double getMaxValue() const;
140 
141  //=========================================================================================================
147  inline void setSamplingRate(double dSamplingRate);
148 
149  //=========================================================================================================
155  inline double getSamplingRate() const;
156 
157  //=========================================================================================================
163  inline void setArraySize(unsigned char ucArraySize);
164 
165  //=========================================================================================================
171  inline unsigned char getArraySize() const;
172 
173  //=========================================================================================================
179  inline const QVector<double>& getSampleArray();
180 
181  //=========================================================================================================
187  inline void setUnit(const QString& unit);
188 
189  //=========================================================================================================
195  inline const QString& getUnit() const;
196 
197  //=========================================================================================================
204  virtual void setValue(double v);
205 
206  //=========================================================================================================
213  virtual double getValue() const;
214 
215 private:
216  mutable QMutex m_qMutex;
218  double m_dMinValue;
219  double m_dMaxValue;
220  double m_dSamplingRate;
221  QString m_qString_Unit;
222  double m_dValue;
223  unsigned char m_ucArraySize;
224  QVector<double> m_vecSamples;
225 };
226 
227 
228 //*************************************************************************************************************
229 //=============================================================================================================
230 // INLINE DEFINITIONS
231 //=============================================================================================================
232 
234 {
235  QMutexLocker locker(&m_qMutex);
236  m_vecSamples.clear();
237 }
238 
239 inline void NewRealTimeSampleArray::setMinValue(double minValue)
240 {
241  QMutexLocker locker(&m_qMutex);
242  m_dMinValue = minValue;
243 }
244 
245 
246 //*************************************************************************************************************
247 
249 {
250  QMutexLocker locker(&m_qMutex);
251  return m_dMinValue;
252 }
253 
254 
255 //*************************************************************************************************************
256 
257 inline void NewRealTimeSampleArray::setMaxValue(double maxValue)
258 {
259  QMutexLocker locker(&m_qMutex);
260  m_dMaxValue = maxValue;
261 }
262 
263 
264 //*************************************************************************************************************
265 
267 {
268  QMutexLocker locker(&m_qMutex);
269  return m_dMaxValue;
270 }
271 
272 
273 //*************************************************************************************************************
274 
275 inline void NewRealTimeSampleArray::setSamplingRate(double dSamplingRate)
276 {
277  QMutexLocker locker(&m_qMutex);
278  m_dSamplingRate = dSamplingRate;
279 }
280 
281 
282 //*************************************************************************************************************
283 
285 {
286  QMutexLocker locker(&m_qMutex);
287  return m_dSamplingRate;
288 }
289 
290 
291 //*************************************************************************************************************
292 
293 inline void NewRealTimeSampleArray::setArraySize(unsigned char ucArraySize)
294 {
295  QMutexLocker locker(&m_qMutex);
296  //Obsolete unsigned char can't be bigger
297 // if(ucArraySize > 255)
298 // m_ucArraySize = 255;
299 // else
300  m_ucArraySize = ucArraySize;
301 }
302 
303 
304 //*************************************************************************************************************
305 
307 {
308  QMutexLocker locker(&m_qMutex);
309  return m_ucArraySize;
310 }
311 
312 
313 //*************************************************************************************************************
314 
315 inline const QVector<double>& NewRealTimeSampleArray::getSampleArray()
316 {
317  QMutexLocker locker(&m_qMutex);
318  return m_vecSamples;
319 }
320 
321 
322 //*************************************************************************************************************
323 
324 inline void NewRealTimeSampleArray::setUnit(const QString& unit)
325 {
326  QMutexLocker locker(&m_qMutex);
327  m_qString_Unit = unit;
328 }
329 
330 
331 //*************************************************************************************************************
332 
333 inline const QString& NewRealTimeSampleArray::getUnit() const
334 {
335  QMutexLocker locker(&m_qMutex);
336  return m_qString_Unit;
337 }
338 
339 } // NAMESPACE
340 
341 Q_DECLARE_METATYPE(XMEASLIB::NewRealTimeSampleArray::SPtr)
342 
343 #endif // NEWREALTIMESAMPLEARRAY_H
Contains the declaration of the NewMeasurement class.
#define XMEASSHARED_EXPORT
Definition: xmeas_global.h:54
QSharedPointer< const NewRealTimeSampleArray > ConstSPtr
QSharedPointer< NewRealTimeSampleArray > SPtr
void setArraySize(unsigned char ucArraySize)
const QVector< double > & getSampleArray()
The NewRealTimeSampleArray class is the base class of every NewRealTimeSampleArray Measurement...
Contains the xMeas library export/import macros.
void setSamplingRate(double dSamplingRate)