nidas v1.2.3
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::DSMEngine Class Reference

Application for running the NIDAS data acquistion process. More...

#include <DSMEngine.h>

Inheritance diagram for nidas::core::DSMEngine:
Inheritance graph
[legend]

Public Types

enum  command {
  DSM_STOP , DSM_RUN , DSM_QUIT , DSM_RESTART ,
  DSM_REBOOT , DSM_SHUTDOWN
}
 

Public Member Functions

 DSMEngine ()
 
 ~DSMEngine ()
 Nuke it.
 
void initLogger ()
 Initialize the Logger.
 
int initProcess ()
 Initialize various process parameters, uid, etc.
 
int run () throw ()
 main loop
 
int parseRunstring (int argc, char **argv)
 Parse the runstring parameters.
 
void usage ()
 Print runstring usage to stderr.
 
void start ()
 Starts the main loop (for the XMLRPC call).
 
void stop ()
 Stops the main loop (for the XMLRPC call).
 
void restart ()
 Restarts the main loop (for the XMLRPC call).
 
void quit ()
 Quit the main loop.
 
void shutdown ()
 Quits the main loop, and spawns a "halt" shell command.
 
void reboot ()
 Quits the main loop, and spawns a "reboot" shell command.
 
const DSMConfiggetDSMConfig () const
 
const SensorHandlergetSensorHandler () const
 
void registerSensorWithXmlRpc (const std::string &devname, DSMSensor *)
 Sensors register with the DSMEngineIntf XmlRpcThread if they have a executeXmlRpc() method which can be invoked with a "SensorAction" XmlRpc request.
 
bool quitCommand (enum command command)
 
enum command getCommand () const
 

Static Public Member Functions

static int main (int argc, char **argv) throw ()
 Entry point to run a DSMEngine process from a command line.
 
static DSMEnginegetInstance ()
 Get a pointer to the singleton instance of DSMEngine created by main().
 

Private Types

enum  run_states { DSM_RUNNING , DSM_ERROR , DSM_STOPPED }
 

Private Member Functions

void setupSignals ()
 Create a signal mask, and block those masked signals.
 
void waitForSignal (int secs)
 Unblock and wait for signals of interest.
 
void initialize (xercesc::DOMDocument *projectDoc)
 Initialize the DSMEngine based on the parameters in the DOMDocument.
 
void startXmlRpcThread ()
 
void killXmlRpcThread ()
 
void openSensors ()
 
void connectOutputs ()
 
void connectProcessors ()
 
void disconnectProcessors () throw ()
 
void closeOutputs () throw ()
 
void interrupt ()
 
void deleteDataThreads () throw ()
 
void joinDataThreads () throw ()
 
void connect (SampleOutput *) throw ()
 Implementation of SampleConnectionRequester connect methods.
 
void disconnect (SampleOutput *) throw ()
 How SampleOutputs notify their SampleConnectionRequester that they wish to be closed, likely do to an IOException.
 
void connect (SampleInput *) throw ()
 DSMEngine does not receive SampleInputs, so this will die with an assert.
 
void disconnect (SampleInput *) throw ()
 DSMEngine does not receive SampleInputs, so these will die with an assert.
 
 DSMEngine (const DSMEngine &)
 No copy.
 
DSMEngineoperator= (const DSMEngine &)
 No assignment.
 

Private Attributes

bool _externalControl
 
bool _disableAutoconfig
 
enum nidas::core::DSMEngine::run_states _runState
 
enum command _command
 
bool _syslogit
 Whether to log messages on syslog (true) or stderr (false).
 
std::string _configFile
 Name of XML configuration file.
 
nidas::util::Inet4SocketAddress _configSockAddr
 Address to use when fishing for the XML configuration.
 
Project_project
 
DSMConfig_dsmConfig
 
SensorHandler_selector
 
SamplePipeline_pipeline
 
DSMEngineStat_statusThread
 A thread that generates streaming XML time and status.
 
DSMEngineIntf_xmlrpcThread
 This thread provides XML-based Remote Procedure calls.
 
std::set< SampleOutput * > _outputSet
 Connected SampleOutputs.
 
nidas::util::Mutex _outputMutex
 
int _logLevel
 
sigset_t _signalMask
 
pthread_t _myThreadId
 
NidasApp _app
 
NidasAppArg ExternalControl
 
NidasAppArg DisableAutoConfig
 

Static Private Attributes

static DSMEngine_instance = 0
 

Detailed Description

Application for running the NIDAS data acquistion process.

Member Enumeration Documentation

◆ command

Enumerator
DSM_STOP 
DSM_RUN 
DSM_QUIT 
DSM_RESTART 
DSM_REBOOT 
DSM_SHUTDOWN 

◆ run_states

Enumerator
DSM_RUNNING 
DSM_ERROR 
DSM_STOPPED 

Constructor & Destructor Documentation

◆ DSMEngine() [1/2]

DSMEngine::DSMEngine ( )

◆ ~DSMEngine()

