nidas
v1.2-1520
|
A SampleOutput for packaging data for a GOES DCP Transmitter. More...
#include <GOESOutput.h>
Public Member Functions | |
GOESOutput (nidas::core::IOChannel *ioc=0, SampleConnectionRequester *rqstr=0) | |
Constructor. More... | |
~GOESOutput () | |
Destructor. More... | |
void | flush () throw () |
Implementation of SampleClient::flush(). More... | |
void | setIOChannel (nidas::core::IOChannel *val) |
Set the IOChannel for this SampleOutput. More... | |
GOESOutput * | clone (nidas::core::IOChannel *iochannel=0) |
Clone invokes copy constructor. More... | |
SampleOutput * | connected (nidas::core::IOChannel *ochan) throw () |
Implemention of IOChannelRequester::connected(). More... | |
int | getXmitInterval () const |
The GOES transmit interval, in seconds. More... | |
int | getXmitOffset () const |
The GOES transmit offset, in seconds. More... | |
void | addRequestedSampleTag (nidas::core::SampleTag *tag) throw (nidas::util::InvalidParameterException) |
Some SampleOutputs don't send out all the Samples that they receive. More... | |
void | addSourceSampleTag (const nidas::core::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 | close () throw () |
size_t | write (const void *, size_t) throw (nidas::util::IOException) |
Raw write not supported. More... | |
bool | receive (const Sample *) throw () |
Send a data record to the RPC server. More... | |
void | fromDOMElement (const xercesc::DOMElement *node) throw (nidas::util::InvalidParameterException) |
Initialize myself from a xercesc::DOMElement. More... | |
int | run () throw (nidas::util::Exception) |
The method which will run in its own thread. More... | |
void | interrupt () |
Interrupt this run method. More... | |
bool | isInterrupted () const |
Has the run method been interrupted? 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 |
std::list< const SampleTag * > | getRequestedSampleTags () const |
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) |
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 | |
GOESOutput (GOESOutput &, nidas::core::IOChannel *) | |
Copy constructor, with a new IOChannel*. More... | |
void | joinThread () throw () |
void | cancelThread () throw () |
void | killThread () throw () |
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... | |
void | testCancel () const |
Check if we have been cancelled. More... | |
virtual bool | amInterrupted () const |
Call testCancel, and return true when this thread has been interrupted. More... | |
Protected Attributes | |
std::string | _name |
Private Member Functions | |
GOESOutput (const GOESOutput &) | |
No normal copy. More... | |
GOESOutput & | operator= (const GOESOutput &) |
No assignment. More... | |
Private Attributes | |
GOESXmtr * | _goesXmtr |
std::map< dsm_sample_id_t, std::vector< std::vector < std::pair< int, int > > > > | _sampleMap |
std::vector< SampleT< float > * > | _outputSamples |
nidas::util::Mutex | _sampleMutex |
nidas::util::ThreadRunnable * | _xmitThread |
bool | _interrupted |
int | _configid |
int | _stationNumber |
long long | _maxPeriodUsec |
Not sure what the plan was for this. More... | |
A SampleOutput for packaging data for a GOES DCP Transmitter.
GOESOutput::GOESOutput | ( | nidas::core::IOChannel * | ioc = 0 , |
SampleConnectionRequester * | rqstr = 0 |
||
) |
Constructor.
References nidas::util::Logger::getInstance(), nidas::util::Logger::log(), and LOG_ERR.
Referenced by clone().
GOESOutput::~GOESOutput | ( | ) |
Destructor.
References _xmitThread, cancelThread(), and joinThread().
|
protected |
Copy constructor, with a new IOChannel*.
Used by clone().
References _goesXmtr, nidas::util::Logger::getInstance(), nidas::core::SampleOutputBase::getIOChannel(), nidas::core::SampleOutputBase::getName(), nidas::util::Logger::log(), LOG_ERR, and nidas::core::SampleOutputBase::setName().
|
private |
No normal copy.
|
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().
|
virtual |
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.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::addRequestedSampleTag(), GET_DSM_ID, GET_SPS_ID, nidas::core::Parameter::getLength(), nidas::core::Parameter::getName(), nidas::core::Parameter::getStringValue(), nidas::core::Parameter::getType(), nidas::core::Variable::setName(), and nidas::core::Parameter::STRING_PARAM.
|
virtual |
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().
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::addSourceSampleTag(), nidas::core::Project::getInstance(), nidas::util::Logger::getInstance(), nidas::core::Parameter::getLength(), nidas::core::Variable::getName(), nidas::core::Parameter::getNumericValue(), nidas::core::Project::getParameter(), nidas::core::SampleTag::getVariableIterator(), nidas::core::VariableIterator::hasNext(), ILOG, nidas::util::Logger::log(), LOG_ERR, and nidas::core::VariableIterator::next().
|
virtualinherited |
Implements nidas::core::SampleOutput.
|
protectedvirtualinherited |
Call testCancel, and return true when this thread has been interrupted.
This is protected because it should only called within the run method of the thread.
Referenced by nidas::core::SampleOutputRequestThread::run(), nidas::core::Looper::run(), run(), nidas::core::DSMServerStat::run(), and nidas::util::Thread::test().
|
protected |
|
inlinevirtual |
|
virtual |
Reimplemented from nidas::core::SampleOutputBase.
References cancelThread(), nidas::core::SampleOutputBase::close(), and joinThread().
|
virtual |
Implemention of IOChannelRequester::connected().
Once we have the connection to the transmitter, initialize things before sending packets.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::connected(), nidas::core::floatNAN, nidas::core::SampleT< DataT >::getDataPtr(), nidas::core::SampleTag::getId(), nidas::util::Logger::getInstance(), nidas::core::Variable::getName(), nidas::core::SampleTag::getPeriod(), nidas::core::SampleTag::getVariableIterator(), nidas::core::SampleTag::getVariables(), nidas::core::VariableIterator::hasNext(), nidas::util::Logger::log(), LOG_WARNING, nidas::core::VariableIterator::next(), nidas::core::Sample::setId(), nidas::core::Sample::setTimeTag(), nidas::util::UTime::toUsecs(), and USECS_PER_SEC.
|
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::IOChannel::createIOChannel(), nidas::core::DOMable::fromDOMElement(), nidas::core::SampleTag::fromDOMElement(), and nidas::core::XDOMElement::getNodeName().
|
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(), GOESOutput(), nidas::dynld::AsciiOutput::printHeader(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), 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(), 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(), GOESOutput(), joinThread(), killThread(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), run(), nidas::dynld::SampleOutputStream::SampleOutputStream(), setIOChannel(), nidas::dynld::raf::CVIOutput::setIOChannel(), and write().
|
inlinestaticinherited |
References nidas::core::DOMable::namespaceURI.
Referenced by nidas::dynld::UDPSampleOutput::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 |
|
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.
|
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(), 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().
|
inline |
The GOES transmit interval, in seconds.
References _goesXmtr, and nidas::dynld::isff::GOESXmtr::getXmitInterval().
Referenced by nidas::dynld::isff::GOESProject::GOESProject(), and run().
|
inline |
The GOES transmit offset, in seconds.
References _goesXmtr, and nidas::dynld::isff::GOESXmtr::getXmitOffset().
Referenced by run().
|
inlineprotectedinherited |
|
virtual |
Interrupt this run method.
This sets a flag which can be tested with isInterrupted(). It is up to the run() implementation to return when interrupted.
Implements nidas::util::Runnable.
References _interrupted.
|
inlinevirtual |
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Reimplemented in nidas::dynld::psql::PSQLSampleOutput, and nidas::dynld::RawSampleOutputStream.
|
protected |
References _xmitThread, nidas::util::Logger::getInstance(), nidas::core::SampleOutputBase::getName(), nidas::util::ThreadRunnable::interrupt(), nidas::util::Thread::isJoined(), nidas::util::Thread::isRunning(), nidas::util::Thread::join(), nidas::util::Logger::log(), LOG_ERR, and nidas::util::Exception::what().
Referenced by close(), and ~GOESOutput().
|
protected |
|
private |
No assignment.
|
virtual |
Send a data record to the RPC server.
Implements nidas::core::SampleClient.
References nidas::core::SampleT< DataT >::getConstDataPtr(), nidas::core::SampleT< DataT >::getDataLength(), nidas::core::SampleT< DataT >::getDataPtr(), nidas::util::Logger::getInstance(), nidas::core::Sample::getTimeTag(), nidas::util::Logger::log(), LOG_ERR, USECS_PER_MSEC, USECS_PER_SEC, and WLOG.
|
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().
|
virtual |
The method which will run in its own thread.
This method must be supplied by the Runnable or Thread subclass.
Implements nidas::util::Runnable.
References _configid, _goesXmtr, _interrupted, _outputSamples, _sampleMutex, nidas::util::Runnable::amInterrupted(), nidas::core::floatNAN, nidas::util::UTime::format(), nidas::core::SampleT< DataT >::freeReference(), nidas::core::SampleT< DataT >::getConstDataPtr(), nidas::core::SampleT< DataT >::getDataLength(), nidas::core::SampleT< DataT >::getDataPtr(), nidas::core::SampleTag::getId(), nidas::util::Logger::getInstance(), nidas::core::SampleOutputBase::getName(), nidas::core::SampleTag::getPeriod(), nidas::core::SampleOutputBase::getRequestedSampleTags(), nidas::core::Sample::getTimeTag(), nidas::core::SampleTag::getVariables(), getXmitInterval(), getXmitOffset(), nidas::dynld::isff::GOESXmtr::init(), nidas::util::Mutex::lock(), nidas::util::Logger::log(), LOG_ERR, MSECS_PER_SEC, periodMsec, PLOG, nidas::dynld::isff::GOESXmtr::printStatus(), nidas::dynld::isff::GOESXmtr::reset(), nidas::util::Thread::RUN_OK, nidas::core::Sample::setId(), nidas::core::Sample::setTimeTag(), nidas::util::sleepUntil(), nidas::util::UTime::toUsecs(), nidas::dynld::isff::GOESXmtr::transmitData(), nidas::util::Mutex::unlock(), USECS_PER_MSEC, USECS_PER_SEC, nidas::util::Exception::what(), and WLOG.
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
|
inlinevirtualinherited |
Implements nidas::core::SampleOutput.
Referenced by NidsMerge::run(), SensorExtract::run(), and ARLIngest::run().
|
virtual |
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 from nidas::core::SampleOutputBase.
References _goesXmtr, nidas::util::Logger::getInstance(), nidas::core::SampleOutputBase::getIOChannel(), nidas::core::SampleOutputBase::getName(), nidas::util::Logger::log(), LOG_ERR, nidas::core::SampleOutputBase::setIOChannel(), and nidas::core::SampleOutputBase::setName().
|
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(), GOESOutput(), nidas::dynld::RawSampleOutputStream::RawSampleOutputStream(), nidas::dynld::SampleOutputStream::SampleOutputStream(), setIOChannel(), and nidas::dynld::raf::CVIOutput::setIOChannel().
|
virtualinherited |
Implements nidas::core::SampleOutput.
References nidas::core::SampleOutputBase::_reconnectDelaySecs.
Referenced by nidas::dynld::raf::SyncServer::init().
|
inlineprotectedinherited |
Check if we have been cancelled.
Calls pthread_testcancel. This is protected since it only checks the current thread - i.e. it must be called within the run method. Since it just calls pthread_testcancel, it is a cancellation point.
|
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.
|
inlinevirtual |
Raw write not supported.
Reimplemented from nidas::core::SampleOutputBase.
References nidas::core::SampleOutputBase::getName().
|
private |
Referenced by run().
|
private |
Referenced by getXmitInterval(), getXmitOffset(), GOESOutput(), run(), and setIOChannel().
|
private |
Referenced by interrupt(), isInterrupted(), and run().
|
private |
Not sure what the plan was for this.
Not currently used.
|
protectedinherited |
|
private |
Referenced by run().
|
private |
|
private |
Referenced by run().
|
private |
|
private |
Referenced by cancelThread(), joinThread(), killThread(), and ~GOESOutput().