nidas v1.2.3
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
Csat3Sim Class Reference

Simulate a CSAT3 sonic. More...

Inheritance diagram for Csat3Sim:
Inheritance graph
[legend]

Public Member Functions

 Csat3Sim (n_u::SerialPort *p, float rate, int nmessages)
 
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 sendMessage ()
 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
 
void interrupt ()
 Stop the simulation.
 
bool isInterrupted () const
 
n_u::SerialPortport ()
 

Protected Member Functions

LoopergetLooper ()
 
void looperNotify () override
 Method called by Looper.
 
void readPrompts ()
 

Protected Attributes

n_u::SerialPort_port
 
bool _prompted
 
string _prompt
 
float _rate
 
int _nmessages
 
bool _interrupted
 

Static Protected Attributes

static Looper_looper = 0
 

Private Attributes

int _cntr
 

Detailed Description

Simulate a CSAT3 sonic.

Constructor & Destructor Documentation

◆ Csat3Sim()

Csat3Sim::Csat3Sim ( n_u::SerialPort * p,
float rate,
int nmessages )
inline

Member Function Documentation

◆ getLooper()

Looper * SensorSimulator::getLooper ( )
protectedinherited

◆ interrupt()

void SensorSimulator::interrupt ( )
inlineinherited

◆ isInterrupted()

bool SensorSimulator::isInterrupted ( ) const
inlineinherited

◆ looperNotify()

void SensorSimulator::looperNotify ( )
overrideprotectedvirtualinherited

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 SensorSimulator::_interrupted, SensorSimulator::_looper, SensorSimulator::_nmessages, nidas::core::getSample(), SensorSimulator::interrupt(), and SensorSimulator::sendMessage().

◆ port()

n_u::SerialPort * SensorSimulator::port ( )
inlineinherited

◆ readPrompts()

void SensorSimulator::readPrompts ( )
protectedinherited

◆ run()

void Csat3Sim::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 from SensorSimulator.

References _cntr, SensorSimulator::_nmessages, SensorSimulator::_port, SensorSimulator::_rate, nidas::util::SerialPort::getFd(), nidas::util::SerialPort::getName(), nidas::core::getSample(), nidas::util::SerialPort::read(), running, sendMessage(), USECS_PER_SEC, and nidas::util::SerialPort::write().

◆ sendMessage()

void Csat3Sim::sendMessage ( )
virtual

Implement this to send a message from the simulated sensor.

Exceptions
nidas::util::IOException

Implements SensorSimulator.

References _cntr, SensorSimulator::_port, nidas::core::getSample(), len, and nidas::util::SerialPort::write().

Referenced by run().

◆ writeMessage() [1/2]

virtual void SensorSimulator::writeMessage ( const char * buf,
std::streamsize l )
inlinevirtualinherited

overloaded function useful for writing binary data

References SensorSimulator::_port, and nidas::util::SerialPort::write().

◆ writeMessage() [2/2]

virtual void SensorSimulator::writeMessage ( const std::string & msg)
inlinevirtualinherited

Subclasses generate the message to send, then call writeMessage() to send it out.

References SensorSimulator::_port, and nidas::util::SerialPort::write().

Referenced by FileSim::sendASCIIMessage(), FileSim::sendBinaryMessage(), and FixedSim::sendMessage().

Member Data Documentation

◆ _cntr

int Csat3Sim::_cntr
private

Referenced by run(), and sendMessage().

◆ _interrupted

bool SensorSimulator::_interrupted
protectedinherited

◆ _looper

Looper * SensorSimulator::_looper = 0
staticprotectedinherited

◆ _nmessages

int SensorSimulator::_nmessages
protectedinherited

◆ _port

n_u::SerialPort* SensorSimulator::_port
protectedinherited

◆ _prompt

string SensorSimulator::_prompt
protectedinherited

◆ _prompted

bool SensorSimulator::_prompted
protectedinherited

Referenced by SensorSimulator::run().

◆ _rate

float SensorSimulator::_rate
protectedinherited

Referenced by SensorSimulator::run(), and run().


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