nidas
v1.2-1520
|
Interface of an output stream of samples. More...
#include <UDPSampleOutput.h>
Classes | |
class | ConnectionMonitor |
Thread that waits for connections to die. More... | |
class | VariableListWorker |
Worker thread that is run when a connection comes in, sending XML over a socket. More... | |
class | XMLSocketListener |
Thread that waits for a connection on a tcp socket, starting a VariableListWorker on each connection. More... | |
Public Member Functions | |
UDPSampleOutput () | |
~UDPSampleOutput () | |
void | flush () throw () |
Implementation of SampleClient::flush(). More... | |
void | allocateBuffer (size_t len) |
nidas::core::SampleOutput * | connected (nidas::core::IOChannel *) throw () |
Implementation of IOChannelRequester::connected(). More... | |
bool | receive (const nidas::core::Sample *s) throw () |
Method called to pass a sample to this client. More... | |
size_t | write (const struct iovec *iov, int iovcnt) throw (nidas::util::IOException) |
void | close () throw (nidas::util::IOException) |
long long | getNumOutputBytes () const |
Total number of bytes written with this IOStream. More... | |
void | addNumOutputBytes (int val) |
void | fromDOMElement (const xercesc::DOMElement *node) throw (nidas::util::InvalidParameterException) |
Initialize myself from a xercesc::DOMElement. More... | |
virtual void | setIOChannel (IOChannel *val) |
Set the IOChannel for this SampleOutput. More... | |
SampleOutput * | getOriginal () const |
Get pointer to SampleOutput that was cloned. More... | |
void | setName (const std::string &val) |
const std::string & | getName () const |
bool | isRaw () const |
void | addRequestedSampleTag (SampleTag *tag) throw (nidas::util::InvalidParameterException) |
Some SampleOutputs don't send out all the Samples that they receive. More... | |
std::list< const SampleTag * > | getRequestedSampleTags () const |
void | addSourceSampleTag (const SampleTag *tag) throw (nidas::util::InvalidParameterException) |
Some SampleOutputs like to be informed of what SampleTags they will be receiving from their SampleSources before they make a connection. More... | |
void | addSourceSampleTags (const std::list< const SampleTag * > &tags) throw (nidas::util::InvalidParameterException) |
std::list< const SampleTag * > | getSourceSampleTags () const |
void | requestConnection (SampleConnectionRequester *) throw (nidas::util::IOException) |
Request a connection, but don't wait for it. More... | |
int | getReconnectDelaySecs () const |
Base class implementation. More... | |
void | setReconnectDelaySecs (int val) |
int | getFd () const |
dsm_time_t | getNextFileTime () const |
void | createNextFile (dsm_time_t) throw (nidas::util::IOException) |
size_t | write (const void *buf, size_t len) override throw (nidas::util::IOException) |
Raw write method, typically used to write the initial header. More... | |
IOChannel * | getIOChannel () const |
void | setHeaderSource (HeaderSource *val) |
void | setDSMConfig (const DSMConfig *val) |
const DSMConfig * | getDSMConfig () const |
size_t | getNumDiscardedSamples () const |
void | addParameter (Parameter *val) |
Add a parameter to this DSMSensor. More... | |
const std::list< const Parameter * > & | getParameters () const |
Get list of parameters. More... | |
const Parameter * | getParameter (const std::string &name) const |
Fetch a parameter by name. More... | |
void | setLatency (float val) throw (nidas::util::InvalidParameterException) |
Set desired latency, providing some control over the response time vs buffer efficiency tradeoff. More... | |
float | getLatency () const |
virtual xercesc::DOMElement * | toDOMParent (xercesc::DOMElement *parent, bool complete) const throw (xercesc::DOMException) |
Create a DOMElement and append it to the parent. More... | |
virtual xercesc::DOMElement * | toDOMElement (xercesc::DOMElement *node, bool complete) const throw (xercesc::DOMException) |
Add my content into a DOMElement. More... | |
Static Public Member Functions | |
static const XMLCh * | getNamespaceURI () |
Protected Member Functions | |
UDPSampleOutput * | clone (nidas::core::IOChannel *iochannel) |
This SampleOutput does not support cloning. More... | |
UDPSampleOutput (UDPSampleOutput &, nidas::core::IOChannel *) | |
This SampleOutput does not support a copy constructor with a new IOChannel. More... | |
size_t | incrementDiscardedSamples () |
SampleConnectionRequester * | getSampleConnectionRequester () |
void | disconnect () throw (nidas::util::IOException) |
Close the IOChannel and notify whoever did the requestConnection that it is time to disconnect, perhaps because of an IOException. More... | |
Protected Attributes | |
std::string | _name |
Private Member Functions | |
xercesc::DOMDocument * | getProjectDOM () throw (xercesc::DOMException) |
Get a pointer to the current project DOM. More... | |
void | releaseProjectDOM () |
UDPSampleOutput (const UDPSampleOutput &) | |
No copying. More... | |
UDPSampleOutput & | operator= (const UDPSampleOutput &) |
No assignment. More... | |
Private Attributes | |
nidas::core::MultipleUDPSockets * | _mochan |
xercesc::DOMDocument * | _doc |
bool | _projectChanged |
nidas::util::Mutex | _docLock |
nidas::util::RWLock | _docRWLock |
nidas::util::Mutex | _listenerLock |
unsigned short | _xmlPortNumber |
unsigned short | _multicastOutPort |
XMLSocketListener * | _listener |
ConnectionMonitor * | _monitor |
long long | _nbytesOut |
char * | _buffer |
data buffer More... | |
char * | _head |
where we insert bytes into the buffer More... | |
char * | _tail |
where we remove bytes from the buffer More... | |
size_t | _buflen |
The actual buffer size. More... | |
char * | _eob |
One past end of buffer. More... | |
nidas::core::dsm_time_t | _lastWrite |
Time of last physical write. More... | |
int | _maxUsecs |
Maximum number of microseconds between physical writes. More... | |
Interface of an output stream of samples.
UDPSampleOutput::UDPSampleOutput | ( | ) |
UDPSampleOutput::~UDPSampleOutput | ( | ) |
|
protected |
This SampleOutput does not support a copy constructor with a new IOChannel.
It will die with an assert.
References nidas::util::Logger::getInstance(), nidas::util::Logger::log(), and LOG_ERR.
|
private |
No copying.
|
inline |
References _nbytesOut.
|
inherited |
Add a parameter to this DSMSensor.
DSMSensor will then own the pointer and will delete it in its destructor. If a Parameter exists with the same name, it will be replaced with the new Parameter.
References nidas::core::SampleOutputBase::_constParameters, nidas::core::SampleOutputBase::_parameters, and nidas::core::Parameter::getName().
|
virtualinherited |
Some SampleOutputs don't send out all the Samples that they receive.
At configuration time, one can use this method to request the SampleTags that should be output from a SampleOutput. SampleOutput will own the pointer.
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::isff::GOESOutput, and nidas::dynld::raf::CVIOutput.
Referenced by nidas::dynld::raf::CVIOutput::addRequestedSampleTag(), nidas::dynld::isff::GOESOutput::addRequestedSampleTag(), and nidas::core::SampleOutputBase::SampleOutputBase().
|
virtualinherited |
Some SampleOutputs like to be informed of what SampleTags they will be receiving from their SampleSources before they make a connection.
Users of SampleOutputs should call this method before calling requestConnection().
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::isff::GOESOutput.
Referenced by nidas::dynld::isff::GOESOutput::addSourceSampleTag(), and nidas::core::SampleOutputBase::SampleOutputBase().
|
virtualinherited |
Implements nidas::core::SampleOutput.
void UDPSampleOutput::allocateBuffer | ( | size_t | len | ) |
|
protectedvirtual |
This SampleOutput does not support cloning.
It will die with an assert.
Implements nidas::core::SampleOutput.
References nidas::util::Logger::getInstance(), nidas::util::Logger::log(), and LOG_ERR.
|
virtual |
|
virtual |
Implementation of IOChannelRequester::connected().
How an IOChannel calls back to a SampleConnectionRequester that it is connected. The ConnectionRequester can then return a clone of itself if the IOChannel is a new instance.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::connected(), nidas::dynld::InitialUDPDataRequestReply::dataMulticastPort, nidas::core::Site::getDSMConfigIterator(), nidas::core::Project::getInstance(), nidas::core::DSMConfig::getName(), nidas::core::Project::getSiteIterator(), nidas::core::SiteIterator::hasNext(), nidas::core::DSMConfigIterator::hasNext(), nidas::dynld::InitialUDPDataRequestReply::magic, nidas::dynld::InitialUDPDataRequestReply::MAGIC, nidas::core::SiteIterator::next(), nidas::core::DSMConfigIterator::next(), nidas::dynld::InitialUDPDataRequestReply::strings, nidas::util::Exception::what(), WLOG, and nidas::dynld::InitialUDPDataRequestReply::xmlTcpPort.
|
inherited |
References nidas::core::HeaderSource::sendDefaultHeader().
|
protectedinherited |
Close the IOChannel and notify whoever did the requestConnection that it is time to disconnect, perhaps because of an IOException.
This is typically called in the receive() method of a SampleOutput if it gets an IOException when writing data. A common implementation of a connection requester is to delete this SampleOutput after the removing it from the sample stream. So the caller method should immediately return after calling disconnect().
References nidas::core::SampleOutputBase::_connectionRequester, nidas::core::SampleOutputBase::close(), nidas::core::SampleConnectionRequester::disconnect(), nidas::core::SampleOutputBase::getName(), and ILOG.
|
inlinevirtual |
Implementation of SampleClient::flush().
Implements nidas::core::SampleClient.
|
virtual |
Initialize myself from a xercesc::DOMElement.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::fromDOMElement(), nidas::core::Parameter::getLength(), nidas::core::Parameter::getName(), nidas::core::Parameter::getNumericValue(), nidas::core::Parameter::getType(), nidas::core::Parameter::INT_PARAM, and nidas::core::UDP_PROCESSED_SAMPLE_FEED.
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Referenced by nidas::core::SampleOutputBase::SampleOutputBase(), and nidas::core::SampleOutputBase::setIOChannel().
|
virtualinherited |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput.
References nidas::core::SampleOutputBase::_iochan, and nidas::core::IOChannel::getFd().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Referenced by nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::dynld::isff::GOESOutput::GOESOutput(), nidas::dynld::AsciiOutput::printHeader(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::isff::GOESOutput::setIOChannel(), and nidas::dynld::raf::CVIOutput::setIOChannel().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Referenced by nidas::dynld::SampleOutputStream::SampleOutputStream().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput.
Referenced by nidas::dynld::UDPSampleOutput::ConnectionMonitor::addConnection(), nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::isff::GOESOutput::cancelThread(), nidas::dynld::UDPSampleOutput::XMLSocketListener::checkWorkers(), nidas::core::SampleOutputBase::close(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::core::SampleOutputBase::disconnect(), nidas::dynld::UDPSampleOutput::XMLSocketListener::fireWorkers(), nidas::dynld::SampleOutputStream::flush(), nidas::dynld::isff::GOESOutput::GOESOutput(), nidas::dynld::isff::GOESOutput::joinThread(), nidas::dynld::isff::GOESOutput::killThread(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), nidas::dynld::isff::GOESOutput::run(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::isff::GOESOutput::setIOChannel(), nidas::dynld::raf::CVIOutput::setIOChannel(), and nidas::dynld::isff::GOESOutput::write().
|
inlinestaticinherited |
References nidas::core::DOMable::namespaceURI.
Referenced by getProjectDOM(), nidas::core::Dataset::toDOMElement(), nidas::core::ProjectConfig::toDOMElement(), nidas::core::Dataset::toDOMParent(), nidas::core::ProjectConfig::toDOMParent(), nidas::core::Datasets::toDOMParent(), nidas::core::ProjectConfigs::toDOMParent(), nidas::core::DSMConfig::toDOMParent(), nidas::core::Project::toDOMParent(), nidas::core::Site::toDOMParent(), nidas::core::SampleTag::toDOMParent(), nidas::core::ServerSocket::toDOMParent(), nidas::core::Variable::toDOMParent(), nidas::core::DSMSensor::toDOMParent(), nidas::core::Datasets::writeXML(), and nidas::core::ProjectConfigs::writeXML().
|
inlineinherited |
|
inlineinherited |
|
inline |
Total number of bytes written with this IOStream.
References _nbytesOut.
|
inlinevirtualinherited |
Get pointer to SampleOutput that was cloned.
Will be NULL if this SampleOutput is an un-cloned original.
Implements nidas::core::SampleOutput.
|
inherited |
Fetch a parameter by name.
Returns a NULL pointer if no such parameter exists.
References nidas::core::SampleOutputBase::_parameters.
|
inlineinherited |
Get list of parameters.
|
private |
Get a pointer to the current project DOM.
The caller acquires a read lock on the DOM, and must call releaseProjectDOM() when they are finised.
References _doc, _docLock, _docRWLock, _projectChanged, nidas::core::XMLImplementation::getImplementation(), nidas::core::Project::getInstance(), nidas::core::DOMable::getNamespaceURI(), nidas::util::RWLock::rdlock(), and nidas::core::Project::toDOMElement().
|
virtualinherited |
Base class implementation.
If setReconnectDelaySecs() has been called on this SampleOutput, then that value will be returned. Otherwise this will return the value of the IOChannel.
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_iochan, nidas::core::SampleOutputBase::_reconnectDelaySecs, and nidas::core::IOChannel::getReconnectDelaySecs().
|
virtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_constRequestedTags, and nidas::core::SampleOutputBase::_tagsMutex.
Referenced by nidas::dynld::isff::GOESProject::GOESProject(), nidas::dynld::isff::GOESOutput::run(), and nidas::core::SampleOutputBase::SampleOutputBase().
|
inlineprotectedinherited |
|
virtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_sourceTags, and nidas::core::SampleOutputBase::_tagsMutex.
Referenced by nidas::core::SampleOutputBase::SampleOutputBase().
|
inlineprotectedinherited |
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput, and nidas::dynld::RawSampleOutputStream.
|
private |
No assignment.
|
virtual |
Method called to pass a sample to this client.
This method is typically called by a SampleSource for each of its SampleClients when it has a sample ready. Returns true: success false: sample rejected. This is meant to signal a warning-type situation - like a socket not being available temporarily. True errors will be thrown as an IOException.
Implements nidas::core::SampleClient.
References nidas::util::Logger::getInstance(), nidas::core::SampleHeader::getSizeOf(), nidas::util::Logger::log(), LOG_ERR, LOG_WARNING, nidas::core::SampleHeader::setDataByteLength(), nidas::core::SampleHeader::setRawId(), nidas::core::SampleHeader::setTimeTag(), and nidas::util::Exception::what().
|
private |
References _docRWLock, and nidas::util::RWLock::unlock().
|
virtualinherited |
Request a connection, but don't wait for it.
Requester will be notified via SampleConnectionRequester interface when the connection has been made. It is not necessary to call this method if a SampleOutput is constructed with a connected IOChannel.
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput, nidas::dynld::raf::CVIOutput, and nidas::dynld::AsciiOutput.
Referenced by nidas::dynld::AsciiOutput::requestConnection(), and nidas::dynld::raf::CVIOutput::requestConnection().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Referenced by NidsMerge::run(), SensorExtract::run(), and ARLIngest::run().
|
virtualinherited |
Set the IOChannel for this SampleOutput.
This IOChannel is not yet connected. The IOChannel must be connected before the SampleOutput is used for I/O, using the requestConnection() method, or by IOChannel::connect() followed by SampleOutput::connected(IOChannel*).
Reimplemented in nidas::dynld::raf::CVIOutput, and nidas::dynld::isff::GOESOutput.
References nidas::core::SampleOutputBase::_iochan, nidas::core::SampleOutputBase::getDSMConfig(), and nidas::core::IOChannel::setDSMConfig().
Referenced by nidas::dynld::isff::GOESOutput::setIOChannel(), and nidas::dynld::raf::CVIOutput::setIOChannel().
|
inlinevirtualinherited |
Set desired latency, providing some control over the response time vs buffer efficiency tradeoff.
Setting a latency of 1/10 sec means buffer data in the IOStream for a 1/10 sec, then send the data to the physical device.
val | Latency, in seconds. |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::SampleOutputStream.
Referenced by nidas::dynld::SampleOutputStream::setLatency().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput.
Referenced by nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::dynld::isff::GOESOutput::GOESOutput(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::isff::GOESOutput::setIOChannel(), and nidas::dynld::raf::CVIOutput::setIOChannel().
|
virtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_reconnectDelaySecs.
Referenced by nidas::dynld::raf::SyncServer::init().
|
virtualinherited |
Add my content into a DOMElement.
Reimplemented in nidas::core::DSMSensor, nidas::core::Variable, nidas::core::ServerSocket, nidas::core::SampleTag, nidas::core::Site, nidas::core::Project, and nidas::core::DSMConfig.
Referenced by nidas::core::ServerSocket::toDOMParent().
|
virtualinherited |
Create a DOMElement and append it to the parent.
Reimplemented in nidas::core::DSMSensor, nidas::core::Variable, nidas::core::ServerSocket, nidas::core::SampleTag, nidas::core::Site, nidas::core::Project, and nidas::core::DSMConfig.
size_t UDPSampleOutput::write | ( | const struct iovec * | iov, |
int | iovcnt | ||
) | |||
throw | ( | nidas::util::IOException | |
) |
References nidas::util::getSystemTime().
|
overridevirtualinherited |
Raw write method, typically used to write the initial header.
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::isff::GOESOutput.
References len.
|
private |
data buffer
Referenced by allocateBuffer().
|
private |
The actual buffer size.
Referenced by allocateBuffer().
|
private |
Referenced by getProjectDOM().
|
private |
Referenced by getProjectDOM().
|
private |
Referenced by getProjectDOM(), and releaseProjectDOM().
|
private |
One past end of buffer.
Referenced by allocateBuffer().
|
private |
where we insert bytes into the buffer
Referenced by allocateBuffer().
|
private |
Time of last physical write.
|
private |
Referenced by close(), and ~UDPSampleOutput().
|
private |
|
private |
Maximum number of microseconds between physical writes.
|
private |
|
private |
Referenced by close(), nidas::dynld::UDPSampleOutput::XMLSocketListener::run(), and ~UDPSampleOutput().
|
private |
|
protectedinherited |
|
private |
Referenced by addNumOutputBytes(), and getNumOutputBytes().
|
private |
Referenced by getProjectDOM().
|
private |
where we remove bytes from the buffer
Referenced by allocateBuffer().
|
private |
Referenced by nidas::dynld::UDPSampleOutput::XMLSocketListener::run().