nidas v1.2.3
SampleTag.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2005, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26#ifndef NIDAS_CORE_SAMPLETAG_H
27#define NIDAS_CORE_SAMPLETAG_H
28
29#include "DOMable.h"
30#include "Sample.h"
31#include "NidsIterators.h"
32
33#include <vector>
34#include <list>
35#include <algorithm>
36
37namespace nidas { namespace core {
38
39class DSMConfig;
40class Variable;
41class Parameter;
42
87class SampleTag : public DOMable
88{
89
90public:
91
95 SampleTag();
96
100 SampleTag(const DSMSensor* sensor);
101
105 SampleTag(const SampleTag&);
106
107 virtual ~SampleTag();
108
109 SampleTag& operator=(const SampleTag& rhs);
110
114 void setSampleId(unsigned int val) {
115 _sampleId = val;
117 }
118
122 unsigned int getSampleId() const { return _sampleId; }
123
127 void setSensorId(unsigned int val) {
128 _sensorId = val;
130 }
131
135 unsigned int getSensorId() const { return _sensorId; }
136
140 void setDSMId(unsigned int val) { _id = SET_DSM_ID(_id,val); }
141
145 unsigned int getDSMId() const { return GET_DSM_ID(_id); }
146
151
155 unsigned int getSpSId() const { return GET_SPS_ID(_id); }
156
160 const std::string& getSuffix() const { return _suffix; }
161
162 void setSuffix(const std::string& val);
163
164 const DSMConfig* getDSMConfig() const { return _dsm; }
165
166 void setDSMConfig(const DSMConfig* val) { _dsm = val; }
167
168 const DSMSensor* getDSMSensor() const { return _sensor; }
169
170 void setDSMSensor(const DSMSensor* val);
171
183 int getStation() const { return _station; }
184
185 void setStation(int val);
186
191 const Site* getSite() const;
192
202 virtual void setRate(double val)
203 {
204 _rate = val;
205 }
206
211 virtual double getRate() const { return _rate; }
212
219 virtual void setPeriod(double val)
220 {
221 _rate = (val > 0.0) ? 1.0 / val : 0.0;
222 }
223
228 virtual double getPeriod() const
229 {
230
231 return (_rate > 0.0) ? 1.0 / _rate : 0.0;
232 }
233
239 void setProcessed(bool val)
240 {
241 _processed = val;
242 }
244 bool isProcessed() const { return _processed; };
245
246 void setScanfFormat(const std::string& val)
247 {
249 }
250
251 const std::string& getScanfFormat() const { return _scanfFormat; }
252
253 void setPromptString(const std::string& val)
254 {
256 }
257
258 const std::string& getPromptString() const { return _promptString; }
259
260 void setPromptOffset(double val)
261 {
263 }
264
265 double getPromptOffset() const { return _promptOffset; }
266
274 virtual void addVariable(Variable* var);
275
276 const std::vector<const Variable*>& getVariables() const;
277
278 const std::vector<Variable*>& getVariables()
279 {
280 return _variables;
281 }
282
283 void removeVariable(const Variable* var);
284
288 Variable& getVariable(int i) { return *_variables[i]; }
289
297 void addParameter(Parameter* val);
298
299 const std::list<const Parameter*>& getParameters() const
300 {
301 return _constParameters;
302 }
303
304 const Parameter* getParameter(const std::string& name) const;
305
306 void setEnabled(bool val) { _enabled = val; }
307 bool isEnabled() const { return _enabled; }
308
314 unsigned int getDataIndex(const Variable* var) const;
315
322 float getTimetagAdjust() const { return _ttAdjustVal; }
323
324 void setTimetagAdjust(float val) { _ttAdjustVal = val; }
325
327
331 void fromDOMElement(const xercesc::DOMElement*);
332
336 xercesc::DOMElement*
337 toDOMParent(xercesc::DOMElement* parent,bool complete) const;
338
342 xercesc::DOMElement*
343 toDOMElement(xercesc::DOMElement* node,bool complete) const;
344
345protected:
346
353
360 void setSpSId(unsigned int val) { _id = SET_SPS_ID(_id,val); }
361
362private:
363
365
366 unsigned int _sampleId;
367
368 unsigned int _sensorId;
369
370 std::string _suffix;
371
373
374 double _rate;
375
377
379
381
382 std::vector<const Variable*> _constVariables;
383
384 std::vector<Variable*> _variables;
385
386 std::vector<std::string> _variableNames;
387
388 std::string _scanfFormat;
389
390 std::string _promptString;
391
393
397 std::list<Parameter*> _parameters;
398
403 std::list<const Parameter*> _constParameters;
404
406
411
412};
413
414}} // namespace nidas namespace core
415
416#endif
#define GET_FULL_ID(tid)
Definition Sample.h:79
#define GET_SPS_ID(tid)
Definition Sample.h:85
#define SET_SPS_ID(tid, val)
Definition Sample.h:88
#define GET_DSM_ID(tid)
Definition Sample.h:82
#define SET_DSM_ID(tid, val)
Definition Sample.h:83
#define SET_FULL_ID(tid, val)
Definition Sample.h:80
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method,...
Definition DOMable.h:51
Class that should include all that is configurable about a DSM.
Definition DSMConfig.h:55
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
Definition Parameter.h:47
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
std::list< Parameter * > _parameters
List of pointers to Parameters.
Definition SampleTag.h:397
void setDSMId(unsigned int val)
Set the DSM portion of the id.
Definition SampleTag.h:140
void setProcessed(bool val)
Set if this sample is going to be post processed.
Definition SampleTag.h:239
const DSMConfig * getDSMConfig() const
Definition SampleTag.h:164
const DSMSensor * _sensor
Definition SampleTag.h:380
void setSensorId(unsigned int val)
Set the sensor portion of the shortId.
Definition SampleTag.h:127
const std::string & getScanfFormat() const
Definition SampleTag.h:251
std::list< const Parameter * > _constParameters
List of const pointers to Parameters for providing via getParameters().
Definition SampleTag.h:403
void addParameter(Parameter *val)
Add a parameter to this SampleTag.
Definition SampleTag.cc:231
void setSpSId(unsigned int val)
Set the sensor + sample portions of the id.
Definition SampleTag.h:360
Variable & getVariable(int i)
Provide a reference to a variable - allowing one to modify it.
Definition SampleTag.h:288
std::string _suffix
Definition SampleTag.h:370
virtual double getPeriod() const
Get sampling period (1/rate) in sec.
Definition SampleTag.h:228
int _station
Definition SampleTag.h:372
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Definition SampleTag.cc:470
unsigned int _sampleId
Definition SampleTag.h:366
float _ttAdjustVal
If positive, enable TimetagAdjustor for these samples.
Definition SampleTag.h:410
bool _enabled
Definition SampleTag.h:405
void setScanfFormat(const std::string &val)
Definition SampleTag.h:246
SampleTag()
Constructor.
Definition SampleTag.cc:45
std::string _scanfFormat
Definition SampleTag.h:388
dsm_sample_id_t _id
Definition SampleTag.h:364
unsigned int getSampleId() const
Get the sample portion of the shortId.
Definition SampleTag.h:122
bool isProcessed() const
Test to see if this sample is to be post processed.
Definition SampleTag.h:244
virtual void setRate(double val)
Set sampling rate in samples/sec.
Definition SampleTag.h:202
std::string _promptString
Definition SampleTag.h:390
const std::vector< const Variable * > & getVariables() const
Definition SampleTag.cc:210
unsigned int getDataIndex(const Variable *var) const
What is the index of a Variable into the data of a sample from this SampleTag.
Definition SampleTag.cc:220
const DSMConfig * _dsm
Definition SampleTag.h:378
virtual double getRate() const
Get sampling rate in samples/sec.
Definition SampleTag.h:211
const DSMSensor * getDSMSensor() const
Definition SampleTag.h:168
double getPromptOffset() const
Definition SampleTag.h:265
virtual void setPeriod(double val)
Set sampling period (1/rate) in sec.
Definition SampleTag.h:219
SampleTag & operator=(const SampleTag &rhs)
Definition SampleTag.cc:103
void setDSMConfig(const DSMConfig *val)
Definition SampleTag.h:166
const std::string & getSuffix() const
Suffix, which is appended to variable names.
Definition SampleTag.h:160
const std::string & getPromptString() const
Definition SampleTag.h:258
void setPromptString(const std::string &val)
Definition SampleTag.h:253
const std::vector< Variable * > & getVariables()
Definition SampleTag.h:278
double _promptOffset
Definition SampleTag.h:392
const Site * getSite() const
Get the Site of this SampleTag, which will be non-NULL only if getDSMConfig() returns non-NULL.
Definition SampleTag.cc:172
const std::list< const Parameter * > & getParameters() const
Definition SampleTag.h:299
void fromDOMElement(const xercesc::DOMElement *)
Definition SampleTag.cc:261
int getStation() const
Station number, which is also known as the Site number.
Definition SampleTag.h:183
unsigned int _sensorId
Definition SampleTag.h:368
void setPromptOffset(double val)
Definition SampleTag.h:260
void setSampleId(unsigned int val)
Set the sample portion of the shortId.
Definition SampleTag.h:114
virtual ~SampleTag()
Definition SampleTag.cc:140
unsigned int getSpSId() const
Get the sensor+sample portion of the id.
Definition SampleTag.h:155
void setEnabled(bool val)
Definition SampleTag.h:306
std::vector< const Variable * > _constVariables
Definition SampleTag.h:382
void setId(dsm_sample_id_t val)
Set the full id.
Definition SampleTag.h:352
float getTimetagAdjust() const
Whether to enable TimetagAdjuster for this sample.
Definition SampleTag.h:322
bool isEnabled() const
Definition SampleTag.h:307
std::vector< Variable * > _variables
Definition SampleTag.h:384
unsigned int getDSMId() const
Get the DSM portion of the id.
Definition SampleTag.h:145
dsm_sample_id_t getId() const
Get the 26 bit id, containing the DSM id and the sensor+sample id.
Definition SampleTag.h:150
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Definition SampleTag.cc:481
std::vector< std::string > _variableNames
Definition SampleTag.h:386
virtual void addVariable(Variable *var)
Add a variable to this SampleTag.
Definition SampleTag.cc:150
double _rate
Definition SampleTag.h:374
void setTimetagAdjust(float val)
Definition SampleTag.h:324
bool _processed
Definition SampleTag.h:376
void removeVariable(const Variable *var)
Definition SampleTag.cc:179
VariableIterator getVariableIterator() const
Definition SampleTag.cc:215
void setStation(int val)
Definition SampleTag.cc:162
void setDSMSensor(const DSMSensor *val)
Definition SampleTag.cc:157
const Parameter * getParameter(const std::string &name) const
Definition SampleTag.cc:251
unsigned int getSensorId() const
Get the sensor portion of the shortId.
Definition SampleTag.h:135
void setSuffix(const std::string &val)
Definition SampleTag.cc:199
A measurement site.
Definition Site.h:49
Class for iterating over the Variables of a Project, Site, DSMConfig, DSMSensor, or SampleTag.
Definition NidsIterators.h:287
Class describing a sampled variable.
Definition Variable.h:47
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31