nidas  v1.2-1520
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. More...
 
void initLogger ()
 Initialize the Logger. More...
 
int initProcess ()
 Initialize various process parameters, uid, etc. More...
 
int run () throw ()
 main loop More...
 
int parseRunstring (int argc, char **argv)
 Parse the runstring parameters. More...
 
void usage ()
 Print runstring usage to stderr. More...
 
void start ()
 Starts the main loop (for the XMLRPC call). More...
 
void stop ()
 Stops the main loop (for the XMLRPC call). More...
 
void restart ()
 Restarts the main loop (for the XMLRPC call). More...
 
void quit ()
 Quit the main loop. More...
 
void shutdown ()
 Quits the main loop, and spawns a "halt" shell command. More...
 
void reboot ()
 Quits the main loop, and spawns a "reboot" shell command. More...
 
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. More...
 
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. More...
 
static DSMEnginegetInstance ()
 Get a pointer to the singleton instance of DSMEngine created by main(). More...
 

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. More...
 
void waitForSignal (int secs)
 Unblock and wait for signals of interest. More...
 
void initialize (xercesc::DOMDocument *projectDoc) throw (nidas::util::InvalidParameterException)
 Initialize the DSMEngine based on the parameters in the DOMDocument. More...
 
void startXmlRpcThread () throw (nidas::util::Exception)
 
void killXmlRpcThread () throw ()
 
void openSensors () throw (nidas::util::IOException)
 
void connectOutputs () throw (nidas::util::IOException)
 
void connectProcessors () throw (nidas::util::IOException, nidas::util::InvalidParameterException)
 
void disconnectProcessors () throw ()
 
void closeOutputs () throw ()
 
void interrupt ()
 
void deleteDataThreads () throw ()
 
void joinDataThreads () throw ()
 
void connect (SampleOutput *) throw ()
 Implementation of SampleConnectionRequester connect methods. More...
 
void disconnect (SampleOutput *) throw ()
 How SampleOutputs notify their SampleConnectionRequester that they wish to be closed, likely do to an IOException. More...
 
void connect (SampleInput *) throw ()
 DSMEngine does not receive SampleInputs, so this will die with an assert. More...
 
void disconnect (SampleInput *) throw ()
 DSMEngine does not receive SampleInputs, so these will die with an assert. More...
 
 DSMEngine (const DSMEngine &)
 No copy. More...
 
DSMEngineoperator= (const DSMEngine &)
 No assignment. More...
 

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). More...
 
std::string _configFile
 Name of XML configuration file. More...
 
nidas::util::Inet4SocketAddress _configSockAddr
 Address to use when fishing for the XML configuration. More...
 
Project_project
 
DSMConfig_dsmConfig
 
SensorHandler_selector
 
SamplePipeline_pipeline
 
DSMEngineStat_statusThread
 A thread that generates streaming XML time and status. More...
 
DSMEngineIntf_xmlrpcThread
 This thread provides XML-based Remote Procedure calls. More...
 
std::set< SampleOutput * > _outputSet
 Connected SampleOutputs. More...
 
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

Enumerator
DSM_STOP 
DSM_RUN 
DSM_QUIT 
DSM_RESTART 
DSM_REBOOT 
DSM_SHUTDOWN 
Enumerator
DSM_RUNNING 
DSM_ERROR 
DSM_STOPPED 

Constructor & Destructor Documentation

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

No copy.

Member Function Documentation

void DSMEngine::closeOutputs ( )
throw (
)
private
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 nidas::util::Logger::getInstance(), nidas::util::Logger::log(), and LOG_INFO.

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

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

void DSMEngine::connectOutputs ( )
throw (nidas::util::IOException
)
private
void DSMEngine::connectProcessors ( )
throw (nidas::util::IOException,
nidas::util::InvalidParameterException
)
private
void DSMEngine::deleteDataThreads ( )
throw (
)
private
void DSMEngine::disconnect ( SampleOutput output)
throw (
)
privatevirtual
void nidas::core::DSMEngine::disconnect ( SampleInput )
throw (
)
inlineprivate

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

