nidas  v1.2-1520
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::core::RemoteSerialConnection Class Reference

#include <RemoteSerialConnection.h>

Inheritance diagram for nidas::core::RemoteSerialConnection:
Inheritance graph
[legend]

Public Member Functions

 RemoteSerialConnection (nidas::util::Socket *sock, SensorHandler *handler)
 
 ~RemoteSerialConnection ()
 
void flush () throw ()
 Implementation of SampleClient::flush(). More...
 
const std::string & getName () const
 
void setName (const std::string &val)
 
void close () throw (nidas::util::IOException)
 
void readSensorName () throw (nidas::util::IOException)
 
int getFd () const
 
const std::string & getSensorName () const
 
void setSensor (CharacterSensor *val) throw (nidas::util::IOException)
 
DSMSensorgetDSMSensor () const
 
void sensorNotFound () throw (nidas::util::IOException)
 Notify this RemoteSerialConnection that a sensor matching getSensorName() was not found. More...
 
bool receive (const Sample *s) throw ()
 Receive a sample from the DSMSensor, write data portion to socket. More...
 
bool handlePollEvents (uint32_t events) throw ()
 An epoll event occurred, most likely it is time to read data from socket, write to DSMSensor. More...
 
void nlTocrnl (std::string &input)
 little utility for translating newlines to carriage-return + newlines in a string. More...
 
std::string doEscCmds (const std::string &inputstr) throw (nidas::util::IOException)
 Parse and execute ESC commands in user input. More...
 

Private Member Functions

 RemoteSerialConnection (const RemoteSerialConnection &)
 Copy not needed. More...
 
RemoteSerialConnectionoperator= (const RemoteSerialConnection &)
 Assignment not needed. More...
 

Private Attributes

std::string _name
 
nidas::util::Socket_socket
 
std::string _devname
 
CharacterSensor_sensor
 
SerialSensor_serSensor
 
std::string _input
 Left over input characters after previous parse for escape sequences. More...
 
bool _nullTerminated
 
SensorHandler_handler
 
bool _closedWarning
 Has the user been sent a "sensor is closed" warning. More...
 
int _timeoutMsecs
 Sensor timeout when the RemoteSerialConnection was established. More...
 

Constructor & Destructor Documentation

RemoteSerialConnection::RemoteSerialConnection ( nidas::util::Socket sock,
SensorHandler handler 
)
RemoteSerialConnection::~RemoteSerialConnection ( )
nidas::core::RemoteSerialConnection::RemoteSerialConnection ( const RemoteSerialConnection )
private

Copy not needed.

Member Function Documentation

void RemoteSerialConnection::close ( )
throw (nidas::util::IOException
)
string RemoteSerialConnection::doEscCmds ( const std::string &  inputstr)
throw (nidas::util::IOException
)

Parse and execute ESC commands in user input.

Return buffer with escape sequences removed. ESC-p toggle prompting ESC-bxxxx set baud rate to xxxx (non-digit after xxxx) ESC-peven set parity to even ESC-podd set parity to odd ESC-ESC send ESC to sensor

Parameters
inputstrinput string
Returns
output string, with recognized escape sequences removed.

References nidas::util::Logger::getInstance(), nidas::util::Logger::log(), LOG_WARNING, MSECS_PER_SEC, and nidas::util::Exception::what().

void nidas::core::RemoteSerialConnection::flush ( )
throw (
)
inlinevirtual

Implementation of SampleClient::flush().

Implements nidas::core::SampleClient.

DSMSensor* nidas::core::RemoteSerialConnection::getDSMSensor ( ) const
inline

References _sensor.

int nidas::core::RemoteSerialConnection::getFd ( ) const
inlinevirtual
const std::string& nidas::core::RemoteSerialConnection::getName ( ) const
inline

References _name.

Referenced by close().

const std::string& nidas::core::RemoteSerialConnection::getSensorName ( ) const
inline

References _devname.

Referenced by sensorNotFound().

bool RemoteSerialConnection::handlePollEvents ( uint32_t  events)
throw (
)
virtual

An epoll event occurred, most likely it is time to read data from socket, write to DSMSensor.

Returns
: read consumed all available data from the socket.

Implements nidas::core::Polled.

References buffer, ILOG, N_POLLERR, N_POLLHUP, N_POLLIN, N_POLLRDHUP, PLOG, and nidas::util::Exception::what().

void RemoteSerialConnection::nlTocrnl ( std::string &  input)

little utility for translating newlines to carriage-return + newlines in a string.

Parameters
inputstring of characters, altered in place.
RemoteSerialConnection& nidas::core::RemoteSerialConnection::operator= ( const RemoteSerialConnection )
private

Assignment not needed.

void RemoteSerialConnection::readSensorName ( )
throw (nidas::util::IOException
)
bool RemoteSerialConnection::receive ( const Sample s)
throw (
)
virtual

Receive a sample from the DSMSensor, write data portion to socket.

Implements nidas::core::SampleClient.

void RemoteSerialConnection::sensorNotFound ( )
throw (nidas::util::IOException
)

Notify this RemoteSerialConnection that a sensor matching getSensorName() was not found.

References _socket, getSensorName(), nidas::util::Socket::send(), and WLOG.

void nidas::core::RemoteSerialConnection::setName ( const std::string &  val)
inline

References _name.

Referenced by RemoteSerialConnection().

void RemoteSerialConnection::setSensor ( CharacterSensor val)
throw (nidas::util::IOException
)

Member Data Documentation

bool nidas::core::RemoteSerialConnection::_closedWarning
private

Has the user been sent a "sensor is closed" warning.

std::string nidas::core::RemoteSerialConnection::_devname
private

Referenced by getSensorName(), and readSensorName().

SensorHandler* nidas::core::RemoteSerialConnection::_handler
private

Referenced by close().

std::string nidas::core::RemoteSerialConnection::_input
private

Left over input characters after previous parse for escape sequences.

std::string nidas::core::RemoteSerialConnection::_name
private

Referenced by getName(), and setName().

bool nidas::core::RemoteSerialConnection::_nullTerminated
private
CharacterSensor* nidas::core::RemoteSerialConnection::_sensor
private

Referenced by close(), and getDSMSensor().

SerialSensor* nidas::core::RemoteSerialConnection::_serSensor
private
nidas::util::Socket* nidas::core::RemoteSerialConnection::_socket
private
int nidas::core::RemoteSerialConnection::_timeoutMsecs
private

Sensor timeout when the RemoteSerialConnection was established.

Referenced by close().


The documentation for this class was generated from the following files: