nidas
v1.2-1520
|
#include <RemoteSerialConnection.h>
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) |
DSMSensor * | getDSMSensor () 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... | |
RemoteSerialConnection & | operator= (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... | |
RemoteSerialConnection::RemoteSerialConnection | ( | nidas::util::Socket * | sock, |
SensorHandler * | handler | ||
) |
RemoteSerialConnection::~RemoteSerialConnection | ( | ) |
References _socket, close(), NLOG, and nidas::util::Exception::what().
|
private |
Copy not needed.
void RemoteSerialConnection::close | ( | ) | ||
throw | ( | nidas::util::IOException | ||
) |
References _handler, _sensor, _socket, _timeoutMsecs, nidas::util::Socket::close(), nidas::core::SensorHandler::getEpollFd(), nidas::util::Socket::getFd(), getName(), nidas::core::DSMSensor::getRawSampleSource(), nidas::core::DSMSensor::getTimeoutMsecs(), nidas::core::SampleSource::removeSampleClient(), nidas::core::DSMSensor::setTimeoutMsecs(), and nidas::core::SensorHandler::updateTimeouts().
Referenced by ~RemoteSerialConnection().
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
inputstr | input string |
References nidas::util::Logger::getInstance(), nidas::util::Logger::log(), LOG_WARNING, MSECS_PER_SEC, and nidas::util::Exception::what().
|
inlinevirtual |
Implementation of SampleClient::flush().
Implements nidas::core::SampleClient.
|
inlinevirtual |
Implements nidas::core::Polled.
References _socket, and nidas::util::Socket::getFd().
Referenced by nidas::core::SensorHandler::handlePollingChange().
|
inline |
|
inline |
References _devname.
Referenced by sensorNotFound().
|
virtual |
An epoll event occurred, most likely it is time to read data from socket, write to DSMSensor.
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.
input | string of characters, altered in place. |
|
private |
Assignment not needed.
void RemoteSerialConnection::readSensorName | ( | ) | ||
throw | ( | nidas::util::IOException | ||
) |
References _devname, _socket, and nidas::util::Socket::recv().
|
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.
|
inline |
References _name.
Referenced by RemoteSerialConnection().
void RemoteSerialConnection::setSensor | ( | CharacterSensor * | val | ) | |
throw | ( | nidas::util::IOException | |||
) |
References nidas::core::DSMSensor::getTimeoutMsecs().
|
private |
Has the user been sent a "sensor is closed" warning.
|
private |
Referenced by getSensorName(), and readSensorName().
|
private |
Referenced by close().
|
private |
Left over input characters after previous parse for escape sequences.
|
private |
|
private |
|
private |
Referenced by close(), and getDSMSensor().
|
private |
|
private |
Referenced by close(), getFd(), readSensorName(), sensorNotFound(), and ~RemoteSerialConnection().
|
private |
Sensor timeout when the RemoteSerialConnection was established.
Referenced by close().