void DSMEngine::disconnectProcessors ( )
throw (
)
private
enum command nidas::core::DSMEngine::getCommand ( ) const
inline

References _command.

Referenced by main().

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

References _dsmConfig.

Referenced by nidas::core::DSMEngineStat::run().

static DSMEngine* nidas::core::DSMEngine::getInstance ( )
inlinestatic
const SensorHandler* nidas::core::DSMEngine::getSensorHandler ( ) const
inline

References _selector.

Referenced by nidas::core::DSMEngineStat::run().

void DSMEngine::initialize ( xercesc::DOMDocument *  projectDoc)
throw (nidas::util::InvalidParameterException
)
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.

Referenced by run().

void DSMEngine::initLogger ( )

Initialize the Logger.

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

Referenced by main().

int DSMEngine::initProcess ( )

Initialize various process parameters, uid, etc.

References _app, nidas::core::NidasApp::checkPidFile(), nidas::core::NidasApp::lockMemory(), and nidas::core::NidasApp::setupProcess().

Referenced by main().

void DSMEngine::interrupt ( )
private
void DSMEngine::joinDataThreads ( )
throw (
)
private
void DSMEngine::killXmlRpcThread ( )
throw (
)
private
int DSMEngine::main ( int  argc,
char **  argv 
)
throw (
)
static
void DSMEngine::openSensors ( )
throw (nidas::util::IOException
)
private
DSMEngine& nidas::core::DSMEngine::operator= ( const DSMEngine )
private

No assignment.

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

Quit the main loop.

References _myThreadId.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

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

References DSM_QUIT, DSM_REBOOT, and DSM_SHUTDOWN.

Referenced by run().

void DSMEngine::reboot ( )

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

References _command, _myThreadId, and DSM_REBOOT.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

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
devname,:string matching the "device" XmlRpc parameter, typically the device name.

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

Referenced by nidas::dynld::raf::PSI9116_Sensor::open(), and nidas::dynld::raf::DSMAnalogSensor::open().

void DSMEngine::restart ( )

Restarts the main loop (for the XMLRPC call).

References _myThreadId.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

int DSMEngine::run ( )
throw (
)
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.

Referenced by DSMEngine().

void DSMEngine::shutdown ( )

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

References _command, _myThreadId, and DSM_SHUTDOWN.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

void DSMEngine::start ( )

Starts the main loop (for the XMLRPC call).

References _command, _myThreadId, and DSM_RUN.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

void DSMEngine::startXmlRpcThread ( )
throw (nidas::util::Exception
)
private
void DSMEngine::stop ( )

Stops the main loop (for the XMLRPC call).

References _command, _myThreadId, and DSM_STOP.

Referenced by nidas::core::DSMEngineIntf::DSMAction::execute().

void DSMEngine::usage ( )
void DSMEngine::waitForSignal ( int  secs)
private

Unblock and wait for signals of interest.

References _command, _signalMask, DSM_QUIT, DSM_RESTART, nidas::util::Exception::errnoToString(), ILOG, PLOG, timeoutSecs, and WLOG.

Referenced by run().

Member Data Documentation

NidasApp nidas::core::DSMEngine::_app
private
enum command nidas::core::DSMEngine::_command
private
std::string nidas::core::DSMEngine::_configFile
private

Name of XML configuration file.

If empty, multicast for config.

Referenced by parseRunstring(), and run().

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

Address to use when fishing for the XML configuration.

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

bool nidas::core::DSMEngine::_disableAutoconfig
private
DSMConfig* nidas::core::DSMEngine::_dsmConfig
private
bool nidas::core::DSMEngine::_externalControl
private
DSMEngine * DSMEngine::_instance = 0
staticprivate

Referenced by getInstance().

int nidas::core::DSMEngine::_logLevel
private
pthread_t nidas::core::DSMEngine::_myThreadId
private

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

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

Referenced by closeOutputs().

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

Connected SampleOutputs.

Referenced by closeOutputs().

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

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

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

Referenced by run().

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

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

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

A thread that generates streaming XML time and status.

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

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.

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

This thread provides XML-based Remote Procedure calls.

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

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

Referenced by parseRunstring().

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

Referenced by parseRunstring().


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