nidas v1.2.3
|
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... | |
Static Public Member Functions | |
static const XMLCh * | getNamespaceURI () |
Protected Member Functions | |
UDPSampleOutput * | clone (nidas::core::IOChannel *iochannel) |
This SampleOutput does not support cloning. | |
UDPSampleOutput (UDPSampleOutput &, nidas::core::IOChannel *) | |
This SampleOutput does not support a copy constructor with a new IOChannel. | |
size_t | incrementDiscardedSamples () |
SampleConnectionRequester * | getSampleConnectionRequester () |
void | disconnect () |
Close the IOChannel and notify whoever did the requestConnection that it is time to disconnect, perhaps because of an IOException. | |
Protected Attributes | |
std::string | _name |
Private Member Functions | |
xercesc::DOMDocument * | getProjectDOM () |
Get a pointer to the current project DOM. | |
void | releaseProjectDOM () |
UDPSampleOutput (const UDPSampleOutput &) | |
No copying. | |
UDPSampleOutput & | operator= (const UDPSampleOutput &) |
No assignment. | |
Static Private Attributes | |
static XMLCh * | namespaceURI = 0 |
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::core::getSample(), and LOG_ERR.
|
private |
No copying.
References _nbytesOut, and nidas::core::getSample().
Referenced by write().
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::getSample().
Referenced by nidas::core::SampleOutputBase::fromDOMElement().
nidas::util::InvalidParameterException |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_constRequestedTags, nidas::core::SampleOutputBase::_requestedTags, nidas::core::SampleOutputBase::_tagsMutex, and nidas::core::getSample().
Referenced by nidas::dynld::raf::CVIOutput::addRequestedSampleTag(), and nidas::core::SampleOutputBase::SampleOutputBase().
nidas::util::InvalidParameterException |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_sourceTags, nidas::core::SampleOutputBase::_tagsMutex, and nidas::core::getSample().
Referenced by nidas::core::SampleOutputBase::addSourceSampleTags(), and nidas::core::SampleOutputBase::SampleOutputBase().
|
virtualinherited |
nidas::util::InvalidParameterException |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::addSourceSampleTag(), and nidas::core::getSample().
|
protectedvirtual |
This SampleOutput does not support cloning.
It will die with an assert.
Implements nidas::core::SampleOutput.
References nidas::core::getSample(), and LOG_ERR.
|
virtual |
nidas::util::IOException |
Reimplemented from nidas::core::SampleOutputBase.
References _listener, _monitor, nidas::core::SampleOutputBase::close(), nidas::dynld::UDPSampleOutput::XMLSocketListener::interrupt(), nidas::util::Thread::interrupt(), nidas::util::Thread::isRunning(), and nidas::util::Thread::join().
|
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::core::Project::getInstance(), nidas::core::getSample(), nidas::dynld::InitialUDPDataRequestReply::strings, and WLOG.
|
inherited |
nidas::util::IOException |
References nidas::core::SampleOutputBase::_headerSource, nidas::core::SampleOutputBase::_nextFileTime, nidas::core::IOChannel::createFile(), nidas::core::SampleOutputBase::getIOChannel(), nidas::core::HeaderSource::sendDefaultHeader(), and nidas::core::HeaderSource::sendHeader().
Referenced by nidas::dynld::AsciiOutput::receive(), and nidas::dynld::raf::CVIOutput::receive().
|
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().
nidas::util::IOException |
References nidas::core::SampleOutputBase::_connectionRequester, nidas::core::SampleOutputBase::close(), nidas::core::SampleConnectionRequester::disconnect(), nidas::core::SampleOutputBase::getName(), nidas::core::getSample(), and ILOG.
Referenced by nidas::dynld::AsciiOutput::receive(), and nidas::dynld::raf::CVIOutput::receive().
|
inlinevirtual |
Implementation of SampleClient::flush().
Implements nidas::core::SampleClient.
nidas::util::InvalidParameterException |
Reimplemented from nidas::core::SampleOutputBase.
References _mochan, _multicastOutPort, _xmlPortNumber, nidas::core::SampleOutputBase::fromDOMElement(), nidas::core::SampleOutputBase::getIOChannel(), nidas::core::SampleOutputBase::getName(), nidas::core::SampleOutputBase::getParameters(), nidas::core::getSample(), nidas::core::Parameter::INT_PARAM, nidas::core::MultipleUDPSockets::setDataPort(), nidas::core::IOChannel::setRequestType(), and nidas::core::UDP_PROCESSED_SAMPLE_FEED.
|
virtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_iochan, and nidas::core::IOChannel::getFd().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_iochan.
Referenced by nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::AsciiOutput::connect(), nidas::core::SampleOutputBase::createNextFile(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::core::SampleOutputBase::fromDOMElement(), nidas::dynld::RawSampleOutputStream::fromDOMElement(), fromDOMElement(), nidas::dynld::AsciiOutput::printHeader(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::AsciiOutput::receive(), nidas::dynld::raf::CVIOutput::receive(), nidas::dynld::raf::CVIOutput::requestConnection(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::raf::CVIOutput::setIOChannel(), and write().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_latency.
Referenced by nidas::dynld::SampleOutputStream::SampleOutputStream(), and nidas::dynld::SampleOutputStream::SampleOutputStream().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_name.
Referenced by nidas::dynld::UDPSampleOutput::ConnectionMonitor::addConnection(), nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::UDPSampleOutput::XMLSocketListener::checkWorkers(), nidas::core::SampleOutputBase::close(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::core::SampleOutputBase::disconnect(), nidas::dynld::UDPSampleOutput::XMLSocketListener::fireWorkers(), nidas::dynld::SampleOutputStream::flush(), nidas::core::SampleOutputBase::fromDOMElement(), fromDOMElement(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::AsciiOutput::receive(), nidas::dynld::raf::CVIOutput::receive(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::raf::CVIOutput::setIOChannel(), and nidas::dynld::SampleOutputStream::setLatency().
References nidas::core::DOMable::namespaceURI.
Referenced by getProjectDOM(), nidas::core::Dataset::toDOMElement(), nidas::core::ProjectConfig::toDOMElement(), nidas::core::Dataset::toDOMParent(), nidas::core::Datasets::toDOMParent(), nidas::core::ProjectConfig::toDOMParent(), nidas::core::ProjectConfigs::toDOMParent(), nidas::core::DSMConfig::toDOMParent(), nidas::core::DSMSensor::toDOMParent(), nidas::core::Project::toDOMParent(), nidas::core::SampleTag::toDOMParent(), nidas::core::Site::toDOMParent(), nidas::core::ServerSocket::toDOMParent(), nidas::core::Variable::toDOMParent(), nidas::core::Datasets::writeXML(), and nidas::core::ProjectConfigs::writeXML().
|
inlineinherited |
References nidas::core::SampleOutputBase::_nextFileTime.
Referenced by nidas::dynld::AsciiOutput::receive(), and nidas::dynld::raf::CVIOutput::receive().
|
inlineinherited |
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.
References nidas::core::SampleOutputBase::_original.
Fetch a parameter by name.
Returns a NULL pointer if no such parameter exists.
References nidas::core::SampleOutputBase::_parameters.
|
inlineinherited |
Get list of parameters.
References nidas::core::SampleOutputBase::_constParameters.
Referenced by fromDOMElement().
|
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::core::getSample(), and nidas::util::RWLock::rdlock().
|
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().
|
inlineprotectedinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_sourceTags, nidas::core::SampleOutputBase::_tagsMutex, and nidas::core::getSample().
|
inlineprotectedinherited |
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
|
private |
No assignment.
|
virtual |
Return true if SampleOutputBase considers the sample handled, such as if it is outside the clipping window.
Otherwise return false to indicate the subclass should handle the sample.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::getSample(), nidas::core::SampleHeader::getSizeOf(), LOG_ERR, LOG_WARNING, nidas::core::SampleHeader::setDataByteLength(), nidas::core::SampleHeader::setRawId(), and nidas::core::SampleHeader::setTimeTag().
|
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.
nidas::util::IOException |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_connectionRequester, nidas::core::SampleOutputBase::_iochan, nidas::core::getSample(), and nidas::core::IOChannel::requestConnection().
Referenced by nidas::dynld::AsciiOutput::requestConnection(), and nidas::dynld::raf::CVIOutput::requestConnection().
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_dsm, and nidas::core::getSample().
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_headerSource, and nidas::core::getSample().
Referenced by ARLIngest::run(), NidsMerge::run(), and SensorExtract::run().
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.
References nidas::core::SampleOutputBase::_iochan, nidas::core::SampleOutputBase::getDSMConfig(), nidas::core::getSample(), and nidas::core::IOChannel::setDSMConfig().
Referenced by nidas::dynld::AsciiOutput::connect(), nidas::core::SampleOutputBase::connected(), nidas::core::SampleOutputBase::fromDOMElement(), and nidas::dynld::raf::CVIOutput::setIOChannel().
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. |
nidas::util::InvalidParameterException |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::SampleOutputStream.
References nidas::core::SampleOutputBase::_latency, and nidas::core::getSample().
Referenced by nidas::core::SampleOutputBase::fromDOMElement(), and nidas::dynld::SampleOutputStream::setLatency().
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_name, and nidas::core::getSample().
Referenced by nidas::dynld::AsciiOutput::AsciiOutput(), nidas::dynld::AsciiOutput::AsciiOutput(), nidas::core::SampleOutputBase::connected(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::dynld::raf::CVIOutput::CVIOutput(), nidas::core::SampleOutputBase::fromDOMElement(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), and nidas::dynld::raf::CVIOutput::setIOChannel().
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_reconnectDelaySecs, and nidas::core::getSample().
Referenced by nidas::dynld::raf::SyncServer::init().
|
inherited |
The sample output can have a time window which clips the samples outside the window.
Only samples at or after startTime
and before endTime
will be passed along. One or both of start and end time can be zero, in which case only the non-zero times are used to clip samples.
References nidas::core::SampleOutputBase::_endTime, nidas::core::SampleOutputBase::_startTime, and nidas::util::UTime::toUsecs().
Referenced by nidas::core::NidasApp::setOutputClipping().
|
virtualinherited |
Add my content into a DOMElement.
xercesc::DOMException |
Reimplemented in nidas::core::DSMConfig, nidas::core::DSMSensor, nidas::core::Project, nidas::core::SampleTag, nidas::core::Site, nidas::core::ServerSocket, and nidas::core::Variable.
Referenced by nidas::core::ServerSocket::toDOMParent().
|
virtualinherited |
Create a DOMElement and append it to the parent.
xercesc::DOMException |
Reimplemented in nidas::core::DSMConfig, nidas::core::DSMSensor, nidas::core::Project, nidas::core::SampleTag, nidas::core::Site, nidas::core::ServerSocket, and nidas::core::Variable.
Raw write method, typically used to write the initial header.
nidas::util::IOException |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_iochan, nidas::core::getSample(), len, and nidas::core::IOChannel::write().
|
private |
data buffer
Referenced by allocateBuffer(), and write().
|
private |
The actual buffer size.
Referenced by allocateBuffer(), and write().
|
privateinherited |
List of const pointers to Parameters for providing via getParameters().
Referenced by nidas::core::SampleOutputBase::addParameter(), and nidas::core::SampleOutputBase::getParameters().
|
private |
Referenced by getProjectDOM().
|
private |
Referenced by getProjectDOM().
|
private |
Referenced by getProjectDOM(), and releaseProjectDOM().
|
privateinherited |
|
private |
One past end of buffer.
Referenced by allocateBuffer(), and write().
|
private |
where we insert bytes into the buffer
Referenced by allocateBuffer(), and write().
|
privateinherited |
|
privateinherited |
Referenced by nidas::core::SampleOutputBase::close(), nidas::core::SampleOutputBase::connected(), nidas::core::SampleOutputBase::getFd(), nidas::core::SampleOutputBase::getIOChannel(), nidas::core::SampleOutputBase::getReconnectDelaySecs(), nidas::core::SampleOutputBase::requestConnection(), nidas::core::SampleOutputBase::SampleOutputBase(), nidas::core::SampleOutputBase::setIOChannel(), nidas::core::SampleOutputBase::write(), and nidas::core::SampleOutputBase::~SampleOutputBase().
|
private |
Time of last physical write.
Referenced by write().
|
privateinherited |
|
private |
Referenced by close(), and ~UDPSampleOutput().
|
private |
|
private |
Maximum number of microseconds between physical writes.
Referenced by write().
|
private |
Referenced by fromDOMElement().
|
private |
Referenced by close(), nidas::dynld::UDPSampleOutput::XMLSocketListener::run(), and ~UDPSampleOutput().
Referenced by fromDOMElement().
|
protectedinherited |
Referenced by nidas::core::SampleOutputBase::getName(), and nidas::core::SampleOutputBase::setName().
Referenced by addNumOutputBytes(), and getNumOutputBytes().
|
privateinherited |
|
privateinherited |
|
privateinherited |
Pointer to the SampleOutput that I was cloned from.
Referenced by nidas::core::SampleOutputBase::getOriginal().
|
privateinherited |
Map of parameters by name.
Referenced by nidas::core::SampleOutputBase::addParameter(), nidas::core::SampleOutputBase::getParameter(), and nidas::core::SampleOutputBase::~SampleOutputBase().
|
private |
Referenced by getProjectDOM().
|
privateinherited |
|
privateinherited |
|
privateinherited |
Clipping time window.
Samples outside the given time window will not pass.
Referenced by nidas::core::SampleOutputBase::receive(), and nidas::core::SampleOutputBase::setTimeClippingWindow().
|
mutableprivateinherited |
|
private |
where we remove bytes from the buffer
Referenced by allocateBuffer(), and write().
Referenced by fromDOMElement(), and nidas::dynld::UDPSampleOutput::XMLSocketListener::run().
|
staticprivateinherited |
Referenced by nidas::core::DOMable::getNamespaceURI().