67 Commits
3.1.0 ... 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
dhickin
7743f3e3fd make "local" *.local files take precedence over those in TOP/.. 2014-12-03 16:52:01 +00:00
dhickin
e9ce6a2f0b include CONFIG_SITE.local instead of CONFIG.local at top-level. 2014-12-03 16:10:25 +00:00
Marty Kraimer
1ed48c15f1 Added tag 4.0.1 for changeset 541b0a7a645c 2014-11-11 07:07:34 -05:00
Marty Kraimer
d27f929595 merge from default branch 2014-11-11 06:52:56 -05:00
Matej Sekoranja
b4e17f271b win32 vs2013 compilation fix 2014-11-11 09:05:25 +01:00
Marty Kraimer
79f407486a in the future remove recordList since pvAccess provides pvlist 2014-11-10 10:24:07 -05:00
Matej Sekoranja
3c359728f7 Added tag 4.0.0 for changeset 85d46a2614f9 2014-10-29 13:17:22 +01:00
Matej Sekoranja
7b9693562a merge 2014-10-29 13:15:33 +01:00
Matej Sekoranja
f1c39ca5d2 clang compilation fixes 2014-10-16 07:30:42 +02:00
Marty Kraimer
16b1775b98 Added tag 4.0.0 for changeset 42dbe8a17f85 2014-10-15 08:37:24 -04:00
Marty Kraimer
f6ee7333bb merge changes from default 2014-10-15 07:29:49 -04:00
Matej Sekoranja
9f45bdfa75 missing epicsShareClass PowerSupply 2014-10-14 21:26:07 +02:00
Matej Sekoranja
03aa15b5f7 added missing lib for win32 2014-10-14 20:41:36 +02:00
Matej Sekoranja
8093952ca2 win32 test dll linkage 2014-10-14 07:40:34 +02:00
Marty Kraimer
2bea54e218 updated pvDatabaseCPP.html and TODO 2014-10-09 09:33:13 -04:00
dhickin
e81230dba5 Corrected spelling of synchrotron in licence. 2014-10-04 02:45:53 +01:00
dhickin
50b8f306c3 Spelling and typos. 2014-10-04 01:39:14 +01:00
Marty Kraimer
65be8e5678 Added tag 4.0.0 for changeset e2e041fa7d04 2014-10-01 09:01:22 -04:00
Marty Kraimer
dbb9310adc flow: Created branch 'release/4.0'. 2014-10-01 08:58:34 -04:00
Matej Sekoranja
50fbb396e8 win32 compilation of test and examples 2014-09-13 23:40:41 +02:00
Matej Sekoranja
ff19fe1cd8 win32 linkage 2014-09-13 23:01:29 +02:00
Matej Sekoranja
230938220e win compilation 2014-09-13 00:18:25 +02:00
Matej Sekoranja
334ed3b70a hopefully fixed windows exports 2014-09-12 10:00:00 +02:00
Marty Kraimer
4c7e51d8ad prepare documentation for pre release 2014-09-03 09:13:45 -04:00
Marty Kraimer
4973a6297e fixed bug in creating implementation of channelArray 2014-08-29 09:33:42 -04:00
Marty Kraimer
f0d1481a28 nanoSecond => nanosecond 2014-08-20 06:36:40 -04:00
Marty Kraimer
d5235db54c mainly documentation changes; did much testing 2014-08-11 14:18:49 -04:00
Marty Kraimer
b125035a11 fixed connection problems 2014-08-07 14:36:35 -04:00
Marty Kraimer
9551b0e4c6 fixed bugs in implementation of montor; connection problems still exist 2014-08-07 08:02:53 -04:00
Marty Kraimer
d6aa03815e changes because of ChannelArray API change; update TODO.md; add RELEASE_NOTES.html and TODO.html 2014-07-22 08:53:32 -04:00
Marty Kraimer
ce0d62fbbc changed upcoming release number. 2014-07-10 13:38:06 -04:00
Marty Kraimer
2fe3e66047 updated documentation; fixed bugs while updating documentation 2014-07-10 13:25:58 -04:00
dhickin
fa53d72258 Corrected includes for CONFIG_SITE files. 2014-07-02 12:27:00 +01:00
Marty Kraimer
b010cf0849 add some records for testing easyPVAJava 2014-07-02 07:11:50 -04:00
Matej Sekoranja
7fd707cb4b Added tag 3.1.0 for changeset 395f48d5196d 2014-07-02 00:12:37 +02:00
82 changed files with 7443 additions and 2437 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,2 +0,0 @@
bba6a2491bdf73681cef01caf0bd89c87d7989cd 0.9.1
abdc90bf52a0c31e24e2f9a079ef72350ee31686 before_merge_changesAfter3_0_2

2489
Doxyfile

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
Copyright (c) 2008 Martin R. Kraimer
Copyright (c) 2006 The University of Chicago, as Operator of Argonne
National Laboratory.
Copyright (c) 2006 Deutsches Elektronen-Synchroton,
Copyright (c) 2006 Deutsches Elektronen-Synchrotron,
Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
Copyright (c) 2007 Control System Laboratory,
(COSYLAB) Ljubljana Slovenia

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

@@ -35,5 +35,5 @@
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../configure/CONFIG_SITE.local

View File

@@ -59,9 +59,9 @@ bool ArrayPerformance::init()
{
initPVRecord();
PVScalarArrayPtr pvScalarArray = getPVStructure()->getScalarArrayField("value",pvLong);
if(pvScalarArray==NULL) 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();
@@ -182,14 +182,18 @@ void ArrayPerformanceThread::run()
nSinceLastReport = 0;
}
++nSinceLastReport;
shared_vector<int64> xxx(arrayPerformance->size,value++);
shared_vector<const int64> data(freeze(xxx));
arrayPerformance->lock();
try {
arrayPerformance->beginGroupPut();
arrayPerformance->pvValue->replace(data);
arrayPerformance->process();
arrayPerformance->endGroupPut();
if(arrayPerformance->getTraceLevel()>1) {
cout << "arrayPerformance size " << arrayPerformance->size;
cout << " value " << value +1 << endl;
}
shared_vector<int64> xxx(arrayPerformance->size,value++);
shared_vector<const int64> data(freeze(xxx));
arrayPerformance->beginGroupPut();
arrayPerformance->pvValue->replace(data);
arrayPerformance->process();
arrayPerformance->endGroupPut();
} catch(...) {
arrayPerformance->unlock();
throw;

View File

@@ -17,7 +17,6 @@
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <epicsThread.h>
#include <pv/standardPVField.h>
#include <pv/timeStamp.h>

View File

@@ -266,9 +266,9 @@ void LongArrayChannelGet::channelGetConnect(
bool structureOK(true);
PVStructurePtr pvStructure = getPVDataCreate()->createPVStructure(structure);
PVFieldPtr pvField = pvStructure->getSubField("timeStamp");
if(pvField==NULL) structureOK = false;
if(!pvField) structureOK = false;
pvField = pvStructure->getSubField("value");
if(pvField==NULL) {
if(!pvField) {
structureOK = false;
} else {
FieldConstPtr field = pvField->getField();
@@ -292,7 +292,7 @@ bool LongArrayChannelGet::init()
{
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
if(!channelProvider) {
cout << "provider " << providerName << " not found" << endl;
return false;
}
@@ -305,7 +305,7 @@ bool LongArrayChannelGet::init()
if(!status.isOK()) return false;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
if(!pvRequest) {
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}
@@ -334,10 +334,10 @@ void LongArrayChannelGet::destroy()
if(runReturned) break;
epicsThreadSleep(.01);
}
if(longArrayChannelRequester!=NULL) {
if(longArrayChannelRequester) {
longArrayChannelRequester->destroy();
}
if(longArrayChannelGetRequester!=NULL) {
if(longArrayChannelGetRequester) {
longArrayChannelGetRequester->destroy();
}
thread->exitWait();
@@ -433,7 +433,7 @@ void LongArrayChannelGet::run()
CreateRequest::create();
PVStructurePtr pvRequest =
createRequest->createRequest(request);
if(pvRequest==NULL) {
if(!pvRequest) {
cout << "request logic error " << createRequest->getMessage() << endl;
return ;
}

View File

@@ -17,8 +17,6 @@
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>

View File

@@ -138,9 +138,9 @@ void LAMMonitorRequester::monitorConnect(Status const & status,
}
bool structureOK(true);
FieldConstPtr field = structure->getField("timeStamp");
if(field==NULL) structureOK = false;
if(!field) structureOK = false;
field = structure->getField("value");
if(field==NULL) {
if(!field) {
structureOK = false;
} else {
if(field->getType()!=scalarArray) {
@@ -179,9 +179,9 @@ void LAMMonitorRequester::run()
{
Lock xx(mutex);
monitorElement = longArrayMonitor->monitor->poll();
if(monitorElement!=NULL) pvStructure = monitorElement->pvStructurePtr;
if(monitorElement) pvStructure = monitorElement->pvStructurePtr;
}
if(monitorElement==NULL) break;
if(!monitorElement) break;
if(waitTime>0.0) epicsThreadSleep(waitTime);
pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
pvTimeStamp.get(timeStamp);
@@ -268,7 +268,7 @@ bool LongArrayMonitor::init(
monitorRequester->init();
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
if(!channelProvider) {
cout << "provider " << providerName << " not found" << endl;
return false;
}
@@ -282,7 +282,7 @@ bool LongArrayMonitor::init(
request += "]field(value,timeStamp,alarm)";
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
if(!pvRequest) {
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}

View File

@@ -16,7 +16,6 @@
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>

View File

@@ -110,7 +110,7 @@ private:
bool LongArrayChannelPut::init()
{
ChannelProvider::shared_pointer channelProvider = getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
if(!channelProvider) {
cout << "provider " << providerName << " not found" << endl;
return false;
}
@@ -119,7 +119,7 @@ bool LongArrayChannelPut::init()
if(!status.isOK()) return false;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
if(!pvRequest) {
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}
@@ -187,7 +187,7 @@ void LongArrayChannelPut::channelPutConnect(
bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields()));
bool structureOK(true);
PVFieldPtr pvField = pvStructure->getSubField("value");
if(pvField==NULL) {
if(!pvField) {
structureOK = false;
} else {
FieldConstPtr field = pvField->getField();
@@ -267,7 +267,6 @@ void LongArrayChannelPut::run()
if(iterBetweenCreateChannel!=0) {
if(numChannelCreate>=iterBetweenCreateChannel) {
channel->destroy();
epicsThreadSleep(1.0);
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
channel = channelProvider->createChannel(
@@ -295,7 +294,7 @@ void LongArrayChannelPut::run()
channelPut->destroy();
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
if(!pvRequest) {
cout << "request logic error " << createRequest->getMessage() << endl;
return ;
}

View File

@@ -17,7 +17,6 @@
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>

View File

@@ -25,4 +25,3 @@ USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/../CONFIG_SITE.local
-include $(TOP)/configure/CONFIG_SITE.local

View File

@@ -0,0 +1,25 @@
<h1>Release 4.0 IN DEVELOPMENT</h1>
<p>The main changes since release 3.0.2 are:</p>
<ul>
<li>array semantics now enforce Copy On Write.</li>
<li>String no longer defined.</li>
<li>toString replaced by stream I/O </li>
<li>union is new type.</li>
<li>copy and monitor use new code in pvDataCPP</li>
</ul>
<h2>New Semantics for Arrays</h2>
<p>pvDatabaseCPP has been changed to use the new array implementation from pvDataCPP.</p>
<h2>String no longer defined</h2>
<p>String is replaced by std::string.</p>
<h2>toString replaced by stream I/O</h2>
<p>All uses of toString have been changed to use the steam I/O that pvDataCPP implements.</p>
<h2>union is a new basic type.</h2>
<p>exampleDatabase now has example records for union and union array.
There are records for regular union and for variant union.</p>
<h2>copy</h2>
<p>The implementation of copy and monitor for pvAccess has been changed
to use the new monitor and copy support from pvDataCPP.</p>
<h2>monitorPlugin</h2>
<p>exampleDatabase now has a example plugin that implements onChange.</p>
<h1>Release 0.9.2</h1>
<p>This was the starting point for RELEASE_NOTES</p>

View File

@@ -0,0 +1,50 @@
Release 4.0 IN DEVELOPMENT
===========
The main changes since release 3.0.2 are:
* array semantics now enforce Copy On Write.
* String no longer defined.
* toString replaced by stream I/O
* union is new type.
* copy and monitor use new code in pvDataCPP
New Semantics for Arrays
--------
pvDatabaseCPP has been changed to use the new array implementation from pvDataCPP.
String no longer defined
---------
String is replaced by std::string.
toString replaced by stream I/O
---------
All uses of toString have been changed to use the steam I/O that pvDataCPP implements.
union is a new basic type.
------------
exampleDatabase now has example records for union and union array.
There are records for regular union and for variant union.
copy
----
The implementation of copy and monitor for pvAccess has been changed
to use the new monitor and copy support from pvDataCPP.
monitorPlugin
-------------
exampleDatabase now has a example plugin that implements onChange.
Release 0.9.2
==========
This was the starting point for RELEASE_NOTES

13
documentation/TODO.html Normal file
View File

@@ -0,0 +1,13 @@
<h1>TODO</h1>
<h2>recordList</h2>
<p>This is putGet support that provides a list of all the records in an IOC.
Since pvAccess implements pvlist this is no longer needed.
Remove it from pvDatabaseCPP and pvIOCCPP.
Also remove channelList from swtshell.</p>
<h2>monitorPlugin</h2>
<p>A debate is on-going about what semantics should be.</p>
<h2>Must test record delete.</h2>
<p>Must test removing a record from the PVDatabase while a pvAccess client
is attached. Also why do both unlisten and detach exists?</p>
<h2>create more regression tests</h2>
<p>Currently only some simple tests exist. Most of the testing has been via the examples</p>

28
documentation/TODO.md Normal file
View File

@@ -0,0 +1,28 @@
TODO
===========
recordList
----------
This is putGet support that provides a list of all the records in an IOC.
Since pvAccess implements pvlist this is no longer needed.
Remove it from pvDatabaseCPP and pvIOCCPP.
Also remove channelList from swtshell.
monitorPlugin
-------------
A debate is on-going about what semantics should be.
Must test record delete.
-------------------
Must test removing a record from the PVDatabase while a pvAccess client
is attached. Also why do both unlisten and detach exists?
create more regression tests
----------------
Currently only some simple tests exist. Most of the testing has been via the examples

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,5 @@ CHECK_RELEASE = WARN
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/../configure/CONFIG_SITE.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../configure/CONFIG_SITE.local

View File

@@ -17,6 +17,7 @@ DB += dbString.db
DB += dbStringArray.db
DB += dbEnum.db
DB += dbCounter.db
DB += dbDouble.db
#----------------------------------------------------
# If <anyname>.db template is not named <anyname>*.template add

View File

@@ -0,0 +1,3 @@
record(ao, "$(name)")
{
}

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,15 +7,17 @@ dbLoadDatabase("dbd/exampleDatabase.dbd")
exampleDatabase_registerRecordDeviceDriver(pdbbase)
## Load record instances
dbLoadRecords("db/dbScalar.db","name=double00,type=ao")
dbLoadRecords("db/dbScalar.db","name=double01,type=ao")
dbLoadRecords("db/dbScalar.db","name=double02,type=ao")
dbLoadRecords("db/dbScalar.db","name=double03,type=ao")
dbLoadRecords("db/dbScalar.db","name=double04,type=ao")
dbLoadRecords("db/dbScalar.db","name=double05,type=ao")
dbLoadRecords("db/dbDouble.db","name=double00")
dbLoadRecords("db/dbDouble.db","name=double01")
dbLoadRecords("db/dbDouble.db","name=double02")
dbLoadRecords("db/dbDouble.db","name=double03")
dbLoadRecords("db/dbDouble.db","name=double04")
dbLoadRecords("db/dbDouble.db","name=double05")
dbLoadRecords("db/dbStringArray.db","name=stringArray01")
dbLoadRecords("db/dbEnum.db","name=enum01")
dbLoadRecords("db/dbCounter.db","name=counter01");
dbLoadRecords("db/dbArray.db","name=doubleArray,type=DOUBLE");
cd ${TOP}/iocBoot/${IOC}
iocInit()

View File

@@ -7,13 +7,11 @@ 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
exampleDatabase_LIBS += pvData

View File

@@ -27,6 +27,8 @@
#include <pv/traceRecord.h>
#include <pv/powerSupply.h>
#define epicsExportSharedSymbols
#include <pv/exampleDatabase.h>
using namespace std;
@@ -147,17 +149,20 @@ void ExampleDatabase::create()
createVariantUnionArrayRecord(master,"exampleVariantUnionArray");
recordName = "examplePowerSupply";
PVStructurePtr pvStructure = createPowerSupply();
PowerSupplyPtr psr =
PowerSupply::create(recordName,pvStructure);
if(psr.get()==NULL) {
cout << "PowerSupply::create failed" << endl;
return;
PowerSupplyPtr psr = PowerSupply::create(recordName,pvStructure);
if(!psr) {
cout << "PowerSupply::create failed" << endl;
} else {
result = master->addRecord(psr);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
result = master->addRecord(psr);
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;
if(!pvRecord) {
cout << "RecordListRecord::create failed" << endl;
} else {
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
}

View File

@@ -16,15 +16,15 @@
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/pvDatabase.h>
#ifdef exampledatabaseEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef exampledatabaseEpicsExportSharedSymbols
# include <shareLib.h>
#endif
#include <shareLib.h>
namespace epics { namespace pvDatabase {
class epicsShareClass ExampleDatabase{

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

@@ -32,7 +32,6 @@
#include <pv/pvDatabase.h>
#include <epicsExport.h>
#include <pv/exampleDatabase.h>
using namespace epics::pvData;

View File

@@ -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/convert.h>
#include <pv/monitorPlugin.h>
#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!=NULL) {
PVStringPtr pvString =
pvFieldOptions->getSubField<PVString>("raiseMonitor");
if(pvString!=NULL) {
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==NULL) {
plugin = OnChangePluginCreatorPtr(new OnChangePluginCreator());
MonitorPluginManager::get()->addPlugin(pluginName,plugin);
}
}
}}

View File

@@ -1,29 +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
#include <shareLib.h>
#include <pv/pvDatabase.h>
#include <pv/monitorPlugin.h>
namespace epics { namespace pvDatabase {
class epicsShareClass ExampleMonitorPlugin{
public:
static void create();
};
}}
#endif /* EXAMPLEMONITORPLUGIN_H */

View File

@@ -1,64 +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 <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.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

@@ -35,5 +35,5 @@
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../configure/CONFIG_SITE.local

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

@@ -13,4 +13,4 @@ cd ${TOP}/iocBoot/${IOC}
iocInit()
startPVAClient
startPVAServer
exampleLinkCreateRecord exampleLinkRemote pvAccess doubleArray
exampleLinkCreateRecord exampleLink pvAccess doubleArray

View File

@@ -9,9 +9,10 @@
* @date 2013.08.02
*/
#include <pv/exampleLink.h>
#include <pv/standardPVField.h>
#include <pv/convert.h>
#define epicsExportSharedSymbols
#include <pv/exampleLink.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
@@ -44,8 +45,7 @@ ExampleLink::ExampleLink(
PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure),
providerName(providerName),
channelName(channelName),
convert(getConvert())
channelName(channelName)
{
}
@@ -61,14 +61,13 @@ 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));
if(pvValue==NULL) {
pvValue = pvStructure->getSubField<PVDoubleArray>("value");
if(!pvValue) {
return false;
}
ChannelProvider::shared_pointer provider =
getChannelProviderRegistry()->getProvider(providerName);
if(provider==NULL) {
if(!provider) {
cout << getRecordName() << " provider "
<< providerName << " does not exist" << endl;
return false;
@@ -93,9 +92,8 @@ bool ExampleLink::init()
<< status.getMessage() << endl;
return false;
}
getPVValue = static_pointer_cast<PVDoubleArray>(
getPVStructure->getScalarArrayField("value",pvDouble));
if(getPVValue==NULL) {
getPVValue = getPVStructure->getSubField<PVDoubleArray>("value");
if(!getPVValue) {
cout << getRecordName() << " get value not PVDoubleArray" << endl;
return false;
}
@@ -119,7 +117,7 @@ void ExampleLink::process()
}
alarm.setSeverity(severity);
} else {
convert->copy(getPVValue,pvValue);
pvValue->copyUnchecked(*getPVValue);
}
alarm.setMessage(status.getMessage());
pvAlarm.set(alarm);
@@ -147,6 +145,7 @@ void ExampleLink::channelGetConnect(
{
this->status = status;
this->channelGet = channelGet;
getPVStructure = getPVDataCreate()->createPVStructure(structure);
event.signal();
}
@@ -157,7 +156,7 @@ void ExampleLink::getDone(
BitSetPtr const & bitSet)
{
this->status = status;
getPVStructure = pvStructure;
getPVStructure->copyUnchecked(*pvStructure);
this->bitSet = bitSet;
event.signal();
}

View File

@@ -11,7 +11,10 @@
#ifndef EXAMPLEPVADOUBLEARRAYGET_H
#define EXAMPLEPVADOUBLEARRAYGET_H
#include <shareLib.h>
#ifdef epicsExportSharedSymbols
# define exampleLinkEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
@@ -22,6 +25,13 @@
#include <pv/pvAccess.h>
#include <pv/serverContext.h>
#ifdef exampleLinkEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef exampleLinkEpicsExportSharedSymbols
#endif
#include <shareLib.h>
namespace epics { namespace pvDatabase {
@@ -73,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

@@ -27,14 +27,14 @@
#include <epicsThread.h>
#include <iocsh.h>
#include <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <epicsExport.h>
#include <pv/exampleLink.h>
using namespace epics::pvData;
@@ -70,8 +70,8 @@ static void exampleLinkCallFunc(const iocshArgBuf *args)
char *providerName = args[1].sval;
char *channelName = args[2].sval;
ExampleLinkPtr record = ExampleLink::create(recordName,providerName,channelName);
if(record!=NULL)
result = master->addRecord(record);
if(record)
result = master->addRecord(record);
if(!result) cout << "recordname" << " not added" << endl;
}
@@ -86,4 +86,4 @@ static void exampleLinkRegister(void)
extern "C" {
epicsExportRegistrar(exampleLinkRegister);
}
}

View File

@@ -35,5 +35,5 @@
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../configure/CONFIG_SITE.local

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,23 +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;
@@ -35,34 +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;
pvRecord.reset();
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;
recordName = "laptoprecordListPGRPC";
pvRecord = RecordListRecord::create(recordName);
result = master->addRecord(pvRecord);
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

@@ -35,5 +35,5 @@
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../configure/CONFIG_SITE.local

View File

@@ -1,4 +1,5 @@
include "base.dbd"
include "PVAClientRegister.dbd"
include "PVAServerRegister.dbd"
include "registerChannelProviderLocal.dbd"
include "dbPv.dbd"

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

@@ -9,7 +9,9 @@
* @date 2013.04.02
*/
#include <pv/standardPVField.h>
#include <pv/standardField.h>
#define epicsExportSharedSymbols
#include <pv/exampleServer.h>
using namespace epics::pvData;
@@ -23,19 +25,20 @@ namespace epics { namespace exampleServer {
ExampleServerPtr ExampleServer::create(
string const & recordName)
{
StandardPVFieldPtr standardPVField = getStandardPVField();
StandardFieldPtr standardField = getStandardField();
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
PVStructurePtr pvArgument = standardPVField->scalar(pvString,"");
PVStructurePtr pvResult = standardPVField->scalar(pvString,"timeStamp");
StringArray names;
names.reserve(2);
PVFieldPtrArray fields;
fields.reserve(2);
names.push_back("argument");
fields.push_back(pvArgument);
names.push_back("result");
fields.push_back(pvResult);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(names,fields);
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
addNestedStructure("argument")->
add("value",pvString)->
endNested()->
addNestedStructure("result") ->
add("value",pvString) ->
add("timeStamp",standardField->timeStamp()) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
ExampleServerPtr pvRecord(
new ExampleServer(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
@@ -63,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,15 +8,26 @@
* @author mrk
* @date 2013.04.02
*/
#ifndef EXAMPLECOUNTER_H
#define EXAMPLECOUNTER_H
#ifndef EXAMPLESERVER_H
#define EXAMPLESERVER_H
#include <shareLib.h>
#ifdef epicsExportSharedSymbols
# define exampleServerEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <pv/pvDatabase.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
#ifdef exampleServerEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef exampleServerEpicsExportSharedSymbols
#endif
#include <shareLib.h>
namespace epics { namespace exampleServer {
@@ -47,4 +58,4 @@ private:
}}
#endif /* EXAMPLECOUNTER_H */
#endif /* EXAMPLESERVER_H */

View File

@@ -10,23 +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;
@@ -35,33 +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);
cout << "result of addRecord " << recordName << " " << result << endl;
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;
pvRecord.reset();
ServerContext::shared_pointer pvaServer =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleServer\n";
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();
recordName = "laptoprecordListPGRPC";
pvRecord = RecordListRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
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;
contextLocal->waitForExit();
return 0;
}

View File

@@ -27,12 +27,13 @@
#include <epicsThread.h>
#include <iocsh.h>
#include <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <pv/recordList.h>
#include <epicsExport.h>
#include <pv/exampleServer.h>
using namespace epics::pvData;
@@ -50,10 +51,19 @@ static const iocshFuncDef exampleServerFuncDef = {
"exampleServerCreateRecord", 1, testArgs};
static void exampleServerCallFunc(const iocshArgBuf *args)
{
PVDatabasePtr master = PVDatabase::getMaster();
char *recordName = args[0].sval;
ExampleServerPtr record = ExampleServer::create(recordName);
bool result = PVDatabase::getMaster()->addRecord(record);
bool result = master->addRecord(record);
if(!result) cout << "recordname" << " not added" << endl;
PVRecordPtr pvRecord = RecordListRecord::create(
"laptoprecordListPGRPC");
if(!pvRecord) {
cout << "RecordListRecord::create failed" << endl;
} else {
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
}
static void exampleServerRegister(void)

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,54 +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

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,15 +21,16 @@
#include <deque>
#include <pv/pvData.h>
#include <pv/convert.h>
#include <pv/pvCopy.h>
#include <pv/pvTimeStamp.h>
#ifdef pvdatabaseEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef pvdatabaseEpicsExportSharedSymbols
# include <shareLib.h>
#endif
#include <shareLib.h>
namespace epics { namespace pvDatabase {
@@ -55,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:
@@ -82,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.
@@ -166,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.
*/
@@ -219,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;
@@ -229,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
*/
@@ -286,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.
@@ -315,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;
@@ -329,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
*/
@@ -364,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.
*/
@@ -379,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 {
@@ -403,6 +411,8 @@ public:
};
/**
* @brief Listener for PVRecord::message.
*
* An interface that is implemented by code that traps calls to PVRecord::message.
* @author mrk
*/
@@ -447,7 +457,8 @@ public:
};
/**
* The interface to a database of PVRecords.
* @brief The interface for a database of PVRecords.
*
* @author mrk
*/
class epicsShareClass PVDatabase {
@@ -502,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;
}
@@ -371,7 +405,7 @@ void PVRecordField::init()
{
fullFieldName = pvField->getFieldName();
PVRecordStructurePtr pvParent = parent;
while(pvParent.get()!= NULL) {
while(pvParent) {
string parentName = pvParent->getPVField()->getFieldName();
if(parentName.size()>0) {
fullFieldName = pvParent->getPVField()->getFieldName()
@@ -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()) {
@@ -434,7 +474,7 @@ void PVRecordField::removeListener(PVListenerPtr const & pvListener)
void PVRecordField::postPut()
{
if(parent!=NULL) {
if(parent) {
parent->postParent(getPtrSelf());
}
postSubField();
@@ -448,7 +488,7 @@ void PVRecordField::postParent(PVRecordFieldPtr const & subField)
{
(*iter)->dataPut(pvrs,subField);
}
if(parent!=NULL) parent->postParent(subField);
if(parent) parent->postParent(subField);
}
void PVRecordField::postSubField()

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;
@@ -70,7 +68,7 @@ typedef std::tr1::shared_ptr<ChannelArrayLocal> ChannelArrayLocalPtr;
static bool getProcess(PVStructurePtr pvRequest,bool processDefault)
{
PVFieldPtr pvField = pvRequest->getSubField("record._options.process");
if(pvField==NULL || pvField->getField()->getType()!=scalar) {
if(!pvField || pvField->getField()->getType()!=scalar) {
return processDefault;
}
ScalarConstPtr scalar = static_pointer_cast<const Scalar>(
@@ -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(
@@ -146,13 +144,13 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
PVFieldPtr pvField;
PVStructurePtr pvOptions;
int nProcess = 1;
if(pvRequest!=NULL) pvField = pvRequest->getSubField("record._options");
if(pvField.get()!=NULL) {
if(pvRequest) pvField = pvRequest->getSubField("record._options");
if(pvField) {
pvOptions = static_pointer_cast<PVStructure>(pvField);
pvField = pvOptions->getSubField("nProcess");
if(pvField.get()!=NULL) {
PVStringPtr pvString = pvOptions->getStringField("nProcess");
if(pvString.get()!=NULL) {
if(pvField) {
PVStringPtr pvString = pvOptions->getSubField<PVString>("nProcess");
if(pvString) {
int size;
std::stringstream ss;
ss << pvString->get();
@@ -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()
{
@@ -291,7 +289,7 @@ ChannelGetLocalPtr ChannelGetLocal::create(
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"");
if(pvCopy==NULL) {
if(!pvCopy) {
Status status(
Status::STATUSTYPE_ERROR,
"invalid pvRequest");
@@ -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()
{
@@ -442,7 +440,7 @@ ChannelPutLocalPtr ChannelPutLocal::create(
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"");
if(pvCopy==NULL) {
if(!pvCopy) {
Status status(
Status::STATUSTYPE_ERROR,
"invalid pvRequest");
@@ -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()
{
@@ -624,7 +622,7 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
pvRecord->getPVRecordStructure()->getPVStructure(),
pvRequest,
"getField");
if(pvPutCopy==NULL || pvGetCopy==NULL) {
if(!pvPutCopy || !pvGetCopy) {
Status status(
Status::STATUSTYPE_ERROR,
"invalid pvRequest");
@@ -777,14 +775,14 @@ public:
PVArrayPtr const &putArray,
size_t offset, size_t count, size_t stride);
virtual void getLength();
virtual void setLength(size_t length, size_t capacity);
virtual void setLength(size_t length);
virtual void destroy();
virtual std::tr1::shared_ptr<Channel> getChannel()
{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()
{
@@ -841,8 +839,12 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
if(pvfs.size()!=1) break;
pvField = pvfs[0];
}
size_t indfield = fieldName.find_first_of("field.");
if(indfield==0) {
fieldName = fieldName.substr(6);
}
pvField = pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(fieldName);
if(pvField==NULL) {
if(!pvField) {
Status status(
Status::STATUSTYPE_ERROR,fieldName +" not found");
ChannelArrayLocalPtr channelArray;
@@ -869,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;
}
@@ -1021,7 +986,7 @@ void ChannelArrayLocal::putArray(
return;
}
size_t newLength = offset + count*stride;
pvArray->setLength(newLength);
if(newLength<pvArray->getLength()) pvArray->setLength(newLength);
const char *exceptionMessage = NULL;
pvRecord->lock();
try {
@@ -1040,12 +1005,10 @@ void ChannelArrayLocal::putArray(
void ChannelArrayLocal::getLength()
{
size_t length = 0;
size_t capacity = 0;
const char *exceptionMessage = NULL;
pvRecord->lock();
try {
length = pvArray->getLength();
capacity = pvArray->getCapacity();
} catch(std::exception e) {
exceptionMessage = e.what();
}
@@ -1054,10 +1017,10 @@ void ChannelArrayLocal::getLength()
if(exceptionMessage!=NULL) {
status = Status(Status::STATUSTYPE_ERROR,exceptionMessage);
}
channelArrayRequester->getLengthDone(status,getPtrSelf(),length,capacity);
channelArrayRequester->getLengthDone(status,getPtrSelf(),length);
}
void ChannelArrayLocal::setLength(size_t length, size_t capacity)
void ChannelArrayLocal::setLength(size_t length)
{
if(isDestroyed) {
channelArrayRequester->setLengthDone(channelDestroyedStatus,getPtrSelf());
@@ -1069,17 +1032,6 @@ void ChannelArrayLocal::setLength(size_t length, size_t capacity)
}
pvRecord->lock();
try {
if(capacity>=0 && !pvArray->isCapacityMutable()) {
Status status(
Status::STATUSTYPE_ERROR,
"capacityImnutable");
channelArrayRequester->setLengthDone(status,getPtrSelf());
pvRecord->unlock();
return;
}
if(capacity>=0) {
if(pvArray->getCapacity()!=capacity) pvArray->setCapacity(capacity);
}
if(length>=0) {
if(pvArray->getLength()!=length) pvArray->setLength(length);
}
@@ -1092,23 +1044,6 @@ void ChannelArrayLocal::setLength(size_t length, size_t capacity)
}
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,
@@ -1170,6 +1105,8 @@ string ChannelLocal::getRemoteAddress()
Channel::ConnectionState ChannelLocal::getConnectionState()
{
Lock xx(mutex);
if(beingDestroyed) return Channel::DESTROYED;
return Channel::CONNECTED;
}
@@ -1185,6 +1122,8 @@ ChannelRequester::shared_pointer ChannelLocal::getChannelRequester()
bool ChannelLocal::isConnected()
{
Lock xx(mutex);
if(beingDestroyed) return false;
return true;
}
@@ -1199,7 +1138,7 @@ void ChannelLocal::getField(GetFieldRequester::shared_pointer const &requester,
}
PVFieldPtr pvField =
pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(subField);
if(pvField.get()!=NULL) {
if(pvField) {
requester->getDone(Status::Ok,pvField->getField());
return;
}
@@ -1308,7 +1247,7 @@ void ChannelLocal::printInfo()
void ChannelLocal::printInfo(std::ostream& out)
{
out << "ChannelLocal provides access to service";
out << "ChannelLocal provides access to a record in the local PVDatabase";
}
}}

View File

@@ -71,8 +71,10 @@ ChannelProviderLocalPtr getChannelProviderLocal()
if(channelProviderLocal.get()==NULL) {
channelProviderLocal = ChannelProviderLocalPtr(
new ChannelProviderLocal());
ChannelProvider::shared_pointer xxx = dynamic_pointer_cast<ChannelProvider>(channelProviderLocal);
channelProviderLocal->channelFinder = SyncChannelFind::shared_pointer(new SyncChannelFind(xxx));
ChannelProvider::shared_pointer xxx =
dynamic_pointer_cast<ChannelProvider>(channelProviderLocal);
channelProviderLocal->channelFinder =
SyncChannelFind::shared_pointer(new SyncChannelFind(xxx));
LocalChannelProviderFactory::create(channelProviderLocal);
}
return channelProviderLocal;
@@ -86,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;
@@ -170,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

@@ -22,21 +22,21 @@
#include <memory>
#include <set>
#include <shareLib.h>
#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
# undef channelProviderLocalEpicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/pvDatabase.h>
@@ -57,12 +57,34 @@ typedef std::tr1::shared_ptr<ChannelLocal> ChannelLocalPtr;
epicsShareExtern MonitorFactoryPtr getMonitorFactory();
/**
* @brief MonitorFactory
*
* This class provides a static method to create a monitor for a PVRecord
*/
class epicsShareClass MonitorFactory
{
public:
POINTER_DEFINITIONS(MonitorFactory);
/**
* Destructor
*/
virtual ~MonitorFactory();
/**
* Destroy the monitor factory.
*/
virtual void destroy();
/**
* Create a monitor on a record.
* This is called by the local channel provider.
* @param pvRecord The record to monitor.
* @param monitorRequester The client callback.
* @param pvRequest Options specified by the client.
* This includes the subset of the fields in the record to monitor.
* @return A shared pointer to the newly created monitor.
* If the monitor can not be created a null monitor is returned.
* This means the pvRequest specified options that could not be satisfied.
*/
epics::pvData::MonitorPtr createMonitor(
PVRecordPtr const & pvRecord,
epics::pvData::MonitorRequester::shared_pointer const & monitorRequester,
@@ -78,24 +100,81 @@ private:
epicsShareExtern ChannelProviderLocalPtr getChannelProviderLocal();
/**
* @brief ChannelProvider for PVDatabase.
*
* An implementation of channelProvider that provides access to records in PVDatabase.
*/
class epicsShareClass ChannelProviderLocal :
public epics::pvAccess::ChannelProvider,
public std::tr1::enable_shared_from_this<ChannelProviderLocal>
{
public:
POINTER_DEFINITIONS(ChannelProviderLocal);
/**
* Destructor
*/
virtual ~ChannelProviderLocal();
/**
* Destroy the channel provider.
* Probably never called.
*/
virtual void destroy();
/**
* Returns the channel provider name.
* @return <b>local</b>
*/
virtual std::string getProviderName();
/**
* Returns either a null channelFind or a channelFind for records in the PVDatabase.
* @param channelName The name of the channel desired.
* @param channelFindRequester The client callback.
* @return shared pointer to ChannelFind.
* This is null if the channelName is not the name of a record in the PVDatabase.
* It is an implementation of SyncChannelFind if the channelName is the name
* of a record in the PVDatabase.
* The interface for SyncChannelFind is defined by pvAccessCPP.
* The channelFindResult method of channelFindRequester is called before the
* method returns.
*/
virtual epics::pvAccess::ChannelFind::shared_pointer channelFind(
std::string const &channelName,
epics::pvAccess::ChannelFindRequester::shared_pointer const & channelFindRequester);
/**
* Calls method channelListRequester::channelListResult which provides the
* caller with a list of the record names on the PVDatabase.
* A record name is the same as a channel name.
* @param channelListRequester The client callback.
* @return shared pointer to ChannelFind.
* The interface for SyncChannelFind is defined by pvAccessCPP.
*/
virtual epics::pvAccess::ChannelFind::shared_pointer channelList(
epics::pvAccess::ChannelListRequester::shared_pointer const & channelListRequester);
/**
* Create a channel for a record.
* This method just calls the next method with a address of "".
* @param channelName The name of the channel desired.
* @param channelRequester The client callback.
* @param priority The priority.
* @return shared pointer to Channel.
*/
virtual epics::pvAccess::Channel::shared_pointer createChannel(
std::string const &channelName,
epics::pvAccess::ChannelRequester::shared_pointer const &channelRequester,
short priority);
/**
* Create a channel for a record.
* @param channelName The name of the channel desired.
* @param channelRequester The callback to call with the result.
* @param priority The priority.
* This is ignored.
* @param address The address.
* This is ignored.
* @return shared pointer to Channel.
* This is null if the channelName is not the name of a record in the PVDatabase.
* Otherwise it is a newly created channel inteface.
* ChannelRequester::channelCreated is called to give the result.
*/
virtual epics::pvAccess::Channel::shared_pointer createChannel(
std::string const &channelName,
epics::pvAccess::ChannelRequester::shared_pointer const &channelRequester,
@@ -115,6 +194,12 @@ private:
friend class ChannelProviderLocalRun;
};
/**
* @brief Channel for accessing a PVRecord.
*
* A Channel for accessing a record in the PVDatabase.
* It is a complete implementation of Channel
*/
class epicsShareClass ChannelLocal :
public epics::pvAccess::Channel,
public PVRecordClient,
@@ -122,54 +207,185 @@ class epicsShareClass ChannelLocal :
{
public:
POINTER_DEFINITIONS(ChannelLocal);
/** Constructor
* @param channelProvider The channel provider.
* @param requester The client callback.
* @param pvRecord The record the channel will access.
*/
ChannelLocal(
ChannelProviderLocalPtr const &channelProvider,
epics::pvAccess::ChannelRequester::shared_pointer const & requester,
PVRecordPtr const & pvRecord
);
/**
* Destructor
*/
virtual ~ChannelLocal();
/**
* Destroy the channel.
* It cleans up all resources used to access the record.
* Note that this assumes that client has destroyed any objects that
* have been created for the channel like channelGet, etc.
* The remote pvAccess server does this cleanup.
*/
virtual void destroy();
/**
* Get the requester name.
* @param returns the name of the channel requester.
*/
virtual std::string getRequesterName();
/**
* Passes the message to the channel requester.
* @param message The message.
* @param messageType The message type.
*/
virtual void message(
std::string const & message,
epics::pvData::MessageType messageType);
/**
* Get the channel provider
* @return The provider.
*/
virtual epics::pvAccess::ChannelProvider::shared_pointer getProvider()
{
return provider;
}
/**
* Get the remote address
* @return <b>local</b>
*/
virtual std::string getRemoteAddress();
/**
* Get the connection state.
* @return Channel::CONNECTED.
*/
virtual epics::pvAccess::Channel::ConnectionState getConnectionState();
/**
* Get the channel name.
* @return the record name.
*/
virtual std::string getChannelName();
/**
* Get the channel requester
* @return The channel requester.
*/
virtual epics::pvAccess::ChannelRequester::shared_pointer getChannelRequester();
/**
* Is the channel connected?
* @return true
*/
virtual bool isConnected();
/**
* Get the introspection interface for subField.
* The introspection interface is given via GetFieldRequester::getDone.
* @param requester The client callback.
* @param The subField of the record.
* If an empty string then the interface for the top level structure of
* the record is provided.
*/
virtual void getField(
epics::pvAccess::GetFieldRequester::shared_pointer const &requester,
std::string const & subField);
/**
* Get the access rights for the record.
* This throws an exception because it is assumed that access rights are
* handled by a higher level.
*/
virtual epics::pvAccess::AccessRights getAccessRights(
epics::pvData::PVField::shared_pointer const &pvField);
/**
* Create a channelProcess.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvAccess::ChannelProcess::shared_pointer createChannelProcess(
epics::pvAccess::ChannelProcessRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a channelGet.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvAccess::ChannelGet::shared_pointer createChannelGet(
epics::pvAccess::ChannelGetRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a channelPut.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvAccess::ChannelPut::shared_pointer createChannelPut(
epics::pvAccess::ChannelPutRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a channelPutGet.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvAccess::ChannelPutGet::shared_pointer createChannelPutGet(
epics::pvAccess::ChannelPutGetRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a channelRPC.
* This is not implemented because pvAccessCPP implements channelRPC.
* The server side of remote pvAccess implements a channel provider
* just for channelRPC.
* @param requester The client callback
* @param pvRequest The options specified by the client.
* @return null.
*/
virtual epics::pvAccess::ChannelRPC::shared_pointer createChannelRPC(
epics::pvAccess::ChannelRPCRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a monitor.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvData::Monitor::shared_pointer createMonitor(
epics::pvData::MonitorRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* Create a channelArray.
* See pvAccess.html for details.
* @param requester The client callback.
* @param pvRequest The options specified by the client.
* @return A shared pointer to the newly created implementation.
* The implementation is null if pvRequest has invalid options.
*/
virtual epics::pvAccess::ChannelArray::shared_pointer createChannelArray(
epics::pvAccess::ChannelArrayRequester::shared_pointer const &requester,
epics::pvData::PVStructurePtr const &pvRequest);
/**
* calls printInfo(std::cout);
*/
virtual void printInfo();
/**
* displays a message
* "ChannelLocal provides access to a record in the local PVDatabase".
* @param out the stream on which the message is displayed.
*/
virtual void printInfo(std::ostream& out);
/**
* This is called when a record is being removed from the database.
* Calls destroy.
* @record The record being destroyed.
*/
virtual void detach(PVRecordPtr const &pvRecord);
protected:
shared_pointer getPtrSelf()
@@ -184,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;
@@ -30,66 +29,27 @@ using std::string;
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();
class ElementQueue;
typedef std::tr1::shared_ptr<ElementQueue> ElementQueuePtr;
class MultipleElementQueue;
typedef std::tr1::shared_ptr<MultipleElementQueue> MultipleElementQueuePtr;
class ElementQueue :
public Monitor,
public std::tr1::enable_shared_from_this<ElementQueue>
{
public:
POINTER_DEFINITIONS(ElementQueue);
virtual ~ElementQueue(){}
virtual bool dataChanged() = 0;
protected:
ElementQueuePtr getPtrSelf()
{
return shared_from_this();
}
};
typedef Queue<MonitorElement> MonitorElementQueue;
typedef std::tr1::shared_ptr<MonitorElementQueue> MonitorElementQueuePtr;
class MultipleElementQueue :
public ElementQueue
{
public:
POINTER_DEFINITIONS(MultipleElementQueue);
virtual ~MultipleElementQueue(){}
MultipleElementQueue(
MonitorLocalPtr const &monitorLocal,
MonitorElementQueuePtr const &queue,
size_t nfields);
virtual void destroy(){}
virtual Status start();
virtual Status stop();
virtual bool dataChanged();
virtual MonitorElementPtr poll();
virtual void release(MonitorElementPtr const &monitorElement);
private:
std::tr1::weak_ptr<MonitorLocal> monitorLocal;
MonitorElementQueuePtr queue;
MonitorElementPtr activeElement;
bool queueIsFull;
};
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();
@@ -97,15 +57,22 @@ public:
virtual Status stop();
virtual MonitorElementPtr poll();
virtual void destroy();
virtual void dataChanged();
virtual void unlisten();
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();
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()
{
@@ -113,12 +80,14 @@ private:
}
MonitorRequester::shared_pointer monitorRequester;
PVRecordPtr pvRecord;
bool isDestroyed;
bool firstMonitor;
MonitorState state;
PVCopyPtr pvCopy;
ElementQueuePtr queue;
PVCopyMonitorPtr pvCopyMonitor;
MonitorElementQueuePtr queue;
MonitorElementPtr activeElement;
bool isGroupPut;
bool dataChanged;
Mutex mutex;
Mutex queueMutex;
};
MonitorLocal::MonitorLocal(
@@ -126,8 +95,9 @@ MonitorLocal::MonitorLocal(
PVRecordPtr const &pvRecord)
: monitorRequester(channelMonitorRequester),
pvRecord(pvRecord),
isDestroyed(false),
firstMonitor(true)
state(idle),
isGroupPut(false),
dataChanged(false)
{
}
@@ -143,125 +113,237 @@ 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();
}
unlisten();
stop();
pvCopyMonitor->destroy();
pvCopy->destroy();
pvCopyMonitor.reset();
queue.reset();
pvCopy.reset();
}
Status MonitorLocal::start()
{
Lock xx(mutex);
if(pvRecord->getTraceLevel()>0)
{
cout << "MonitorLocal::start() " << endl;
}
if(isDestroyed) return wasDestroyedStatus;
firstMonitor = true;
return queue->start();
{
Lock xx(mutex);
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();
}
return Status::Ok;
}
Status MonitorLocal::stop()
{
pvCopyMonitor->stopMonitoring();
if(pvRecord->getTraceLevel()>0){
cout << "MonitorLocal::stop() " << endl;
}
{
Lock xx(mutex);
if(pvRecord->getTraceLevel()>0){
cout << "MonitorLocal::stop() " << endl;
}
if(!isDestroyed) queue->stop();
}
if(state==destroyed) return wasDestroyedStatus;
if(state==idle) return notStartedStatus;
state = idle;
}
pvRecord->removeListener(getPtrSelf(),pvCopy);
return Status::Ok;
}
MonitorElementPtr MonitorLocal::poll()
{
Lock xx(mutex);
if(pvRecord->getTraceLevel()>1)
{
cout << "MonitorLocal::poll() " << endl;
}
if(isDestroyed) {
return NULLMonitorElement;
{
Lock xx(queueMutex);
if(state!=active) return NULLMonitorElement;
return queue->getUsed();
}
return queue->poll();
}
void MonitorLocal::release(MonitorElementPtr const & monitorElement)
{
Lock xx(mutex);
if(pvRecord->getTraceLevel()>1)
{
cout << "MonitorLocal::release() " << endl;
}
if(isDestroyed) {
return;
{
Lock xx(queueMutex);
if(state!=active) return;
queue->releaseUsed(monitorElement);
}
queue->release(monitorElement);
}
void MonitorLocal::dataChanged()
void MonitorLocal::releaseActiveElement()
{
if(pvRecord->getTraceLevel()>1)
{
cout << "MonitorLocal::dataChanged() " "firstMonitor " << firstMonitor << endl;
cout << "MonitorLocal::releaseActiveElement() " << endl;
}
bool getMonitorEvent = false;
{
Lock xx(mutex);
if(isDestroyed) return;
getMonitorEvent = queue->dataChanged();
firstMonitor = false;
Lock xx(queueMutex);
if(state!=active) return;
MonitorElementPtr newActive = queue->getFree();
if(!newActive) return;
pvCopy->updateCopyFromBitSet(activeElement->pvStructurePtr,activeElement->changedBitSet);
BitSetUtil::compress(activeElement->changedBitSet,activeElement->pvStructurePtr);
BitSetUtil::compress(activeElement->overrunBitSet,activeElement->pvStructurePtr);
queue->setUsed(activeElement);
activeElement = newActive;
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
}
if(getMonitorEvent) monitorRequester->monitorEvent(getPtrSelf());
monitorRequester->monitorEvent(getPtrSelf());
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;
}
@@ -273,31 +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);
}
MonitorElementQueuePtr elementQueue(new MonitorElementQueue(monitorElementArray));
queue = MultipleElementQueuePtr(new MultipleElementQueue(
getPtrSelf(),
elementQueue,
nfields));
// MARTY MUST IMPLEMENT algorithm
queue = MonitorElementQueuePtr(new MonitorElementQueue(monitorElementArray));
monitorRequester->monitorConnect(
Status::Ok,
getPtrSelf(),
@@ -318,7 +390,6 @@ MonitorFactory::~MonitorFactory()
void MonitorFactory::destroy()
{
Lock lock(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
@@ -335,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";
@@ -345,75 +421,6 @@ MonitorPtr MonitorFactory::createMonitor(
}
MultipleElementQueue::MultipleElementQueue(
MonitorLocalPtr const &monitorLocal,
MonitorElementQueuePtr const &queue,
size_t nfields)
: monitorLocal(monitorLocal),
queue(queue),
queueIsFull(false)
{
}
Status MultipleElementQueue::start()
{
queue->clear();
queueIsFull = false;
activeElement = queue->getFree();
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
MonitorLocalPtr ml = monitorLocal.lock();
if(ml==NULL) return wasDestroyedStatus;
ml->getPVCopyMonitor()->setMonitorElement(activeElement);
ml->getPVCopyMonitor()->startMonitoring();
return Status::Ok;
}
Status MultipleElementQueue::stop()
{
return Status::Ok;
}
bool MultipleElementQueue::dataChanged()
{
MonitorLocalPtr ml = monitorLocal.lock();
if(ml==NULL) return false;
if(queueIsFull) return false;
ml->getPVCopy()->updateCopyFromBitSet(
activeElement->pvStructurePtr,activeElement->changedBitSet);
BitSetUtil::compress(activeElement->changedBitSet,activeElement->pvStructurePtr);
BitSetUtil::compress(activeElement->overrunBitSet,activeElement->pvStructurePtr);
queue->setUsed(activeElement);
activeElement = queue->getFree();
if(activeElement==NULL) {
throw std::logic_error("MultipleElementQueue::dataChanged() logic error");
}
if(queue->getNumberFree()==0) queueIsFull = true;
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
ml->getPVCopyMonitor()->setMonitorElement(activeElement);
return true;
}
MonitorElementPtr MultipleElementQueue::poll()
{
MonitorLocalPtr ml = monitorLocal.lock();
if(ml==NULL) return MonitorElementPtr();
MonitorElementPtr monitorElement = queue->getUsed();
if(monitorElement==NULL) return monitorElement;
ml->getPVCopyMonitor()->monitorDone(monitorElement);
return monitorElement;
}
void MultipleElementQueue::release(MonitorElementPtr const &element)
{
queue->releaseUsed(element);
if(!queueIsFull) return;
queueIsFull = false;
if(!activeElement->changedBitSet->isEmpty()) {
dataChanged();
}
}
MonitorFactoryPtr getMonitorFactory()
{

View File

@@ -1,309 +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)
{
}
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!=NULL) {
PVStringPtr pvName = pvOptions->getSubField<PVString>("plugin");
if(pvName!=NULL) {
string pluginName = pvName->get();
MonitorPluginManagerPtr manager = MonitorPluginManager::get();
MonitorPluginCreatorPtr pluginCreator = manager->findPlugin(pluginName);
if(pluginCreator!=NULL) {
StructureConstPtr top = pvCopy->getStructure();
FieldConstPtr field = pvField->getField();
MonitorPluginPtr monitorPlugin = pluginCreator->create(field,top,pvOptions);
if(monitorPlugin!=NULL) {
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;
}
stopMonitoring();
pvCopyMonitorRequester.reset();
pvCopy.reset();
}
void PVCopyMonitor::startMonitoring()
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::startMonitoring()" << endl;
}
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->lock();
try {
pvRecord->addListener(getPtrSelf());
pvCopy->traverseMaster(getPtrSelf());
monitorElement->changedBitSet->clear();
monitorElement->overrunBitSet->clear();
monitorElement->changedBitSet->set(0);
pvCopyMonitorRequester->dataChanged();
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;
}
Lock xx(mutex);
if(!isMonitoring) return;
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
(*iter)->monitorPlugin->stopMonitoring();
}
isMonitoring = false;
pvRecord->removeListener(getPtrSelf());
}
void PVCopyMonitor::setMonitorElement(MonitorElementPtr const &xxx)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::setMonitorElement()" << endl;
}
monitorElement = xxx;
}
void PVCopyMonitor::monitorDone(MonitorElementPtr const &monitorElement)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::monitorDone()" << endl;
}
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
PVCopyMonitorFieldNodePtr fieldNode = *iter;
MonitorPluginPtr monitorPlugin = fieldNode->monitorPlugin;
monitorPlugin->monitorDone(monitorElement);
}
}
void PVCopyMonitor::detach(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::detach()" << endl;
}
}
void PVCopyMonitor::dataPut(PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::dataPut(pvRecordField)" << endl;
}
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);
bool causeMonitor = true;
if(monitorPlugin!=NULL) {
causeMonitor = monitorPlugin->causeMonitor(
pvRecordField->getPVField(),
pvRecord->getPVRecordStructure()->getPVStructure(),
monitorElement);
}
if(causeMonitor) {
if(!isGroupPut) pvCopyMonitorRequester->dataChanged();
dataChanged = true;
}
}
void PVCopyMonitor::dataPut(
PVRecordStructurePtr const & requested,
PVRecordFieldPtr const & pvRecordField)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::dataPut(requested,pvRecordField)" << endl;
}
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);
bool causeMonitor = true;
if(monitorPlugin!=NULL) {
causeMonitor = monitorPlugin->causeMonitor(
requested->getPVField(),
pvRecord->getPVRecordStructure()->getPVStructure(),
monitorElement);
}
if(causeMonitor) {
if(!isGroupPut) pvCopyMonitorRequester->dataChanged();
dataChanged = true;
}
}
void PVCopyMonitor::beginGroupPut(PVRecordPtr const & pvRecord)
{
if(pvRecord->getTraceLevel()>0)
{
cout << "PVCopyMonitor::beginGroupPut()" << endl;
}
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()>0)
{
cout << "PVCopyMonitor::endGroupPut() dataChanged " << dataChanged << endl;
}
isGroupPut = false;
std::list<PVCopyMonitorFieldNodePtr>::iterator iter;
for (iter = monitorFieldNodeList.begin();iter!=monitorFieldNodeList.end();++iter)
{
(*iter)->monitorPlugin->endGroupPut();
}
if(dataChanged) {
dataChanged = false;
pvCopyMonitorRequester->dataChanged();
}
}
void PVCopyMonitor::unlisten(PVRecordPtr const & pvRecord)
{
pvCopyMonitorRequester->unlisten();
}
}}

View File

@@ -1,109 +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 <shareLib.h>
#include <pv/monitorPlugin.h>
#include <pv/pvCopy.h>
#include <pv/pvAccess.h>
#ifdef pvCopyMonitorEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef pvCopyMonitorEpicsExportSharedSymbols
#endif
#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;
class epicsShareClass PVCopyMonitor :
public PVListener,
public epics::pvData::PVCopyTraverseMasterCallback,
public std::tr1::enable_shared_from_this<PVCopyMonitor>
{
public:
POINTER_DEFINITIONS(PVCopyMonitor);
static PVCopyMonitorPtr create(
PVCopyMonitorRequesterPtr const &pvCopyMonitorRequester,
PVRecordPtr const &pvRecord,
epics::pvData::PVCopyPtr const & pvCopy);
virtual ~PVCopyMonitor();
virtual void destroy();
void startMonitoring();
void stopMonitoring();
void setMonitorElement(epics::pvData::MonitorElementPtr const &monitorElement);
void monitorDone(epics::pvData::MonitorElementPtr const &monitorElement);
// following are PVListener methods
virtual void detach(PVRecordPtr const & pvRecord);
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);
// following is PVCopyTraverseMasterCallback method
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;
epics::pvData::Mutex mutex;
std::list<PVCopyMonitorFieldNodePtr> monitorFieldNodeList;
};
class epicsShareClass PVCopyMonitorRequester
{
public:
POINTER_DEFINITIONS(PVCopyMonitorRequester);
virtual ~PVCopyMonitorRequester() {}
virtual void dataChanged() = 0;
virtual void unlisten() = 0;
};
}}
#endif /* PVCOPYMONITOR_H */

View File

@@ -27,12 +27,12 @@
#include <iocsh.h>
#include <shareLib.h>
#include <epicsExport.h>
#include <pv/pvAccess.h>
#include <pv/serverContext.h>
#define epicsExportSharedSymbols
// this declared epicsExportSharedSymbols
#include <epicsExport.h>
#include <pv/channelProviderLocal.h>
using std::cout;
@@ -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

@@ -24,26 +24,16 @@ RecordListRecordPtr RecordListRecord::create(
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StringArray argNames(2);
FieldConstPtrArray argFields(2);
argNames[0] = "database";
argFields[0] = fieldCreate->createScalar(pvString);
argNames[1] = "regularExpression";
argFields[1] = fieldCreate->createScalar(pvString);
StringArray resNames(2);
FieldConstPtrArray resFields(2);
resNames[0] = "status";
resFields[0] = fieldCreate->createScalar(pvString);
resNames[1] = "names";
resFields[1] = fieldCreate->createScalarArray(pvString);
StringArray topNames(2);
FieldConstPtrArray topFields(2);
topNames[0] = "argument";
topFields[0] = fieldCreate->createStructure(argNames,argFields);
topNames[1] = "result";
topFields[1] = fieldCreate->createStructure(resNames,resFields);
StructureConstPtr topStructure =
fieldCreate->createStructure(topNames,topFields);
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
addNestedStructure("argument")->
add("database",pvString)->
add("regularExpression",pvString)->
endNested()->
addNestedStructure("result") ->
add("status",pvString) ->
addArray("names",pvString) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
RecordListRecordPtr pvRecord(
new RecordListRecord(recordName,pvStructure));
@@ -71,28 +61,27 @@ 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;
}
names = static_pointer_cast<PVStringArray>(
pvStructure->getScalarArrayField("result.names",pvString));
if(names.get()==NULL) return false;
name = pvStructure->getSubField<PVStringArray>("result.names");
if(name.get()==NULL) return false;
return true;
}
void RecordListRecord::process()
{
PVStringArrayPtr pvNames = PVDatabase::getMaster()->getRecordNames();
names->replace(pvNames->view());
name->replace(pvNames->view());
string message("");
if(database->get().compare("master")!=0) {
message += " can only access master ";

View File

@@ -20,16 +20,43 @@ namespace epics { namespace pvDatabase {
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.
*/
class epicsShareClass RecordListRecord :
public PVRecord
{
public:
POINTER_DEFINITIONS(RecordListRecord);
/**
* Factory methods to create RecordListRecord.
* @param recordName The name for the RecordListRecord.
* @return A shared pointer to RecordListRecord..
*/
static RecordListRecordPtr create(
std::string const & recordName);
/**
* destructor
*/
virtual ~RecordListRecord();
/**
* Clean up any resources used.
*/
virtual void destroy();
/**
* standard init method required by PVRecord
* @return true unless record name already exists.
*/
virtual bool init();
/*
* Generated the list of record names.
*/
virtual void process();
private:
RecordListRecord(std::string const & recordName,
@@ -37,7 +64,7 @@ private:
epics::pvData::PVStringPtr database;
epics::pvData::PVStringPtr regularExpression;
epics::pvData::PVStringPtr status;
epics::pvData::PVStringArrayPtr names;
epics::pvData::PVStringArrayPtr name;
};
}}

View File

@@ -24,24 +24,15 @@ TraceRecordPtr TraceRecord::create(
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StringArray topNames(2);
FieldConstPtrArray topFields(2);
topNames[0] = "argument";
topNames[1] = "result";
StringArray argNames(2);
FieldConstPtrArray argFields(2);
argNames[0] = "recordName";
argNames[1] = "level";
argFields[0] = fieldCreate->createScalar(pvString);
argFields[1] = fieldCreate->createScalar(pvInt);
topFields[0] = fieldCreate->createStructure(argNames,argFields);
StringArray resNames(1);
FieldConstPtrArray resFields(1);
resNames[0] = "status";
resFields[0] = fieldCreate->createScalar(pvString);
topFields[1] = fieldCreate->createStructure(resNames,resFields);
StructureConstPtr topStructure =
fieldCreate->createStructure(topNames,topFields);
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
addNestedStructure("argument")->
add("recordName",pvString)->
add("level",pvInt)->
endNested()->
addNestedStructure("result") ->
add("status",pvString) ->
endNested()->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
TraceRecordPtr pvRecord(
new TraceRecord(recordName,pvStructure));
@@ -71,12 +62,12 @@ bool TraceRecord::init()
{
initPVRecord();
PVStructurePtr pvStructure = getPVStructure();
pvRecordName = pvStructure->getStringField("argument.recordName");
if(pvRecordName==NULL) return false;
pvLevel = pvStructure->getIntField("argument.level");
if(pvLevel==NULL) return false;
pvResult = pvStructure->getStringField("result.status");
if(pvResult==NULL) return false;
pvRecordName = pvStructure->getSubField<PVString>("argument.recordName");
if(!pvRecordName) return false;
pvLevel = pvStructure->getSubField<PVInt>("argument.level");
if(!pvLevel) return false;
pvResult = pvStructure->getSubField<PVString>("result.status");
if(!pvResult) return false;
return true;
}
@@ -84,7 +75,7 @@ void TraceRecord::process()
{
string name = pvRecordName->get();
PVRecordPtr pvRecord = pvDatabase->findRecord(name);
if(pvRecord==NULL) {
if(!pvRecord) {
pvResult->put(name + " not found");
return;
}

View File

@@ -21,16 +21,42 @@ 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 epicsShareClass TraceRecord :
public PVRecord
{
public:
POINTER_DEFINITIONS(TraceRecord);
/**
* Factory methods to create TraceRecord.
* @param recordName The name for the TraceRecord.
* @return A shared pointer to TraceRecord..
*/
static TraceRecordPtr create(
std::string const & recordName);
/**
* destructor
*/
virtual ~TraceRecord();
/**
* Clean up any resources used.
*/
virtual void destroy();
/**
* standard init method required by PVRecord
* @return true unless record name already exists.
*/
virtual bool init();
/**
* Set the trace level.
*/
virtual void process();
private:
TraceRecord(

View File

@@ -35,5 +35,5 @@
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local
-include $(TOP)/../../CONFIG_SITE.local
-include $(TOP)/../configure/CONFIG_SITE.local

View File

@@ -9,12 +9,17 @@
* @date 2013.04.02
*/
#include "powerSupply.h"
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#define epicsExportSharedSymbols
#include "powerSupply.h"
using namespace epics::pvData;
using std::string;
using std::cout;
using std::cerr;
using std::endl;
namespace epics { namespace pvDatabase {
@@ -24,24 +29,23 @@ PVStructurePtr createPowerSupply()
StandardFieldPtr standardField = getStandardField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
size_t nfields = 5;
StringArray names;
names.reserve(nfields);
FieldConstPtrArray powerSupply;
powerSupply.reserve(nfields);
names.push_back("alarm");
powerSupply.push_back(standardField->alarm());
names.push_back("timeStamp");
powerSupply.push_back(standardField->timeStamp());
string properties("alarm,display");
names.push_back("voltage");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("power");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("current");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
return pvDataCreate->createPVStructure(
fieldCreate->createStructure(names,powerSupply));
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addNestedStructure("power") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("voltage") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("current") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
createStructure());
}
PowerSupplyPtr PowerSupply::create(
@@ -77,62 +81,40 @@ bool PowerSupply::init()
PVFieldPtr pvField;
bool result;
pvField = pvStructure->getSubField("timeStamp");
if(pvField.get()==NULL) {
std::cerr << "no timeStamp" << std::endl;
if(!pvField) {
cerr << "no timeStamp" << endl;
return false;
}
result = pvTimeStamp.attach(pvField);
if(!result) {
std::cerr << "no timeStamp" << std::endl;
cerr << "no timeStamp" << endl;
return false;
}
pvField = pvStructure->getSubField("alarm");
if(pvField.get()==NULL) {
std::cerr << "no alarm" << std::endl;
if(!pvField) {
cerr << "no alarm" << endl;
return false;
}
result = pvAlarm.attach(pvField);
if(!result) {
std::cerr << "no alarm" << std::endl;
cerr << "no alarm" << endl;
return false;
}
string name;
name = "current.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "current";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no current" << std::endl;
pvCurrent = pvStructure->getSubField<PVDouble>("current.value");
if(!pvCurrent) {
cerr << "no current\n";
return false;
}
pvCurrent = pvStructure->getDoubleField(name);
if(pvCurrent.get()==NULL) return false;
name = "voltage.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "voltage";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no voltage" << std::endl;
pvVoltage = pvStructure->getSubField<PVDouble>("voltage.value");
if(!pvVoltage) {
cerr << "no current\n";
return false;
}
pvVoltage = pvStructure->getDoubleField(name);
if(pvVoltage.get()==NULL) return false;
name = "power.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "power";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no power" << std::endl;
pvPower = pvStructure->getSubField<PVDouble>("power.value");
if(!pvPower) {
cerr << "no powert\n";
return false;
}
pvPower = pvStructure->getDoubleField(name);
if(pvPower.get()==NULL) return false;
return true;
}

View File

@@ -11,13 +11,25 @@
#ifndef POWERSUPPLY_H
#define POWERSUPPLY_H
#include <shareLib.h>
#include <pv/pvDatabase.h>
#ifdef epicsExportSharedSymbols
# define powerSupplyEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <pv/timeStamp.h>
#include <pv/alarm.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAlarm.h>
#include <pv/pvDatabase.h>
#ifdef powerSupplyEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef powerSupplyEpicsExportSharedSymbols
#endif
#include <shareLib.h>
namespace epics { namespace pvDatabase {
@@ -26,7 +38,7 @@ epicsShareExtern epics::pvData::PVStructurePtr createPowerSupply();
class PowerSupply;
typedef std::tr1::shared_ptr<PowerSupply> PowerSupplyPtr;
class PowerSupply :
class epicsShareClass PowerSupply :
public PVRecord
{
public:

View File

@@ -27,12 +27,12 @@
#include <epicsThread.h>
#include <iocsh.h>
#include <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <epicsExport.h>
#include <pv/powerSupply.h>
using namespace epics::pvData;
@@ -69,4 +69,4 @@ static void powerSupplyRegister(void)
extern "C" {
epicsExportRegistrar(powerSupplyRegister);
}
}

View File

@@ -23,14 +23,14 @@
#include <epicsEvent.h>
#include <epicsThread.h>
#include <epicsExport.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include "powerSupply.h"
#include <epicsExport.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;

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;
@@ -236,21 +236,21 @@ static void scalarTest()
valueNameRecord = request = "value";
CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,value";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
@@ -273,24 +273,24 @@ static void arrayTest()
pvRecord = createScalarArray("doubleArrayRecord",pvDouble,"alarm,timeStamp");
valueNameRecord = request = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
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->dumpValue(cout) << endl ;
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->dumpValue(cout) << endl ;
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();
}
@@ -311,28 +311,28 @@ static void powerSupplyTest()
pvRecord = PowerSupply::create("powerSupply",pv);
valueNameRecord = request = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,voltage.value,power.value,current.value";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,voltage{value,alarm},power{value,alarm,display},current.value";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
cout << "request " << request << endl << "pvRequest" << *pvRequest << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);