nidas v1.2.3
DSMConfig.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 ** 2004, 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
27#ifndef NIDAS_CORE_DSMCONFIG_H
28#define NIDAS_CORE_DSMCONFIG_H
29
30#include "Sample.h"
31#include "DOMable.h"
32#include "NidsIterators.h"
33#include "Dictionary.h"
34
37
38#include <list>
39
40namespace nidas { namespace core {
41
42class Project;
43class Site;
44class DSMSensor;
45class FileSet;
46class SensorHandler;
47class SampleOutput;
48
55class DSMConfig : public DOMable {
56public:
57 DSMConfig();
58 virtual ~DSMConfig();
59
60 void setSite(const Site* val) { _site = val; }
61 const Site* getSite() const { return _site; }
62
63 const Project* getProject() const;
64
65 const std::string& getName() const { return _name; }
66 void setName(const std::string& val) { _name = val; }
67
68 const std::string& getLocation() const { return _location; }
69 void setLocation(const std::string& val) { _location = val; }
70
71 dsm_sample_id_t getId() const { return _id; }
72 void setId(dsm_sample_id_t val) { _id = val; }
73
74 void addSensor(DSMSensor* sensor);
75 void removeSensor(DSMSensor* sensor);
76
77 const std::list<DSMSensor*>& getSensors() const
78 {
79 return _allSensors;
80 }
81
85 void initSensors();
86
91
92 void addOutput(SampleOutput* output) { _outputs.push_back(output); }
93
94 const std::list<SampleOutput*>& getOutputs() const { return _outputs; }
95
96 std::list<nidas::core::FileSet*> findSampleOutputStreamFileSets() const;
97
98 unsigned short getRemoteSerialSocketPort() const { return _remoteSerialSocketPort; }
99
101
103
105
107
111 float getRawSorterLength() const
112 {
113 return _rawSorterLength;
114 }
115
119 void setRawSorterLength(float val)
120 {
122 }
123
128 {
129 return _procSorterLength;
130 }
131
135 void setProcSorterLength(float val)
136 {
138 }
139
145 size_t getRawHeapMax() const
146 {
147 return _rawHeapMax;
148 }
149
155 void setRawHeapMax(size_t val)
156 {
158 }
159
165 size_t getProcHeapMax() const
166 {
167 return _procHeapMax;
168 }
169
175 void setProcHeapMax(size_t val)
176 {
178 }
179
184 unsigned int getRawLateSampleCacheSize() const
185 {
187 }
188
194 void setRawLateSampleCacheSize(unsigned int val)
195 {
197 }
198
203 unsigned int getProcLateSampleCacheSize() const
204 {
206 }
207
213 void setProcLateSampleCacheSize(unsigned int val)
214 {
216 }
217
227 DSMSensor* sensorFromDOMElement(const xercesc::DOMElement* node);
228
232 void validate();
233
237 void fromDOMElement(const xercesc::DOMElement*);
238
242 xercesc::DOMElement*
243 toDOMParent(xercesc::DOMElement* parent,bool complete) const;
244
248 xercesc::DOMElement*
249 toDOMElement(xercesc::DOMElement* node,bool complete) const;
250
258 std::string expandString(const std::string& input) const
259 {
260 return _dictionary.expandString(input);
261 }
262
267 bool getTokenValue(const std::string& token,std::string& value) const
268 {
269 return _dictionary.getTokenValue(token,value);
270 }
271
273 {
274 return _dictionary;
275 }
276
282
287
289 {
290 delete _statusSocketAddr;
291 _statusSocketAddr = val.clone();
292 }
293
295 {
296 return *_statusSocketAddr;
297 }
298
303 virtual void addProcessor(SampleIOProcessor* proc)
304 {
305 _processors.push_back(proc);
306 }
307
308 virtual const std::list<SampleIOProcessor*>& getProcessors() const
309 {
310 return _processors;
311 }
312
314
315private:
316
324
325 const Site* _site;
326
327 std::string _name;
328
329 std::string _suffix;
330
331 std::string _location;
332
333 class MyDictionary : public Dictionary {
334 public:
338 {
339 if (&rhs != this) {
340 *(Dictionary*) this = rhs;
341 _dsm = rhs._dsm;
342 }
343 return *this;
344 }
345 bool getTokenValue(const std::string& token, std::string& value) const;
346 private:
349
350 unsigned int _id;
351
357 std::list<DSMSensor*> _ownedSensors;
358
362 std::list<DSMSensor*> _allSensors;
363
367 std::list<SampleOutput*> _outputs;
368
374
376
378
380
382
384
386
388
389 std::list<SampleIOProcessor*> _processors;
390
392
393private:
394 // no copying
396
397 // no assignment
399};
400
401}} // namespace nidas namespace core
402
403#endif
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method,...
Definition DOMable.h:51
Definition DSMConfig.h:333
MyDictionary & operator=(const MyDictionary &rhs)
Definition DSMConfig.h:337
bool getTokenValue(const std::string &token, std::string &value) const
Definition DSMConfig.cc:687
DSMConfig * _dsm
Definition DSMConfig.h:347
MyDictionary(const MyDictionary &x)
Definition DSMConfig.h:336
MyDictionary(DSMConfig *dsm)
Definition DSMConfig.h:335
Class that should include all that is configurable about a DSM.
Definition DSMConfig.h:55
void removeSensor(DSMSensor *sensor)
Definition DSMConfig.cc:111
const Site * getSite() const
Definition DSMConfig.h:61
DSMSensor * sensorFromDOMElement(const xercesc::DOMElement *node)
Parse a DOMElement for a DSMSensor, returning a pointer to the DSMSensor.
Definition DSMConfig.cc:457
unsigned short _remoteSerialSocketPort
TCP socket port that DSMEngine listens on for remote serial connections.
Definition DSMConfig.h:373
virtual const std::list< SampleIOProcessor * > & getProcessors() const
Definition DSMConfig.h:308
const std::string & getName() const
Definition DSMConfig.h:65
void openSensors(SensorHandler *)
Pass my sensors to the SensorHandler for opening.
Definition DSMConfig.cc:145
void setId(dsm_sample_id_t val)
Definition DSMConfig.h:72
nidas::util::SocketAddress * _derivedDataSocketAddr
Definition DSMConfig.h:387
void setProcLateSampleCacheSize(unsigned int val)
Cache this number of samples with potentially anomalous, late time tags in the processed sample sorte...
Definition DSMConfig.h:213
void setStatusSocketAddr(const nidas::util::SocketAddress &val)
Definition DSMConfig.h:288
unsigned int getRawLateSampleCacheSize() const
Get the size of the late sample cache in the raw sample sorter.
Definition DSMConfig.h:184
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Definition DSMConfig.cc:667
void setProcHeapMax(size_t val)
Set the size of in bytes of the processed SampleSorter.
Definition DSMConfig.h:175
size_t getProcHeapMax() const
Get the size of in bytes of the processed SampleSorter.
Definition DSMConfig.h:165
ProcessorIterator getProcessorIterator() const
Definition DSMConfig.cc:83
nidas::core::DSMConfig::MyDictionary _dictionary
void initSensors()
Definition DSMConfig.cc:136
const std::list< DSMSensor * > & getSensors() const
Definition DSMConfig.h:77
std::string _name
Definition DSMConfig.h:327
void validateSensorAndSampleIds()
Validate the ids of the DSMSensors belonging to this DSMConfig, and their SampleTags,...
Definition DSMConfig.cc:523
std::list< SampleIOProcessor * > _processors
Definition DSMConfig.h:389
void addSensor(DSMSensor *sensor)
Definition DSMConfig.cc:104
void setLocation(const std::string &val)
Definition DSMConfig.h:69
DSMConfig & operator=(const DSMConfig &x)
float getRawSorterLength() const
Get the length of the SampleSorter of raw Samples, in seconds.
Definition DSMConfig.h:111
nidas::util::SocketAddress * _statusSocketAddr
Definition DSMConfig.h:391
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets() const
Definition DSMConfig.cc:155
void validate()
Definition DSMConfig.cc:448
void addOutput(SampleOutput *output)
Definition DSMConfig.h:92
float _procSorterLength
Definition DSMConfig.h:377
unsigned int _id
Definition DSMConfig.h:350
void setRawHeapMax(size_t val)
Set the size of in bytes of the raw SampleSorter.
Definition DSMConfig.h:155
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Definition DSMConfig.cc:656
void setProcSorterLength(float val)
Set the length of the SampleSorter of processed Samples, in seconds.
Definition DSMConfig.h:135
void setRemoteSerialSocketPort(unsigned short val)
Definition DSMConfig.h:100
void setName(const std::string &val)
Definition DSMConfig.h:66
DSMConfig()
Definition DSMConfig.cc:48
unsigned int getProcLateSampleCacheSize() const
Get the size of the late sample cache in the processed sample sorter.
Definition DSMConfig.h:203
std::list< SampleOutput * > _outputs
SampleOutputs.
Definition DSMConfig.h:367
void fromDOMElement(const xercesc::DOMElement *)
Definition DSMConfig.cc:170
VariableIterator getVariableIterator() const
Definition DSMConfig.cc:99
std::string expandString(const std::string &input) const
Utility function to expand ${TOKEN} or $TOKEN fields in a string with their value from getTokenValue(...
Definition DSMConfig.h:258
const nidas::util::SocketAddress & getDerivedDataSocketAddr() const
Definition DSMConfig.h:283
virtual ~DSMConfig()
Definition DSMConfig.cc:61
std::string _location
Definition DSMConfig.h:331
std::string _suffix
Definition DSMConfig.h:329
float getProcSorterLength() const
Get the length of the SampleSorter of processed Samples, in seconds.
Definition DSMConfig.h:127
size_t getRawHeapMax() const
Get the size of in bytes of the raw SampleSorter.
Definition DSMConfig.h:145
const nidas::util::SocketAddress & getStatusSocketAddr() const
Definition DSMConfig.h:294
void setDerivedDataSocketAddr(const nidas::util::SocketAddress &val)
Definition DSMConfig.h:277
const Dictionary & getDictionary() const
Definition DSMConfig.h:272
std::list< DSMSensor * > _ownedSensors
A list of the sensors on this DSM that have not been passed to a SensorHandler, i....
Definition DSMConfig.h:357
dsm_sample_id_t getId() const
Definition DSMConfig.h:71
const Project * getProject() const
Definition DSMConfig.cc:77
DSMConfig(const DSMConfig &x)
size_t _procHeapMax
Definition DSMConfig.h:381
SampleTagIterator getSampleTagIterator() const
Definition DSMConfig.cc:94
bool getTokenValue(const std::string &token, std::string &value) const
Implement a lookup for tokens that I know about, like $DSM, $LOCATION.
Definition DSMConfig.h:267
const std::list< SampleOutput * > & getOutputs() const
Definition DSMConfig.h:94
const std::string & getLocation() const
Definition DSMConfig.h:68
const Site * _site
Definition DSMConfig.h:325
float _rawSorterLength
Definition DSMConfig.h:375
unsigned short getRemoteSerialSocketPort() const
Definition DSMConfig.h:98
std::list< DSMSensor * > _allSensors
A list of all sensors configured on this DSM.
Definition DSMConfig.h:362
void setSite(const Site *val)
Definition DSMConfig.h:60
virtual void addProcessor(SampleIOProcessor *proc)
Add a processor to this DSM.
Definition DSMConfig.h:303
SensorIterator getSensorIterator() const
Definition DSMConfig.cc:89
unsigned int _procLateSampleCacheSize
Definition DSMConfig.h:385
size_t _rawHeapMax
Definition DSMConfig.h:379
unsigned int _rawLateSampleCacheSize
Definition DSMConfig.h:383
void setRawLateSampleCacheSize(unsigned int val)
Cache this number of samples with potentially anomalous, late time tags in the raw sample sorter.
Definition DSMConfig.h:194
void setRawSorterLength(float val)
Set the length of the SampleSorter of raw Samples, in seconds.
Definition DSMConfig.h:119
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
Interface for a Dictionary class, which can return a string value for a string token name.
Definition Dictionary.h:38
std::string expandString(const std::string &input) const
Utility function that scans a string for tokens like ${XXXX}, or $XXX followed by any characters from...
Definition Dictionary.cc:34
Class for iterating over the Processors of a DSMServer or DSMConfig.
Definition NidsIterators.h:150
Definition Project.h:60
Interface of a processor of samples.
Definition SampleIOProcessor.h:50
Interface of an output stream of samples.
Definition SampleOutput.h:49
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
SensorHandler implements a DSMSensor event loop.
Definition SensorHandler.h:88
Class for iterating over the DSMSensors of a Project, Site, or DSMConfig.
Definition NidsIterators.h:186
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
An interface for a socket address.
Definition SocketAddress.h:36
virtual SocketAddress * clone() const =0
Virtual constructor.
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