nidas v1.2.3
SerialSensor.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 ** 2011, 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_DYNLD_SERIALSENSOR_H
27#define NIDAS_DYNLD_SERIALSENSOR_H
28
29#include "CharacterSensor.h"
30#include "LooperClient.h"
31#include "SerialPortIODevice.h"
32
33namespace nidas { namespace core {
34
35using namespace nidas::core;
36
65{
66
67public:
68
74
76
82
86 const nidas::util::Termios& getTermios() const { return _termios; }
87
96
112
121 void open(int flags);
122
123 /*
124 * Close the device connected to the sensor.
125 *
126 * @throws nidas::util::IOException
127 **/
128 void close();
129
136 void applyTermios();
137
144 void setMessageParameters(unsigned int len,const std::string& sep, bool eom);
145
146 void printStatus(std::ostream& ostr) throw();
147
152 bool isPrompting() const { return _prompting; }
153
160 void startPrompting();
161
165 void stopPrompting();
166
170 void fromDOMElement(const xercesc::DOMElement* node);
171
178 int getUsecsPerByte() const;
179
180protected:
181
188 void initPrompting();
189
195 void shutdownPrompting();
196
200 void unixDevInit(int flags);
201
202private:
203
208
213
215 {
216 public:
220
221 ~Prompter();
222
223 void setPrompt(const std::string& val);
224 const std::string getPrompt() const { return _prompt; }
225
226 void setPromptPeriodMsec(const int);
228
229 void setPromptOffsetMsec(const int);
231
235 void looperNotify() throw();
236 private:
238 char* _prompt;
242
245
247 Prompter& operator=(const Prompter&);
248 };
249
250 std::list<Prompter*> _prompters;
251
253
259
262
264 SerialSensor& operator=(const SerialSensor&);
265
266};
267
268}} // namespace nidas namespace core
269
270#endif
Implementation of support for a sensor which generates character output.
Definition CharacterSensor.h:46
An interface to an IO device.
Definition IODevice.h:42
Interface of a client of Looper.
Definition LooperClient.h:38
A scanner of sample data.
Definition SampleScanner.h:74
A serial port.
Definition SerialPortIODevice.h:47
Definition SerialSensor.h:215
const std::string getPrompt() const
Definition SerialSensor.h:224
int getPromptOffsetMsec() const
Definition SerialSensor.h:230
int _promptPeriodMsec
Definition SerialSensor.h:240
~Prompter()
Definition SerialSensor.cc:345
Prompter(SerialSensor *sensor)
Definition SerialSensor.h:217
int _promptOffsetMsec
Definition SerialSensor.h:241
SerialSensor * _sensor
Definition SerialSensor.h:237
int getPromptPeriodMsec() const
Definition SerialSensor.h:227
int _promptLen
Definition SerialSensor.h:239
void looperNotify()
Method called by Looper in order to send a prompt.
Definition SerialSensor.cc:370
void setPromptPeriodMsec(const int)
Definition SerialSensor.cc:360
void setPrompt(const std::string &val)
Definition SerialSensor.cc:350
char * _prompt
Definition SerialSensor.h:238
void setPromptOffsetMsec(const int)
Definition SerialSensor.cc:365
Support for a sensor that is sending packets on a TCP socket, a UDP socket, a Bluetooth RF Comm socke...
Definition SerialSensor.h:65
void unixDevInit(int flags)
void fromDOMElement(const xercesc::DOMElement *node)
Definition SerialSensor.cc:233
~SerialSensor()
Definition SerialSensor.cc:57
void applyTermios()
If the underlying IODevice is a SerialPortIODevice, update the current Termios to the device.
Definition SerialSensor.cc:142
int _rts485
Should the RTS line on this port be controled for half-duplex 485? See SerialPortIODevice....
Definition SerialSensor.h:258
std::list< Prompter * > _prompters
Definition SerialSensor.h:250
SampleScanner * buildSampleScanner()
Calls CharacterSensor::buildSampleScanner(), and then sets the per-byte transmission delay for that s...
Definition SerialSensor.cc:63
void stopPrompting()
Definition SerialSensor.cc:193
SerialPortIODevice * _serialDevice
Non-null if the underlying IODevice is a SerialPortIODevice.
Definition SerialSensor.h:212
const nidas::util::Termios & getTermios() const
Get a read-only copy of the Termios.
Definition SerialSensor.h:86
IODevice * buildIODevice()
Creates an IODevice depending on the device name prefix: name prefix type of IODevice inet: TCPSocket...
Definition SerialSensor.cc:71
bool isPrompting() const
Is prompting active, i.e.
Definition SerialSensor.h:152
int getUsecsPerByte() const
If the underlying IODevice is a SerialPortIODevice, return the value of SerialPortIODevice::getUsecsP...
Definition SerialSensor.cc:91
void open(int flags)
Open the device connected to the sensor.
Definition SerialSensor.cc:97
nidas::util::Termios _termios
Serial I/O parameters.
Definition SerialSensor.h:207
void close()
close my associated device.
Definition SerialSensor.cc:136
void startPrompting()
Start the prompters.
Definition SerialSensor.cc:178
void initPrompting()
Perform whatever is necessary to initialize prompting right after the device is opened.
Definition SerialSensor.cc:150
SerialSensor()
No arg constructor.
Definition SerialSensor.cc:47
bool _prompting
Definition SerialSensor.h:252
void shutdownPrompting()
Shutdown prompting, typically done when a device is closed.
Definition SerialSensor.cc:170
void setMessageParameters(unsigned int len, const std::string &sep, bool eom)
Set message separator and message length parameters, which are used to parse and time-tag samples fro...
Definition SerialSensor.cc:123
void printStatus(std::ostream &ostr)
Definition SerialSensor.cc:206
nidas::util::Termios & termios()
Expose the Termios.
Definition SerialSensor.h:81
A class providing get/set methods into a termios structure.
Definition Termios.h:48
The essential core classes of nidas.
Definition A2DConverter.h:31
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948