DSMEngine::~DSMEngine ( )

◆ DSMEngine() [2/2]

nidas::core::DSMEngine::DSMEngine ( const DSMEngine & )
private

No copy.

Member Function Documentation

◆ closeOutputs()

void DSMEngine::closeOutputs ( )
throw ( )
private

◆ connect() [1/2]

void nidas::core::DSMEngine::connect ( SampleInput * )
throw ( )
inlineprivate

DSMEngine does not receive SampleInputs, so this will die with an assert.

References nidas::core::getSample().

◆ connect() [2/2]

void DSMEngine::connect ( SampleOutput * output)
throw ( )
privatevirtual

Implementation of SampleConnectionRequester connect methods.

This is how DSMEngine is notified of remote connections.

Implements nidas::core::SampleConnectionRequester.

References LOG_INFO.

◆ connectOutputs()

void DSMEngine::connectOutputs ( )
private

◆ connectProcessors()

void DSMEngine::connectProcessors ( )
private

◆ deleteDataThreads()

void DSMEngine::deleteDataThreads ( )
throw ( )
private

◆ disconnect() [1/2]

void nidas::core::DSMEngine::disconnect ( SampleInput * )
throw ( )
inlineprivate

DSMEngine does not receive SampleInputs, so these will die with an assert.

References nidas::core::getSample().

◆ disconnect() [2/2]

void DSMEngine::disconnect ( SampleOutput * output)
throw ( )
privatevirtual

How SampleOutputs notify their SampleConnectionRequester that they wish to be closed, likely do to an IOException.

Implements nidas::core::SampleConnectionRequester.

References nidas::core::SampleOutputRequestThread::getInstance(), nidas::core::SampleOutput::getOriginal(), and LOG_ERR.

◆ disconnectProcessors()

void DSMEngine::disconnectProcessors ( )
throw ( )
private

◆ getCommand()

enum command nidas::core::DSMEngine::getCommand ( ) const
inline

References _command.

◆ getDSMConfig()

const DSMConfig * nidas::core::DSMEngine::getDSMConfig ( ) const
inline

References _dsmConfig.

◆ getInstance()

static DSMEngine * nidas::core::DSMEngine::getInstance ( )
inlinestatic

◆ getSensorHandler()

const SensorHandler * nidas::core::DSMEngine::getSensorHandler ( ) const
inline

References _selector.

◆ initialize()

void DSMEngine::initialize ( xercesc::DOMDocument * projectDoc)
private

Initialize the DSMEngine based on the parameters in the DOMDocument.

This method initializes the Project object, _project from the DOM, and sets the value of _dsmConfig.

Exceptions
nidas::util::InvalidParameterException

References _app, _configFile, _disableAutoconfig, _dsmConfig, _project, nidas::core::Project::disableAutoconfig(), nidas::core::Project::findDSM(), nidas::core::Project::fromDOMElement(), nidas::core::NidasApp::getHostName(), nidas::core::DSMConfig::getName(), ILOG, and nidas::core::Project::setConfigName().

Referenced by run().

◆ initLogger()

void DSMEngine::initLogger ( )

Initialize the Logger.

References _app, and nidas::core::NidasApp::setupDaemon().

◆ initProcess()

int DSMEngine::initProcess ( )

◆ interrupt()

void DSMEngine::interrupt ( )
private

◆ joinDataThreads()

void DSMEngine::joinDataThreads ( )
throw ( )
private

◆ killXmlRpcThread()

void DSMEngine::killXmlRpcThread ( )
private

◆ main()

int DSMEngine::main ( int argc,
char ** argv )
throw ( )
static

Entry point to run a DSMEngine process from a command line.

main creates an instance of DSMEngine, passes it the command line arguments and calls the run method.

References nidas::core::DSMSensor::deleteLooper(), nidas::core::getSample(), ILOG, NSECS_PER_SEC, PLOG, and nidas::core::XMLImplementation::terminate().

Referenced by main().

◆ openSensors()

void DSMEngine::openSensors ( )
private

◆ operator=()

DSMEngine & nidas::core::DSMEngine::operator= ( const DSMEngine & )
private

No assignment.

◆ parseRunstring()

int DSMEngine::parseRunstring ( int argc,
char ** argv )

◆ quit()

void DSMEngine::quit ( )

Quit the main loop.

References _myThreadId, and nidas::core::getSample().

◆ quitCommand()

bool nidas::core::DSMEngine::quitCommand ( enum command command)
inline

References DSM_QUIT, DSM_REBOOT, and DSM_SHUTDOWN.

Referenced by run().

◆ reboot()

void DSMEngine::reboot ( )

Quits the main loop, and spawns a "reboot" shell command.

References _command, _myThreadId, DSM_REBOOT, and nidas::core::getSample().

◆ registerSensorWithXmlRpc()

void DSMEngine::registerSensorWithXmlRpc ( const std::string & devname,
DSMSensor * sensor )

