nidas  v1.2-1520
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 
36 #include <nidas/util/IOException.h>
37 
38 #include <list>
39 
40 namespace nidas { namespace core {
41 
42 class Project;
43 class Site;
44 class DSMSensor;
45 class FileSet;
46 class SensorHandler;
47 class SampleOutput;
48 
55 class DSMConfig : public DOMable {
56 public:
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 
82  void initSensors() throw(nidas::util::IOException);
83 
88 
89  void addOutput(SampleOutput* output) { _outputs.push_back(output); }
90 
91  const std::list<SampleOutput*>& getOutputs() const { return _outputs; }
92 
93  std::list<nidas::core::FileSet*> findSampleOutputStreamFileSets() const;
94 
95  unsigned short getRemoteSerialSocketPort() const { return _remoteSerialSocketPort; }
96 
97  void setRemoteSerialSocketPort(unsigned short val) { _remoteSerialSocketPort = val; }
98 
100 
102 
104 
108  float getRawSorterLength() const
109  {
110  return _rawSorterLength;
111  }
112 
116  void setRawSorterLength(float val)
117  {
118  _rawSorterLength = val;
119  }
120 
124  float getProcSorterLength() const
125  {
126  return _procSorterLength;
127  }
128 
132  void setProcSorterLength(float val)
133  {
134  _procSorterLength = val;
135  }
136 
142  size_t getRawHeapMax() const
143  {
144  return _rawHeapMax;
145  }
146 
152  void setRawHeapMax(size_t val)
153  {
154  _rawHeapMax = val;
155  }
156 
162  size_t getProcHeapMax() const
163  {
164  return _procHeapMax;
165  }
166 
172  void setProcHeapMax(size_t val)
173  {
174  _procHeapMax = val;
175  }
176 
181  unsigned int getRawLateSampleCacheSize() const
182  {
184  }
185 
191  void setRawLateSampleCacheSize(unsigned int val)
192  {
194  }
195 
200  unsigned int getProcLateSampleCacheSize() const
201  {
203  }
204 
210  void setProcLateSampleCacheSize(unsigned int val)
211  {
213  }
214 
222  DSMSensor* sensorFromDOMElement(const xercesc::DOMElement* node)
224 
225  void validate()
226  throw(nidas::util::InvalidParameterException);
227 
228  void fromDOMElement(const xercesc::DOMElement*)
229  throw(nidas::util::InvalidParameterException);
230 
231  xercesc::DOMElement*
232  toDOMParent(xercesc::DOMElement* parent,bool complete) const
233  throw(xercesc::DOMException);
234 
235  xercesc::DOMElement*
236  toDOMElement(xercesc::DOMElement* node,bool complete) const
237  throw(xercesc::DOMException);
238 
246  std::string expandString(const std::string& input) const
247  {
248  return _dictionary.expandString(input);
249  }
250 
255  bool getTokenValue(const std::string& token,std::string& value) const
256  {
257  return _dictionary.getTokenValue(token,value);
258  }
259 
260  const Dictionary& getDictionary() const
261  {
262  return _dictionary;
263  }
264 
266  {
267  delete _derivedDataSocketAddr;
269  }
270 
272  {
273  return *_derivedDataSocketAddr;
274  }
275 
277  {
278  delete _statusSocketAddr;
279  _statusSocketAddr = val.clone();
280  }
281 
283  {
284  return *_statusSocketAddr;
285  }
286 
291  virtual void addProcessor(SampleIOProcessor* proc)
292  {
293  _processors.push_back(proc);
294  }
295 
296  virtual const std::list<SampleIOProcessor*>& getProcessors() const
297  {
298  return _processors;
299  }
300 
302 
303 private:
304 
310  throw(nidas::util::InvalidParameterException);
311 
312  const Site* _site;
313 
314  std::string _name;
315 
316  std::string _suffix;
317 
318  std::string _location;
319 
320  class MyDictionary : public Dictionary {
321  public:
322  MyDictionary(DSMConfig* dsm): _dsm(dsm) {}
323  MyDictionary(const MyDictionary& x): Dictionary(),_dsm(x._dsm) {}
325  {
326  if (&rhs != this) {
327  *(Dictionary*) this = rhs;
328  _dsm = rhs._dsm;
329  }
330  return *this;
331  }
332  bool getTokenValue(const std::string& token, std::string& value) const;
333  private:
335  } _dictionary;
336 
337  unsigned int _id;
338 
344  std::list<DSMSensor*> _ownedSensors;
345 
349  std::list<DSMSensor*> _allSensors;
350 
354  std::list<SampleOutput*> _outputs;
355 
360  unsigned short _remoteSerialSocketPort;
361 
363 
365 
366  size_t _rawHeapMax;
367 
368  size_t _procHeapMax;
369 
371 
373 
375 
376  std::list<SampleIOProcessor*> _processors;
377 
379 
380 private:
381  // no copying
382  DSMConfig(const DSMConfig& x);
383 
384  // no assignment
385  DSMConfig& operator=(const DSMConfig& x);
386 };
387 
388 }} // namespace nidas namespace core
389 
390 #endif
const Site * _site
Definition: DSMConfig.h:312
Interface for a Dictionary class, which can return a string value for a string token name...
Definition: Dictionary.h:38
Definition: DSMConfig.h:320
const std::list< DSMSensor * > & getSensors() const
Definition: DSMConfig.h:77
void fromDOMElement(const xercesc::DOMElement *)
Initialize myself from a xercesc::DOMElement.
Definition: DSMConfig.cc:171
void setRawHeapMax(size_t val)
Set the size of in bytes of the raw SampleSorter.
Definition: DSMConfig.h:152
const Project * getProject() const
Definition: DSMConfig.cc:77
VariableIterator getVariableIterator() const
Definition: DSMConfig.cc:99
virtual ~DSMConfig()
Definition: DSMConfig.cc:61
dsm_sample_id_t getId() const
Definition: DSMConfig.h:71
unsigned int dsm_sample_id_t
Definition: Sample.h:63
SensorHandler implements a DSMSensor event loop.
Definition: SensorHandler.h:87
void setProcHeapMax(size_t val)
Set the size of in bytes of the processed SampleSorter.
Definition: DSMConfig.h:172
std::list< DSMSensor * > _allSensors
A list of all sensors configured on this DSM.
Definition: DSMConfig.h:349
SensorIterator getSensorIterator() const
Definition: DSMConfig.cc:89
A measurement site.
Definition: Site.h:49
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Add my content into a DOMElement.
Definition: DSMConfig.cc:675
An interface for a socket address.
Definition: SocketAddress.h:36
unsigned int _rawLateSampleCacheSize
Definition: DSMConfig.h:370
unsigned int _procLateSampleCacheSize
Definition: DSMConfig.h:372
unsigned short getRemoteSerialSocketPort() const
Definition: DSMConfig.h:95
Interface of an output stream of samples.
Definition: SampleOutput.h:47
nidas::util::SocketAddress * _statusSocketAddr
Definition: DSMConfig.h:378
virtual void addProcessor(SampleIOProcessor *proc)
Add a processor to this DSM.
Definition: DSMConfig.h:291
void removeSensor(DSMSensor *sensor)
Definition: DSMConfig.cc:111
Class that should include all that is configurable about a DSM.
Definition: DSMConfig.h:55
float getProcSorterLength() const
Get the length of the SampleSorter of processed Samples, in seconds.
Definition: DSMConfig.h:124
Class for iterating over the Variables of a Project, Site, DSMConfig, DSMSensor, or SampleTag...
Definition: NidsIterators.h:286
MyDictionary & operator=(const MyDictionary &rhs)
Definition: DSMConfig.h:324
void initSensors()
Definition: DSMConfig.cc:136
void setProcLateSampleCacheSize(unsigned int val)
Cache this number of samples with potentially anomalous, late time tags in the processed sample sorte...
Definition: DSMConfig.h:210
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method...
Definition: DOMable.h:51
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:33
void setId(dsm_sample_id_t val)
Definition: DSMConfig.h:72
void setRawSorterLength(float val)
Set the length of the SampleSorter of raw Samples, in seconds.
Definition: DSMConfig.h:116
unsigned short _remoteSerialSocketPort
TCP socket port that DSMEngine listens on for remote serial connections.
Definition: DSMConfig.h:360
const std::string & getName() const
Definition: DSMConfig.h:65
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets() const
Definition: DSMConfig.cc:156
const Dictionary & getDictionary() const
Definition: DSMConfig.h:260
float _procSorterLength
Definition: DSMConfig.h:364
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Create a DOMElement and append it to the parent.
Definition: DSMConfig.cc:664
unsigned int _id
Definition: DSMConfig.h:337
size_t getProcHeapMax() const
Get the size of in bytes of the processed SampleSorter.
Definition: DSMConfig.h:162
std::string _suffix
Definition: DSMConfig.h:316
void validateSensorAndSampleIds()
Validate the ids of the DSMSensors belonging to this DSMConfig, and their SampleTags, for uniqueness.
Definition: DSMConfig.cc:530
const nidas::util::SocketAddress & getDerivedDataSocketAddr() const
Definition: DSMConfig.h:271
Class for iterating over the Processors of a DSMServer or DSMConfig.
Definition: NidsIterators.h:149
nidas::core::DSMConfig::MyDictionary _dictionary
void openSensors(SensorHandler *)
Pass my sensors to the SensorHandler for opening.
Definition: DSMConfig.cc:146
float getRawSorterLength() const
Get the length of the SampleSorter of raw Samples, in seconds.
Definition: DSMConfig.h:108
void setLocation(const std::string &val)
Definition: DSMConfig.h:69
SampleTagIterator getSampleTagIterator() const
Definition: DSMConfig.cc:94
std::list< SampleIOProcessor * > _processors
Definition: DSMConfig.h:376
size_t getRawHeapMax() const
Get the size of in bytes of the raw SampleSorter.
Definition: DSMConfig.h:142
std::list< DSMSensor * > _ownedSensors
A list of the sensors on this DSM that have not been passed to a SensorHandler, i.e.
Definition: DSMConfig.h:344
void setStatusSocketAddr(const nidas::util::SocketAddress &val)
Definition: DSMConfig.h:276
unsigned int getRawLateSampleCacheSize() const
Get the size of the late sample cache in the raw sample sorter.
Definition: DSMConfig.h:181
float _rawSorterLength
Definition: DSMConfig.h:362
std::string _name
Definition: DSMConfig.h:314
nidas::util::SocketAddress * _derivedDataSocketAddr
Definition: DSMConfig.h:374
std::string _location
Definition: DSMConfig.h:318
void addOutput(SampleOutput *output)
Definition: DSMConfig.h:89
size_t _rawHeapMax
Definition: DSMConfig.h:366
void setProcSorterLength(float val)
Set the length of the SampleSorter of processed Samples, in seconds.
Definition: DSMConfig.h:132
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition: DSMSensor.h:87
void setRemoteSerialSocketPort(unsigned short val)
Definition: DSMConfig.h:97
const std::list< SampleOutput * > & getOutputs() const
Definition: DSMConfig.h:91
void setName(const std::string &val)
Definition: DSMConfig.h:66
bool getTokenValue(const std::string &token, std::string &value) const
Definition: DSMConfig.cc:695
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
const nidas::util::SocketAddress & getStatusSocketAddr() const
Definition: DSMConfig.h:282
std::list< SampleOutput * > _outputs
SampleOutputs.
Definition: DSMConfig.h:354
Interface of a processor of samples.
Definition: SampleIOProcessor.h:49
DSMConfig & operator=(const DSMConfig &x)
Class for iterating over the DSMSensors of a Project, Site, or DSMConfig.
Definition: NidsIterators.h:185
DSMSensor * sensorFromDOMElement(const xercesc::DOMElement *node)
Parse a DOMElement for a DSMSensor, returning a pointer to the DSMSensor.
Definition: DSMConfig.cc:463
virtual const std::list< SampleIOProcessor * > & getProcessors() const
Definition: DSMConfig.h:296
DSMConfig * _dsm
Definition: DSMConfig.h:334
size_t _procHeapMax
Definition: DSMConfig.h:368
MyDictionary(const MyDictionary &x)
Definition: DSMConfig.h:323
Definition: Project.h:60
void setDerivedDataSocketAddr(const nidas::util::SocketAddress &val)
Definition: DSMConfig.h:265
ProcessorIterator getProcessorIterator() const
Definition: DSMConfig.cc:83
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:255
virtual SocketAddress * clone() const =0
Virtual constructor.
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:246
unsigned int getProcLateSampleCacheSize() const
Get the size of the late sample cache in the processed sample sorter.
Definition: DSMConfig.h:200
void setSite(const Site *val)
Definition: DSMConfig.h:60
MyDictionary(DSMConfig *dsm)
Definition: DSMConfig.h:322
const std::string & getLocation() const
Definition: DSMConfig.h:68
void addSensor(DSMSensor *sensor)
Definition: DSMConfig.cc:104
void setRawLateSampleCacheSize(unsigned int val)
Cache this number of samples with potentially anomalous, late time tags in the raw sample sorter...
Definition: DSMConfig.h:191
void validate()
Definition: DSMConfig.cc:453
DSMConfig()
Definition: DSMConfig.cc:48
Definition: InvalidParameterException.h:35
const Site * getSite() const
Definition: DSMConfig.h:61