32 Commits
4.0.2 ... 4.1.0

Author SHA1 Message Date
Ralph Lange
b20fd4c5c5 jenkins: set dependency versions (part of epics-base/jenkins-jobs#10) 2015-09-04 13:02:29 +02:00
Ralph Lange
409b045779 jenkins: add configurable dependent branch versions 2015-09-03 13:50:03 +02:00
mrkraimer
fda81767a5 update README 2015-09-03 06:40:42 -04:00
Ralph Lange
fe1b167e23 jenkins: remove hgweb job; split build and doc jobs; update EPICS Base version 2015-08-18 16:27:57 +02:00
Ralph Lange
dc0f20cc5f Add QtCreator pattern to .gitignore 2015-08-18 16:14:36 +02:00
dhickin
6e7d887e6e Merge pull request #2 from dhickin/replace_calls_getScalarArrayField
Replace calls of deprecated PVStructure::getScalarArrayField
2015-07-28 17:01:30 +01:00
Dave Hickin
699a6cd8b4 Remove unused argument in testPVScalarArray 2015-07-24 10:45:01 +01:00
Dave Hickin
70454a6006 Remove calls of deprecated getScalarArrayField 2015-07-24 10:42:45 +01:00
dhickin
deebe46378 Merge pull request #1 from dhickin/replace_deprecated_getDerivedTypeField
Replace calls of deprecated functions for getting subfields of a PVStructure
2015-07-23 16:36:20 +01:00
Ralph Lange
18dc4279ad jenkins: fix URL for pvAccessCPP tar 2015-07-17 17:23:14 +02:00
Ralph Lange
61e9dc0368 jenkins: use pvAccessCPP without microbench 2015-07-17 17:09:14 +02:00
Dave Hickin
6b0d1ce49b Replace calls of deprecated subfield functions
The non-template functions for getting subfields of a PVStructure, such
as PVStructure::getIntField were marked as deprecated in the 4.4 release
and now generate build warnings. Replace calls of these functions with
calls of the template function getSubField, e.g. getSubField<PVInt>.
2015-07-15 19:06:04 +01:00
Marty Kraimer
81b160d7b6 finish hg to git; remove qtcreator files 2015-06-09 09:28:12 -04:00
dhickin
4e22a056d2 Fixed win32 build error. 2015-06-08 13:12:15 +01:00
Marty Kraimer
4af5ba92d9 had wrong name for ifdef 2015-03-30 06:39:39 -04:00
Matej Sekoranja
e79c70c74c ContextLocal added 2015-02-24 10:59:30 +01:00
Marty Kraimer
c0694e2d69 remove plugin from exampleDatabase 2015-02-23 16:14:17 -05:00
Matej Sekoranja
36dac883f4 using new copy API 2015-02-18 10:04:19 +01:00
Andrew Johnson
35dcbf35b3 Fix */iocBoot/Makefile include lines 2015-02-09 11:44:02 -06:00
Marty Kraimer
30dd2ed046 simplify monitors; cleanup code; fix race condidition for monitor cleanup 2015-02-06 14:49:28 -05:00
Ralph Lange
e30e4f3638 jenkins: fix cloudbees script (commands must return 0) 2014-12-19 14:22:01 +01:00
Ralph Lange
15578d1647 jenkins: create and update documentation in only one build configuration 2014-12-19 13:18:45 +01:00
Ralph Lange
e3e270e242 jenkins: fix artefact (binary CB distribution tar) name 2014-12-13 16:00:01 +01:00
Marty Kraimer
ec44251df0 changes for doxygen 2014-12-12 09:28:49 -05:00
Marty Kraimer
3344165f19 commit after merge 2014-12-12 08:20:07 -05:00
Marty Kraimer
c2ea402be0 one more race condition when server server exits 2014-12-12 08:18:56 -05:00
Ralph Lange
0535ff990d Merge jenkins changes 2014-12-12 13:24:11 +01:00
Ralph Lange
18ff90e641 jenkins: make EPICS base a parameter in jenkins job 2014-12-12 13:21:37 +01:00
Marty Kraimer
a781195458 more changes for possible race conditions in pvCopyMonitor.cpp 2014-12-12 07:03:55 -05:00
Marty Kraimer
1a641f0d1b fix race condition between startMonitoring and beginGroupPut in pvCopyMonitor.cpp 2014-12-12 06:25:45 -05:00
Marty Kraimer
0e6639c149 instead of just isDestroyed monitorFactory keeps state idle,active,destroyed 2014-12-09 09:31:32 -05:00
Marty Kraimer
93ba23aeb8 merge branch release/4.0 2014-12-04 09:22:25 -05:00
46 changed files with 2355 additions and 1919 deletions

13
.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
bin/
lib/
doc/
include/
db/
dbd/
documentation/html
documentation/*.tag
envPaths
configure/*.local
!configure/ExampleRELEASE.local
**/O.*
QtC-*

View File

@@ -1,8 +0,0 @@
[branchname]
master = master
develop = default
feature = feature/
release = release/
hotfix = hotfix/
support = support/

View File

@@ -1,11 +0,0 @@
^QtC-
bin/
lib/
doc/
include/
db/
dbd/
documentation/html
envPaths
configure/.*\.local
/O\..*

View File

@@ -1,9 +0,0 @@
bba6a2491bdf73681cef01caf0bd89c87d7989cd 0.9.1
abdc90bf52a0c31e24e2f9a079ef72350ee31686 before_merge_changesAfter3_0_2
395f48d5196dde5bf7f24a1849aee3f8d92e91b8 3.1.0
e2e041fa7d04a37836a4343589077001588ae031 4.0.0
e2e041fa7d04a37836a4343589077001588ae031 4.0.0
42dbe8a17f851861a16be7d426ef1206324aa197 4.0.0
42dbe8a17f851861a16be7d426ef1206324aa197 4.0.0
85d46a2614f925ccb423d6abd5dfe20d42fb5099 4.0.0
541b0a7a645c63d136e397994ed0ab7178cf02cf 4.0.1

2489
Doxyfile

File diff suppressed because it is too large Load Diff

38
README.md Normal file
View File

@@ -0,0 +1,38 @@
pvaDatabaseCPP
============
A brief description of a pvDatabase is that it is a set of network accessible, smart, memory resident records. Each record has data composed of a top level PVStructure. Each record has a name which is the channelName for pvAccess. A local Channel Provider implements the complete ChannelProvider and Channel interfaces as defined by pvAccess. The local provider provides access to the records in the pvDatabase. This local provider is accessed by the remote pvAccess server. A record is smart because code can be attached to a record, which is accessed via a method named process.
pvaDatabase is a synchronous Database interface to pvAccess,
which is callback based.
pvaDatabase is thus easier to use than pvAccess itself.
See documentation/pvaDatabaseCPP.html for details.
Building
--------
If a proper RELEASE.local file exists one directory level above pvaDatabaseCPP
then just type:
make
If RELEASE.local does not exist then look at <b>configure/RELEASE</b>
for directions for how to build.
Examples
------------
The examples require the database in pvaDatabaseTestCPP.
For example:
mrk> pwd
/home/epicsv4/pvaDatabaseTestCPP/database/iocBoot/exampleDatabase
mrk> ../../bin/linux-x86_64/exampleDatabase st.cmd
Status
------
* The API is for release 4.5.0-pre1

View File

@@ -59,9 +59,9 @@ bool ArrayPerformance::init()
{
initPVRecord();
PVScalarArrayPtr pvScalarArray = getPVStructure()->getScalarArrayField("value",pvLong);
if(!pvScalarArray) return false;
pvValue = static_pointer_cast<PVLongArray>(pvScalarArray);
PVLongArrayPtr pvLongArray = getPVStructure()->getSubField<PVLongArray>("value");
if(!pvLongArray) return false;
pvValue = pvLongArray;
ArrayPerformancePtr xxx = dynamic_pointer_cast<ArrayPerformance>(getPtrSelf());
arrayPerformanceThread = ArrayPerformanceThreadPtr(new ArrayPerformanceThread(xxx));
arrayPerformanceThread->init();

View File

@@ -4,4 +4,3 @@ include "registerChannelProviderLocal.dbd"
include "dbPv.dbd"
include "powerSupplyRegister.dbd"
registrar("exampleDatabaseRegister")
registrar("exampleMonitorPluginRegister")

View File

@@ -3,5 +3,5 @@ include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard example*)
include $(EPICS_BASE)/configure/RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -7,13 +7,10 @@ include $(TOP)/configure/CONFIG
DBD += exampleDatabase.dbd
INC += exampleDatabase.h
INC += exampleMonitorPlugin.h
LIBRARY += exampleDatabase
exampleDatabase_SRCS += exampleDatabase.cpp
exampleDatabase_SRCS += exampleMonitorPlugin.cpp
exampleDatabase_SRCS += exampleDatabaseRegister.cpp
exampleDatabase_SRCS += exampleMonitorPluginRegister.cpp
exampleDatabase_LIBS += powerSupply
exampleDatabase_LIBS += pvDatabase
exampleDatabase_LIBS += pvAccess

View File

@@ -1,2 +1 @@
registrar("exampleDatabaseRegister")
registrar("exampleMonitorPluginRegister")

View File

@@ -10,48 +10,27 @@
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <vector>
#include <iostream>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/exampleDatabase.h>
#include <pv/exampleMonitorPlugin.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
ExampleDatabase::create();
ExampleMonitorPlugin::create();
ServerContext::shared_pointer ctx =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleDatabase\n";
PVStringArrayPtr pvNames = master->getRecordNames();
cout << "recordNames" << endl << *pvNames << endl;
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
ctx->destroy();
epicsThreadSleep(1.0);
channelProvider->destroy();
ContextLocal::shared_pointer contextLocal = ContextLocal::create();
contextLocal->start();
cout << "pvAccess server exampleDatabase running..." << endl;
epics::pvData::PVStringArrayPtr pvNames = PVDatabase::getMaster()->getRecordNames();
cout << "Hosted records: " << endl << *pvNames << endl;
contextLocal->waitForExit();
return 0;
}

View File

@@ -1,101 +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/convert.h>
#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");
static ConvertPtr convert(getConvert());
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 = convert->equals(pvNew,pvField);
if(isSame) return false;
convert->copy(pvNew,pvField);
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);
}
}
}}

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -3,5 +3,5 @@ include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard example*)
include $(EPICS_BASE)/configure/RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -10,7 +10,6 @@
*/
#include <pv/standardPVField.h>
#include <pv/convert.h>
#define epicsExportSharedSymbols
#include <pv/exampleLink.h>
@@ -46,8 +45,7 @@ ExampleLink::ExampleLink(
PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure),
providerName(providerName),
channelName(channelName),
convert(getConvert())
channelName(channelName)
{
}
@@ -63,8 +61,7 @@ bool ExampleLink::init()
PVStructurePtr pvStructure = getPVRecordStructure()->getPVStructure();
pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
pvAlarm.attach(pvStructure->getSubField("alarm"));
pvValue = static_pointer_cast<PVDoubleArray>(
pvStructure->getScalarArrayField("value",pvDouble));
pvValue = pvStructure->getSubField<PVDoubleArray>("value");
if(!pvValue) {
return false;
}
@@ -95,8 +92,7 @@ bool ExampleLink::init()
<< status.getMessage() << endl;
return false;
}
getPVValue = static_pointer_cast<PVDoubleArray>(
getPVStructure->getScalarArrayField("value",pvDouble));
getPVValue = getPVStructure->getSubField<PVDoubleArray>("value");
if(!getPVValue) {
cout << getRecordName() << " get value not PVDoubleArray" << endl;
return false;
@@ -121,7 +117,7 @@ void ExampleLink::process()
}
alarm.setSeverity(severity);
} else {
convert->copy(getPVValue,pvValue);
pvValue->copyUnchecked(*getPVValue);
}
alarm.setMessage(status.getMessage());
pvAlarm.set(alarm);
@@ -160,7 +156,7 @@ void ExampleLink::getDone(
BitSetPtr const & bitSet)
{
this->status = status;
convert->copyStructure(pvStructure,getPVStructure);
getPVStructure->copyUnchecked(*pvStructure);
this->bitSet = bitSet;
event.signal();
}

View File

@@ -83,7 +83,6 @@ private:
epics::pvData::PVStructurePtr const & pvStructure);
std::string providerName;
std::string channelName;
epics::pvData::ConvertPtr convert;
epics::pvData::PVDoubleArrayPtr pvValue;
epics::pvData::PVTimeStamp pvTimeStamp;
epics::pvData::TimeStamp timeStamp;

View File

@@ -3,5 +3,5 @@ include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard power*)
include $(EPICS_BASE)/configure/RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -10,24 +10,15 @@
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/recordList.h>
#include <pv/powerSupply.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
@@ -36,37 +27,30 @@ using namespace epics::pvDatabase;
int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
PVRecordPtr pvRecord;
bool result(false);
bool result = false;
string recordName;
recordName = "powerSupply";
PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create(recordName,pv);
result = master->addRecord(pvRecord);
cout << "result of addRecord " << recordName << " " << result << endl;
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
if (!result) cout<< "record " << recordName << " not added" << endl;
recordName = "laptoprecordListPGRPC";
pvRecord = RecordListRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
ServerContext::shared_pointer pvaServer =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "powerSupply\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
if (!result) cout<< "record " << recordName << " not added" << endl;
ContextLocal::shared_pointer contextLocal = ContextLocal::create();
contextLocal->start(true);
}
pvaServer->shutdown();
epicsThreadSleep(1.0);
pvaServer->destroy();
channelProvider->destroy();
return 0;
}

View File

@@ -3,5 +3,5 @@ include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard example*)
include $(EPICS_BASE)/configure/RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -66,9 +66,9 @@ bool ExampleServer::init()
initPVRecord();
PVFieldPtr pvField;
pvArgumentValue = getPVStructure()->getStringField("argument.value");
pvArgumentValue = getPVStructure()->getSubField<PVString>("argument.value");
if(pvArgumentValue.get()==NULL) return false;
pvResultValue = getPVStructure()->getStringField("result.value");
pvResultValue = getPVStructure()->getSubField<PVString>("result.value");
if(pvResultValue.get()==NULL) return false;
pvTimeStamp.attach(getPVStructure()->getSubField("result.timeStamp"));
return true;

View File

@@ -8,8 +8,8 @@
* @author mrk
* @date 2013.04.02
*/
#ifndef EXAMPLECOUNTER_H
#define EXAMPLECOUNTER_H
#ifndef EXAMPLESERVER_H
#define EXAMPLESERVER_H
#ifdef epicsExportSharedSymbols
# define exampleServerEpicsExportSharedSymbols
@@ -58,4 +58,4 @@ private:
}}
#endif /* EXAMPLECOUNTER_H */
#endif /* EXAMPLESERVER_H */

View File

@@ -10,24 +10,15 @@
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/exampleServer.h>
#include <pv/traceRecord.h>
#include <pv/recordList.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
@@ -36,38 +27,35 @@ using namespace epics::exampleServer;
int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
PVRecordPtr pvRecord;
bool result(false);
bool result = false;
string recordName;
recordName = "exampleServer";
pvRecord = ExampleServer::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
recordName = "laptoprecordListPGRPC";
pvRecord = RecordListRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
ServerContext::shared_pointer pvaServer =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
ContextLocal::shared_pointer contextLocal = ContextLocal::create();
contextLocal->start();
PVStringArrayPtr pvNames = master->getRecordNames();
shared_vector<const string> names = pvNames->view();
for(size_t i=0; i<names.size(); ++i) cout << names[i] << endl;
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
pvaServer->shutdown();
epicsThreadSleep(1.0);
pvaServer->destroy();
channelProvider->destroy();
contextLocal->waitForExit();
return 0;
}

View File

@@ -1,13 +1,28 @@
# pvDatabaseCPP
# pvDatabase C++ implementation
# Jenkins @ Cloudbees build script
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <Ralph.Lange@gmx.de>
# Author: Ralph Lange <ralph.lange@gmx.de>
# Copyright (C) 2014 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# Copyright (C) 2014-2015 ITER Organization.
# All rights reserved. Use is subject to license terms.
###########################################
# Determine EPICS Base version
DEFAULT_BASE=3.14.12.5
BASE=${1:-${DEFAULT_BASE}}
USE_MB=${2:-"MB_NO"}
# Dependent module branches (empty = master)
PVCOMMON_BRANCH="Release-4.1-"
PVDATA_BRANCH="Release-5.0-"
PVACCESS_BRANCH="Release-4.1-"
PVASRV_BRANCH="Release-0.11-"
###########################################
# Fetch and unpack dependencies
@@ -17,17 +32,20 @@ rm -fr ${STUFF}
mkdir -p ${STUFF}
cd ${STUFF}
wget -nv https://openepics.ci.cloudbees.com/job/Base-3.14.12.3_Build/lastSuccessfulBuild/artifact/baseR3.14.12.3.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/Doxygen-1.8.3_Build/lastSuccessfulBuild/artifact/doxygen-1.8.3.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvData_CPP_Build/lastSuccessfulBuild/artifact/pvData.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvAccess_CPP_Build/lastSuccessfulBuild/artifact/pvAccess.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvaSrv_CPP_Build/lastSuccessfulBuild/artifact/pvaSrv.CB-dist.tar.gz
tar -xzf baseR3.14.12.3.CB-dist.tar.gz
tar -xzf doxygen-1.8.3.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/Base-${BASE}_Build/lastSuccessfulBuild/artifact/base-${BASE}.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvDataCPP_${PVDATA_BRANCH}Build/BASE=${BASE},USE_MB=MB_NO/lastSuccessfulBuild/artifact/pvData.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvAccessCPP_${PVACCESS_BRANCH}Build/BASE=${BASE},USE_MB=${USE_MB}/lastSuccessfulBuild/artifact/pvAccess.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/pvaSrvCPP_${PVASRV_BRANCH}Build/BASE=${BASE},USE_MB=MB_NO/lastSuccessfulBuild/artifact/pvaSrv.CB-dist.tar.gz
tar -xzf base-${BASE}.CB-dist.tar.gz
tar -xzf pvData.CB-dist.tar.gz
tar -xzf pvAccess.CB-dist.tar.gz
tar -xzf pvaSrv.CB-dist.tar.gz
if [ "${USE_MB}" = "MB_YES" ]; then
wget -nv https://openepics.ci.cloudbees.com/job/pvCommonCPP_${PVCOMMON_BRANCH}Build/BASE=${BASE},USE_MB=MB_YES/lastSuccessfulBuild/artifact/pvCommon.CB-dist.tar.gz
tar -xzf pvCommon.CB-dist.tar.gz
fi
###########################################
# Build
@@ -43,7 +61,6 @@ EPICS_BASE=${EPICS_BASE}
EOF
make distclean all
doxygen
###########################################
# Test
@@ -53,9 +70,4 @@ doxygen
###########################################
# Create distribution
tar -czf pvDatabaseCPP.CB-dist.tar.gz lib include dbd COPYRIGHT LICENSE
###########################################
# Publish documentation
rsync -aP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvDatabaseCPP/tip
tar -czf pvDatabase.CB-dist.tar.gz lib include dbd COPYRIGHT LICENSE

46
jenkins/cloudbees_doc Normal file
View File

@@ -0,0 +1,46 @@
# pvDatabase C++ implementation
# Jenkins @ Cloudbees documentation generation and deployment
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <ralph.lange@gmx.de>
# Copyright (C) 2014 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# Copyright (C) 2014-2015 ITER Organization.
# All rights reserved. Use is subject to license terms.
###########################################
# Determine EPICS Base version
DEFAULT_BASE=3.14.12.5
BASE=${1:-${DEFAULT_BASE}}
###########################################
# Fetch and unpack dependencies
export STUFF=/tmp/stuff
rm -fr ${STUFF}
mkdir -p ${STUFF}
cd ${STUFF}
wget -nv https://openepics.ci.cloudbees.com/job/Doxygen-1.8.3_Build/lastSuccessfulBuild/artifact/doxygen-1.8.3.CB-dist.tar.gz
tar -xzf doxygen-1.8.3.CB-dist.tar.gz
###########################################
# Generate
cd ${WORKSPACE}
wget -nv https://openepics.ci.cloudbees.com/job/pvDatabaseCPP_Build/BASE=${BASE},USE_MB=MB_NO/lastSuccessfulBuild/artifact/pvDatabase.CB-dist.tar.gz
tar -xzf pvDatabase.CB-dist.tar.gz
export PATH=${STUFF}/bin:${PATH}
doxygen
###########################################
# Publish
rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvDatabaseCPP/tip

View File

@@ -1,20 +0,0 @@
# pvDatabaseCPP
# Jenkins @ Cloudbees hgweb sync script
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <Ralph.Lange@gmx.de>
# Copyright (C) 2014 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# All rights reserved. Use is subject to license terms.
###########################################
# Fetch complete repo
rm -fr hgweb
hg clone -U http://hg.code.sf.net/p/epics-pvdata/pvDatabaseCPP hgweb
###########################################
# Sync into SF webspace
rsync -aqP --delete --exclude=\.hg/hgrc -e ssh hgweb/.hg epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/repos/pvDatabaseCPP

View File

@@ -1 +0,0 @@
// ADD PREDEFINED MACROS HERE!

View File

@@ -1 +0,0 @@
[General]

View File

@@ -1,124 +0,0 @@
arrayPerformance/src/arrayPerformance.cpp
arrayPerformance/src/arrayPerformance.h
arrayPerformance/src/arrayPerformanceMain.cpp
arrayPerformance/src/longArrayGet.cpp
arrayPerformance/src/longArrayGet.h
arrayPerformance/src/longArrayGetMain.cpp
arrayPerformance/src/longArrayMonitor.cpp
arrayPerformance/src/longArrayMonitor.h
arrayPerformance/src/longArrayMonitorMain.cpp
arrayPerformance/src/longArrayPut.cpp
arrayPerformance/src/longArrayPut.h
arrayPerformance/src/longArrayPutMain.cpp
arrayPerformance/src/vectorPerformanceMain.cpp
exampleDatabase/ioc/src/O.linux-x86_64/exampleDatabase_registerRecordDeviceDriver.cpp
exampleDatabase/ioc/src/exampleDatabaseMain.cpp
exampleDatabase/src/exampleDatabase.cpp
exampleDatabase/src/exampleDatabase.h
exampleDatabase/src/exampleDatabaseMain.cpp
exampleDatabase/src/exampleDatabaseRegister.cpp
exampleLink/ioc/src/O.linux-x86_64/exampleLink_registerRecordDeviceDriver.cpp
exampleLink/ioc/src/exampleLinkMain.cpp
exampleLink/src/exampleLink.cpp
exampleLink/src/exampleLink.h
exampleLink/src/exampleLinkRegister.cpp
examplePowerSupply/ioc/src/O.linux-x86_64/powerSupply_registerRecordDeviceDriver.cpp
examplePowerSupply/ioc/src/powerSupplyMain.cpp
examplePowerSupply/src/powerSupplyMain.cpp
exampleServer/ioc/src/O.linux-x86_64/exampleServer_registerRecordDeviceDriver.cpp
exampleServer/ioc/src/exampleServerMain.cpp
exampleServer/src/exampleServer.cpp
exampleServer/src/exampleServer.h
exampleServer/src/exampleServerMain.cpp
exampleServer/src/exampleServerRegister.cpp
src/database/pvDatabase.cpp
src/database/pvDatabase.h
src/database/pvRecord.cpp
src/pvAccess/channelLocal.cpp
src/pvAccess/channelProviderLocal.cpp
src/pvAccess/channelProviderLocal.h
src/pvAccess/monitorAlgorithm.h
src/pvAccess/monitorFactory.cpp
src/pvAccess/pvCopy.cpp
src/pvAccess/pvCopy.h
src/pvAccess/registerChannelProviderLocal.cpp
src/special/recordList.cpp
src/special/recordList.h
src/special/traceRecord.cpp
src/special/traceRecord.h
test/src/powerSupply.cpp
test/src/powerSupply.h
test/src/powerSupplyRegister.cpp
test/src/testExampleRecord.cpp
test/src/testPVCopy.cpp
test/src/testPVRecord.cpp
arrayPerformance/include/pv/arrayPerformance.h
arrayPerformance/include/pv/longArrayGet.h
arrayPerformance/include/pv/longArrayMonitor.h
arrayPerformance/include/pv/longArrayPut.h
arrayPerformance/src/arrayPerformance.cpp
arrayPerformance/src/arrayPerformance.h
arrayPerformance/src/arrayPerformanceMain.cpp
arrayPerformance/src/longArrayGet.cpp
arrayPerformance/src/longArrayGet.h
arrayPerformance/src/longArrayGetMain.cpp
arrayPerformance/src/longArrayMonitor.cpp
arrayPerformance/src/longArrayMonitor.h
arrayPerformance/src/longArrayMonitorMain.cpp
arrayPerformance/src/longArrayPut.cpp
arrayPerformance/src/longArrayPut.h
arrayPerformance/src/longArrayPutMain.cpp
arrayPerformance/src/vectorPerformanceMain.cpp
exampleDatabase/include/pv/exampleDatabase.h
exampleDatabase/include/pv/exampleMonitorPlugin.h
exampleDatabase/ioc/src/O.darwin-x86/exampleDatabase_registerRecordDeviceDriver.cpp
exampleDatabase/ioc/src/exampleDatabaseMain.cpp
exampleDatabase/src/exampleDatabase.cpp
exampleDatabase/src/exampleDatabase.h
exampleDatabase/src/exampleDatabaseMain.cpp
exampleDatabase/src/exampleDatabaseRegister.cpp
exampleDatabase/src/exampleMonitorPlugin.cpp
exampleDatabase/src/exampleMonitorPlugin.h
exampleDatabase/src/exampleMonitorPluginRegister.cpp
exampleLink/include/pv/exampleLink.h
exampleLink/ioc/src/O.darwin-x86/exampleLink_registerRecordDeviceDriver.cpp
exampleLink/ioc/src/exampleLinkMain.cpp
exampleLink/src/exampleLink.cpp
exampleLink/src/exampleLink.h
exampleLink/src/exampleLinkRegister.cpp
examplePowerSupply/ioc/src/O.darwin-x86/powerSupply_registerRecordDeviceDriver.cpp
examplePowerSupply/ioc/src/powerSupplyMain.cpp
examplePowerSupply/src/powerSupplyMain.cpp
exampleServer/include/pv/exampleServer.h
exampleServer/ioc/src/O.darwin-x86/exampleServer_registerRecordDeviceDriver.cpp
exampleServer/ioc/src/exampleServerMain.cpp
exampleServer/src/exampleServer.cpp
exampleServer/src/exampleServer.h
exampleServer/src/exampleServerMain.cpp
exampleServer/src/exampleServerRegister.cpp
include/pv/channelProviderLocal.h
include/pv/pvCopyMonitor.h
include/pv/pvDatabase.h
include/pv/recordList.h
include/pv/traceRecord.h
src/database/pvDatabase.cpp
src/database/pvDatabase.h
src/database/pvRecord.cpp
src/pvAccess/channelLocal.cpp
src/pvAccess/channelProviderLocal.cpp
src/pvAccess/channelProviderLocal.h
src/pvAccess/monitorFactory.cpp
src/pvAccess/pvCopyMonitor.cpp
src/pvAccess/pvCopyMonitor.h
src/pvAccess/registerChannelProviderLocal.cpp
src/special/recordList.cpp
src/special/recordList.h
src/special/traceRecord.cpp
src/special/traceRecord.h
test/include/pv/powerSupply.h
test/src/powerSupply.cpp
test/src/powerSupply.h
test/src/powerSupplyRegister.cpp
test/src/testExampleRecord.cpp
test/src/testPVCopy.cpp
test/src/testPVRecord.cpp

View File

@@ -1,8 +0,0 @@
arrayPerformance/src
exampleDatabase/src
exampleLink/src
exampleServer/src
src/database
src/pvAccess
src/special
test/src

View File

@@ -21,8 +21,8 @@
#include <deque>
#include <pv/pvData.h>
#include <pv/convert.h>
#include <pv/pvCopy.h>
#include <pv/pvTimeStamp.h>
#ifdef pvdatabaseEpicsExportSharedSymbols
# define epicsExportSharedSymbols
@@ -56,10 +56,12 @@ class PVDatabase;
typedef std::tr1::shared_ptr<PVDatabase> PVDatabasePtr;
/**
* Base interface for a record.
* @brief Base interface for a record.
*
* @author mrk
*/
class epicsShareClass PVRecord :
public epics::pvData::PVCopyTraverseMasterCallback,
public std::tr1::enable_shared_from_this<PVRecord>
{
public:
@@ -83,7 +85,7 @@ public:
* If it encounters errors it should raise alarms and/or
* call the <b>message</b> method provided by the base class.
*/
virtual void process() {}
virtual void process();
/**
* Destroy the PVRecord. Release any resources used and
* get rid of listeners and requesters.
@@ -167,15 +169,26 @@ public:
* Add a PVListener.
* This must be called before calling pvRecordField.addListener.
* @param pvListener The listener.
* @param pvCopy The pvStructure that has the client fields.
* @return <b>true</b> if the listener was added.
*/
bool addListener(PVListenerPtr const & pvListener);
bool addListener(
PVListenerPtr const & pvListener,
epics::pvData::PVCopyPtr const & pvCopy);
/*
* PVCopyTraverseMasterCallback method
* @param pvField The next client field.
*/
void nextMasterPVField(epics::pvData::PVFieldPtr const & pvField);
/**
* Remove a listener.
* @param pvListener The listener.
* @param pvCopy The pvStructure that has the client fields.
* @return <b>true</b> if the listener was removed.
*/
bool removeListener(PVListenerPtr const & pvListener);
bool removeListener(
PVListenerPtr const & pvListener,
epics::pvData::PVCopyPtr const & pvCopy);
/**
* Begins a group of puts.
*/
@@ -220,9 +233,9 @@ private:
PVRecordFieldPtr findPVRecordField(
PVRecordStructurePtr const & pvrs,
epics::pvData::PVFieldPtr const & pvField);
std::string recordName;
epics::pvData::PVStructurePtr pvStructure;
epics::pvData::ConvertPtr convert;
PVRecordStructurePtr pvRecordStructure;
std::list<PVListenerPtr> pvListenerList;
std::list<PVRecordClientPtr> pvRecordClientList;
@@ -230,12 +243,20 @@ private:
std::size_t depthGroupPut;
int traceLevel;
bool isDestroyed;
epics::pvData::PVTimeStamp pvTimeStamp;
epics::pvData::TimeStamp timeStamp;
// following only valid while addListener or removeListener is active.
bool isAddListener;
PVListenerPtr pvListener;
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const PVRecord& record);
/**
* Interface for a field of a record.
* @brief Interface for a field of a record.
*
* One exists for each field of the top level PVStructure.
* @author mrk
*/
@@ -287,21 +308,6 @@ public:
* @return The shared pointer,
*/
PVRecordPtr getPVRecord();
/**
* Add A PVListener to this field.
* Whenever this field or any subfield if this field is modified the listener will be notified.
* PVListener is described below.
* Before a listener can call addListener it must first call PVRecord.registerListener.
* @param pvListener The listener.
* @return <b<true</b> if listener is added.
*/
bool addListener(PVListenerPtr const & pvListener);
/**
* Remove a listener.
* @param pvListener The listener.
* @return <b<true</b> if listener is removed.
*/
virtual void removeListener(PVListenerPtr const & pvListener);
/**
* This is called by the code that implements the data interface.
* It is called whenever the put method is called.
@@ -316,6 +322,8 @@ protected:
virtual void postParent(PVRecordFieldPtr const & subField);
virtual void postSubField();
private:
bool addListener(PVListenerPtr const & pvListener);
virtual void removeListener(PVListenerPtr const & pvListener);
void callListener();
std::list<PVListenerPtr> pvListenerList;
@@ -330,7 +338,8 @@ private:
};
/**
* Interface for a field that is a structure.
* @brief Interface for a field that is a structure.
*
* One exists for each structure field of the top level PVStructure.
* @author mrk
*/
@@ -365,11 +374,6 @@ public:
* @return The shared pointer.
*/
epics::pvData::PVStructurePtr getPVStructure();
/**
* Called by PVRecord::removeListener.
* @param pvListener The listener.
*/
virtual void removeListener(PVListenerPtr const & pvListener);
/**
* Called by implementation code of PVRecord.
*/
@@ -380,13 +384,16 @@ protected:
*/
virtual void init();
private:
virtual void removeListener(PVListenerPtr const & pvListener);
epics::pvData::PVStructurePtr pvStructure;
PVRecordFieldPtrArrayPtr pvRecordFields;
friend class PVRecord;
};
/**
* An interface that must be implemented by any code that accesses the record.
* @brief An interface implemented by code that accesses the record.
*
* @author mrk
*/
class epicsShareClass PVRecordClient {
@@ -404,6 +411,8 @@ public:
};
/**
* @brief Listener for PVRecord::message.
*
* An interface that is implemented by code that traps calls to PVRecord::message.
* @author mrk
*/
@@ -448,7 +457,8 @@ public:
};
/**
* The interface to a database of PVRecords.
* @brief The interface for a database of PVRecords.
*
* @author mrk
*/
class epicsShareClass PVDatabase {
@@ -503,3 +513,10 @@ private:
}}
#endif /* PVDATABASE_H */
/** @page Overview Documentation
*
* <a href = "pvDatabaseCPP.html">pvDatabase.html</a>
*
*/

View File

@@ -39,10 +39,10 @@ PVRecord::PVRecord(
PVStructurePtr const & pvStructure)
: recordName(recordName),
pvStructure(pvStructure),
convert(getConvert()),
depthGroupPut(0),
traceLevel(0),
isDestroyed(false)
isDestroyed(false),
isAddListener(false)
{
}
@@ -59,6 +59,8 @@ void PVRecord::initPVRecord()
pvRecordStructure = PVRecordStructurePtr(
new PVRecordStructure(pvStructure,parent,getPtrSelf()));
pvRecordStructure->init();
PVFieldPtr pvField = pvStructure->getSubField("timeStamp");
if(pvField) pvTimeStamp.attach(pvField);
}
void PVRecord::destroy()
@@ -73,6 +75,7 @@ void PVRecord::destroy()
return;
}
isDestroyed = true;
pvTimeStamp.detach();
std::list<PVRecordClientPtr>::iterator clientIter;
while(true) {
@@ -94,7 +97,6 @@ void PVRecord::destroy()
}
pvRecordStructure->destroy();
pvRecordStructure.reset();
convert.reset();
pvStructure.reset();
unlock();
} catch(...) {
@@ -103,6 +105,17 @@ void PVRecord::destroy()
}
}
void PVRecord::process()
{
if(traceLevel>2) {
cout << "PVRecord::process() " << recordName << endl;
}
if(pvTimeStamp.isAttached()) {
timeStamp.getCurrent();
pvTimeStamp.set(timeStamp);
}
}
string PVRecord::getRecordName() const {return recordName;}
PVRecordStructurePtr PVRecord::getPVRecordStructure() const {return pvRecordStructure;}
@@ -263,7 +276,9 @@ void PVRecord::detachClients()
}
}
bool PVRecord::addListener(PVListenerPtr const & pvListener)
bool PVRecord::addListener(
PVListenerPtr const & pvListener,
PVCopyPtr const & pvCopy)
{
if(traceLevel>1) {
cout << "PVRecord::addListener() " << recordName << endl;
@@ -283,6 +298,10 @@ bool PVRecord::addListener(PVListenerPtr const & pvListener)
}
}
pvListenerList.push_back(pvListener);
this->pvListener = pvListener;
isAddListener = true;
pvCopy->traverseMaster(getPtrSelf());
this->pvListener = PVListenerPtr();;
unlock();
return true;
} catch(...) {
@@ -291,7 +310,19 @@ bool PVRecord::addListener(PVListenerPtr const & pvListener)
}
}
bool PVRecord::removeListener(PVListenerPtr const & pvListener)
void PVRecord::nextMasterPVField(PVFieldPtr const & pvField)
{
PVRecordFieldPtr pvRecordField = findPVRecordField(pvField);
if(isAddListener) {
pvRecordField->addListener(pvListener);
} else {
pvRecordField->removeListener(pvListener);
}
}
bool PVRecord::removeListener(
PVListenerPtr const & pvListener,
PVCopyPtr const & pvCopy)
{
if(traceLevel>1) {
cout << "PVRecord::removeListener() " << recordName << endl;
@@ -307,7 +338,10 @@ bool PVRecord::removeListener(PVListenerPtr const & pvListener)
{
if((*iter).get()==pvListener.get()) {
pvListenerList.erase(iter);
pvRecordStructure->removeListener(pvListener);
this->pvListener = pvListener;
isAddListener = false;
pvCopy->traverseMaster(getPtrSelf());
this->pvListener = PVListenerPtr();;
unlock();
return true;
}
@@ -411,6 +445,9 @@ PVRecordPtr PVRecordField::getPVRecord() {return pvRecord;}
bool PVRecordField::addListener(PVListenerPtr const & pvListener)
{
if(pvRecord->getTraceLevel()>1) {
cout << "PVRecordField::addListener() " << getFullName() << endl;
}
std::list<PVListenerPtr>::iterator iter;
for (iter = pvListenerList.begin(); iter!=pvListenerList.end(); iter++ ) {
if((*iter).get()==pvListener.get()) {
@@ -423,6 +460,9 @@ bool PVRecordField::addListener(PVListenerPtr const & pvListener)
void PVRecordField::removeListener(PVListenerPtr const & pvListener)
{
if(pvRecord->getTraceLevel()>1) {
cout << "PVRecordField::removeListener() " << getFullName() << endl;
}
std::list<PVListenerPtr>::iterator iter;
for (iter = pvListenerList.begin(); iter!=pvListenerList.end(); iter++ ) {
if((*iter).get()==pvListener.get()) {

View File

@@ -3,13 +3,11 @@
SRC_DIRS += $(PVDATABASE_SRC)/pvAccess
INC += channelProviderLocal.h
INC += pvCopyMonitor.h
DBD += registerChannelProviderLocal.dbd
LIBSRCS += channelProviderLocal.cpp
LIBSRCS += channelLocal.cpp
LIBSRCS += pvCopyMonitor.cpp
LIBSRCS += monitorFactory.cpp
LIBSRCS += registerChannelProviderLocal.cpp

View File

@@ -13,7 +13,6 @@
#include <epicsThread.h>
#include <pv/timeStamp.h>
#include <pv/convert.h>
#include <pv/pvSubArrayCopy.h>
#define epicsExportSharedSymbols
@@ -30,7 +29,6 @@ using std::string;
namespace epics { namespace pvDatabase {
static ConvertPtr convert = getConvert();
static StructureConstPtr nullStructure;
static PVStructurePtr nullPVStructure;
static BitSetPtr nullBitSet;
@@ -109,8 +107,8 @@ public:
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
virtual void lock() {pvRecord->lock();}
virtual void unlock() {pvRecord->unlock();}
private:
shared_pointer getPtrSelf()
{
@@ -133,8 +131,8 @@ private:
ChannelLocalPtr channelLocal;
ChannelProcessRequester::shared_pointer channelProcessRequester;
PVRecordPtr pvRecord;
Mutex mutex;
int nProcess;
Mutex mutex;
};
ChannelProcessLocalPtr ChannelProcessLocal::create(
@@ -151,7 +149,7 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
pvOptions = static_pointer_cast<PVStructure>(pvField);
pvField = pvOptions->getSubField("nProcess");
if(pvField) {
PVStringPtr pvString = pvOptions->getStringField("nProcess");
PVStringPtr pvString = pvOptions->getSubField<PVString>("nProcess");
if(pvString) {
int size;
std::stringstream ss;
@@ -242,8 +240,8 @@ public:
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
virtual void lock() {pvRecord->lock();}
virtual void unlock() {pvRecord->unlock();}
private:
shared_pointer getPtrSelf()
{
@@ -401,8 +399,8 @@ public:
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
virtual void lock() {pvRecord->lock();}
virtual void unlock() {pvRecord->unlock();}
private:
shared_pointer getPtrSelf()
{
@@ -570,8 +568,8 @@ public:
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
virtual void lock() {pvRecord->lock();}
virtual void unlock() {pvRecord->unlock();}
private:
shared_pointer getPtrSelf()
{
@@ -783,8 +781,8 @@ public:
{return channelLocal;}
virtual void cancel(){}
virtual void lastRequest() {}
virtual void lock() {mutex.lock();}
virtual void unlock() {mutex.unlock();}
virtual void lock() {pvRecord->lock();}
virtual void unlock() {pvRecord->unlock();}
private:
shared_pointer getPtrSelf()
{
@@ -873,66 +871,29 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
PVScalarArrayPtr xxx = static_pointer_cast<PVScalarArray>(pvField);
pvCopy = getPVDataCreate()->createPVScalarArray(
xxx->getScalarArray()->getElementType());
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
if(pvField->getField()->getType()==structureArray) {
} else if(pvField->getField()->getType()==structureArray) {
PVStructureArrayPtr xxx = static_pointer_cast<PVStructureArray>(pvField);
pvCopy = getPVDataCreate()->createPVStructureArray(
xxx->getStructureArray()->getStructure());
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
if(pvField->getField()->getType()==unionArray) {
} else {
PVUnionArrayPtr xxx = static_pointer_cast<PVUnionArray>(pvField);
pvCopy = getPVDataCreate()->createPVUnionArray(
xxx->getUnionArray()->getUnion());
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
Status status(Status::STATUSTYPE_ERROR,
"Logic error. Should not reach this code");
ChannelArrayLocalPtr channelArray;
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(status,channelArray,array);
return channelArray;
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}
@@ -1083,23 +1044,6 @@ void ChannelArrayLocal::setLength(size_t length)
}
class ChannelRPCLocal :
public ChannelRPC
{
public:
POINTER_DEFINITIONS(ChannelRPCLocal);
virtual ~ChannelRPCLocal();
static ChannelRPC::shared_pointer create(
ChannelProviderLocalPtr const &channelProvider,
ChannelRPC::shared_pointer const & channelRPCRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord);
virtual void request(
PVStructurePtr const & pvArgument,
bool lastRequest);
};
ChannelLocal::ChannelLocal(
ChannelProviderLocalPtr const & provider,
ChannelRequester::shared_pointer const & requester,
@@ -1161,6 +1105,8 @@ string ChannelLocal::getRemoteAddress()
Channel::ConnectionState ChannelLocal::getConnectionState()
{
Lock xx(mutex);
if(beingDestroyed) return Channel::DESTROYED;
return Channel::CONNECTED;
}
@@ -1176,6 +1122,8 @@ ChannelRequester::shared_pointer ChannelLocal::getChannelRequester()
bool ChannelLocal::isConnected()
{
Lock xx(mutex);
if(beingDestroyed) return false;
return true;
}

View File

@@ -88,12 +88,12 @@ ChannelProviderLocal::ChannelProviderLocal()
ChannelProviderLocal::~ChannelProviderLocal()
{
cout << "~ChannelProviderLocal()" << endl;
// TODO should I call destroy() here
destroy();
}
void ChannelProviderLocal::destroy()
{
cout << "ChannelProviderLocal::destroy()" << endl;
Lock xx(mutex);
if(beingDestroyed) return;
beingDestroyed = true;
@@ -172,4 +172,47 @@ Channel::shared_pointer ChannelProviderLocal::createChannel(
return Channel::shared_pointer();
}
ContextLocal::shared_pointer ContextLocal::create()
{
return ContextLocal::shared_pointer(new ContextLocal());
}
void ContextLocal::start(bool _waitForExit)
{
m_context = startPVAServer(
PVACCESS_ALL_PROVIDERS,
0,
true,
true);
if (_waitForExit)
waitForExit();
}
void ContextLocal::waitForExit()
{
while (true)
{
std::cout << "Type 'exit' to stop: ";
std::string input;
std::cin >> input;
if (input == "exit")
break;
}
destroy();
}
void ContextLocal::destroy()
{
if (m_context)
m_context->destroy();
}
ContextLocal::ContextLocal()
{
m_channelProvider = getChannelProviderLocal();
}
}}

View File

@@ -25,10 +25,10 @@
#include <pv/lock.h>
#include <pv/pvType.h>
#include <pv/pvData.h>
#include <pv/monitorPlugin.h>
#include <pv/pvCopy.h>
#include <pv/pvAccess.h>
#include <pv/status.h>
#include <pv/serverContext.h>
#ifdef channelProviderLocalEpicsExportSharedSymbols
# define epicsExportSharedSymbols
@@ -57,7 +57,9 @@ typedef std::tr1::shared_ptr<ChannelLocal> ChannelLocalPtr;
epicsShareExtern MonitorFactoryPtr getMonitorFactory();
/** MonitorFactory
/**
* @brief MonitorFactory
*
* This class provides a static method to create a monitor for a PVRecord
*/
class epicsShareClass MonitorFactory
@@ -99,6 +101,8 @@ private:
epicsShareExtern ChannelProviderLocalPtr getChannelProviderLocal();
/**
* @brief ChannelProvider for PVDatabase.
*
* An implementation of channelProvider that provides access to records in PVDatabase.
*/
class epicsShareClass ChannelProviderLocal :
@@ -191,6 +195,8 @@ private:
};
/**
* @brief Channel for accessing a PVRecord.
*
* A Channel for accessing a record in the PVDatabase.
* It is a complete implementation of Channel
*/
@@ -394,7 +400,44 @@ private:
epics::pvData::Mutex mutex;
};
/**
* @brief A pvAccess server context that provides
* remote access to a local channel providers (i.e. pvDatabase records).
*/
class epicsShareClass ContextLocal
{
public:
POINTER_DEFINITIONS(ContextLocal);
static shared_pointer create();
/**
* Start the context thread.
* After this is called clients can connect to the server.
* @param waitForExit In true then waitForExit() method is called after the server is started.
*/
void start(bool waitForExit = false);
/**
* Waits for "exit" to be entered on standard input and calls destroy() before returning.
*/
void waitForExit();
/**
* This destroys the context.
* All clients will be disconnected.
*/
void destroy();
private:
ContextLocal();
ChannelProviderLocalPtr m_channelProvider;
epics::pvAccess::ServerContext::shared_pointer m_context;
};
}}
#endif /* CHANNELPROVIDERLOCAL_H */

View File

@@ -18,7 +18,6 @@
#define epicsExportSharedSymbols
#include <pv/pvCopyMonitor.h>
#include <pv/channelProviderLocal.h>
using namespace epics::pvData;
@@ -33,9 +32,11 @@ namespace epics { namespace pvDatabase {
static MonitorPtr nullMonitor;
static MonitorElementPtr NULLMonitorElement;
static Status failedToCreateMonitorStatus(Status::STATUSTYPE_ERROR,"failed to create monitor");
static Status wasDestroyedStatus(Status::STATUSTYPE_ERROR,"was destroyed");
static Status alreadyStartedStatus(Status::STATUSTYPE_ERROR,"already started");
static Status notStartedStatus(Status::STATUSTYPE_ERROR,"not started");
static ConvertPtr convert = getConvert();
typedef Queue<MonitorElement> MonitorElementQueue;
@@ -45,9 +46,10 @@ typedef std::tr1::shared_ptr<MonitorElementQueue> MonitorElementQueuePtr;
class MonitorLocal :
public Monitor,
public PVCopyMonitorRequester,
public PVListener,
public std::tr1::enable_shared_from_this<MonitorLocal>
{
enum MonitorState {idle,active, destroyed};
public:
POINTER_DEFINITIONS(MonitorLocal);
virtual ~MonitorLocal();
@@ -55,16 +57,22 @@ public:
virtual Status stop();
virtual MonitorElementPtr poll();
virtual void destroy();
virtual void detach(PVRecordPtr const & pvRecord){destroy();}
virtual void release(MonitorElementPtr const & monitorElement);
virtual void dataPut(PVRecordFieldPtr const & pvRecordField);
virtual void dataPut(
PVRecordStructurePtr const & requested,
PVRecordFieldPtr const & pvRecordField);
virtual void beginGroupPut(PVRecordPtr const & pvRecord);
virtual void endGroupPut(PVRecordPtr const & pvRecord);
virtual void unlisten(PVRecordPtr const & pvRecord);
MonitorElementPtr getActiveElement();
MonitorElementPtr releaseActiveElement();
void unlisten();
void releaseActiveElement();
bool init(PVStructurePtr const & pvRequest);
MonitorLocal(
MonitorRequester::shared_pointer const & channelMonitorRequester,
PVRecordPtr const &pvRecord);
PVCopyPtr getPVCopy() { return pvCopy;}
PVCopyMonitorPtr getPVCopyMonitor() { return pvCopyMonitor;}
private:
MonitorLocalPtr getPtrSelf()
{
@@ -72,13 +80,14 @@ private:
}
MonitorRequester::shared_pointer monitorRequester;
PVRecordPtr pvRecord;
bool isDestroyed;
bool firstMonitor;
MonitorState state;
PVCopyPtr pvCopy;
MonitorElementQueuePtr queue;
MonitorElementPtr activeElement;
PVCopyMonitorPtr pvCopyMonitor;
bool isGroupPut;
bool dataChanged;
Mutex mutex;
Mutex queueMutex;
};
MonitorLocal::MonitorLocal(
@@ -86,8 +95,9 @@ MonitorLocal::MonitorLocal(
PVRecordPtr const &pvRecord)
: monitorRequester(channelMonitorRequester),
pvRecord(pvRecord),
isDestroyed(false),
firstMonitor(true)
state(idle),
isGroupPut(false),
dataChanged(false)
{
}
@@ -103,17 +113,21 @@ void MonitorLocal::destroy()
{
if(pvRecord->getTraceLevel()>0)
{
cout << "MonitorLocal::destroy " << isDestroyed << endl;
cout << "MonitorLocal::destroy state " << state << endl;
}
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
if(state==destroyed) return;
}
if(pvCopy) pvCopy->destroy();
{
Lock xx(mutex);
state = destroyed;
}
{
Lock xx(queueMutex);
queue.reset();
}
pvCopyMonitor->destroy();
pvCopy->destroy();
pvCopyMonitor.reset();
queue.reset();
pvCopy.reset();
}
@@ -123,16 +137,27 @@ Status MonitorLocal::start()
{
cout << "MonitorLocal::start() " << endl;
}
if(isDestroyed) return wasDestroyedStatus;
{
Lock xx(mutex);
firstMonitor = true;
if(state==destroyed) return wasDestroyedStatus;
if(state==active) return alreadyStartedStatus;
}
pvRecord->addListener(getPtrSelf(),pvCopy);
pvRecord->lock();
try {
Lock xx(mutex);
state = active;
queue->clear();
isGroupPut = false;
activeElement = queue->getFree();
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
activeElement->changedBitSet->set(0);
releaseActiveElement();
pvRecord->unlock();
} catch(...) {
pvRecord->unlock();
}
pvCopyMonitor->startMonitoring(activeElement);
return Status::Ok;
}
@@ -141,8 +166,13 @@ Status MonitorLocal::stop()
if(pvRecord->getTraceLevel()>0){
cout << "MonitorLocal::stop() " << endl;
}
if(isDestroyed) return Status::Ok;
pvCopyMonitor->stopMonitoring();
{
Lock xx(mutex);
if(state==destroyed) return wasDestroyedStatus;
if(state==idle) return notStartedStatus;
state = idle;
}
pvRecord->removeListener(getPtrSelf(),pvCopy);
return Status::Ok;
}
@@ -152,9 +182,11 @@ MonitorElementPtr MonitorLocal::poll()
{
cout << "MonitorLocal::poll() " << endl;
}
if(isDestroyed) return NULLMonitorElement;
Lock xx(mutex);
return queue->getUsed();
{
Lock xx(queueMutex);
if(state!=active) return NULLMonitorElement;
return queue->getUsed();
}
}
void MonitorLocal::release(MonitorElementPtr const & monitorElement)
@@ -163,22 +195,24 @@ void MonitorLocal::release(MonitorElementPtr const & monitorElement)
{
cout << "MonitorLocal::release() " << endl;
}
if(isDestroyed) return;
Lock xx(mutex);
queue->releaseUsed(monitorElement);
{
Lock xx(queueMutex);
if(state!=active) return;
queue->releaseUsed(monitorElement);
}
}
MonitorElementPtr MonitorLocal::releaseActiveElement()
void MonitorLocal::releaseActiveElement()
{
if(pvRecord->getTraceLevel()>1)
{
cout << "MonitorLocal::releaseActiveElement() " << endl;
}
if(isDestroyed) return activeElement;
{
Lock xx(mutex);
Lock xx(queueMutex);
if(state!=active) return;
MonitorElementPtr newActive = queue->getFree();
if(!newActive) return activeElement;
if(!newActive) return;
pvCopy->updateCopyFromBitSet(activeElement->pvStructurePtr,activeElement->changedBitSet);
BitSetUtil::compress(activeElement->changedBitSet,activeElement->pvStructurePtr);
BitSetUtil::compress(activeElement->overrunBitSet,activeElement->pvStructurePtr);
@@ -188,45 +222,128 @@ MonitorElementPtr MonitorLocal::releaseActiveElement()
activeElement->overrunBitSet->clear();
}
monitorRequester->monitorEvent(getPtrSelf());
return activeElement;
return;
}
void MonitorLocal::unlisten()
void MonitorLocal::dataPut(PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>0)
if(pvRecord->getTraceLevel()>1)
{
cout << "MonitorLocal::unlisten() " << endl;
cout << "PVCopyMonitor::dataPut(pvRecordField)" << endl;
}
if(state!=active) return;
{
Lock xx(mutex);
size_t offset = pvCopy->getCopyOffset(pvRecordField->getPVField());
BitSetPtr const &changedBitSet = activeElement->changedBitSet;
BitSetPtr const &overrunBitSet = activeElement->overrunBitSet;
bool isSet = changedBitSet->get(offset);
changedBitSet->set(offset);
if(isSet) overrunBitSet->set(offset);
dataChanged = true;
}
if(!isGroupPut) {
releaseActiveElement();
dataChanged = false;
}
monitorRequester->unlisten(getPtrSelf());
}
void MonitorLocal::dataPut(
PVRecordStructurePtr const & requested,
PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::dataPut(requested,pvRecordField)" << endl;
}
if(state!=active) return;
{
Lock xx(mutex);
BitSetPtr const &changedBitSet = activeElement->changedBitSet;
BitSetPtr const &overrunBitSet = activeElement->overrunBitSet;
size_t offsetCopyRequested = pvCopy->getCopyOffset(
requested->getPVField());
size_t offset = offsetCopyRequested
+ (pvRecordField->getPVField()->getFieldOffset()
- requested->getPVField()->getFieldOffset());
bool isSet = changedBitSet->get(offset);
changedBitSet->set(offset);
if(isSet) overrunBitSet->set(offset);
dataChanged = true;
}
if(!isGroupPut) {
releaseActiveElement();
dataChanged = false;
}
}
void MonitorLocal::beginGroupPut(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::beginGroupPut()" << endl;
}
if(state!=active) return;
{
Lock xx(mutex);
isGroupPut = true;
dataChanged = false;
}
}
void MonitorLocal::endGroupPut(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::endGroupPut() dataChanged " << dataChanged << endl;
}
if(state!=active) return;
{
Lock xx(mutex);
isGroupPut = false;
}
if(dataChanged) {
dataChanged = false;
releaseActiveElement();
}
}
void MonitorLocal::unlisten(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::unlisten\n";
}
pvRecord->removeListener(getPtrSelf(),pvCopy);
}
bool MonitorLocal::init(PVStructurePtr const & pvRequest)
{
PVFieldPtr pvField;
PVStructurePtr pvOptions;
size_t queueSize = 2;
pvField = pvRequest->getSubField("record._options");
if(pvField.get()!=NULL) {
pvOptions = static_pointer_cast<PVStructure>(pvField);
pvField = pvOptions->getSubField("queueSize");
if(pvField.get()!=NULL) {
PVStringPtr pvString = pvOptions->getStringField("queueSize");
if(pvString.get()!=NULL) {
PVStructurePtr pvOptions = pvRequest->getSubField<PVStructure>("record._options");
if(pvOptions) {
PVStringPtr pvString = pvOptions->getSubField<PVString>("queueSize");
if(pvString) {
try {
int32 size;
std::stringstream ss;
ss << pvString->get();
ss >> size;
queueSize = size;
} catch (...) {
monitorRequester->message("queueSize " +pvString->get() + " illegal",errorMessage);
return false;
}
}
}
pvField = pvRequest->getSubField("field");
if(pvField.get()==NULL) {
if(!pvField) {
pvCopy = PVCopy::create(
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,"");
if(pvCopy.get()==NULL) {
if(!pvCopy) {
monitorRequester->message("illegal pvRequest",errorMessage);
return false;
}
@@ -238,27 +355,21 @@ bool MonitorLocal::init(PVStructurePtr const & pvRequest)
pvCopy = PVCopy::create(
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,"field");
if(pvCopy.get()==NULL) {
if(!pvCopy) {
monitorRequester->message("illegal pvRequest",errorMessage);
return false;
}
}
pvCopyMonitor = PVCopyMonitor::create(
getPtrSelf(),pvRecord,pvCopy);
// MARTY MUST IMPLEMENT periodic
if(queueSize<2) queueSize = 2;
std::vector<MonitorElementPtr> monitorElementArray;
monitorElementArray.reserve(queueSize);
size_t nfields = 0;
for(size_t i=0; i<queueSize; i++) {
PVStructurePtr pvStructure = pvCopy->createPVStructure();
if(nfields==0) nfields = pvStructure->getNumberFields();
MonitorElementPtr monitorElement(
new MonitorElement(pvStructure));
monitorElementArray.push_back(monitorElement);
}
queue = MonitorElementQueuePtr(new MonitorElementQueue(monitorElementArray));
// MARTY MUST IMPLEMENT algorithm
monitorRequester->monitorConnect(
Status::Ok,
getPtrSelf(),
@@ -279,7 +390,6 @@ MonitorFactory::~MonitorFactory()
void MonitorFactory::destroy()
{
Lock lock(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
@@ -296,7 +406,12 @@ MonitorPtr MonitorFactory::createMonitor(
MonitorLocalPtr monitor(new MonitorLocal(
monitorRequester,pvRecord));
bool result = monitor->init(pvRequest);
if(!result) return nullMonitor;
if(!result) {
MonitorPtr monitor;
StructureConstPtr structure;
monitorRequester->monitorConnect(failedToCreateMonitorStatus,monitor,structure);
return nullMonitor;
}
if(pvRecord->getTraceLevel()>0)
{
cout << "MonitorFactory::createMonitor";

View File

@@ -1,318 +0,0 @@
/* pvCopyMonitor.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 Marty Kraimer
* @date 2013.04
*/
#include <string>
#include <stdexcept>
#include <memory>
#include <sstream>
#include <pv/thread.h>
#define epicsExportSharedSymbols
#include <pv/channelProviderLocal.h>
#include <pv/pvCopyMonitor.h>
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::size_t;
using std::cout;
using std::endl;
using std::string;
namespace epics { namespace pvDatabase {
struct PVCopyMonitorFieldNode
{
MonitorPluginPtr monitorPlugin;
size_t offset; // in pvCopy
};
PVCopyMonitorPtr PVCopyMonitor::create(
PVCopyMonitorRequesterPtr const &pvCopyMonitorRequester,
PVRecordPtr const &pvRecord,
PVCopyPtr const & pvCopy)
{
PVCopyMonitorPtr pvCopyMonitor( new PVCopyMonitor(
pvRecord,pvCopy,pvCopyMonitorRequester));
pvCopyMonitor->init(pvRecord->getPVRecordStructure()->getPVStructure());
return pvCopyMonitor;
}
PVCopyMonitor::PVCopyMonitor(
PVRecordPtr const &pvRecord,
PVCopyPtr const &pvCopy,
PVCopyMonitorRequesterPtr const &pvCopyMonitorRequester
)
: pvRecord(pvRecord),
pvCopy(pvCopy),
pvCopyMonitorRequester(pvCopyMonitorRequester),
isGroupPut(false),
dataChanged(false),
isMonitoring(false),
isDestroyed(false)
{
}
PVCopyMonitor::~PVCopyMonitor()
{
if(pvRecord->getTraceLevel()>0)
{
cout << "~PVCopyMonitor" << endl;
}
}
// pvField is in top level structure of PVRecord.
void PVCopyMonitor::init(PVFieldPtr const &pvField)
{
size_t offset = pvCopy->getCopyOffset(pvField);
if(offset==string::npos) return;
PVStructurePtr pvOptions = pvCopy->getOptions(offset);
if(pvOptions) {
PVStringPtr pvName = pvOptions->getSubField<PVString>("plugin");
if(pvName) {
string pluginName = pvName->get();
MonitorPluginManagerPtr manager = MonitorPluginManager::get();
MonitorPluginCreatorPtr pluginCreator = manager->findPlugin(pluginName);
if(pluginCreator) {
StructureConstPtr top = pvCopy->getStructure();
FieldConstPtr field = pvField->getField();
MonitorPluginPtr monitorPlugin = pluginCreator->create(field,top,pvOptions);
if(monitorPlugin) {
PVCopyMonitorFieldNodePtr fieldNode(new PVCopyMonitorFieldNode());
fieldNode->monitorPlugin = monitorPlugin;
fieldNode->offset = offset;
monitorFieldNodeList.push_back(fieldNode);
}
}
}
}
if(pvField->getField()->getType()!=structure) return;
PVStructurePtr pv = static_pointer_cast<PVStructure>(pvField);
const PVFieldPtrArray &pvFields = pv->getPVFields();
for(size_t i=0; i<pvFields.size(); ++i ) init(pvFields[i]);
}
MonitorPluginPtr PVCopyMonitor::getMonitorPlugin(size_t offset)
{
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
if((*iter)->offset==offset) return (*iter)->monitorPlugin;
}
return MonitorPluginPtr();
}
void PVCopyMonitor::destroy()
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::destroy()" << endl;
}
if(isDestroyed) return;
Lock xx(mutex);
isDestroyed = true;
stopMonitoring();
pvCopyMonitorRequester.reset();
pvCopy.reset();
}
void PVCopyMonitor::startMonitoring(MonitorElementPtr const & startElement)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::startMonitoring()" << endl;
}
if(isDestroyed) return;
monitorElement = startElement;
Lock xx(mutex);
if(isMonitoring) return;
isMonitoring = true;
isGroupPut = false;
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
(*iter)->monitorPlugin->startMonitoring();
}
pvRecord->addListener(getPtrSelf());
pvRecord->lock();
try {
pvCopy->traverseMaster(getPtrSelf());
monitorElement->changedBitSet->clear();
monitorElement->overrunBitSet->clear();
monitorElement->changedBitSet->set(0);
monitorElement = pvCopyMonitorRequester->releaseActiveElement();
pvRecord->unlock();
} catch(...) {
pvRecord->unlock();
}
}
void PVCopyMonitor::nextMasterPVField(epics::pvData::PVFieldPtr const &pvField)
{
pvRecord->findPVRecordField(pvField)->addListener(getPtrSelf());
}
void PVCopyMonitor::stopMonitoring()
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::stopMonitoring()" << endl;
}
if(isDestroyed) return;
if(!isMonitoring) return;
pvRecord->removeListener(getPtrSelf());
Lock xx(mutex);
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
(*iter)->monitorPlugin->stopMonitoring();
}
isMonitoring = false;
}
void PVCopyMonitor::detach(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::detach()" << endl;
}
}
void PVCopyMonitor::dataPut(PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::dataPut(pvRecordField)" << endl;
}
if(isDestroyed) return;
bool causeMonitor = true;
{
Lock xx(mutex);
size_t offset = pvCopy->getCopyOffset(pvRecordField->getPVField());
BitSetPtr const &changedBitSet = monitorElement->changedBitSet;
BitSetPtr const &overrunBitSet = monitorElement->overrunBitSet;
bool isSet = changedBitSet->get(offset);
changedBitSet->set(offset);
if(isSet) overrunBitSet->set(offset);
MonitorPluginPtr monitorPlugin = getMonitorPlugin(offset);
if(monitorPlugin) {
causeMonitor = monitorPlugin->causeMonitor(
pvRecordField->getPVField(),
pvRecord->getPVRecordStructure()->getPVStructure(),
monitorElement);
}
if(causeMonitor) dataChanged = true;
}
if(causeMonitor) {
if(!isGroupPut) {
monitorElement = pvCopyMonitorRequester->releaseActiveElement();
dataChanged = false;
}
}
}
void PVCopyMonitor::dataPut(
PVRecordStructurePtr const & requested,
PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::dataPut(requested,pvRecordField)" << endl;
}
if(isDestroyed) return;
bool causeMonitor = true;
{
Lock xx(mutex);
BitSetPtr const &changedBitSet = monitorElement->changedBitSet;
BitSetPtr const &overrunBitSet = monitorElement->overrunBitSet;
size_t offsetCopyRequested = pvCopy->getCopyOffset(
requested->getPVField());
size_t offset = offsetCopyRequested
+ (pvRecordField->getPVField()->getFieldOffset()
- requested->getPVField()->getFieldOffset());
bool isSet = changedBitSet->get(offset);
changedBitSet->set(offset);
if(isSet) overrunBitSet->set(offset);
MonitorPluginPtr monitorPlugin = getMonitorPlugin(offsetCopyRequested);
if(monitorPlugin) {
causeMonitor = monitorPlugin->causeMonitor(
requested->getPVField(),
pvRecord->getPVRecordStructure()->getPVStructure(),
monitorElement);
}
if(causeMonitor) dataChanged = true;
}
if(causeMonitor) {
if(!isGroupPut) {
monitorElement = pvCopyMonitorRequester->releaseActiveElement();
dataChanged = false;
}
}
}
void PVCopyMonitor::beginGroupPut(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::beginGroupPut()" << endl;
}
if(isDestroyed) return;
{
Lock xx(mutex);
isGroupPut = true;
dataChanged = false;
}
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();
iter!=monitorFieldNodeList.end();
++iter)
{
(*iter)->monitorPlugin->beginGroupPut();
}
}
void PVCopyMonitor::endGroupPut(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::endGroupPut() dataChanged " << dataChanged << endl;
}
if(isDestroyed) return;
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
(*iter)->monitorPlugin->endGroupPut();
}
{
Lock xx(mutex);
isGroupPut = false;
}
if(dataChanged) {
monitorElement = pvCopyMonitorRequester->releaseActiveElement();
dataChanged = false;
}
}
void PVCopyMonitor::unlisten(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>1)
{
cout << "PVCopyMonitor::unlisten\n";
}
if(isDestroyed) return;
pvCopyMonitorRequester->unlisten();
}
}}

View File

@@ -1,168 +0,0 @@
/* pvCopyMonitor.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 Marty Kraimer
* @date 2013.04
*/
#ifndef PVCOPYMONITOR_H
#define PVCOPYMONITOR_H
#ifdef epicsExportSharedSymbols
# define pvCopyMonitorEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <string>
#include <stdexcept>
#include <memory>
#include <list>
#include <pv/monitorPlugin.h>
#include <pv/pvCopy.h>
#include <pv/pvAccess.h>
#ifdef pvCopyMonitorEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef pvCopyMonitorEpicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/pvDatabase.h>
namespace epics { namespace pvDatabase {
class PVCopyMonitor;
typedef std::tr1::shared_ptr<PVCopyMonitor> PVCopyMonitorPtr;
class PVCopyMonitorRequester;
typedef std::tr1::shared_ptr<PVCopyMonitorRequester> PVCopyMonitorRequesterPtr;
struct PVCopyMonitorFieldNode;
typedef std::tr1::shared_ptr<PVCopyMonitorFieldNode> PVCopyMonitorFieldNodePtr;
/**
* PVCopyMonitor
* This class manages changes to fields being monitored in a PVRecord.
*/
class epicsShareClass PVCopyMonitor :
public PVListener,
public epics::pvData::PVCopyTraverseMasterCallback,
public std::tr1::enable_shared_from_this<PVCopyMonitor>
{
public:
POINTER_DEFINITIONS(PVCopyMonitor);
/**
* Factory method to create a PVCopyMonoitor
* @param pvCopyMonitorRequester This is usually MonitorLocal.
* @param pvRecord The record being monitored.
* @param pvCopy An instance of pvCopy
* @return A shared pointer to a PVCopyMonitor.
*/
static PVCopyMonitorPtr create(
PVCopyMonitorRequesterPtr const &pvCopyMonitorRequester,
PVRecordPtr const &pvRecord,
epics::pvData::PVCopyPtr const & pvCopy);
/**
* Destructor
*/
virtual ~PVCopyMonitor();
/**
* Destroy the PVCopyMonitor
*/
virtual void destroy();
/**
* Calls pvRecord methods to start monitoring for calls to postPut.
* @param monitorElement the initial monotorElement
* This holds the change and overrun bitSets that are updated
* when postPut is called.
*/
void startMonitoring(
epics::pvData::MonitorElementPtr const & monitorElement);
/**
* Calls pvRecord methods to stop monitoring for calls to postPut.
*/
void stopMonitoring();
// following are PVListener methods
/**
* The record is being removed from the PVDatabase.
* @param The record being removed.
*/
virtual void detach(PVRecordPtr const & pvRecord);
/**
* A postPut has been issued to a field being monitored.
* @param pvRecordField The field.
*/
virtual void dataPut(PVRecordFieldPtr const & pvRecordField);
/**
* A postPut has been issued to a subfield of a field being monitored.
* @param requested The field being monitored.
* @param pvRecordField The field being modified.
*/
virtual void dataPut(
PVRecordStructurePtr const & requested,
PVRecordFieldPtr const & pvRecordField);
/**
* A group of puts are being changed.
* No monitors should be issued until endGroupPut is called.
* @param pvRecord The record.
*/
virtual void beginGroupPut(PVRecordPtr const & pvRecord);
/**
* The end of a group of puts.
* If any fields have changed value since beginGroupPut a monitor
* can be issued.
* @param pvRecord The record.
*/
virtual void endGroupPut(PVRecordPtr const & pvRecord);
/**
* The record is being removed from the database.
* @param pvRecord The record.
*/
virtual void unlisten(PVRecordPtr const & pvRecord);
// following is PVCopyTraverseMasterCallback method
/**
* The PVCopyTraverseMasterCallback callback
* Called for every field of PVRecord that is being monoitored.
* @param pvField The field in the PVRecord.
*/
virtual void nextMasterPVField(epics::pvData::PVFieldPtr const &pvField);
private:
PVCopyMonitorPtr getPtrSelf()
{
return shared_from_this();
}
PVCopyMonitor(
PVRecordPtr const &pvRecord,
epics::pvData::PVCopyPtr const &pvCopy,
PVCopyMonitorRequesterPtr const &pvCopyMonitorRequester);
void init(epics::pvData::PVFieldPtr const &pvField);
epics::pvData::MonitorPluginPtr getMonitorPlugin(size_t offset);
PVRecordPtr pvRecord;
epics::pvData::PVCopyPtr pvCopy;
PVCopyMonitorRequesterPtr pvCopyMonitorRequester;
epics::pvData::MonitorElementPtr monitorElement;
bool isGroupPut;
bool dataChanged;
bool isMonitoring;
bool isDestroyed;
epics::pvData::Mutex mutex;
std::list<PVCopyMonitorFieldNodePtr> monitorFieldNodeList;
};
class epicsShareClass PVCopyMonitorRequester
{
public:
POINTER_DEFINITIONS(PVCopyMonitorRequester);
virtual ~PVCopyMonitorRequester() {}
virtual epics::pvData::MonitorElementPtr releaseActiveElement() = 0;
virtual void unlisten() = 0;
};
}}
#endif /* PVCOPYMONITOR_H */

View File

@@ -44,7 +44,7 @@ using namespace epics::pvDatabase;
static const iocshFuncDef pvdblFuncDef = {
"pvdbl", 0, 0
};
extern "C" void epicsShareAPI pvdbl(const iocshArgBuf *args)
extern "C" void pvdbl(const iocshArgBuf *args)
{
PVDatabasePtr master = PVDatabase::getMaster();
PVStringArrayPtr pvNames = master->getRecordNames();

View File

@@ -61,20 +61,19 @@ bool RecordListRecord::init()
{
initPVRecord();
PVStructurePtr pvStructure = getPVStructure();
database = pvStructure->getStringField("argument.database");
database = pvStructure->getSubField<PVString>("argument.database");
if(database.get()==NULL) return false;
regularExpression = pvStructure->getStringField(
regularExpression = pvStructure->getSubField<PVString>(
"argument.regularExpression");
if(regularExpression.get()==NULL) return false;
status = pvStructure->getStringField("result.status");
status = pvStructure->getSubField<PVString>("result.status");
if(status.get()==NULL) return false;
PVFieldPtr pvField = pvStructure->getSubField("result.names");
if(pvField.get()==NULL) {
std::cerr << "no result.names" << std::endl;
return false;
}
name = static_pointer_cast<PVStringArray>(
pvStructure->getScalarArrayField("result.names",pvString));
name = pvStructure->getSubField<PVStringArray>("result.names");
if(name.get()==NULL) return false;
return true;
}

View File

@@ -21,6 +21,10 @@ class RecordListRecord;
typedef std::tr1::shared_ptr<RecordListRecord> RecordListRecordPtr;
/**
* @brief List records in PVDatabase.
*
* @deprecated no longer needed because of pvlist command for pvAccess.
*
* This is a record that provides a PVStringArray that
* has the record names of all records in the local PVDatabase.
* It is meant to be used by a channelPutGet request.

View File

@@ -62,11 +62,11 @@ bool TraceRecord::init()
{
initPVRecord();
PVStructurePtr pvStructure = getPVStructure();
pvRecordName = pvStructure->getStringField("argument.recordName");
pvRecordName = pvStructure->getSubField<PVString>("argument.recordName");
if(!pvRecordName) return false;
pvLevel = pvStructure->getIntField("argument.level");
pvLevel = pvStructure->getSubField<PVInt>("argument.level");
if(!pvLevel) return false;
pvResult = pvStructure->getStringField("result.status");
pvResult = pvStructure->getSubField<PVString>("result.status");
if(!pvResult) return false;
return true;
}

View File

@@ -18,15 +18,17 @@
namespace epics { namespace pvDatabase {
class TraceRecord;
typedef std::tr1::shared_ptr<TraceRecord> TraceRecordPtr;
/**
* @brief Trace activity of PVRecord.
*
* A record to set the trace value for another record
* It is meant to be used via a channelPutGet request.
* The argument has two fields: recordName and level.
* The result has a field named status.
*/
class TraceRecord;
typedef std::tr1::shared_ptr<TraceRecord> TraceRecordPtr;
class epicsShareClass TraceRecord :
public PVRecord
{

View File

@@ -26,6 +26,7 @@
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/channelProviderLocal.h>
#include <pv/convert.h>
#include "powerSupply.h"
@@ -143,7 +144,6 @@ static void testPVScalar(
}
static void testPVScalarArray(
ScalarType scalarType,
string const & valueNameRecord,
string const & valueNameCopy,
PVRecordPtr const & pvRecord,
@@ -159,14 +159,14 @@ static void testPVScalarArray(
shared_vector<double> values(n);
cout << endl;
pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
pvValueRecord = pvStructureRecord->getScalarArrayField(valueNameRecord,scalarType);
pvValueRecord = pvStructureRecord->getSubField<PVScalarArray>(valueNameRecord);
for(size_t i=0; i<n; i++) values[i] = i;
const shared_vector<const double> xxx(freeze(values));
pvValueRecord->putFrom(xxx);
StructureConstPtr structure = pvCopy->getStructure();
cout << "structure from copy" << endl << *structure << endl;
pvStructureCopy = pvCopy->createPVStructure();
pvValueCopy = pvStructureCopy->getScalarArrayField(valueNameCopy,scalarType);
pvValueCopy = pvStructureCopy->getSubField<PVScalarArray>(valueNameCopy);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
cout << "after initCopy pvValueCopy " << *pvValueCopy << endl;
@@ -276,21 +276,21 @@ static void arrayTest()
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
testPVScalarArray(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
testPVScalarArray(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,value";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
testPVScalarArray(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
pvRecord->destroy();
}