nidas v1.2.3
|
Base class for sensor simulators. More...
Public Member Functions | |
SensorSimulator (n_u::SerialPort *p, bool prompted, string prompt, float rate, int nmessages) | |
virtual void | sendMessage ()=0 |
Implement this to send a message from the simulated sensor. | |
virtual void | writeMessage (const std::string &msg) |
Subclasses generate the message to send, then call writeMessage() to send it out. | |
virtual void | writeMessage (const char *buf, std::streamsize l) |
overloaded function useful for writing binary data | |
virtual void | run () |
Default implementation of run will call the sendMessage() method either after receipt of a prompt or at the given rate if the sensor is not prompted. | |
void | interrupt () |
Stop the simulation. | |
bool | isInterrupted () const |
n_u::SerialPort * | port () |
Protected Member Functions | |
Looper * | getLooper () |
void | looperNotify () override |
Method called by Looper. | |
void | readPrompts () |
SensorSimulator (const SensorSimulator &) | |
SensorSimulator & | operator= (const SensorSimulator &) |
Protected Attributes | |
n_u::SerialPort * | _port |
bool | _prompted |
string | _prompt |
float | _rate |
int | _nmessages |
bool | _interrupted |
Static Protected Attributes | |
static Looper * | _looper = 0 |
Base class for sensor simulators.
|
inline |
|
protected |
|
inline |
Stop the simulation.
References _interrupted.
Referenced by looperNotify(), readPrompts(), FileSim::sendASCIIMessage(), and FileSim::sendBinaryMessage().
|
inline |
References _interrupted.
Referenced by readPrompts().
|
overrideprotectedvirtual |
Method called by Looper.
This method should not be a heavy user of resources, since the notification of other clients is delayed until this method finishes. If much work is to be done, this method should post a semaphore for another worker thread to proceed.
Implements nidas::core::LooperClient.
References _interrupted, _looper, _nmessages, nidas::core::getSample(), interrupt(), and sendMessage().
|
protected |
|
inline |
References _port.
|
protected |
References _nmessages, _port, _prompt, nidas::core::getSample(), interrupt(), isInterrupted(), nidas::util::SerialPort::readchar(), and sendMessage().
Referenced by run().
|
virtual |
Default implementation of run will call the sendMessage() method either after receipt of a prompt or at the given rate if the sensor is not prompted.
run() will return when isInterrupted() is true.
Reimplemented in Csat3Sim.
References _looper, _prompted, _rate, getLooper(), nidas::core::getSample(), MSECS_PER_SEC, and readPrompts().
Implement this to send a message from the simulated sensor.
nidas::util::IOException |
Implemented in FixedSim, FileSim, and Csat3Sim.
Referenced by looperNotify(), and readPrompts().
overloaded function useful for writing binary data
References _port, and nidas::util::SerialPort::write().
Subclasses generate the message to send, then call writeMessage() to send it out.
References _port, and nidas::util::SerialPort::write().
Referenced by FileSim::sendASCIIMessage(), FileSim::sendBinaryMessage(), and FixedSim::sendMessage().
|
protected |
Referenced by interrupt(), isInterrupted(), and looperNotify().
|
staticprotected |
Referenced by getLooper(), looperNotify(), and run().
|
protected |
Referenced by looperNotify(), readPrompts(), and Csat3Sim::run().
|
protected |
Referenced by port(), readPrompts(), Csat3Sim::run(), Csat3Sim::sendMessage(), writeMessage(), and writeMessage().
|
protected |
Referenced by readPrompts().
|
protected |
Referenced by run(), and Csat3Sim::run().