Sensors register with the DSMEngineIntf XmlRpcThread if they have a executeXmlRpc() method which can be invoked with a "SensorAction" XmlRpc request.

Parameters
devnamestring matching the "device" XmlRpc parameter, typically the device name.

References _xmlrpcThread, and nidas::core::DSMEngineIntf::registerSensor().

◆ restart()

void DSMEngine::restart ( )

Restarts the main loop (for the XMLRPC call).

References _myThreadId, and nidas::core::getSample().

◆ run()

int DSMEngine::run ( )
throw ( )

◆ setupSignals()

void DSMEngine::setupSignals ( )
private

Create a signal mask, and block those masked signals.

DSMEngine uses sigwait, and does not register asynchronous signal handlers.

References _signalMask, and nidas::core::getSample().

Referenced by DSMEngine().

◆ shutdown()

void DSMEngine::shutdown ( )

Quits the main loop, and spawns a "halt" shell command.

References _command, _myThreadId, DSM_SHUTDOWN, and nidas::core::getSample().

◆ start()

void DSMEngine::start ( )

Starts the main loop (for the XMLRPC call).

References _command, _myThreadId, DSM_RUN, and nidas::core::getSample().

◆ startXmlRpcThread()

void DSMEngine::startXmlRpcThread ( )
private

◆ stop()

void DSMEngine::stop ( )

Stops the main loop (for the XMLRPC call).

References _command, _myThreadId, DSM_STOP, and nidas::core::getSample().

◆ usage()

void DSMEngine::usage ( )

◆ waitForSignal()

void DSMEngine::waitForSignal ( int secs)
private

Unblock and wait for signals of interest.

References _command, _signalMask, DSM_QUIT, DSM_RESTART, nidas::core::getSample(), ILOG, PLOG, timeoutSecs, and WLOG.

Referenced by run().

Member Data Documentation

◆ _app

NidasApp nidas::core::DSMEngine::_app
private

◆ _command

enum command nidas::core::DSMEngine::_command
private

◆ _configFile

std::string nidas::core::DSMEngine::_configFile
private

Name of XML configuration file.

If empty, multicast for config.

Referenced by initialize(), parseRunstring(), and run().

◆ _configSockAddr

nidas::util::Inet4SocketAddress nidas::core::DSMEngine::_configSockAddr
private

Address to use when fishing for the XML configuration.

Referenced by DSMEngine(), parseRunstring(), and run().

◆ _disableAutoconfig

bool nidas::core::DSMEngine::_disableAutoconfig
private

Referenced by initialize().

◆ _dsmConfig

DSMConfig* nidas::core::DSMEngine::_dsmConfig
private

◆ _externalControl

bool nidas::core::DSMEngine::_externalControl
private

◆ _instance

DSMEngine * DSMEngine::_instance = 0
staticprivate

Referenced by getInstance().

◆ _logLevel

int nidas::core::DSMEngine::_logLevel
private

◆ _myThreadId

pthread_t nidas::core::DSMEngine::_myThreadId
private

Referenced by quit(), reboot(), restart(), shutdown(), start(), and stop().

◆ _outputMutex

nidas::util::Mutex nidas::core::DSMEngine::_outputMutex
private

Referenced by closeOutputs().

◆ _outputSet

std::set<SampleOutput*> nidas::core::DSMEngine::_outputSet
private

Connected SampleOutputs.

Referenced by closeOutputs().

◆ _pipeline

SamplePipeline* nidas::core::DSMEngine::_pipeline
private

◆ _project

Project* nidas::core::DSMEngine::_project
private

Referenced by initialize(), run(), and ~DSMEngine().

◆ _runState

enum nidas::core::DSMEngine::run_states nidas::core::DSMEngine::_runState
private

Referenced by run().

◆ _selector

SensorHandler* nidas::core::DSMEngine::_selector
private

◆ _signalMask

sigset_t nidas::core::DSMEngine::_signalMask
private

Referenced by run(), setupSignals(), and waitForSignal().

◆ _statusThread

DSMEngineStat* nidas::core::DSMEngine::_statusThread
private

A thread that generates streaming XML time and status.

Referenced by deleteDataThreads(), interrupt(), joinDataThreads(), run(), and ~DSMEngine().

◆ _syslogit

bool nidas::core::DSMEngine::_syslogit
private

Whether to log messages on syslog (true) or stderr (false).

Set to false from -d runstring option, otherwise true.

◆ _xmlrpcThread

DSMEngineIntf* nidas::core::DSMEngine::_xmlrpcThread
private

This thread provides XML-based Remote Procedure calls.

Referenced by killXmlRpcThread(), registerSensorWithXmlRpc(), startXmlRpcThread(), and ~DSMEngine().

◆ DisableAutoConfig

NidasAppArg nidas::core::DSMEngine::DisableAutoConfig
private

Referenced by parseRunstring().

◆ ExternalControl

NidasAppArg nidas::core::DSMEngine::ExternalControl
private

Referenced by parseRunstring().


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