nidas v1.2.3
DSMEngineIntf.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2005, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26
27#ifndef NIDAS_CORE_ENGINEINTF_H
28#define NIDAS_CORE_ENGINEINTF_H
29
30#include "XmlRpcThread.h"
32#include <xmlrpcpp/XmlRpcException.h>
33
34#include <iostream>
35
36namespace nidas { namespace core {
37
38class DSMSensor;
39
45{
46public:
48
52 int run();
53
59 void registerSensor(const std::string& devname, DSMSensor* sensor)
60 {
61 _sensorAction.registerSensor(devname,sensor);
62 }
63
64private:
65
70 class DSMAction : public XmlRpc::XmlRpcServerMethod
71 {
72 public:
73 DSMAction(XmlRpc::XmlRpcServer* s) : XmlRpc::XmlRpcServerMethod("DSMAction", s) {}
74 void execute(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result) throw();
75 std::string help() { return std::string("parameter \"action\" should be \"start\", \"stop\", \"restart\", \"quit\", \"reboot\" or \"shutdown\""); }
76
77 };
78
85 class SensorAction : public XmlRpc::XmlRpcServerMethod
86 {
87 public:
88 SensorAction(XmlRpc::XmlRpcServer* s) : XmlRpc::XmlRpcServerMethod("SensorAction", s),_nameToSensor() {}
89 void execute(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result) throw();
90
91 std::string help() { return std::string("parameter \"device\" should match a device name for a DSMSensor that has registered itself with DSMEngineIntf"); }
92
93 void registerSensor(const std::string& devname, DSMSensor* sensor)
94 {
95 _nameToSensor[devname] = sensor;
96 }
97
98 private:
99 std::map<std::string,DSMSensor*> _nameToSensor;
100 };
101
102 XmlRpc::XmlRpcServer* _xmlrpc_server;
105
108
111};
112
113}} // namespace nidas namespace core
114
115#endif
Send a command to a DSMEngine.
Definition DSMEngineIntf.h:71
DSMAction(XmlRpc::XmlRpcServer *s)
Definition DSMEngineIntf.h:73
void execute(XmlRpc::XmlRpcValue &params, XmlRpc::XmlRpcValue &result)
Definition DSMEngineIntf.cc:52
std::string help()
Definition DSMEngineIntf.h:75
Invoke an executeXmlRpc() method on a DSMSensor.
Definition DSMEngineIntf.h:86
std::map< std::string, DSMSensor * > _nameToSensor
Definition DSMEngineIntf.h:99
void execute(XmlRpc::XmlRpcValue &params, XmlRpc::XmlRpcValue &result)
Definition DSMEngineIntf.cc:76
SensorAction(XmlRpc::XmlRpcServer *s)
Definition DSMEngineIntf.h:88
void registerSensor(const std::string &devname, DSMSensor *sensor)
Definition DSMEngineIntf.h:93
std::string help()
Definition DSMEngineIntf.h:91
A thread that provides XML-based Remote Procedure Calls to web interfaces from the DSMEngine.
Definition DSMEngineIntf.h:45
DSMAction _dsmAction
Definition DSMEngineIntf.h:103
int run()
Definition DSMEngineIntf.cc:98
XmlRpc::XmlRpcServer * _xmlrpc_server
Definition DSMEngineIntf.h:102
DSMEngineIntf(const DSMEngineIntf &)
Copy not needed.
void registerSensor(const std::string &devname, DSMSensor *sensor)
Register a sensor to have its executeXmlRpc() method called when a "SensorAction" XmlRpc request come...
Definition DSMEngineIntf.h:59
SensorAction _sensorAction
Definition DSMEngineIntf.h:104
DSMEngineIntf()
Definition DSMEngineIntf.cc:44
DSMEngineIntf & operator=(const DSMEngineIntf &)
Assignment not needed.
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
A thread that provides XML-based Remote Procedure Calls to web interfaces.
Definition XmlRpcThread.h:40
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31