nidas v1.2.3
DSMSensor.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#ifndef NIDAS_CORE_DSMSENSOR_H
27#define NIDAS_CORE_DSMSENSOR_H
28
29#include "SampleClient.h"
30#include "SampleSourceSupport.h"
31#include "SampleScanner.h"
32#include "SampleTag.h"
33#include "IODevice.h"
34#include "DOMable.h"
35#include "Dictionary.h"
36#include "VariableIndex.h"
37
40
41#include <xmlrpcpp/XmlRpc.h>
42
43#include <string>
44#include <list>
45
46#include <fcntl.h>
47
48namespace nidas { namespace core {
49
50class DSMConfig;
51class Parameter;
52class CalFile;
53class Looper;
54
87class DSMSensor : public SampleSource, public SampleClient, public DOMable
88{
89
90public:
91
96 DSMSensor();
97
98 virtual ~DSMSensor();
99
103 void setDSMConfig(const DSMConfig* val);
104
108 const DSMConfig* getDSMConfig() const
109 {
110 return _dsm;
111 }
112
116 const Site* getSite() const;
117
123 virtual void setDeviceName(const std::string& val)
124 {
125 _devname = val;
126 }
127
132 virtual const std::string& getDeviceName() const
133 {
134 return _devname;
135 }
136
143 virtual void setClassName(const std::string& val)
144 {
145 _className = val;
146 }
147
151 virtual const std::string& getClassName() const
152 {
153 return _className;
154 }
155
159 virtual void setCatalogName(const std::string& val)
160 {
162 }
163
167 virtual const std::string& getCatalogName() const
168 {
169 return _catalogName;
170 }
171
175 const std::string& getDSMName() const;
176
183 virtual std::string getName() const
184 {
185 return getDSMName() + ':' + getDeviceName();
186 }
187
193 const std::string& getLocation() const;
194
195 void setLocation(const std::string& val) { _location = val; }
196
209 const std::string& getSuffix() const { return _suffix; }
210
211 void setSuffix(const std::string& val);
212
213 int getStation() const
214 {
215 return _station;
216 }
217
218 void setStation(int val);
219
229 void setHeight(const std::string& val);
230
238 void setHeight(float val);
239
244 const std::string& getHeightString() const { return _heightString; }
245
250 float getHeight() const { return _height; }
251
261 void setDepth(const std::string& val);
262
271 void setDepth(float val);
272
277 const std::string& getDepthString() const { return _depthString; }
278
283 float getDepth() const { return -_height; }
284
292 const std::string& getFullSuffix() const { return _fullSuffix; }
293
301 std::string expandString(const std::string& input) const
302 {
303 return _dictionary.expandString(input);
304 }
305
310 bool getTokenValue(const std::string& token,std::string& value) const
311 {
312 return _dictionary.getTokenValue(token,value);
313 }
314
316 {
317 return _dictionary;
318 }
319
327 {
328 return &_rawSource;
329 }
330
336 {
337 return this;
338 }
339
346 {
347 return &_rawSampleTag;
348 }
349
364 virtual void addSampleTag(SampleTag* val);
365
369 virtual void removeSampleTag(SampleTag* val);
370
374 std::list<const SampleTag*> getSampleTags() const
375 {
376 return _source.getSampleTags();
377 }
378
382 std::list<SampleTag*>& getSampleTags()
383 {
384 return _sampleTags;
385 }
386
388 {
389 return SampleTagIterator(this);
390 }
391
398 {
399 return _source.addSampleClient(c);
400 }
401
408 {
409 return _source.removeSampleClient(c);
410 }
411
417 void addSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
418 {
419 return _source.addSampleClientForTag(client,tag);
420 }
421
427 void removeSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
428 {
429 return _source.removeSampleClientForTag(client,tag);
430 }
431
435 int getClientCount() const throw()
436 {
437 return _source.getClientCount();
438 }
439
444 void flush() {}
445
450 void distributeRaw(const Sample* s)
451 {
453 }
454
456 {
457 return _source.getSampleStats();
458 }
459
460 virtual int getReadFd() const
461 {
462 if (_iodev) return _iodev->getReadFd();
463 return -1;
464 }
465
466 virtual int getWriteFd() const
467 {
468 if (_iodev) return _iodev->getWriteFd();
469 return -1;
470 }
471
477 virtual bool reopenOnIOException() const { return true; }
478
486 void setSensorId(unsigned int val) { _id = SET_SPS_ID(_id,val); }
487 void setDSMId(unsigned int val) { _id = SET_DSM_ID(_id,val); }
488
496 unsigned int getDSMId() const { return GET_DSM_ID(_id); }
497 unsigned int getSensorId() const { return GET_SPS_ID(_id); }
498
510 virtual void setLatency(float val)
511 {
512 _latency = val;
513 }
514
515 virtual float getLatency() const { return _latency; }
516
526 virtual void setTimeoutMsecs(int val)
527 {
529 }
530
531 virtual int getTimeoutMsecs() const
532 {
533 return _timeoutMsecs;
534 }
535
536 int getTimeoutCount() const
537 {
538 return _nTimeouts;
539 }
540
542 {
543 _nTimeouts++;
544 }
545
552 void addParameter(Parameter* val);
553
557 const std::list<const Parameter*>& getParameters() const
558 {
559 return _constParameters;
560 }
561
566 const Parameter* getParameter(const std::string& name) const;
567
574 virtual IODevice* buildIODevice() = 0;
575
581 {
582 _iodev = val;
583 }
584
592
598 {
599 _scanner = val;
600 }
601
608 virtual void validate();
609
615 virtual void open(int flags);
616
628 virtual void init();
629
634 virtual int getDefaultMode() const
635 {
636 return _defaultMode;
637 }
638
639 virtual void setDefaultMode(int val)
640 {
642 }
643
650 virtual size_t getBytesAvailable() const
651 {
652 return _iodev->getBytesAvailable();
653 }
654
661 virtual size_t read(void *buf, size_t len)
662 {
663 return _iodev->read(buf,len);
664 }
665
671 virtual size_t read(void *buf, size_t len,int msecTimeout)
672 {
673 return _iodev->read(buf,len,msecTimeout);
674 }
675
682 virtual size_t write(const void *buf, size_t len)
683 {
684 return _iodev->write(buf,len);
685 }
686
694 virtual void ioctl(int request, void* buf, size_t len)
695 {
696 _iodev->ioctl(request,buf,len);
697 }
698
704 virtual void close();
705
719 virtual bool readSamples();
720
726 {
727 return _scanner->nextSample(this);
728 }
729
735 virtual Sample* readSample();
736
747 bool receive(const Sample *s);
748
755 virtual bool process(const Sample*,std::list<const Sample*>& result) = 0;
756
757 void printStatusHeader(std::ostream& ostr);
758 virtual void printStatus(std::ostream&);
759 void printStatusTrailer(std::ostream& ostr);
760
766 void calcStatistics(unsigned int periodUsec)
767 {
768 if (_scanner) _scanner->calcStatistics(periodUsec);
769 }
770
771 unsigned int getMaxSampleLength() const
772 {
773 if (_scanner) return _scanner->getMaxSampleLength();
774 return 0;
775 }
776
777 unsigned int getMinSampleLength() const
778 {
779 if (_scanner) return _scanner->getMinSampleLength();
780 return 0;
781 }
782
784 {
786 return 0.0;
787 }
788
790 {
792 return 0.0;
793 }
794
795 size_t getBadTimeTagCount() const
796 {
797 if (_scanner) return _scanner->getBadTimeTagCount();
798 return 0;
799 }
800
802
810 static const std::string getClassName(const xercesc::DOMElement* node,
811 const Project* project);
812
816 void fromDOMElement(const xercesc::DOMElement*);
817
821 xercesc::DOMElement*
822 toDOMParent(xercesc::DOMElement* parent, bool complete) const;
823
827 xercesc::DOMElement*
828 toDOMElement(xercesc::DOMElement* node, bool complete) const;
829
836 virtual void setTypeName(const std::string& val)
837 {
838 _typeName = val;
839 }
840
844 virtual const std::string& getTypeName(void) const
845 {
846 return _typeName;
847 }
848
858 bool getDuplicateIdOK() const
859 {
860 return _duplicateIdOK;
861 }
862
866 void setDuplicateIdOK(bool val)
867 {
869 }
870
871 virtual bool getApplyVariableConversions() const
872 {
874 }
875
876 virtual void setApplyVariableConversions(bool val)
877 {
879 }
880
881 virtual int getDriverTimeTagUsecs() const
882 {
883 return _driverTimeTagUsecs;
884 }
885
886 virtual void setDriverTimeTagUsecs(int val)
887 {
889 }
890
896 void addCalFile(CalFile* val);
897
901 const std::map<std::string,CalFile*>& getCalFiles()
902 {
903 return _calFiles;
904 }
905
909 CalFile* getCalFile(const std::string& name);
910
914 void removeCalFiles();
915
922 virtual void executeXmlRpc(XmlRpc::XmlRpcValue&, XmlRpc::XmlRpcValue&)
923 {}
924
925 static void deleteLooper();
926
932 virtual const std::list<SampleTag*>& getNonConstSampleTags()
933 {
934 return _sampleTags;
935 }
936
937
939 {
940 return _openable;
941 }
942
949 {
950 bool exhausted;
951 _scanner->readBuffer(this,exhausted);
952 return exhausted;
953 }
954
960 bool readBuffer(int msecTimeout)
961 {
962 bool exhausted;
963 _scanner->readBuffer(this,exhausted, msecTimeout);
964 return exhausted;
965 }
966
967
968protected:
969
974 {
976 }
977
978
979 IODevice* getIODevice() const { return _iodev; }
980
982
983 void setFullSuffix(const std::string& val) { _fullSuffix = val; }
984
990 static Looper* getLooper();
991
1009 virtual int getLagUsecs() const
1010 {
1011 return _lag;
1012 }
1017 virtual double getLagSecs() const
1018 {
1019 return (double)_lag / USECS_PER_SEC;
1020 }
1021
1047 virtual void setLagSecs(double val)
1048 {
1049 _lag = (int) rint(val * USECS_PER_SEC);
1050 }
1051
1075 void
1076 applyConversions(SampleTag* stag, SampleT<float>* outs, float* results=0);
1077
1086 void
1087 trimUnparsed(SampleTag* stag, SampleT<float>* outs, int nparsed);
1088
1095 findVariableIndex(const std::string& vprefix);
1096
1107
1108
1109private:
1110
1117 void addSampleTag(const SampleTag* val);
1118
1125 void removeSampleTag(const SampleTag* val);
1126
1127 std::string _devname;
1128
1129 class MyDictionary : public Dictionary {
1130 public:
1131 MyDictionary(DSMSensor* sensor): _sensor(sensor) {}
1134 {
1135 if (&rhs != this) {
1136 *(Dictionary*)this = rhs;
1137 _sensor = rhs._sensor;
1138 }
1139 return *this;
1140 }
1141 bool getTokenValue(const std::string& token, std::string& value) const;
1142 private:
1145
1146
1148
1150
1155 std::string _className;
1156
1157 std::string _catalogName;
1158
1162 std::string _suffix;
1163
1164 std::string _heightString;
1165
1166 std::string _depthString;
1167
1168 float _height;
1169
1173 std::string _fullSuffix;
1174
1175 std::string _location;
1176
1178
1180
1186
1188
1189 std::list<SampleTag*> _sampleTags;
1190
1192
1194
1195 // toggle flag for zebra striping printStatus
1196 static bool zebra;
1197
1199
1203 std::map<std::string,Parameter*> _parameters;
1204
1209 std::list<const Parameter*> _constParameters;
1210
1211 std::map<std::string,CalFile*> _calFiles;
1212
1213 std::string _typeName;
1214
1216
1218
1220
1222
1224
1226
1228
1229 int _lag;
1230
1232
1233private:
1234
1235 // no copying
1237
1238 // no assignment
1240
1241};
1242
1243}} // namespace nidas namespace core
1244
1245#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
A class for reading ASCII files containing a time series of calibration data.
Definition CalFile.h:166
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
Definition DSMSensor.h:1129
MyDictionary(DSMSensor *sensor)
Definition DSMSensor.h:1131
bool getTokenValue(const std::string &token, std::string &value) const
Definition DSMSensor.cc:455
MyDictionary(const MyDictionary &x)
Definition DSMSensor.h:1132
DSMSensor * _sensor
Definition DSMSensor.h:1143
MyDictionary & operator=(const MyDictionary &rhs)
Definition DSMSensor.h:1133
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
unsigned int getSensorId() const
Definition DSMSensor.h:497
virtual bool process(const Sample *, std::list< const Sample * > &result)=0
Apply further necessary processing to a raw sample from this DSMSensor.
virtual void setDefaultMode(int val)
Definition DSMSensor.h:639
void setFullSuffix(const std::string &val)
Definition DSMSensor.h:983
bool getTokenValue(const std::string &token, std::string &value) const
Implement a lookup for tokens that I know about, like $HEIGHT.
Definition DSMSensor.h:310
const DSMConfig * _dsm
Definition DSMSensor.h:1179
std::string _catalogName
Definition DSMSensor.h:1157
virtual void setTimeoutMsecs(int val)
Set the sensor timeout value in milliseconds.
Definition DSMSensor.h:526
xercesc::DOMElement * toDOMElement(xercesc::DOMElement *node, bool complete) const
Definition DSMSensor.cc:895
virtual float getLatency() const
Definition DSMSensor.h:515
unsigned int getMaxSampleLength() const
Definition DSMSensor.h:771
static void deleteLooper()
Definition DSMSensor.cc:927
SampleSourceSupport _rawSource
Definition DSMSensor.h:1191
int getTimeoutCount() const
Definition DSMSensor.h:536
static Looper * _looper
Definition DSMSensor.h:1225
const DSMConfig * getDSMConfig() const
What DSMConfig am I associated with?
Definition DSMSensor.h:108
const Site * getSite() const
What Site am I associated with?
Definition DSMSensor.cc:147
void removeSampleClientForTag(SampleClient *client, const SampleTag *tag)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition DSMSensor.h:427
int getStation() const
Definition DSMSensor.h:213
std::string _devname
Definition DSMSensor.h:1127
void printStatusTrailer(std::ostream &ostr)
Definition DSMSensor.cc:515
unsigned int getDSMId() const
Definition DSMSensor.h:496
void addSampleClientForTag(SampleClient *client, const SampleTag *tag)
Add a SampleClient to this SampleSource.
Definition DSMSensor.h:417
float getHeight() const
Get sensor height above ground.
Definition DSMSensor.h:250
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition DSMSensor.h:397
virtual void ioctl(int request, void *buf, size_t len)
Perform an ioctl on the device.
Definition DSMSensor.h:694
virtual bool getApplyVariableConversions() const
Definition DSMSensor.h:871
VariableIterator getVariableIterator() const
Definition DSMSensor.cc:139
virtual SampleScanner * buildSampleScanner()=0
Factory method for a SampleScanner for this DSMSensor.
virtual void addSampleTag(SampleTag *val)
Add a SampleTag to this sensor.
Definition DSMSensor.cc:103
virtual void setLatency(float val)
Set desired latency, providing some control over the response time vs buffer efficiency tradeoff.
Definition DSMSensor.h:510
virtual size_t read(void *buf, size_t len, int msecTimeout)
Read from the device with a timeout.
Definition DSMSensor.h:671
void trimUnparsed(SampleTag *stag, SampleT< float > *outs, int nparsed)
Fill with floatNAN all the values past nparsed values in output sample outs, and trim the length of t...
Definition DSMSensor.cc:405
virtual bool reopenOnIOException() const
Whether to reopen this sensor on an IOException.
Definition DSMSensor.h:477
virtual const std::string & getClassName() const
Fetch the class name.
Definition DSMSensor.h:151
virtual void setTypeName(const std::string &val)
Set the type name of this sensor, e.g.: "ACME Model 99 Mach7 Particle Disambiguator".
Definition DSMSensor.h:836
const Parameter * getParameter(const std::string &name) const
Fetch a parameter by name.
Definition DSMSensor.cc:322
SampleSourceSupport _source
Definition DSMSensor.h:1193
void fromDOMElement(const xercesc::DOMElement *)
Definition DSMSensor.cc:568
virtual int getDriverTimeTagUsecs() const
Definition DSMSensor.h:881
void setIODevice(IODevice *val)
Set the IODevice for this sensor.
Definition DSMSensor.h:580
virtual int getTimeoutMsecs() const
Definition DSMSensor.h:531
void setDSMConfig(const DSMConfig *val)
Set the DSMConfig for this sensor.
Definition DSMSensor.cc:97
int _timeoutMsecs
Definition DSMSensor.h:1215
std::string _heightString
Definition DSMSensor.h:1164
int _driverTimeTagUsecs
Definition DSMSensor.h:1221
virtual void close()
close my associated device.
Definition DSMSensor.cc:344
virtual size_t read(void *buf, size_t len)
Read from the device (duh).
Definition DSMSensor.h:661
void calcStatistics(unsigned int periodUsec)
Update the sensor sampling statistics.
Definition DSMSensor.h:766
void setSensorId(unsigned int val)
Definition DSMSensor.h:486
std::string _location
Definition DSMSensor.h:1175
virtual int getReadFd() const
Definition DSMSensor.h:460
bool getDuplicateIdOK() const
getDuplicateIdOK will be true if it is OK for samples from this sensor to have identical IDs to sampl...
Definition DSMSensor.h:858
virtual const std::list< SampleTag * > & getNonConstSampleTags()
We'll allow derived classes and calibration applications to change the SampleTags,...
Definition DSMSensor.h:932
void setSampleScanner(SampleScanner *val)
Set the SampleScanner for this sensor.
Definition DSMSensor.h:597
virtual const std::string & getCatalogName() const
Fetch the name of the catalog entry for this sensor.
Definition DSMSensor.h:167
SampleSource * getRawSampleSource()
Implementation of SampleSource::getRawSampleSource().
Definition DSMSensor.h:326
int _nTimeouts
Definition DSMSensor.h:1223
void removeCalFiles()
Remove all CalFiles.
Definition DSMSensor.cc:285
const Dictionary & getDictionary() const
Definition DSMSensor.h:315
const std::string & getLocation() const
Location string.
Definition DSMSensor.cc:165
DSMSensor & operator=(const DSMSensor &x)
xercesc::DOMElement * toDOMParent(xercesc::DOMElement *parent, bool complete) const
Definition DSMSensor.cc:875
const std::map< std::string, CalFile * > & getCalFiles()
Return the collection of CalFiles, mapped by name.
Definition DSMSensor.h:901
unsigned int getMinSampleLength() const
Definition DSMSensor.h:777
bool readBuffer()
Read into my SampleScanner's buffer.
Definition DSMSensor.h:948
bool _applyVariableConversions
Definition DSMSensor.h:1219
virtual ~DSMSensor()
Definition DSMSensor.cc:81
static bool zebra
Definition DSMSensor.h:1196
virtual Sample * readSample()
Return the next sample.
Definition DSMSensor.cc:383
virtual void removeSampleTag(SampleTag *val)
Remove val from the list of SampleTags, and delete it.
Definition DSMSensor.cc:119
void clearBuffer()
Clear the internal buffer.
Definition DSMSensor.h:973
virtual void printStatus(std::ostream &)
Definition DSMSensor.cc:519
void setLocation(const std::string &val)
Definition DSMSensor.h:195
float _latency
Definition DSMSensor.h:1198
virtual IODevice * buildIODevice()=0
Factory method for an IODevice for this DSMSensor.
virtual void setLagSecs(double val)
Set the sampling lag for this sensor in seconds.
Definition DSMSensor.h:1047
IODevice * getIODevice() const
Definition DSMSensor.h:979
float _height
Definition DSMSensor.h:1168
virtual Sample * nextSample()
Extract the next sample from the buffer.
Definition DSMSensor.h:725
virtual void setDriverTimeTagUsecs(int val)
Definition DSMSensor.h:886
DSMSensor(const DSMSensor &x)
void setHeight(const std::string &val)
Set sensor height above ground via a string which is added to variable names.
Definition DSMSensor.cc:191
CalFile * getCalFile(const std::string &name)
Return a CalFile by its getName().
Definition DSMSensor.cc:276
virtual bool readSamples()
Read samples from my associated file descriptor, and distribute() them to my RawSampleClient's.
Definition DSMSensor.cc:355
const std::string & getDSMName() const
Fetch the DSM name.
Definition DSMSensor.cc:156
VariableIndex findVariableIndex(const std::string &vprefix)
Search all the sample tags for a variable whose name starts with the given prefix,...
Definition DSMSensor.cc:848
virtual void validate()
validate() is called once on a DSMSensor after it has been configured, but before open() or init() ar...
Definition DSMSensor.cc:833
void setDuplicateIdOK(bool val)
Set the duplicate ID attribute of this DSMSensor.
Definition DSMSensor.h:866
int getClientCount() const
How many SampleClients are currently in my list.
Definition DSMSensor.h:435
const std::string & getDepthString() const
Get sensor depth below ground in a string.
Definition DSMSensor.h:277
const std::string & getSuffix() const
Sensor suffix, which is added to variable names.
Definition DSMSensor.h:209
virtual int getWriteFd() const
Definition DSMSensor.h:466
virtual const std::string & getDeviceName() const
Fetch the name of the system device that the sensor is connected to.
Definition DSMSensor.h:132
void distributeRaw(const Sample *s)
Distribute a raw sample which has been read from my file descriptor in real time.
Definition DSMSensor.h:450
virtual void executeXmlRpc(XmlRpc::XmlRpcValue &, XmlRpc::XmlRpcValue &)
Method invoked when the DSMEngineIntf XmlRpcServer receives a "SensorAction" request,...
Definition DSMSensor.h:922
SampleScanner * getSampleScanner() const
Definition DSMSensor.h:981
int _lag
Definition DSMSensor.h:1229
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition DSMSensor.h:407
IODevice * _iodev
Definition DSMSensor.h:1147
std::string _suffix
Sensor suffix, which is added to variable names.
Definition DSMSensor.h:1162
void addParameter(Parameter *val)
Add a parameter to this DSMSensor.
Definition DSMSensor.cc:297
void addCalFile(CalFile *val)
Add a calibration file for this DSMSensor.
Definition DSMSensor.cc:269
float getObservedSamplingRate() const
Definition DSMSensor.h:783
SampleTagIterator getSampleTagIterator() const
Definition DSMSensor.h:387
std::map< std::string, CalFile * > _calFiles
Definition DSMSensor.h:1211
const SampleTag * getRawSampleTag() const
Convenience function to get my one-and-only raw SampleTag().
Definition DSMSensor.h:345
float getObservedDataRate() const
Definition DSMSensor.h:789
SampleTag _rawSampleTag
Definition DSMSensor.h:1187
SampleScanner * _scanner
Definition DSMSensor.h:1177
void applyConversions(SampleTag *stag, SampleT< float > *outs, float *results=0)
Perform variable conversions for the variables in stag whose values and sample time have been set in ...
Definition DSMSensor.cc:424
void incrementTimeoutCount()
Definition DSMSensor.h:541
virtual void open(int flags)
Open the device.
Definition DSMSensor.cc:332
std::list< SampleTag * > _sampleTags
Definition DSMSensor.h:1189
int _defaultMode
Definition DSMSensor.h:1149
void setId(dsm_sample_id_t val)
Set the various levels of the sensor identification.
Definition DSMSensor.h:485
bool readBuffer(int msecTimeout)
Read into my SampleScanner's buffer.
Definition DSMSensor.h:960
std::list< SampleTag * > & getSampleTags()
Non-const method to get a list of non-const pointers to SampleTags.
Definition DSMSensor.h:382
virtual void setClassName(const std::string &val)
Set the class name.
Definition DSMSensor.h:143
dsm_sample_id_t getId() const
Get the various levels of the samples identification.
Definition DSMSensor.h:495
std::string _className
Class name attribute of this sensor.
Definition DSMSensor.h:1155
size_t getBadTimeTagCount() const
Definition DSMSensor.h:795
bool _openable
Whether this sensor is allowed to be opened.
Definition DSMSensor.h:1106
void setDepth(const std::string &val)
Set sensor depth below ground via a string which is added to variable names.
Definition DSMSensor.cc:230
std::string _typeName
Definition DSMSensor.h:1213
const std::string & getHeightString() const
Get sensor height above ground in a string.
Definition DSMSensor.h:244
SampleSource * getProcessedSampleSource()
Implementation of SampleSource::getProcessedSampleSource().
Definition DSMSensor.h:335
virtual std::string getName() const
Return a name that should fully identify this sensor.
Definition DSMSensor.h:183
void setStation(int val)
Definition DSMSensor.cc:170
virtual void init()
Initialize the DSMSensor.
Definition DSMSensor.cc:351
DSMSensor()
Constructor.
Definition DSMSensor.cc:56
std::list< const SampleTag * > getSampleTags() const
Implementation of SampleSource::getSampleTags().
Definition DSMSensor.h:374
virtual void setApplyVariableConversions(bool val)
Definition DSMSensor.h:876
void setDSMId(unsigned int val)
Definition DSMSensor.h:487
virtual int getLagUsecs() const
Return the sampling lag for this sensor in microseconds.
Definition DSMSensor.h:1009
void setSuffix(const std::string &val)
Definition DSMSensor.cc:180
float getDepth() const
Get sensor depth below ground.
Definition DSMSensor.h:283
const std::string & getFullSuffix() const
Full sensor suffix, the concatenation of the sensor suffix, if any, and the height or depth string,...
Definition DSMSensor.h:292
std::string _fullSuffix
Concatenation of sensor suffix, and the height or depth string.
Definition DSMSensor.h:1173
dsm_sample_id_t _id
Id of this sensor.
Definition DSMSensor.h:1185
static nidas::util::Mutex _looperMutex
Definition DSMSensor.h:1227
int _station
Definition DSMSensor.h:1231
virtual void setDeviceName(const std::string &val)
Set the name of the system device that the sensor is connected to.
Definition DSMSensor.h:123
virtual size_t write(const void *buf, size_t len)
Write to the device (duh).
Definition DSMSensor.h:682
bool receive(const Sample *s)
A DSMSensor can be used as a SampleClient, meaning it receives its own raw samples.
Definition DSMSensor.cc:394
std::list< const Parameter * > _constParameters
List of const pointers to Parameters for providing via getParameters().
Definition DSMSensor.h:1209
void flush()
Implementation of SampleClient::flush().
Definition DSMSensor.h:444
virtual void setCatalogName(const std::string &val)
Set the name of the catalog entry for this sensor.
Definition DSMSensor.h:159
virtual int getDefaultMode() const
How do I want to be opened.
Definition DSMSensor.h:634
const SampleStats & getSampleStats() const
Definition DSMSensor.h:455
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 DSMSensor.h:301
virtual size_t getBytesAvailable() const
How many bytes are available to read on this sensor.
Definition DSMSensor.h:650
std::map< std::string, Parameter * > _parameters
Map of parameters by name.
Definition DSMSensor.h:1203
void printStatusHeader(std::ostream &ostr)
Definition DSMSensor.cc:489
nidas::core::DSMSensor::MyDictionary _dictionary
bool _duplicateIdOK
Definition DSMSensor.h:1217
virtual const std::string & getTypeName(void) const
Get the type name of this sensor.
Definition DSMSensor.h:844
virtual double getLagSecs() const
Return the sampling lag for this sensor in seconds.
Definition DSMSensor.h:1017
bool allowOpen()
Definition DSMSensor.h:938
static Looper * getLooper()
Fetch a pointer to a static instance of a Looper thread.
Definition DSMSensor.cc:908
const std::list< const Parameter * > & getParameters() const
Get list of parameters.
Definition DSMSensor.h:557
std::string _depthString
Definition DSMSensor.h:1166
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
An interface to an IO device.
Definition IODevice.h:42
virtual void ioctl(int request, void *buf, size_t len)=0
virtual int getWriteFd() const =0
The file descriptor used when writing to this sensor.
virtual size_t write(const void *buf, size_t len)=0
Write to the sensor.
virtual size_t read(void *buf, size_t len)=0
Read from the sensor.
virtual int getReadFd() const =0
The file descriptor used when reading from this sensor.
virtual size_t getBytesAvailable() const
Return how many bytes are available to read on this IODevice.
Definition IODevice.h:122
Looper is a Thread that periodically loops, calling the LooperClient::looperNotify() method of Looper...
Definition Looper.h:51
Definition Parameter.h:47
Definition Project.h:60
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
A scanner of sample data.
Definition SampleScanner.h:74
unsigned int getMaxSampleLength() const
Definition SampleScanner.h:183
float getObservedSamplingRate() const
Definition SampleScanner.cc:211
virtual void calcStatistics(unsigned int periodUsec)
Update the sensor sampling statistics: samples/sec, bytes/sec, min/max sample size,...
Definition SampleScanner.cc:196
unsigned int getMinSampleLength() const
Definition SampleScanner.h:186
virtual void clearBuffer()
Definition SampleScanner.cc:177
unsigned int getBadTimeTagCount() const
Definition SampleScanner.h:193
virtual size_t readBuffer(DSMSensor *sensor, bool &exhausted)
Read from the sensor into the internal buffer of this SampleScanner.
Definition SampleScanner.cc:82
virtual Sample * nextSample(DSMSensor *sensor)=0
Extract the next sample from the buffer.
float getObservedDataRate() const
Definition SampleScanner.cc:219
A source of samples.
Definition SampleSourceSupport.h:47
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition SampleSourceSupport.cc:88
void removeSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:121
void distribute(const Sample *s)
Distribute a sample to my clients, calling the receive() method of each client, passing the const poi...
Definition SampleSourceSupport.cc:141
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:101
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:80
int getClientCount() const
How many SampleClients are currently in my list.
Definition SampleSourceSupport.cc:136
const SampleStats & getSampleStats() const
Definition SampleSourceSupport.h:149
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition SampleSourceSupport.cc:54
Pure virtual interface for a source of Samples.
Definition SampleSource.h:48
A source of samples.
Definition SampleStats.h:41
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
Interface to a data sample.
Definition Sample.h:190
A measurement site.
Definition Site.h:49
A VariableIndex associates a Variable pointer with it's index into it's SampleTag.
Definition VariableIndex.h:52
Class for iterating over the Variables of a Project, Site, DSMConfig, DSMSensor, or SampleTag.
Definition NidsIterators.h:287
A C++ wrapper for a POSIX mutex.
Definition ThreadSupport.h:161
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
int len
Definition sing.cc:948
#define USECS_PER_SEC
Definition ublox.cc:59