remove plugin from exampleDatabase
This commit is contained in:
@ -4,4 +4,3 @@ include "registerChannelProviderLocal.dbd"
|
|||||||
include "dbPv.dbd"
|
include "dbPv.dbd"
|
||||||
include "powerSupplyRegister.dbd"
|
include "powerSupplyRegister.dbd"
|
||||||
registrar("exampleDatabaseRegister")
|
registrar("exampleDatabaseRegister")
|
||||||
registrar("exampleMonitorPluginRegister")
|
|
||||||
|
@ -7,13 +7,10 @@ include $(TOP)/configure/CONFIG
|
|||||||
DBD += exampleDatabase.dbd
|
DBD += exampleDatabase.dbd
|
||||||
|
|
||||||
INC += exampleDatabase.h
|
INC += exampleDatabase.h
|
||||||
INC += exampleMonitorPlugin.h
|
|
||||||
|
|
||||||
LIBRARY += exampleDatabase
|
LIBRARY += exampleDatabase
|
||||||
exampleDatabase_SRCS += exampleDatabase.cpp
|
exampleDatabase_SRCS += exampleDatabase.cpp
|
||||||
exampleDatabase_SRCS += exampleMonitorPlugin.cpp
|
|
||||||
exampleDatabase_SRCS += exampleDatabaseRegister.cpp
|
exampleDatabase_SRCS += exampleDatabaseRegister.cpp
|
||||||
exampleDatabase_SRCS += exampleMonitorPluginRegister.cpp
|
|
||||||
exampleDatabase_LIBS += powerSupply
|
exampleDatabase_LIBS += powerSupply
|
||||||
exampleDatabase_LIBS += pvDatabase
|
exampleDatabase_LIBS += pvDatabase
|
||||||
exampleDatabase_LIBS += pvAccess
|
exampleDatabase_LIBS += pvAccess
|
||||||
|
@ -1,2 +1 @@
|
|||||||
registrar("exampleDatabaseRegister")
|
registrar("exampleDatabaseRegister")
|
||||||
registrar("exampleMonitorPluginRegister")
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <pv/serverContext.h>
|
#include <pv/serverContext.h>
|
||||||
|
|
||||||
#include <pv/exampleDatabase.h>
|
#include <pv/exampleDatabase.h>
|
||||||
#include <pv/exampleMonitorPlugin.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using std::tr1::static_pointer_cast;
|
using std::tr1::static_pointer_cast;
|
||||||
@ -37,7 +36,6 @@ int main(int argc,char *argv[])
|
|||||||
PVDatabasePtr master = PVDatabase::getMaster();
|
PVDatabasePtr master = PVDatabase::getMaster();
|
||||||
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
|
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
|
||||||
ExampleDatabase::create();
|
ExampleDatabase::create();
|
||||||
ExampleMonitorPlugin::create();
|
|
||||||
ServerContext::shared_pointer ctx =
|
ServerContext::shared_pointer ctx =
|
||||||
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
|
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
|
||||||
cout << "exampleDatabase\n";
|
cout << "exampleDatabase\n";
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
/* exampleMonitorPlugin.h */
|
|
||||||
/**
|
|
||||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
|
||||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
|
||||||
* in file LICENSE that is included with this distribution.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @author mrk
|
|
||||||
* @date 2014.04.16
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <pv/monitorPlugin.h>
|
|
||||||
|
|
||||||
#define epicsExportSharedSymbols
|
|
||||||
#include <pv/exampleMonitorPlugin.h>
|
|
||||||
|
|
||||||
using namespace epics::pvData;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
|
||||||
|
|
||||||
static string pluginName("onChange");
|
|
||||||
|
|
||||||
class OnChangePlugin;
|
|
||||||
typedef std::tr1::shared_ptr<OnChangePlugin> OnChangePluginPtr;
|
|
||||||
class OnChangePluginCreator;
|
|
||||||
typedef std::tr1::shared_ptr<OnChangePluginCreator> OnChangePluginCreatorPtr;
|
|
||||||
|
|
||||||
class OnChangePlugin : public MonitorPlugin
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~OnChangePlugin(){}
|
|
||||||
OnChangePlugin() {}
|
|
||||||
bool init(
|
|
||||||
FieldConstPtr const &field,
|
|
||||||
StructureConstPtr const &top,
|
|
||||||
PVStructurePtr const &pvFieldOptions)
|
|
||||||
{
|
|
||||||
pvField = getPVDataCreate()->createPVField(field);
|
|
||||||
raiseMonitor = true;
|
|
||||||
if(pvFieldOptions) {
|
|
||||||
PVStringPtr pvString =
|
|
||||||
pvFieldOptions->getSubField<PVString>("raiseMonitor");
|
|
||||||
if(pvString) {
|
|
||||||
string value = pvString->get();
|
|
||||||
if(value.compare("false")==0) raiseMonitor = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual string &getName(){return pluginName;}
|
|
||||||
virtual bool causeMonitor(
|
|
||||||
PVFieldPtr const &pvNew,
|
|
||||||
PVStructurePtr const &pvTop,
|
|
||||||
MonitorElementPtr const &monitorElement)
|
|
||||||
{
|
|
||||||
bool isSame = (*pvNew == *pvField);
|
|
||||||
if(isSame) return false;
|
|
||||||
pvField->copyUnchecked(*pvNew);
|
|
||||||
return raiseMonitor;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
PVFieldPtr pvField;
|
|
||||||
bool raiseMonitor;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OnChangePluginCreator : public MonitorPluginCreator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual string &getName(){return pluginName;}
|
|
||||||
virtual MonitorPluginPtr create(
|
|
||||||
FieldConstPtr const &field,
|
|
||||||
StructureConstPtr const &top,
|
|
||||||
PVStructurePtr const &pvFieldOptions)
|
|
||||||
{
|
|
||||||
OnChangePluginPtr plugin(new OnChangePlugin());
|
|
||||||
bool result = plugin->init(field,top,pvFieldOptions);
|
|
||||||
if(!result) return MonitorPluginPtr();
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void ExampleMonitorPlugin::create()
|
|
||||||
{
|
|
||||||
static OnChangePluginCreatorPtr plugin;
|
|
||||||
static Mutex mutex;
|
|
||||||
Lock xx(mutex);
|
|
||||||
if(!plugin) {
|
|
||||||
plugin = OnChangePluginCreatorPtr(new OnChangePluginCreator());
|
|
||||||
MonitorPluginManager::get()->addPlugin(pluginName,plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
/* exampleMonitorPlugin.h */
|
|
||||||
/**
|
|
||||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
|
||||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
|
||||||
* in file LICENSE that is included with this distribution.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @author mrk
|
|
||||||
* @date 2014.04.16
|
|
||||||
*/
|
|
||||||
#ifndef EXAMPLEMONITORPLUGIN_H
|
|
||||||
#define EXAMPLEMONITORPLUGIN_H
|
|
||||||
|
|
||||||
#ifdef epicsExportSharedSymbols
|
|
||||||
# define examplemonitorPluginEpicsExportSharedSymbols
|
|
||||||
# undef epicsExportSharedSymbols
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pv/pvDatabase.h>
|
|
||||||
#include <pv/monitorPlugin.h>
|
|
||||||
|
|
||||||
#ifdef examplemonitorPluginEpicsExportSharedSymbols
|
|
||||||
# define epicsExportSharedSymbols
|
|
||||||
# undef examplemonitorPluginEpicsExportSharedSymbols
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <shareLib.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
|
||||||
|
|
||||||
class epicsShareClass ExampleMonitorPlugin{
|
|
||||||
public:
|
|
||||||
static void create();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif /* EXAMPLEMONITORPLUGIN_H */
|
|
@ -1,65 +0,0 @@
|
|||||||
/*exampleMonitorPlugin.cpp */
|
|
||||||
/**
|
|
||||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
|
||||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
|
||||||
* in file LICENSE that is included with this distribution.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @author mrk
|
|
||||||
* @date 2013.07.24
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Author: Marty Kraimer */
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <cantProceed.h>
|
|
||||||
#include <epicsStdio.h>
|
|
||||||
#include <epicsMutex.h>
|
|
||||||
#include <epicsEvent.h>
|
|
||||||
#include <epicsThread.h>
|
|
||||||
#include <iocsh.h>
|
|
||||||
|
|
||||||
#include <pv/pvIntrospect.h>
|
|
||||||
#include <pv/pvData.h>
|
|
||||||
#include <pv/pvAccess.h>
|
|
||||||
#include <pv/pvDatabase.h>
|
|
||||||
|
|
||||||
#include <epicsExport.h>
|
|
||||||
#include <pv/exampleMonitorPlugin.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace epics::pvData;
|
|
||||||
using namespace epics::pvAccess;
|
|
||||||
using namespace epics::pvDatabase;
|
|
||||||
|
|
||||||
|
|
||||||
static const iocshFuncDef exampleMonitorPluginFuncDef = {
|
|
||||||
"exampleMonitorPlugin", 0,0 };
|
|
||||||
|
|
||||||
|
|
||||||
static void exampleMonitorPluginCallFunc(const iocshArgBuf *args)
|
|
||||||
{
|
|
||||||
ExampleMonitorPlugin::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void exampleMonitorPluginRegister(void)
|
|
||||||
{
|
|
||||||
std::cout << "exampleMonitorPluginRegister\n";
|
|
||||||
static int firstTime = 1;
|
|
||||||
if (firstTime) {
|
|
||||||
firstTime = 0;
|
|
||||||
iocshRegister(&exampleMonitorPluginFuncDef, exampleMonitorPluginCallFunc);
|
|
||||||
}
|
|
||||||
std::cout << "exampleMonitorPluginRegister returning\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
epicsExportRegistrar(exampleMonitorPluginRegister);
|
|
||||||
}
|
|
@ -25,7 +25,6 @@
|
|||||||
#include <pv/lock.h>
|
#include <pv/lock.h>
|
||||||
#include <pv/pvType.h>
|
#include <pv/pvType.h>
|
||||||
#include <pv/pvData.h>
|
#include <pv/pvData.h>
|
||||||
#include <pv/monitorPlugin.h>
|
|
||||||
#include <pv/pvCopy.h>
|
#include <pv/pvCopy.h>
|
||||||
#include <pv/pvAccess.h>
|
#include <pv/pvAccess.h>
|
||||||
#include <pv/status.h>
|
#include <pv/status.h>
|
||||||
|
Reference in New Issue
Block a user