76 Commits
0.9.1 ... 3.1.0

Author SHA1 Message Date
Marty Kraimer
5d823307f0 make records double00, ..., double04 2014-06-25 09:16:31 -04:00
Marty Kraimer
d41d5726d2 add records for testing easyPVAJava multiChannel 2014-06-24 15:05:19 -04:00
Matej Sekoranja
723f98bc44 added extern C on epicsExportRegistrar 2014-06-20 09:16:35 +02:00
Matej Sekoranja
1544147bdd win dll linkage 2014-06-20 08:56:39 +02:00
Matej Sekoranja
0447441cfa toString replaced with <<operator 2014-06-20 08:38:54 +02:00
Matej Sekoranja
8ce42ebb9a String -> std::string, toString methods removed, take 2 2014-06-19 14:55:44 +02:00
Matej Sekoranja
c39b966121 String -> std::string, toString methods removed 2014-06-19 14:30:40 +02:00
Marty Kraimer
61edf17cdf fix bug related to stride 2014-06-13 09:53:46 -04:00
Matej Sekoranja
39f537d7da win port: visibility declarations added/fixed 2014-06-13 11:43:22 +02:00
Matej Sekoranja
ba496de2d3 VxWorks fix: there is no Status::Status type 2014-06-13 11:04:29 +02:00
Marty Kraimer
38574ed76f support for ChannelArray UnionArray 2014-06-12 15:27:26 -04:00
Marty Kraimer
92be294bbf merge feature/changesAfter3_0_2; resolve conflicts 2014-06-10 15:53:37 -04:00
Marty Kraimer
35429bf4df flow: Merged <feature> 'changesAfter3_0_2' to <develop> ('default'). 2014-06-10 09:05:48 -04:00
Marty Kraimer
552925dfe6 flow: Closed <feature> 'changesAfter3_0_2'. 2014-06-10 08:55:18 -04:00
Marty Kraimer
d1791393ad Added tag before_merge_changesAfter3_0_2 for changeset abdc90bf52a0 2014-06-10 08:53:33 -04:00
Matej Sekoranja
3dbad700f7 channelList implemented 2014-06-09 22:19:52 +02:00
Marty Kraimer
c06e33e197 better implementation of ChannelArray::getLength 2014-06-09 07:55:08 -04:00
Marty Kraimer
1d8f01517a more work on stride 2014-06-06 11:28:41 -04:00
Marty Kraimer
8c1b142e48 working on support for stride for ChannelArray 2014-06-05 10:23:51 -04:00
Marty Kraimer
ca27cb5e3c changes for new pvAccess API 2014-06-04 10:48:12 -04:00
Andrew Johnson
8fb02d5602 flow: Merged <feature> 'housekeeping' to <develop> ('default'). 2014-04-29 10:53:06 -05:00
Andrew Johnson
38f8f1de51 flow: Closed <feature> 'housekeeping'. 2014-04-29 10:53:06 -05:00
Marty Kraimer
a5fa17aca7 pvAccess added method cancel 2014-04-23 11:01:14 -04:00
Marty Kraimer
fe62a7181f use copy and monitor from pvDataCPP; imlement example plugin; algorithm => plugin 2014-04-23 09:25:58 -04:00
Andrew Johnson
69fe610c5d Merged changes from default branch 2014-04-18 17:54:35 -05:00
Andrew Johnson
83f2fa9d9a epicsExportRegistrar() must be inside extern "C" block 2014-04-18 17:53:12 -05:00
Andrew Johnson
5faa9902ea DBD file cleanup
Renamed DBD files that only contain registrar entries.
Removed the ...Include.dbd files, create them from the Makefile.
2014-04-18 17:40:17 -05:00
Andrew Johnson
f10a5f8279 Rename arrayPerformance to arrayPerfTop 2014-04-17 15:46:26 -05:00
Andrew Johnson
fcb82fd31f Rename test to testTop and adjust build config 2014-04-17 15:35:29 -05:00
Andrew Johnson
16fbd0f205 Merged Windows port changes from default branch. 2014-04-16 16:29:12 -05:00
Matej Sekoranja
597bca1ca5 Windows port (visibility declrations). 2014-04-14 18:11:12 +02:00
Andrew Johnson
3e790e34e3 Move example and test headers out of include/pv
The only headers installed there should be
those for the official API of the module.
2014-04-10 16:01:32 -05:00
Andrew Johnson
144da546ea Clean up top-level Makefiles, fix dependencies 2014-04-10 15:57:38 -05:00
Andrew Johnson
2d450bdd5b Unify configure files with the other V4 modules 2014-04-10 15:53:36 -05:00
Andrew Johnson
333bbca2f2 Fix exampleDatabase/Makefile dependencies 2014-04-04 14:50:30 -05:00
Andrew Johnson
d17192804e Correct and expand ExampleRELEASE.local 2014-04-03 17:31:47 -05:00
Andrew Johnson
63e7401ff1 Fix instructions in RELEASE file 2014-04-02 16:55:53 -05:00
Andrew Johnson
42e2e72474 Enable CHECK_RELEASE warnings 2014-04-02 16:55:38 -05:00
Marty Kraimer
342ab45dc8 changes for changesAfter3_0_2
pvCopy modified and moved to pvDataCPP
2014-04-01 14:07:43 -04:00
Andrew Johnson
c91f2e7263 Split src/Makefile into fragments 2014-03-28 15:29:31 -05:00
Andrew Johnson
f3dc67e620 flow: Created branch 'feature/housekeeping'. 2014-03-28 15:22:24 -05:00
Marty Kraimer
127830e3c7 flow: Created branch 'feature/changesAfter3_0_2'. 2014-03-25 07:18:10 -04:00
Marty Kraimer
9d3873c3fe flow initialization: Added configuration file. 2014-03-25 07:18:00 -04:00
Marty Kraimer
3ce6df5b0d add include; files for qtCreater 2014-03-24 09:58:42 -04:00
Marty Kraimer
0f1c0c28d0 bug found in Java implementation. Make corresponding change in C++ mimplementation. 2014-03-04 07:00:17 -05:00
Marty Kraimer
e740687635 pvaSrv is automatically started 2014-03-03 10:13:32 -05:00
Marty Kraimer
d1df670c83 pvCopy : do not "collapse" structures 2014-03-03 09:06:19 -05:00
Marty Kraimer
6b47485810 correct order of dependent LIBS; update doc for latest build conventions 2014-02-19 14:35:39 -05:00
Marty Kraimer
228b46a622 remove Support from generated library name to be consistent with other examples. 2014-02-19 08:39:59 -05:00
Ralph Lange
e932c01cf1 Fix: moved embedded top rules to TOP/configure/RULES_TOP 2014-02-14 14:45:53 +01:00
Ralph Lange
c6f6465457 More RELEASE cleanup 2014-02-14 14:45:11 +01:00
Ralph Lange
068d3070e2 Makefile: comment-out inter-app dependency definitions (not working) 2014-02-14 14:43:59 +01:00
Ralph Lange
4ad2e56a08 Fix: add all directories to TOP Makefile 2014-02-14 15:00:06 +01:00
Ralph Lange
d63610c7f5 Add Jenkins CI jobs for CloudBees build and hgweb service 2014-02-14 13:23:21 +01:00
Ralph Lange
92509abde8 Add dependency of exampleDatabase and examplePowerSupply to test 2014-02-14 13:17:58 +01:00
Ralph Lange
c445368537 Add RULES_TOP and top Makefile definitions to build embedded TOPs (test, examples) as part of the main build 2014-02-14 12:28:02 +01:00
Ralph Lange
2269a5bd66 Add RELEASE file improvements to arrayPerformance 2014-02-14 11:31:40 +01:00
Ralph Lange
876ec8062f Improve RELEASE files to be slim, self-contained, portable - including test and examples 2014-02-14 10:42:36 +01:00
Marty Kraimer
53c3901099 pvDatabaseCPP/src/V3IOC/* has been moved to pvAccessCPP; epicsShare has been added. 2014-02-13 07:06:14 -05:00
Matej Sekoranja
51f4820c24 src/V3IOC removed, moved to pvAccessCPP 2014-02-13 00:00:23 +01:00
Marty Kraimer
a21189cfda these should only be created by user 2014-02-07 14:40:36 -05:00
Marty Kraimer
61d884334a more work in examples; documentation is now up to date 2014-02-07 13:57:32 -05:00
Marty Kraimer
9a798bc05a more work on examples; documentation is only changed up to exampleServer 2014-02-06 16:46:47 -05:00
Marty Kraimer
94bd84211b move all examples to separate top level build areas.
Documentation needs updating.
2014-02-05 11:57:35 -05:00
Marty Kraimer
5d0718ab3a prepare for moving everything in src/V3IOC to pvAccessCPP 2014-02-04 09:21:50 -05:00
Marty Kraimer
e8a9771d1e try the make channel->destroy() followed immediately by recreate work but failed 2013-11-22 09:21:11 -05:00
Marty Kraimer
ac971042de add epicsThreadSleep between channel destroy and recreate 2013-11-21 06:24:28 -05:00
Marty Kraimer
ce116eefb8 added longArrayGet and longArrayPut; much more testing 2013-11-20 10:41:29 -05:00
Marty Kraimer
3e1a405d01 changed monitor queue implementation 2013-11-13 09:56:18 -05:00
Marty Kraimer
3039e1cdb0 more work on monitor queues 2013-11-12 11:09:25 -05:00
Marty Kraimer
006859120e make compatible with latest pvDataCPP and pvAccessCPP; lots of work on queues. 2013-11-06 15:44:58 -05:00
Marty Kraimer
14b3640e9a latest changes; memory leaks fixed 2013-10-16 08:13:15 -04:00
dhickin
ed5bf2d79b Fixed build error.Removed 'typename' from non template function. 2013-10-04 23:36:29 +01:00
Marty Kraimer
313ba68a06 more changes for arrayPerformance; added vectorPerformanceMain.cpp 2013-09-04 14:10:02 -04:00
Marty Kraimer
22786bb07e html syntax change 2013-08-28 10:55:20 -04:00
Marty Kraimer
534671dbe8 Added tag 0.9.1 for changeset bba6a2491bdf 2013-08-28 10:51:53 -04:00
236 changed files with 19765 additions and 4244 deletions

8
.hgflow Normal file
View File

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

View File

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

2
.hgtags Normal file
View File

@@ -0,0 +1,2 @@
bba6a2491bdf73681cef01caf0bd89c87d7989cd 0.9.1
abdc90bf52a0c31e24e2f9a079ef72350ee31686 before_merge_changesAfter3_0_2

View File

@@ -1,16 +1,27 @@
#Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS += configure
DIRS := $(DIRS) $(filter-out $(DIRS), configure)
DIRS := $(DIRS) $(filter-out $(DIRS), src)
DIRS := $(DIRS) $(filter-out $(DIRS), test)
DIRS := $(DIRS) $(filter-out $(DIRS), arrayPerformance)
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard example*))
DIRS += src
src_DEPEND_DIRS = configure
EMBEDDED_TOPS := $(EMBEDDED_TOPS) $(filter-out $(EMBEDDED_TOPS), test)
EMBEDDED_TOPS := $(EMBEDDED_TOPS) $(filter-out $(EMBEDDED_TOPS), arrayPerformance)
EMBEDDED_TOPS := $(EMBEDDED_TOPS) $(filter-out $(EMBEDDED_TOPS), $(wildcard example*))
DIRS += example
test_DEPEND_DIRS = src
define DIR_template
$(1)_DEPEND_DIRS = configure
endef
$(foreach dir, $(filter-out configure,$(DIRS)),$(eval $(call DIR_template,$(dir))))
DIRS += iocBoot
define EMB_template
$(1)_DEPEND_DIRS = src
endef
$(foreach dir, $(EMBEDDED_TOPS),$(eval $(call EMB_template,$(dir))))
#exampleDatabase_DEPEND_DIRS += test
#examplePowerSupply_DEPEND_DIRS += test
include $(TOP)/configure/RULES_TOP

11
arrayPerformance/Makefile Normal file
View File

@@ -0,0 +1,11 @@
#Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS += configure
DIRS += src
src_DEPEND_DIRS = configure
include $(TOP)/configure/RULES_TOP

View File

@@ -0,0 +1,29 @@
# CONFIG - Load build configuration data
#
# Do not make changes to this file!
# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)
# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
# Override the Base definition:
INSTALL_LOCATION = $(TOP)
# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif

View File

@@ -0,0 +1,39 @@
# CONFIG_SITE
# Make any application-specific changes to the EPICS build
# configuration variables in this file.
#
# Host/target specific settings can be specified in files named
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
# CONFIG_SITE.Common.$(T_A)
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
# CHECK_RELEASE controls the consistency checking of the support
# applications pointed to by the RELEASE* files.
# Normally CHECK_RELEASE should be set to YES.
# Set CHECK_RELEASE to NO to disable checking completely.
# Set CHECK_RELEASE to WARN to perform consistency checking but
# continue building anyway if conflicts are found.
#CHECK_RELEASE = YES
# Set this when you only want to compile this application
# for a subset of the cross-compiled target architectures
# that Base is built for.
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</path/name/to/install/top>
# Set this when your IOC and the host use different paths
# to access the application. This will be needed to boot
# from a Microsoft FTP server or with some NFS mounts.
# You must rebuild in the iocBoot directory for this to
# take effect.
#IOCS_APPL_TOP = </IOC/path/to/application/top>
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local

View File

@@ -0,0 +1,8 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
PVDATABASE=${EPICSV4HOME}/pvDatabaseCPP
PVASRV=${EPICSV4HOME}/pvaSrv

View File

@@ -0,0 +1,8 @@
TOP=..
include $(TOP)/configure/CONFIG
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES

View File

@@ -0,0 +1,40 @@
# pvDatabaseCPP/arrayPerformance RELEASE - Location of external support modules
#
# IF YOU CHANGE this file or any file it includes you must
# subsequently do a "gnumake rebuild" in the application's
# top level directory.
#
# The build process does not check dependencies against files
# that are outside this application, thus you should also do a
# "gnumake rebuild" in the top level directory after EPICS_BASE
# or any other external module pointed to below is rebuilt.
#
# Host- or target-specific settings can be given in files named
# RELEASE.$(EPICS_HOST_ARCH).Common
# RELEASE.Common.$(T_A)
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
# EPICS V4 Developers: Do not edit the locations in this file!
#
# Create a file RELEASE.local pointing to your places
# for the dependencies, e.g.
# PVACCESS = /path/to/epics/pvAccessCPP
# PVDATA = /path/to/epics/pvDataCPP
# PVCOMMON = /path/to/epics/pvCommonCPP
# EPICS_BASE = /path/to/epics/base
# If this example is built in a directory under pvDatabaseCPP,
# use the following definitions:
PVDATABASE = $(TOP)/..
-include $(TOP)/../../RELEASE.local
-include $(TOP)/../configure/RELEASE.local
# If you copied this example from pvDatabaseCPP to be built as a
# standalone TOP, define
# PVDATABASE = /path/to/epics/pvDatabaseCPP
# in the appropriate RELEASE[.local],
# and use the following definitions instead:
#-include $(TOP)/../RELEASE.local
#-include $(TOP)/configure/RELEASE.local

View File

@@ -0,0 +1,6 @@
# RULES
include $(CONFIG)/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile

View File

@@ -0,0 +1,2 @@
#RULES.ioc
include $(CONFIG)/RULES.ioc

View File

@@ -0,0 +1,2 @@
#RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -0,0 +1,2 @@
#RULES_TOP
include $(CONFIG)/RULES_TOP

View File

@@ -0,0 +1,45 @@
TOP = ..
include $(TOP)/configure/CONFIG
LIBRARY_IOC += pvDatabaseExample
pvDatabaseExample_LIBS += pvDatabase pvAccess pvData Com
pvDatabaseExample_LIBS += $(EPICS_BASE_IOC_LIBS)
INC+= arrayPerformance.h
LIBSRCS += arrayPerformance.cpp
INC+= longArrayMonitor.h
LIBSRCS += longArrayMonitor.cpp
INC+= longArrayGet.h
LIBSRCS += longArrayGet.cpp
INC+= longArrayPut.h
LIBSRCS += longArrayPut.cpp
PROD_HOST += arrayPerformanceMain
arrayPerformanceMain_SRCS += arrayPerformanceMain.cpp
arrayPerformanceMain_LIBS += pvDatabase pvAccess pvData Com
arrayPerformanceMain_LIBS += pvDatabaseExample
PROD_HOST += longArrayMonitorMain
longArrayMonitorMain_SRCS += longArrayMonitorMain.cpp
longArrayMonitorMain_LIBS += pvDatabase pvAccess pvData Com
longArrayMonitorMain_LIBS += pvDatabaseExample
PROD_HOST += longArrayGetMain
longArrayGetMain_SRCS += longArrayGetMain.cpp
longArrayGetMain_LIBS += pvDatabase pvAccess pvData Com
longArrayGetMain_LIBS += pvDatabaseExample
PROD_HOST += longArrayPutMain
longArrayPutMain_SRCS += longArrayPutMain.cpp
longArrayPutMain_LIBS += pvDatabase pvAccess pvData Com
longArrayPutMain_LIBS += pvDatabaseExample
PROD_HOST += vectorPerformanceMain
vectorPerformanceMain_SRCS += vectorPerformanceMain.cpp
vectorPerformanceMain_LIBS += pvDatabase pvAccess pvData Com
vectorPerformanceMain_LIBS += pvDatabaseExample
include $(TOP)/configure/RULES

View File

@@ -8,8 +8,13 @@
* @author mrk
* @date 2013.08.08
*/
#include <pv/lock.h>
#include <pv/arrayPerformance.h>
#define epicsExportSharedSymbols
#include <arrayPerformance.h>
namespace epics { namespace pvDatabase {
@@ -18,9 +23,10 @@ using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::cout;
using std::endl;
using std::ostringstream;
ArrayPerformancePtr ArrayPerformance::create(
epics::pvData::String const & recordName,
std::string const & recordName,
size_t size,
double delay)
{
@@ -33,7 +39,7 @@ ArrayPerformancePtr ArrayPerformance::create(
}
ArrayPerformance::ArrayPerformance(
epics::pvData::String const & recordName,
std::string const & recordName,
epics::pvData::PVStructurePtr const & pvStructure,
size_t size,
double delay)
@@ -87,7 +93,8 @@ ArrayPerformanceThread::ArrayPerformanceThread(ArrayPerformancePtr const & array
arrayPerformance(arrayPerformance),
isDestroyed(false),
runReturned(false),
threadName("arrayPerformance")
threadName("arrayPerformance"),
value(0)
{}
void ArrayPerformanceThread::init()
@@ -138,17 +145,39 @@ void ArrayPerformanceThread::run()
timeStamp.getCurrent();
double diff = TimeStamp::diff(timeStamp,timeStampLast);
if(diff>=1.0) {
cout << "arrayPerformance value " << value;
cout << " time " << diff;
ostringstream out;
out << "arrayPerformance value " << value;
out << " time " << diff ;
double iterations = nSinceLastReport;
iterations /= diff;
cout << " iterations/sec " << iterations;
if(iterations>10.0e9) {
iterations /= 1e9;
out << " gigaIterations/sec " << iterations;
} else if(iterations>10.0e6) {
iterations /= 1e6;
out << " megaIterations/sec " << iterations;
} else if(iterations>10.0e3) {
iterations /= 1e3;
out << " kiloIterations/sec " << iterations;
} else {
out << " Iterations/sec " << iterations;
}
double elementSize = arrayPerformance->size;
double elementsPerSecond = elementSize*nSinceLastReport;
elementsPerSecond /= diff;
elementsPerSecond /= 1e6;
cout << " elements/sec " << elementsPerSecond << "million" << endl;
cout.flush();
if(elementsPerSecond>10.0e9) {
elementsPerSecond /= 1e9;
out << " gigaElements/sec " << elementsPerSecond;
} else if(elementsPerSecond>10.0e6) {
elementsPerSecond /= 1e6;
out << " megaElements/sec " << elementsPerSecond;
} else if(elementsPerSecond>10.0e3) {
elementsPerSecond /= 1e3;
out << " kiloElements/sec " << elementsPerSecond;
} else {
out << " Elements/sec " << elementsPerSecond;
}
cout << out.str() << endl;
timeStampLast = timeStamp;
nSinceLastReport = 0;
}

View File

@@ -11,12 +11,25 @@
#ifndef ARRAYPERFORMANCE_H
#define ARRAYPERFORMANCE_H
#ifdef epicsExportSharedSymbols
# define arrayperformanceEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <epicsThread.h>
#include <pv/standardPVField.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvDatabase.h>
#ifdef arrayperformanceEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef arrayperformanceEpicsExportSharedSymbols
# include <shareLib.h>
#endif
namespace epics { namespace pvDatabase {
class ArrayPerformance;
@@ -25,13 +38,13 @@ typedef std::tr1::shared_ptr<ArrayPerformance> ArrayPerformancePtr;
class ArrayPerformanceThread;
typedef std::tr1::shared_ptr<ArrayPerformanceThread> ArrayPerformanceThreadPtr;
class ArrayPerformance :
class epicsShareClass ArrayPerformance :
public PVRecord
{
public:
POINTER_DEFINITIONS(ArrayPerformance);
static ArrayPerformancePtr create(
epics::pvData::String const & recordName,
std::string const & recordName,
size_t size,
double delay);
virtual ~ArrayPerformance();
@@ -40,7 +53,7 @@ public:
virtual void process();
virtual void destroy();
private:
ArrayPerformance(epics::pvData::String const & recordName,
ArrayPerformance(std::string const & recordName,
epics::pvData::PVStructurePtr const & pvStructure,
size_t size,
double delay);
@@ -54,7 +67,7 @@ private:
friend class ArrayPerformanceThread;
};
class ArrayPerformanceThread :
class epicsShareClass ArrayPerformanceThread :
public epicsThreadRunable
{
public:
@@ -68,7 +81,7 @@ private:
ArrayPerformancePtr arrayPerformance;
bool isDestroyed;
bool runReturned;
epics::pvData::String threadName;
std::string threadName;
epics::pvData::Mutex mutex;
epics::pvData::int64 value;
std::auto_ptr<epicsThread> thread;

View File

@@ -22,13 +22,14 @@
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/arrayPerformance.h>
#include <pv/longArrayMonitor.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/clientFactory.h>
#include <arrayPerformance.h>
#include <longArrayMonitor.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
@@ -38,16 +39,17 @@ using namespace epics::pvDatabase;
int main(int argc,char *argv[])
{
bool result(false);
String recordName;
string recordName;
recordName = "arrayPerformance";
size_t size = 50000000;
double delay = .01;
String providerName("local");
size_t size = 10000000;
double delay = .0001;
string providerName("local");
size_t nMonitor = 1;
bool useQueue = false;
if(argc==2 && String(argv[1])==String("-help")) {
int queueSize = 2;
double waitTime = 0.0;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "arrayPerformanceMain recordName size";
cout << " delay providerName nMonitor useQueue" << endl;
cout << " delay providerName nMonitor queueSize waitTime" << endl;
cout << "default" << endl;
cout << "arrayPerformance ";
cout << recordName << " ";
@@ -55,7 +57,8 @@ int main(int argc,char *argv[])
cout << delay << " ";
cout << providerName << " ";
cout << nMonitor << " ";
cout << (useQueue ? "true" : "false") << endl;
cout << queueSize << " ";
cout << "0.0" << endl;
return 0;
}
if(argc>1) recordName = argv[1];
@@ -63,20 +66,24 @@ int main(int argc,char *argv[])
if(argc>3) delay = atof(argv[3]);
if(argc>4) providerName = argv[4];
if(argc>5) nMonitor = strtoul(argv[5],0,0);
if(argc>6) useQueue = (argv[6]==String("true") ? true : false);
if(argc>6) queueSize = strtol(argv[6],0,0);
if(argc>7) waitTime = atof(argv[7]);
cout << "arrayPerformance ";
cout << recordName << " ";
cout << size << " ";
cout << delay << " ";
cout << providerName << " ";
cout << nMonitor << " ";
cout << (useQueue ? "true" : "false") << endl;
cout << queueSize << " ";
cout << waitTime << endl;
ClientFactory::start();
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
PVRecordPtr pvRecord;
pvRecord = ArrayPerformance::create(recordName,size,delay);
result = master->addRecord(pvRecord);
PVRecordPtr arrayPreformance = pvRecord;
arrayPreformance->setTraceLevel(0);
pvRecord = TraceRecord::create("traceRecordPGRPC");
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
@@ -86,8 +93,9 @@ int main(int argc,char *argv[])
std::vector<LongArrayMonitorPtr> longArrayMonitor(nMonitor);
for(size_t i=0; i<nMonitor; ++i) {
longArrayMonitor[i]
= LongArrayMonitor::create(providerName,recordName,useQueue);
= LongArrayMonitor::create(providerName,recordName,queueSize,waitTime);
}
epicsThreadSleep(1.0);
for(size_t i=0; i<nMonitor; ++i) longArrayMonitor[i]->start();
cout << "arrayPerformance\n";
string str;
@@ -97,11 +105,14 @@ int main(int argc,char *argv[])
if(str.compare("exit")==0) break;
}
arrayPreformance.reset();
for(size_t i=0; i<nMonitor; ++i) longArrayMonitor[i]->stop();
for(size_t i=0; i<nMonitor; ++i) longArrayMonitor[i]->destroy();
pvaServer->shutdown();
epicsThreadSleep(1.0);
pvaServer->destroy();
ClientFactory::stop();
epicsThreadSleep(1.0);
channelProvider->destroy();
return 0;
}

View File

@@ -0,0 +1,543 @@
/* longArrayGet.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.08.09
*/
#include <epicsThread.h>
#include <pv/caProvider.h>
#define epicsExportSharedSymbols
#include <longArrayGet.h>
namespace epics { namespace pvDatabase {
using namespace epics::pvData;
using namespace epics::pvAccess;
using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::cout;
using std::endl;
using std::ostringstream;
using std::string;
static string requesterName("longArrayGet");
static string request("value,timeStamp,alarm");
static epics::pvData::Mutex printMutex;
class LongArrayChannelRequester;
typedef std::tr1::shared_ptr<LongArrayChannelRequester> LongArrayChannelRequesterPtr;
class LongArrayChannelGetRequester;
typedef std::tr1::shared_ptr<LongArrayChannelGetRequester> LongArrayChannelGetRequesterPtr;
class LongArrayChannelRequester :
virtual public ChannelRequester,
public std::tr1::enable_shared_from_this<LongArrayChannelRequester>
{
public:
LongArrayChannelRequester(
LongArrayChannelGetPtr const & longArrayChannelGet)
: longArrayChannelGet(longArrayChannelGet),
isDestroyed(false)
{}
virtual ~LongArrayChannelRequester(){}
virtual void destroy()
{
Lock guard(mutex);
if(isDestroyed) return;
isDestroyed = true;
longArrayChannelGet.reset();
}
virtual string getRequesterName() { return requesterName;}
virtual void message(string const & message, MessageType messageType)
{
Lock guard(printMutex);
cout << requesterName << " message " << message << endl;
}
virtual void channelCreated(
const Status& status,
Channel::shared_pointer const & channel);
virtual void channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState);
private:
LongArrayChannelRequesterPtr getPtrSelf()
{
return shared_from_this();
}
LongArrayChannelGetPtr longArrayChannelGet;
bool isDestroyed;
Mutex mutex;
};
class LongArrayChannelGetRequester :
virtual public ChannelGetRequester,
public std::tr1::enable_shared_from_this<LongArrayChannelGetRequester>
{
public:
LongArrayChannelGetRequester(
LongArrayChannelGetPtr const & longArrayChannelGet)
: longArrayChannelGet(longArrayChannelGet),
isDestroyed(false)
{}
virtual ~LongArrayChannelGetRequester(){}
virtual void destroy()
{
Lock guard(mutex);
if(isDestroyed) return;
isDestroyed = true;
longArrayChannelGet.reset();
}
virtual string getRequesterName() { return requesterName;}
virtual void message(string const & message, MessageType messageType)
{
Lock guard(printMutex);
cout << requesterName << " message " << message << endl;
}
virtual void channelGetConnect(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
StructureConstPtr const &structure);
virtual void getDone(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
PVStructurePtr const &pvStructure,
BitSetPtr const & bitSet);
private:
LongArrayChannelGetRequesterPtr getPtrSelf()
{
return shared_from_this();
}
LongArrayChannelGetPtr longArrayChannelGet;
bool isDestroyed;
Mutex mutex;
};
class LongArrayChannelGet :
public std::tr1::enable_shared_from_this<LongArrayChannelGet>,
public epicsThreadRunable
{
public:
LongArrayChannelGet(
string providerName,
string channelName,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelGet,
double delayTime)
: providerName(providerName),
channelName(channelName),
iterBetweenCreateChannel(iterBetweenCreateChannel),
iterBetweenCreateChannelGet(iterBetweenCreateChannelGet),
delayTime(delayTime),
isDestroyed(false),
runReturned(false),
threadName("longArrayGet")
{}
virtual ~LongArrayChannelGet(){}
bool init();
virtual void destroy();
virtual void run();
void message(string const & message, MessageType messageType)
{
Lock guard(printMutex);
cout << requesterName << " message " << message << endl;
}
virtual void channelCreated(
const Status& status,
Channel::shared_pointer const & channel);
virtual void channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState);
virtual void channelGetConnect(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
StructureConstPtr const &structure);
virtual void getDone(
Status const & status,
ChannelGet::shared_pointer channelGet,
PVStructurePtr const &pvStructure,
BitSetPtr const & bitSet);
private:
LongArrayChannelGetPtr getPtrSelf()
{
return shared_from_this();
}
size_t checkResult();
string providerName;
string channelName;
int iterBetweenCreateChannel;
int iterBetweenCreateChannelGet;
double delayTime;
bool isDestroyed;
bool runReturned;
std::string threadName;
Status status;
Event event;
Mutex mutex;
std::auto_ptr<epicsThread> thread;
Channel::shared_pointer channel;
ChannelGet::shared_pointer channelGet;
PVStructurePtr pvStructure;
BitSetPtr bitSet;
LongArrayChannelRequesterPtr longArrayChannelRequester;
LongArrayChannelGetRequesterPtr longArrayChannelGetRequester;
};
void LongArrayChannelRequester::channelCreated(
const Status& status,
Channel::shared_pointer const & channel)
{
Lock guard(mutex);
if(isDestroyed) return;
longArrayChannelGet->channelCreated(status,channel);
}
void LongArrayChannelRequester::channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState)
{
string mess(Channel::ConnectionStateNames[connectionState]);
message(mess,infoMessage);
Lock guard(mutex);
if(isDestroyed) return;
longArrayChannelGet->channelStateChange(channel,connectionState);
}
void LongArrayChannelGetRequester::channelGetConnect(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
StructureConstPtr const &structure)
{
Lock guard(mutex);
if(isDestroyed) return;
longArrayChannelGet->channelGetConnect(
status,channelGet,structure);
}
void LongArrayChannelGetRequester::getDone(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
PVStructurePtr const &pvStructure,
BitSetPtr const & bitSet)
{
Lock guard(mutex);
if(isDestroyed) return;
longArrayChannelGet->getDone(status,channelGet,pvStructure,bitSet);
}
void LongArrayChannelGet::channelCreated(
const Status& status,
Channel::shared_pointer const & channel)
{
if(!status.isOK()) message(status.getMessage(),errorMessage);
this->status = status;
this->channel = channel;
event.signal();
}
void LongArrayChannelGet::channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState)
{
MessageType messageType =
(connectionState==Channel::CONNECTED ? infoMessage : errorMessage);
message("channelStateChange",messageType);
}
void LongArrayChannelGet::channelGetConnect(
Status const & status,
ChannelGet::shared_pointer const & channelGet,
StructureConstPtr const &structure)
{
this->status = status;
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
event.signal();
return;
}
this->channelGet = channelGet;
bool structureOK(true);
PVStructurePtr pvStructure = getPVDataCreate()->createPVStructure(structure);
PVFieldPtr pvField = pvStructure->getSubField("timeStamp");
if(pvField==NULL) structureOK = false;
pvField = pvStructure->getSubField("value");
if(pvField==NULL) {
structureOK = false;
} else {
FieldConstPtr field = pvField->getField();
if(field->getType()!=scalarArray) {
structureOK = false;
} else {
ScalarArrayConstPtr scalarArray = dynamic_pointer_cast<const ScalarArray>(field);
if(scalarArray->getElementType()!=pvLong) structureOK = false;
}
}
if(!structureOK) {
string mess("channelGetConnect: illegal structure");
message(mess,errorMessage);
this->status = Status(Status::STATUSTYPE_ERROR,mess);
}
event.signal();
}
bool LongArrayChannelGet::init()
{
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
cout << "provider " << providerName << " not found" << endl;
return false;
}
longArrayChannelRequester.reset(new LongArrayChannelRequester(getPtrSelf()));
channel = channelProvider->createChannel(
channelName,
longArrayChannelRequester);
event.wait();
channelProvider.reset();
if(!status.isOK()) return false;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}
longArrayChannelGetRequester.reset(new LongArrayChannelGetRequester(getPtrSelf()));
channelGet = channel->createChannelGet(
longArrayChannelGetRequester,
pvRequest);
event.wait();
if(!status.isOK()) return false;
thread = std::auto_ptr<epicsThread>(new epicsThread(
*this,
threadName.c_str(),
epicsThreadGetStackSize(epicsThreadStackSmall),
epicsThreadPriorityLow));
thread->start();
event.signal();
return true;
}
void LongArrayChannelGet::destroy()
{
if(isDestroyed) return;
isDestroyed = true;
event.signal();
while(true) {
if(runReturned) break;
epicsThreadSleep(.01);
}
if(longArrayChannelRequester!=NULL) {
longArrayChannelRequester->destroy();
}
if(longArrayChannelGetRequester!=NULL) {
longArrayChannelGetRequester->destroy();
}
thread->exitWait();
channel->destroy();
channelGet.reset();
channel.reset();
}
void LongArrayChannelGet::run()
{
while(true) {
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
TimeStamp timeStamp;
TimeStamp timeStampLast;
timeStampLast.getCurrent();
int numChannelGet = 0;
int numChannelCreate = 0;
size_t nElements = 0;
while(true) {
channelGet->get();
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
size_t latestSize = checkResult();
nElements += latestSize;
timeStamp.getCurrent();
double diff = TimeStamp::diff(timeStamp,timeStampLast);
if(diff>=1.0) {
ostringstream out;
out << "get";
double elementsPerSec = nElements;
elementsPerSec /= diff;
if(elementsPerSec>10.0e9) {
elementsPerSec /= 1e9;
out << " gigaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e6) {
elementsPerSec /= 1e6;
out << " megaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e3) {
elementsPerSec /= 1e3;
out << " kiloElements/sec " << elementsPerSec;
} else {
out << " Elements/sec " << elementsPerSec;
}
cout << out.str() << endl;
timeStampLast = timeStamp;
nElements = 0;
}
if(delayTime>0.0) epicsThreadSleep(delayTime);
if(isDestroyed) {
runReturned = true;
return;
}
++numChannelCreate;
bool createGet = false;
if(iterBetweenCreateChannel!=0) {
if(numChannelCreate>=iterBetweenCreateChannel) {
longArrayChannelRequester->destroy();
channel->destroy();
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
longArrayChannelRequester.reset(new LongArrayChannelRequester(getPtrSelf()));
channel = channelProvider->createChannel(
channelName,
longArrayChannelRequester);
event.wait();
channelProvider.reset();
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
return;
}
cout<< "createChannel success" << endl;
createGet = true;
numChannelCreate = 0;
}
}
++numChannelGet;
if(iterBetweenCreateChannelGet!=0) {
if(numChannelGet>=iterBetweenCreateChannelGet) createGet = true;
}
if(createGet) {
numChannelGet = 0;
longArrayChannelGetRequester->destroy();
channelGet->destroy();
CreateRequest::shared_pointer createRequest =
CreateRequest::create();
PVStructurePtr pvRequest =
createRequest->createRequest(request);
if(pvRequest==NULL) {
cout << "request logic error " << createRequest->getMessage() << endl;
return ;
}
longArrayChannelGetRequester.reset(new LongArrayChannelGetRequester(getPtrSelf()));
channelGet = channel->createChannelGet(
longArrayChannelGetRequester,
pvRequest);
event.wait();
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
return;
}
cout<< "createChannelGet success" << endl;
}
}
}
}
void LongArrayChannelGet::getDone(
Status const & status,
ChannelGet::shared_pointer channelGet,
PVStructurePtr const &pvStructure,
BitSetPtr const & bitSet)
{
this->pvStructure = pvStructure;
this->bitSet = bitSet;
event.signal();
}
size_t LongArrayChannelGet::checkResult()
{
PVLongArrayPtr pvValue;
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
return 0;
}
pvValue = dynamic_pointer_cast<PVLongArray>(pvStructure->getSubField("value"));
if(!bitSet->get(pvValue->getFieldOffset())) {
return 0;
}
bitSet->clear();
shared_vector<const int64> data = pvValue->view();
if(data.size()>0) {
int64 first = data[0];
int64 last = data[data.size()-1];
if(first!=last) {
cout << "error first=" << first << " last=" << last << endl;
}
}
return data.size();
}
LongArrayGetPtr LongArrayGet::create(
string const &providerName,
string const & channelName,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelGet,
double delayTime)
{
LongArrayGetPtr longArrayGet(
new LongArrayGet(
providerName,
channelName,
iterBetweenCreateChannel,
iterBetweenCreateChannelGet,
delayTime));
if(!longArrayGet->init()) longArrayGet.reset();
return longArrayGet;
}
LongArrayGet::LongArrayGet(
string const &providerName,
string const & channelName,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelGet,
double delayTime)
: providerName(providerName),
channelName(channelName),
iterBetweenCreateChannel(iterBetweenCreateChannel),
iterBetweenCreateChannelGet(iterBetweenCreateChannelGet),
delayTime(delayTime)
{}
LongArrayGet::~LongArrayGet() {}
bool LongArrayGet::init()
{
longArrayChannelGet = LongArrayChannelGetPtr(new LongArrayChannelGet(
providerName,
channelName,
iterBetweenCreateChannel,
iterBetweenCreateChannelGet,
delayTime));
return longArrayChannelGet->init();
}
void LongArrayGet::destroy()
{
longArrayChannelGet->destroy();
longArrayChannelGet.reset();
}
}}

View File

@@ -0,0 +1,83 @@
/* longArrayGet.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 2013.08.09
*/
#ifndef LONGARRAYGET_H
#define LONGARRAYGET_H
#ifdef epicsExportSharedSymbols
# define longarraygetEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAccess.h>
#ifdef longarraygetEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef longarraygetEpicsExportSharedSymbols
# include <shareLib.h>
#endif
namespace epics { namespace pvDatabase {
class LongArrayGet;
typedef std::tr1::shared_ptr<LongArrayGet> LongArrayGetPtr;
class LongArrayChannelGet;
typedef std::tr1::shared_ptr<LongArrayChannelGet> LongArrayChannelGetPtr;
class epicsShareClass LongArrayGet :
public std::tr1::enable_shared_from_this<LongArrayGet>
{
public:
POINTER_DEFINITIONS(LongArrayGet);
static LongArrayGetPtr create(
std::string const & providerName,
std::string const & channelName,
int iterBetweenCreateChannel = 0,
int iterBetweenCreateChannelGet = 0,
double delayTime = 0.0);
~LongArrayGet();
void destroy();
private:
LongArrayGetPtr getPtrSelf()
{
return shared_from_this();
}
LongArrayGet(
std::string const & providerName,
std::string const & channelName,
int iterBetweenCreateChannel = 0,
int iterBetweenCreateChannelGet = 0,
double delayTime = 0.0);
bool init();
std::string providerName;
std::string channelName;
int iterBetweenCreateChannel;
int iterBetweenCreateChannelGet;
double delayTime;
LongArrayChannelGetPtr longArrayChannelGet;
};
}}
#endif /* LONGARRAYGET_H */

View File

@@ -0,0 +1,87 @@
/*longArrayGetMain.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.08.10
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <vector>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/clientFactory.h>
#include <arrayPerformance.h>
#include <longArrayGet.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[])
{
string channelName("arrayPerformance");
int iterBetweenCreateChannel = 0;
int iterBetweenCreateChannelGet = 0;
double delayTime = 1.0;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "longArrayGetMain channelName ";
cout << "iterBetweenCreateChannel iterBetweenCreateChannelGet delayTime" << endl;
cout << "default" << endl;
cout << "longArrayGetMain " << channelName << " ";
cout << iterBetweenCreateChannel << " ";
cout << iterBetweenCreateChannelGet << " ";
cout << delayTime << endl;
return 0;
}
ClientFactory::start();
if(argc>1) channelName = argv[1];
if(argc>2) iterBetweenCreateChannel = strtol(argv[2],0,0);
if(argc>3) iterBetweenCreateChannelGet = strtol(argv[3],0,0);
if(argc>4) delayTime = atof(argv[4]);
cout << "longArrayGetMain " << channelName << " ";
cout << iterBetweenCreateChannel << " ";
cout << iterBetweenCreateChannelGet << " ";
cout << delayTime << endl;
LongArrayGetPtr longArrayGet
= LongArrayGet::create(
"pvAccess",
channelName,
iterBetweenCreateChannel,
iterBetweenCreateChannelGet,
delayTime);
cout << "longArrayGet\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
longArrayGet->destroy();
longArrayGet.reset();
double xxx = 1.0;
if(xxx<delayTime) xxx = delayTime;
ClientFactory::stop();
epicsThreadSleep(xxx);
return 0;
}

View File

@@ -9,10 +9,14 @@
* @date 2013.08.09
*/
#include <epicsThread.h>
#include <pv/longArrayMonitor.h>
#include <pv/caProvider.h>
#define epicsExportSharedSymbols
#include <longArrayMonitor.h>
namespace epics { namespace pvDatabase {
using namespace epics::pvData;
@@ -21,10 +25,12 @@ using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::cout;
using std::endl;
using std::string;
using std::ostringstream;
static String requesterName("longArrayMonitor");
static string requesterName("longArrayMonitor");
static void messagePvt(String const & message, MessageType messageType)
static void messagePvt(string const & message, MessageType messageType)
{
cout << requesterName << " message " << message << endl;
}
@@ -37,8 +43,9 @@ public:
: longArrayMonitor(longArrayMonitor)
{}
virtual ~LAMChannelRequester(){}
virtual String getRequesterName() { return requesterName;}
virtual void message(String const & message, MessageType messageType)
virtual void destroy(){longArrayMonitor.reset();}
virtual string getRequesterName() { return requesterName;}
virtual void message(string const & message, MessageType messageType)
{ messagePvt(message,messageType);}
virtual void channelCreated(const Status& status, Channel::shared_pointer const & channel);
virtual void channelStateChange(Channel::shared_pointer const & channel, Channel::ConnectionState connectionState);
@@ -66,8 +73,9 @@ class LAMMonitorRequester :
public epicsThreadRunable
{
public:
LAMMonitorRequester(LongArrayMonitorPtr const &longArrayMonitor)
LAMMonitorRequester(LongArrayMonitorPtr const &longArrayMonitor,double waitTime)
: longArrayMonitor(longArrayMonitor),
waitTime(waitTime),
isDestroyed(false),
runReturned(false),
threadName("longArrayMonitor")
@@ -76,20 +84,21 @@ public:
void init();
virtual void destroy();
virtual void run();
virtual String getRequesterName() { return requesterName;}
virtual void message(String const & message, MessageType messageType)
virtual string getRequesterName() { return requesterName;}
virtual void message(string const & message, MessageType messageType)
{ messagePvt(message,messageType);}
virtual void monitorConnect(Status const & status,
MonitorPtr const & monitor, StructureConstPtr const & structure);
virtual void monitorEvent(MonitorPtr const & monitor);
virtual void unlisten(MonitorPtr const & monitor);
private:
void handleMonitor();
LongArrayMonitorPtr longArrayMonitor;
double waitTime;
bool isDestroyed;
bool runReturned;
epics::pvData::String threadName;
std::string threadName;
Event event;
Mutex mutex;
std::auto_ptr<epicsThread> thread;
};
@@ -142,7 +151,7 @@ void LAMMonitorRequester::monitorConnect(Status const & status,
}
}
if(!structureOK) {
String message("monitorConnect: illegal structure");
string message("monitorConnect: illegal structure");
messagePvt(message,errorMessage);
longArrayMonitor->status = Status(Status::STATUSTYPE_ERROR,message);
}
@@ -156,6 +165,8 @@ void LAMMonitorRequester::run()
TimeStamp timeStamp;
TimeStamp timeStampLast;
timeStampLast.getCurrent();
size_t nElements = 0;
int nSinceLastReport = 0;
while(true) {
event.wait();
if(isDestroyed) {
@@ -163,35 +174,55 @@ void LAMMonitorRequester::run()
return;
}
while(true) {
MonitorElementPtr monitorElement = longArrayMonitor->monitor->poll();
MonitorElementPtr monitorElement;
PVStructurePtr pvStructure;
{
Lock xx(mutex);
monitorElement = longArrayMonitor->monitor->poll();
if(monitorElement!=NULL) pvStructure = monitorElement->pvStructurePtr;
}
if(monitorElement==NULL) break;
PVStructurePtr pvStructure = monitorElement->pvStructurePtr;
if(waitTime>0.0) epicsThreadSleep(waitTime);
pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
pvTimeStamp.get(timeStamp);
pvValue = dynamic_pointer_cast<PVLongArray>(pvStructure->getSubField("value"));
shared_vector<const int64> data = pvValue->view();
if(data.size()>0) {
nElements += data.size();
int64 first = data[0];
int64 last = data[data.size()-1];
int64 sum = 0;
for(size_t i=0; i<data.size(); ++i) sum += data[i];
if(first!=last) {
cout << "error first=" << first << " last=" << last << endl;
}
double diff = TimeStamp::diff(timeStamp,timeStampLast);
double elementsPerSecond = data.size();
elementsPerSecond = 1e-6*elementsPerSecond/diff;
cout.flush();
cout << "first " << first << " last " << last << " sum " << sum;
cout << " elements/sec " << elementsPerSecond << "million";
BitSetPtr changed = monitorElement->changedBitSet;
BitSetPtr overrun = monitorElement->overrunBitSet;
String buffer;
changed->toString(&buffer);
cout << " changed " << buffer;
buffer.clear();
overrun->toString(&buffer);
cout << " overrun " << buffer;
cout << endl;
cout.flush();
timeStampLast = timeStamp;
if(diff>=1.0) {
ostringstream out;
out << " monitors/sec " << nSinceLastReport << " ";
out << "first " << first << " last " << last ;
BitSetPtr changed = monitorElement->changedBitSet;
BitSetPtr overrun = monitorElement->overrunBitSet;
out << " changed " << *changed;
out << " overrun " << *overrun;
double elementsPerSec = nElements;
elementsPerSec /= diff;
if(elementsPerSec>10.0e9) {
elementsPerSec /= 1e9;
out << " gigaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e6) {
elementsPerSec /= 1e6;
out << " megaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e3) {
elementsPerSec /= 1e3;
out << " kiloElements/sec " << elementsPerSec;
} else {
out << " Elements/sec " << elementsPerSec;
}
cout << out.str() << endl;
timeStampLast = timeStamp;
nSinceLastReport = 0;
nElements = 0;
}
++nSinceLastReport;
} else {
cout << "size = 0" << endl;
}
@@ -212,12 +243,13 @@ void LAMMonitorRequester::unlisten(MonitorPtr const & monitor)
LongArrayMonitorPtr LongArrayMonitor::create(
String const &providerName,
String const & channelName,
bool useQueue)
string const &providerName,
string const & channelName,
int queueSize,
double waitTime)
{
LongArrayMonitorPtr longArrayMonitor(new LongArrayMonitor());
if(!longArrayMonitor->init(providerName,channelName,useQueue)) longArrayMonitor.reset();
if(!longArrayMonitor->init(providerName,channelName,queueSize,waitTime)) longArrayMonitor.reset();
return longArrayMonitor;
}
@@ -226,14 +258,16 @@ LongArrayMonitor::LongArrayMonitor() {}
LongArrayMonitor::~LongArrayMonitor() {}
bool LongArrayMonitor::init(
String const &providerName,
String const &channelName,
bool useQueue)
string const &providerName,
string const &channelName,
int queueSize,
double waitTime)
{
channelRequester = LAMChannelRequesterPtr(new LAMChannelRequester(getPtrSelf()));
monitorRequester = LAMMonitorRequesterPtr(new LAMMonitorRequester(getPtrSelf()));
monitorRequester = LAMMonitorRequesterPtr(new LAMMonitorRequester(getPtrSelf(),waitTime));
monitorRequester->init();
ChannelProvider::shared_pointer channelProvider = getChannelAccess()->getProvider(providerName);
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
cout << "provider " << providerName << " not found" << endl;
return false;
@@ -241,15 +275,15 @@ bool LongArrayMonitor::init(
channel = channelProvider->createChannel(channelName,channelRequester,0);
event.wait();
if(!status.isOK()) return false;
String queueSize("0");
if(useQueue) queueSize="2";
String request("record[queueSize=");
request += queueSize;
string request("record[queueSize=");
char buff[20];
sprintf(buff,"%d",queueSize);
request += buff;
request += "]field(value,timeStamp,alarm)";
PVStructurePtr pvRequest =
getCreateRequest()->createRequest(request,channelRequester);
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
cout << "request logic error " << request << endl;
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}
monitor = channel->createMonitor(monitorRequester,pvRequest);
@@ -276,6 +310,7 @@ void LongArrayMonitor::destroy()
monitor.reset();
channel->destroy();
channel.reset();
channelRequester->destroy();
channelRequester.reset();
}

View File

@@ -11,6 +11,12 @@
#ifndef LONGARRAYMONITOR_H
#define LONGARRAYMONITOR_H
#ifdef epicsExportSharedSymbols
# define longarraymonitorEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>
@@ -18,6 +24,13 @@
#include <pv/pvTimeStamp.h>
#include <pv/pvAccess.h>
#ifdef longarraymonitorEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef longarraymonitorEpicsExportSharedSymbols
# include <shareLib.h>
#endif
namespace epics { namespace pvDatabase {
@@ -30,15 +43,16 @@ typedef std::tr1::shared_ptr<LAMChannelRequester> LAMChannelRequesterPtr;
class LAMMonitorRequester;
typedef std::tr1::shared_ptr<LAMMonitorRequester> LAMMonitorRequesterPtr;
class LongArrayMonitor :
class epicsShareClass LongArrayMonitor :
public std::tr1::enable_shared_from_this<LongArrayMonitor>
{
public:
POINTER_DEFINITIONS(LongArrayMonitor);
static LongArrayMonitorPtr create(
epics::pvData::String const & providerName,
epics::pvData::String const & channelName,
bool useQueue = false);
std::string const & providerName,
std::string const & channelName,
int queueSize = 1,
double waitTime = 0.0);
~LongArrayMonitor();
void start();
void stop();
@@ -46,9 +60,10 @@ public:
private:
static epics::pvData::Mutex printMutex;
bool init(
epics::pvData::String const & providerName,
epics::pvData::String const & channelName,
bool useQueue);
std::string const & providerName,
std::string const & channelName,
int queueSize,
double waitTime);
LongArrayMonitorPtr getPtrSelf()
{
return shared_from_this();

View File

@@ -22,13 +22,14 @@
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/arrayPerformance.h>
#include <pv/longArrayMonitor.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/clientFactory.h>
#include <arrayPerformance.h>
#include <longArrayMonitor.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
@@ -37,22 +38,26 @@ using namespace epics::pvDatabase;
int main(int argc,char *argv[])
{
String channelName("arrayPerformance");
bool useQueue = false;
if(argc==2 && String(argv[1])==String("-help")) {
cout << "longArrayMonitorMain channelName useQueue" << endl;
string channelName("arrayPerformance");
int queueSize = 2;
double waitTime = 0.0;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "longArrayMonitorMain channelName queueSize waitTime" << endl;
cout << "default" << endl;
cout << "longArrayMonitorMain " << channelName << " ";
cout << (useQueue ? "true" : "false") << endl;
cout << queueSize << " ";
cout << "0.0" << endl;
return 0;
}
ClientFactory::start();
if(argc>1) channelName = argv[1];
if(argc>2) useQueue = (String(argv[2])==String("true") ? true : false);
if(argc>2) queueSize = strtol(argv[2],0,0);
if(argc>3) waitTime = atof(argv[3]);
cout << "longArrayMonitorMain " << channelName << " ";
cout << (useQueue ? "true" : "false") << endl;
cout << queueSize << " ";
cout << waitTime << endl;
LongArrayMonitorPtr longArrayMonitor
= LongArrayMonitor::create("pvAccess",channelName,useQueue);
= LongArrayMonitor::create("pvAccess",channelName,queueSize,waitTime);
longArrayMonitor->start();
cout << "longArrayMonitor\n";
string str;
@@ -65,6 +70,7 @@ int main(int argc,char *argv[])
longArrayMonitor->destroy();
longArrayMonitor.reset();
ClientFactory::stop();
epicsThreadSleep(1.0);
return 0;
}

View File

@@ -0,0 +1,384 @@
/* longArrayPut.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.08.09
*/
#include <epicsThread.h>
#include <pv/caProvider.h>
#define epicsExportSharedSymbols
#include <longArrayPut.h>
namespace epics { namespace pvDatabase {
using namespace epics::pvData;
using namespace epics::pvAccess;
using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::cout;
using std::endl;
using std::ostringstream;
using std::string;
static string requesterName("longArrayPut");
static string request("value");
static epics::pvData::Mutex printMutex;
class LongArrayChannelPut :
virtual public ChannelRequester,
virtual public ChannelPutRequester,
public std::tr1::enable_shared_from_this<LongArrayChannelPut>,
public epicsThreadRunable
{
public:
LongArrayChannelPut(
string providerName,
string channelName,
size_t arraySize,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelPut,
double delayTime)
: providerName(providerName),
channelName(channelName),
arraySize(arraySize),
iterBetweenCreateChannel(iterBetweenCreateChannel),
iterBetweenCreateChannelPut(iterBetweenCreateChannelPut),
delayTime(delayTime),
isDestroyed(false),
runReturned(false),
threadName("longArrayPut")
{}
virtual ~LongArrayChannelPut(){}
bool init();
virtual void destroy();
virtual void run();
virtual string getRequesterName() { return requesterName;}
virtual void message(string const & message, MessageType messageType)
{
Lock guard(printMutex);
cout << requesterName << " message " << message << endl;
}
virtual void channelCreated(
const Status& status,
Channel::shared_pointer const & channel);
virtual void channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState);
virtual void channelPutConnect(
Status const & status,
ChannelPut::shared_pointer const & channelPut,
StructureConstPtr const &structure);
virtual void putDone(
Status const & status,
ChannelPut::shared_pointer const & channelPut);
virtual void getDone(
Status const & status,
ChannelPut::shared_pointer const & channelPut,
PVStructurePtr const &pvStructure,
BitSetPtr const & bitSet){}
private:
LongArrayChannelPutPtr getPtrSelf()
{
return shared_from_this();
}
string providerName;
string channelName;
size_t arraySize;
int iterBetweenCreateChannel;
int iterBetweenCreateChannelPut;
double delayTime;
bool isDestroyed;
bool runReturned;
std::string threadName;
Status status;
Event event;
Mutex mutex;
std::auto_ptr<epicsThread> thread;
Channel::shared_pointer channel;
ChannelPut::shared_pointer channelPut;
PVStructurePtr pvStructure;
PVLongArrayPtr pvLongArray;
BitSetPtr bitSet;
};
bool LongArrayChannelPut::init()
{
ChannelProvider::shared_pointer channelProvider = getChannelProviderRegistry()->getProvider(providerName);
if(channelProvider==NULL) {
cout << "provider " << providerName << " not found" << endl;
return false;
}
channel = channelProvider->createChannel(channelName,getPtrSelf(),0);
event.wait();
if(!status.isOK()) return false;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
cout << "request logic error " << createRequest->getMessage() << endl;
return false;
}
channelPut = channel->createChannelPut(getPtrSelf(),pvRequest);
event.wait();
if(!status.isOK()) return false;
thread = std::auto_ptr<epicsThread>(new epicsThread(
*this,
threadName.c_str(),
epicsThreadGetStackSize(epicsThreadStackSmall),
epicsThreadPriorityLow));
thread->start();
event.signal();
return true;
}
void LongArrayChannelPut::destroy()
{
if(isDestroyed) return;
isDestroyed = true;
event.signal();
while(true) {
if(runReturned) break;
epicsThreadSleep(.01);
}
thread->exitWait();
channel->destroy();
channelPut.reset();
channel.reset();
}
void LongArrayChannelPut::channelCreated(
const Status& status,
Channel::shared_pointer const & channel)
{
if(!status.isOK()) message(status.getMessage(),errorMessage);
this->status = status;
this->channel = channel;
event.signal();
}
void LongArrayChannelPut::channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState)
{
MessageType messageType =
(connectionState==Channel::CONNECTED ? infoMessage : errorMessage);
message("channelStateChange",messageType);
}
void LongArrayChannelPut::channelPutConnect(
Status const & status,
ChannelPut::shared_pointer const & channelPut,
StructureConstPtr const &structure)
{
this->status = status;
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
event.signal();
return;
}
this->channelPut = channelPut;
pvStructure = getPVDataCreate()->createPVStructure(structure);
bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields()));
bool structureOK(true);
PVFieldPtr pvField = pvStructure->getSubField("value");
if(pvField==NULL) {
structureOK = false;
} else {
FieldConstPtr field = pvField->getField();
if(field->getType()!=scalarArray) {
structureOK = false;
} else {
ScalarArrayConstPtr scalarArray = dynamic_pointer_cast<const ScalarArray>(field);
if(scalarArray->getElementType()!=pvLong) structureOK = false;
}
}
if(!structureOK) {
string mess("channelPutConnect: illegal structure");
message(mess,errorMessage);
this->status = Status(Status::STATUSTYPE_ERROR,mess);
}
pvLongArray = static_pointer_cast<PVLongArray>(pvField);
event.signal();
}
void LongArrayChannelPut::run()
{
while(true) {
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
TimeStamp timeStamp;
TimeStamp timeStampLast;
timeStampLast.getCurrent();
int numChannelPut = 0;
int numChannelCreate = 0;
size_t nElements = 0;
while(true) {
nElements += sizeof(int64) * arraySize;
shared_vector<int64> xxx(arraySize,numChannelPut);
shared_vector<const int64> data(freeze(xxx));
pvLongArray->replace(data);
bitSet->set(pvLongArray->getFieldOffset());
channelPut->put(pvStructure,bitSet);
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
if(delayTime>0.0) epicsThreadSleep(delayTime);
if(isDestroyed) {
runReturned = true;
return;
}
timeStamp.getCurrent();
double diff = TimeStamp::diff(timeStamp,timeStampLast);
if(diff>=1.0) {
ostringstream out;
out << "put numChannelPut " << numChannelPut;
out << " time " << diff ;
double elementsPerSec = nElements;
elementsPerSec /= diff;
if(elementsPerSec>10.0e9) {
elementsPerSec /= 1e9;
out << " gigaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e6) {
elementsPerSec /= 1e6;
out << " megaElements/sec " << elementsPerSec;
} else if(elementsPerSec>10.0e3) {
elementsPerSec /= 1e3;
out << " kiloElements/sec " << elementsPerSec;
} else {
out << " Elements/sec " << elementsPerSec;
}
cout << out.str() << endl;
timeStampLast = timeStamp;
nElements = 0;
}
++numChannelCreate;
bool createPut = false;
if(iterBetweenCreateChannel!=0) {
if(numChannelCreate>=iterBetweenCreateChannel) {
channel->destroy();
epicsThreadSleep(1.0);
ChannelProvider::shared_pointer channelProvider =
getChannelProviderRegistry()->getProvider(providerName);
channel = channelProvider->createChannel(
channelName,getPtrSelf(),0);
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
return;
}
cout<< "createChannel success" << endl;
createPut = true;
numChannelCreate = 0;
}
}
++numChannelPut;
if(iterBetweenCreateChannelPut!=0) {
if(numChannelPut>=iterBetweenCreateChannelPut) createPut = true;
}
if(createPut) {
numChannelPut = 0;
channelPut->destroy();
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(pvRequest==NULL) {
cout << "request logic error " << createRequest->getMessage() << endl;
return ;
}
channelPut = channel->createChannelPut(getPtrSelf(),pvRequest);
event.wait();
if(isDestroyed) {
runReturned = true;
return;
}
if(!status.isOK()) {
message(status.getMessage(),errorMessage);
return;
}
cout<< "createChannelPut success" << endl;
}
}
}
}
void LongArrayChannelPut::putDone(
Status const & status,
ChannelPut::shared_pointer const & channelPut)
{
event.signal();
}
LongArrayPutPtr LongArrayPut::create(
string const &providerName,
string const & channelName,
size_t arraySize,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelPut,
double delayTime)
{
LongArrayPutPtr longArrayPut(
new LongArrayPut(
providerName,
channelName,
arraySize,
iterBetweenCreateChannel,
iterBetweenCreateChannelPut,
delayTime));
if(!longArrayPut->init()) longArrayPut.reset();
return longArrayPut;
}
LongArrayPut::LongArrayPut(
string const &providerName,
string const & channelName,
size_t arraySize,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelPut,
double delayTime)
: providerName(providerName),
channelName(channelName),
arraySize(arraySize),
iterBetweenCreateChannel(iterBetweenCreateChannel),
iterBetweenCreateChannelPut(iterBetweenCreateChannelPut),
delayTime(delayTime)
{}
LongArrayPut::~LongArrayPut() {}
bool LongArrayPut::init()
{
longArrayChannelPut = LongArrayChannelPutPtr(new LongArrayChannelPut(
providerName,
channelName,
arraySize,
iterBetweenCreateChannel,
iterBetweenCreateChannelPut,
delayTime));
return longArrayChannelPut->init();
}
void LongArrayPut::destroy()
{
longArrayChannelPut->destroy();
longArrayChannelPut.reset();
}
}}

View File

@@ -0,0 +1,85 @@
/* longArrayPut.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 2013.08.09
*/
#ifndef LONGARRAYPUT_H
#define LONGARRAYPUT_H
#ifdef epicsExportSharedSymbols
# define longarrayputEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <pv/standardPVField.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAccess.h>
#ifdef longarrayputEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef longarrayputEpicsExportSharedSymbols
# include <shareLib.h>
#endif
namespace epics { namespace pvDatabase {
class LongArrayPut;
typedef std::tr1::shared_ptr<LongArrayPut> LongArrayPutPtr;
class LongArrayChannelPut;
typedef std::tr1::shared_ptr<LongArrayChannelPut> LongArrayChannelPutPtr;
class epicsShareClass LongArrayPut :
public std::tr1::enable_shared_from_this<LongArrayPut>
{
public:
POINTER_DEFINITIONS(LongArrayPut);
static LongArrayPutPtr create(
std::string const & providerName,
std::string const & channelName,
size_t arraySize = 100,
int iterBetweenCreateChannel = 0,
int iterBetweenCreateChannelPut = 0,
double delayTime = 0.0);
~LongArrayPut();
void destroy();
private:
LongArrayPutPtr getPtrSelf()
{
return shared_from_this();
}
LongArrayPut(
std::string const & providerName,
std::string const & channelName,
size_t arraySize,
int iterBetweenCreateChannel,
int iterBetweenCreateChannelPut,
double delayTime);
bool init();
std::string providerName;
std::string channelName;
size_t arraySize;
int iterBetweenCreateChannel;
int iterBetweenCreateChannelPut;
double delayTime;
LongArrayChannelPutPtr longArrayChannelPut;
};
}}
#endif /* LONGARRAYPUT_H */

View File

@@ -0,0 +1,93 @@
/*longArrayPutMain.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.08.10
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <vector>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/clientFactory.h>
#include <arrayPerformance.h>
#include <longArrayPut.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[])
{
string channelName("arrayPerformance");
size_t arraySize = 10;
int iterBetweenCreateChannel = 0;
int iterBetweenCreateChannelPut = 0;
double delayTime = 1.0;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "longArrayPutMain channelName arraySize ";
cout << "iterBetweenCreateChannel iterBetweenCreateChannelPut delayTime" << endl;
cout << "default" << endl;
cout << "longArrayPutMain " << channelName << " ";
cout << arraySize << " ";
cout << iterBetweenCreateChannel << " ";
cout << iterBetweenCreateChannelPut << " ";
cout << delayTime << endl;
return 0;
}
ClientFactory::start();
if(argc>1) channelName = argv[1];
if(argc>2) arraySize = strtoul(argv[2],0,0);
if(argc>3) iterBetweenCreateChannel = strtol(argv[3],0,0);
if(argc>4) iterBetweenCreateChannelPut = strtol(argv[4],0,0);
if(argc>5) delayTime = atof(argv[5]);
cout << "longArrayPutMain " << channelName << " ";
cout << arraySize << " ";
cout << iterBetweenCreateChannel << " ";
cout << iterBetweenCreateChannelPut << " ";
cout << delayTime << endl;
LongArrayPutPtr longArrayPut
= LongArrayPut::create(
"pvAccess",
channelName,
arraySize,
iterBetweenCreateChannel,
iterBetweenCreateChannelPut,
delayTime);
cout << "longArrayPut\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
longArrayPut->destroy();
longArrayPut.reset();
double xxx = 1.0;
if(xxx<delayTime) xxx = delayTime;
epicsThreadSleep(xxx);
ClientFactory::stop();
epicsThreadSleep(1.0);
return 0;
}

View File

@@ -0,0 +1,189 @@
/*vectorPerformanceMain.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.09.02
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <vector>
#include <epicsThread.h>
#include <pv/timeStamp.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
class VectorPerformanceThread;
typedef std::tr1::shared_ptr<VectorPerformanceThread> VectorPerformanceThreadPtr;
class VectorPerformanceThread :
public epicsThreadRunable
{
public:
VectorPerformanceThread(int threadNumber,size_t size,double delay);
virtual ~VectorPerformanceThread(){};
void init();
void start();
virtual void run();
void destroy();
private:
bool isDestroyed;
bool runReturned;
int threadNumber;
size_t size;
epics::pvData::int64 value;
double delay;
Mutex mutex;
std::vector<int64> vector;
std::auto_ptr<epicsThread> thread;
};
VectorPerformanceThread::VectorPerformanceThread(
int threadNumber,size_t size,double delay)
:
isDestroyed(false),
runReturned(false),
threadNumber(threadNumber),
size(size),
value(0),
delay(delay)
{}
void VectorPerformanceThread::init()
{
vector.resize(size);
thread = std::auto_ptr<epicsThread>(new epicsThread(
*this,
"vectorPerform",
epicsThreadGetStackSize(epicsThreadStackSmall),
epicsThreadPriorityHigh));
}
void VectorPerformanceThread::start()
{
thread->start();
}
void VectorPerformanceThread::destroy()
{
Lock lock(mutex);
if(isDestroyed) return;
isDestroyed = true;
while(true) {
if(runReturned) break;
lock.unlock();
epicsThreadSleep(.01);
lock.lock();
}
thread->exitWait();
thread.reset();
}
void VectorPerformanceThread::run()
{
TimeStamp timeStamp;
TimeStamp timeStampLast;
timeStampLast.getCurrent();
int nSinceLastReport = 0;
while(true) {
if(delay>0.0) epicsThreadSleep(delay);
{
Lock lock(mutex);
if(isDestroyed) {
cout << " found isDestroyed " << threadNumber << endl;
runReturned = true;
return;
}
}
timeStamp.getCurrent();
double diff = TimeStamp::diff(timeStamp,timeStampLast);
if(diff>=1.0) {
cout << "thread" << threadNumber;
cout << " value " << value;
cout << " time " << diff;
double iterations = nSinceLastReport;
iterations /= diff;
cout << " iterations/sec " << iterations;
double elementSize = size;
double elementsPerSecond = elementSize*nSinceLastReport;
elementsPerSecond /= diff;
elementsPerSecond /= 1e6;
cout << " elements/sec " << elementsPerSecond << "million" << endl;
cout.flush();
timeStampLast = timeStamp;
nSinceLastReport = 0;
}
++nSinceLastReport;
++value;
for(size_t i=0; i<size; ++i) vector[i] = value;
}
}
int main(int argc,char *argv[])
{
size_t size = 50000000;
double delay = .01;
size_t nThread = 1;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "vectorPerformanceMain size delay nThread" << endl;
cout << "default" << endl;
cout << "vectorPerformance ";
cout << size << " ";
cout << delay << " ";
cout << nThread << " ";
cout << endl;
return 0;
}
if(argc>1) size = strtoul(argv[1],0,0);
if(argc>2) delay = atof(argv[2]);
if(argc>3) nThread = strtoul(argv[3],0,0);
cout << "vectorPerformance ";
cout << size << " ";
cout << delay << " ";
cout << nThread << " ";
cout << endl;
cout << "vectorPerformance\n";
std::vector<VectorPerformanceThreadPtr> threads;
for(size_t i=0; i<nThread; ++i) {
threads.push_back(
VectorPerformanceThreadPtr(
new VectorPerformanceThread(i,size,delay)));
}
epicsThreadSleep(.1);
for(size_t i=0; i<nThread; ++i) {
threads[i]->init();
}
for(size_t i=0; i<nThread; ++i) {
threads[i]->start();
}
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
for(size_t i=0; i<nThread; ++i) {
cout << "" << i << " calling destroy" << endl;
threads[i]->destroy();
threads[i].reset();
}
return 0;
}

View File

@@ -16,24 +16,13 @@
# continue building anyway if conflicts are found.
#CHECK_RELEASE = YES
# Set this when you only want to compile this application
# for a subset of the cross-compiled target architectures
# that Base is built for.
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</path/name/to/install/top>
# Set this when your IOC and the host use different paths
# to access the application. This will be needed to boot
# from a Microsoft FTP server or with some NFS mounts.
# You must rebuild in the iocBoot directory for this to
# take effect.
#IOCS_APPL_TOP = </IOC/path/to/application/top>
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/../CONFIG_SITE.local
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local

View File

@@ -0,0 +1,8 @@
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICS_BASE=/home/install/epics/base
PVCOMMON=/home/hg/pvCommonCPP
PVDATA=/home/hg/pvDataCPP
PVACCESS=/home/hg/pvAccessCPP
PVASRV=/home/hg/pvaSrv

View File

@@ -6,3 +6,4 @@ TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES

View File

@@ -1,11 +1,11 @@
# RELEASE - Location of external support modules
# pvDatabaseCPP RELEASE - Location of external support modules
#
# IF YOU MAKE ANY CHANGES to this file you must subsequently
# do a "gnumake rebuild" in this application's top level
# directory.
# IF YOU CHANGE this file or any file it includes you must
# subsequently do a "gnumake rebuild" in the application's
# top level directory.
#
# The build process does not check dependencies against files
# that are outside this application, thus you should do a
# that are outside this application, thus you should also do a
# "gnumake rebuild" in the top level directory after EPICS_BASE
# or any other external module pointed to below is rebuilt.
#
@@ -13,32 +13,16 @@
# RELEASE.$(EPICS_HOST_ARCH).Common
# RELEASE.Common.$(T_A)
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
# EPICS V4 Developers: Do not edit the locations in this file!
#
# This file should ONLY define paths to other support modules,
# or include statements that pull in similar RELEASE files.
# Build settings that are NOT module paths should appear in a
# CONFIG_SITE file.
# Create a file RELEASE.local pointing to your PVASRV, PVACCESS,
# PVDATA, PVCOMMON and EPICS_BASE build directories, e.g.
# PVASRV = /path/to/epics/pvaSrvCPP
# PVACCESS = /path/to/epics/pvAccessCPP
# PVDATA = /path/to/epics/pvDataCPP
# PVCOMMON = /path/to/epics/pvCommonCPP
# EPICS_BASE = /path/to/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
# If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
# EPICS_BASE usually appears last so other apps can override stuff:
# do not edit the locations in this file
# create RELEASE.local with the paths to your EPICS_BASE, PVDATA, and PVACCESS
# these default locations are needed for the BNL Jenkins server to work
# Set RULES here if you want to take build rules from somewhere
# other than EPICS_BASE:
#RULES=/path/to/epics/support/module/rules/x-y
# Leave these in for the Jenkins build at BNL to work
EPICS_BASE=/home/install/epics/base
PVDATA=/home/mrk/hg/pvDataCPP
PVACCESS=/home/mrk/hg/pvAccessCPP
# set your EPICS_BASE, PVDATA and PVACCESS paths in here
-include $(TOP)/configure/RELEASE.local
-include $(TOP)/../RELEASE.local
-include $(TOP)/configure/RELEASE.local

View File

@@ -1,3 +1,16 @@
#RULES_TOP
include $(CONFIG)/RULES_TOP
EMTOPACTIONS += cvsclean realuninstall
distclean: emtop_distclean
emtopDistcleanTargets += $(foreach dir, $(EMBEDDED_TOPS), \
$(dir)$(DIVIDER)emtop_dummy_action)
$(emtopDistcleanTargets) :
$(MAKE) -C $(dirPart) $(EMTOPACTIONS)
emtop_distclean : $(emtopDistcleanTargets)
.PHONY : $(emtopDistcleanTargets)

File diff suppressed because it is too large Load Diff

View File

@@ -70,28 +70,9 @@ The minimum that an extenson must provide is a top level PVStructure and a proce
but the framework provides for complex extensions.</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:</p>
<dl>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvDataJava/tip/documentation/pvDataJava.html">pvData</a></dt>
<dd>pvData (Process Variable Data) defines and implements an efficent way
to store, access, and communicate memory resident structured data</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvAccessJava/tip/documentation/pvAccessJava.html">pvAccess</a></dt>
<dd>pvAccess is a software library for high speed controls network communications,
optimized for pvData</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvIOCJava/tip/documentation/pvIOCJava.html">pvIOC</a></dt>
<dd>pvIOC is a software framework for building network accessable "smart" real time
databases, suitable for interfacing devices in a distributed control system,
that can exchange pvData over pvAccess.
</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvServiceJava/tip/documentation/pvAccessJava.html">pvService</a></dt>
<dd>A middle layer for implementing data services.</dd>
</dl>
<p>Each of these products has a Java and a C++ implementation.</p>
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumemntsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -72,28 +72,10 @@ The minimum that an extenson must provide is a top level PVStructure and a proce
but the framework provides for complex extensions.</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:</p>
<dl>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvDataJava/tip/documentation/pvDataJava.html">pvData</a></dt>
<dd>pvData (Process Variable Data) defines and implements an efficent way
to store, access, and communicate memory resident structured data</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvAccessJava/tip/documentation/pvAccessJava.html">pvAccess</a></dt>
<dd>pvAccess is a software library for high speed controls network communications,
optimized for pvData</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvIOCJava/tip/documentation/pvIOCJava.html">pvIOC</a></dt>
<dd>pvIOC is a software framework for building network accessable "smart" real time
databases, suitable for interfacing devices in a distributed control system,
that can exchange pvData over pvAccess.
</dd>
<dt><a
href="http://epics-pvdata.sourceforge.net/docbuild/pvServiceJava/tip/documentation/pvAccessJava.html">pvService</a></dt>
<dd>A middle layer for implementing data services.</dd>
</dl>
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<p>Each of these products has a Java and a C++ implementation.</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -71,6 +71,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -71,6 +71,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -71,6 +71,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -71,6 +71,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -71,6 +71,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

View File

@@ -70,6 +70,11 @@ The framework can be extended in order to create record instances that implement
The minimum that an extenson must provide is a top level PVStructure and a process method.
</p>
<p>EPICS version 4 is a set of related products in the EPICS
V4 control system programming environment:<br />
<a href="http://epics-pvdata.sourceforge.net/relatedDocumentsV4.html">relatedDocumentsV4.html</a>
</p>
<h2 class="nocount">Status of this Document</h2>

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

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS += src
DIRS += record
DIRS += pvCopy
DIRS += exampleCounter
DIRS += exampleServer
DIRS += examplePVADoubleArrayGet
DIRS += arrayPerformance
DIRS += v3IOC
include $(TOP)/configure/RULES_DIRS

View File

@@ -1,20 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += arrayPerformanceMain
arrayPerformanceMain_SRCS += arrayPerformanceMain.cpp
arrayPerformanceMain_LIBS += pvDatabase pvAccess pvData Com
arrayPerformanceMain_LIBS += pvDatabaseExample
PROD_HOST += longArrayMonitorMain
longArrayMonitorMain_SRCS += longArrayMonitorMain.cpp
longArrayMonitorMain_LIBS += pvDatabase pvAccess pvData Com
longArrayMonitorMain_LIBS += pvDatabaseExample
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,13 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += exampleCounterMain
exampleCounterMain_SRCS += exampleCounterMain.cpp
exampleCounterMain_LIBS += pvDatabase pvAccess pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,14 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += examplePVADoubleArrayGetMain
examplePVADoubleArrayGetMain_SRCS += examplePVADoubleArrayGetMain.cpp
examplePVADoubleArrayGetMain_LIBS += pvDatabase pvAccess pvData Com
examplePVADoubleArrayGetMain_LIBS += pvDatabaseExample
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,12 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += exampleServerMain
exampleServerMain_SRCS += exampleServerMain.cpp
exampleServerMain_LIBS += pvDatabase pvDatabaseExample pvAccess pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,16 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += testPVCopy
testPVCopy_SRCS += testPVCopy.cpp
testPVCopy_LIBS += pvDatabase pvAccess pvData Com
PROD_HOST += testPVRecord
testPVRecord_SRCS += testPVRecord.cpp
testPVRecord_LIBS += pvDatabase pvAccess pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,13 +0,0 @@
TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += testExampleRecord
testExampleRecord_SRCS += testExampleRecordMain.cpp
testExampleRecord_LIBS += pvDatabase pvAccess pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,29 +0,0 @@
TOP = ../..
include $(TOP)/configure/CONFIG
EXAMPLESRC = $(TOP)/example/src/
LIBRARY_IOC += pvDatabaseExample
pvDatabaseExample_LIBS += $(EPICS_BASE_IOC_LIBS)
pvDatabaseExample_LIBS += Com pvData pvAccess pvDatabase
SRC_DIRS += $(EXAMPLESRC)/exampleCounter
INC += exampleCounter.h
SRC_DIRS += $(EXAMPLESRC)/exampleServer
INC+= exampleServerCreateRecords.h
LIBSRCS += exampleServerCreateRecords.cpp
SRC_DIRS += $(EXAMPLESRC)/examplePVADoubleArrayGet
INC+= examplePVADoubleArrayGet.h
LIBSRCS += examplePVADoubleArrayGet.cpp
SRC_DIRS += $(EXAMPLESRC)/arrayPerformance
INC+= arrayPerformance.h
LIBSRCS += arrayPerformance.cpp
INC+= longArrayMonitor.h
LIBSRCS += longArrayMonitor.cpp
include $(TOP)/configure/RULES

View File

@@ -1,92 +0,0 @@
/* exampleCounter.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 2013.04.02
*/
#ifndef EXAMPLECOUNTER_H
#define EXAMPLECOUNTER_H
#include <pv/pvDatabase.h>
#include <pv/standardPVField.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
namespace epics { namespace pvDatabase {
class ExampleCounter;
typedef std::tr1::shared_ptr<ExampleCounter> ExampleCounterPtr;
class ExampleCounter :
public PVRecord
{
public:
POINTER_DEFINITIONS(ExampleCounter);
static ExampleCounterPtr create(
epics::pvData::String const & recordName);
virtual ~ExampleCounter();
virtual void destroy();
virtual bool init();
virtual void process();
private:
ExampleCounter(epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
epics::pvData::PVLongPtr pvValue;
epics::pvData::PVTimeStamp pvTimeStamp;
epics::pvData::TimeStamp timeStamp;
};
ExampleCounterPtr ExampleCounter::create(
epics::pvData::String const & recordName)
{
epics::pvData::PVStructurePtr pvStructure =
epics::pvData::getStandardPVField()->scalar(epics::pvData::pvLong,"timeStamp,alarm");
ExampleCounterPtr pvRecord(
new ExampleCounter(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
ExampleCounter::ExampleCounter(
epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure)
{
pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
}
ExampleCounter::~ExampleCounter()
{
}
void ExampleCounter::destroy()
{
PVRecord::destroy();
}
bool ExampleCounter::init()
{
initPVRecord();
epics::pvData::PVFieldPtr pvField;
pvValue = getPVStructure()->getLongField("value");
if(pvValue.get()==NULL) return false;
return true;
}
void ExampleCounter::process()
{
pvValue->put(pvValue->get() + 1.0);
timeStamp.getCurrent();
pvTimeStamp.set(timeStamp);
}
}}
#endif /* EXAMPLECOUNTER_H */

View File

@@ -1,7 +0,0 @@
TOP = ../..
include $(TOP)/configure/CONFIG
DIRS += exampleCounter
DIRS += exampleServer
DIRS += examplePVADoubleArrayGet
include $(TOP)/configure/RULES_DIRS

View File

@@ -1,48 +0,0 @@
TOP=../../../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += exampleCounter.dbd
LIBRARY_IOC += exampleCounterSupport
exampleCounterSupport_SRCS += exampleCounter.cpp
exampleCounterSupport_LIBS += pvData
exampleCounterSupport_LIBS += pvAccess
exampleCounterSupport_LIBS += pvDatabase
exampleCounterSupport_LIBS += pvDatabaseExample
exampleCounterSupport_LIBS += $(EPICS_BASE_IOC_LIBS)
#=============================
# build an ioc application
PROD_IOC += exampleCounter
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
exampleCounter_SRCS += exampleCounter_registerRecordDeviceDriver.cpp
exampleCounter_SRCS_DEFAULT += exampleCounterMain.cpp
exampleCounter_SRCS_vxWorks += -nil-
# The following adds support from base/src/vxWorks
exampleCounter_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
exampleCounter_LIBS += pvData pvAccess
exampleCounter_LIBS += pvDatabase
exampleCounter_LIBS += pvDatabaseExample
exampleCounter_LIBS += exampleCounterSupport
exampleCounter_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,3 +0,0 @@
include "base.dbd"
include "PVAServerRegister.dbd"
registrar("exampleCounterRegister")

View File

@@ -1,48 +0,0 @@
TOP=../../../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += examplePVADoubleArrayGet.dbd
LIBRARY_IOC += examplePVADoubleArrayGetSupport
examplePVADoubleArrayGetSupport_SRCS += examplePVADoubleArrayGet.cpp
examplePVADoubleArrayGetSupport_LIBS += pvData
examplePVADoubleArrayGetSupport_LIBS += pvAccess
examplePVADoubleArrayGetSupport_LIBS += pvDatabase
examplePVADoubleArrayGetSupport_LIBS += pvDatabaseExample
examplePVADoubleArrayGetSupport_LIBS += $(EPICS_BASE_IOC_LIBS)
#=============================
# build an ioc application
PROD_IOC += examplePVADoubleArrayGet
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
examplePVADoubleArrayGet_SRCS += examplePVADoubleArrayGet_registerRecordDeviceDriver.cpp
examplePVADoubleArrayGet_SRCS_DEFAULT += examplePVADoubleArrayGetMain.cpp
examplePVADoubleArrayGet_SRCS_vxWorks += -nil-
# The following adds support from base/src/vxWorks
examplePVADoubleArrayGet_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
examplePVADoubleArrayGet_LIBS += pvData pvAccess
examplePVADoubleArrayGet_LIBS += pvDatabase
examplePVADoubleArrayGet_LIBS += pvDatabaseExample
examplePVADoubleArrayGet_LIBS += examplePVADoubleArrayGetSupport
examplePVADoubleArrayGet_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,3 +0,0 @@
include "base.dbd"
include "PVAServerRegister.dbd"
registrar("exampleServerRegister")

19
exampleDatabase/Makefile Normal file
View File

@@ -0,0 +1,19 @@
# Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS += configure
DIRS += src
src_DEPEND_DIRS = configure
DIRS += ioc
ioc_DEPEND_DIRS = src
DIRS += iocBoot
iocBoot_DEPEND_DIRS = src
include $(TOP)/configure/RULES_TOP

View File

@@ -0,0 +1,29 @@
# CONFIG - Load build configuration data
#
# Do not make changes to this file!
# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)
# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
# Override the Base definition:
INSTALL_LOCATION = $(TOP)
# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif

View File

@@ -0,0 +1,28 @@
# CONFIG_SITE
# Make any application-specific changes to the EPICS build
# configuration variables in this file.
#
# Host/target specific settings can be specified in files named
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
# CONFIG_SITE.Common.$(T_A)
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
# CHECK_RELEASE controls the consistency checking of the support
# applications pointed to by the RELEASE* files.
# Normally CHECK_RELEASE should be set to YES.
# Set CHECK_RELEASE to NO to disable checking completely.
# Set CHECK_RELEASE to WARN to perform consistency checking but
# continue building anyway if conflicts are found.
CHECK_RELEASE = WARN
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</path/name/to/install/top>
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

View File

@@ -0,0 +1,9 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
PVDATABASE=${EPICSV4HOME}/pvDatabaseCPP
PVDATABASETEST=${EPICSV4HOME}/pvDatabaseCPP/test
PVASRV=${EPICSV4HOME}/pvaSrv

View File

@@ -0,0 +1,8 @@
TOP=..
include $(TOP)/configure/CONFIG
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES

View File

@@ -0,0 +1,43 @@
# pvDatabaseCPP/example RELEASE - Location of external support modules
#
# IF YOU CHANGE this file or any file it includes you must
# subsequently do a "gnumake rebuild" in the application's
# top level directory.
#
# The build process does not check dependencies against files
# that are outside this application, thus you should also do a
# "gnumake rebuild" in the top level directory after EPICS_BASE
# or any other external module pointed to below is rebuilt.
#
# Host- or target-specific settings can be given in files named
# RELEASE.$(EPICS_HOST_ARCH).Common
# RELEASE.Common.$(T_A)
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
# EPICS V4 Developers: Do not edit the locations in this file!
#
# Create a file RELEASE.local pointing to your PVASRV, PVACCESS,
# PVDATA, PVCOMMON and EPICS_BASE build directories, e.g.
# PVASRV = /path/to/epics/pvaSrvCPP
# PVACCESS = /path/to/epics/pvAccessCPP
# PVDATA = /path/to/epics/pvDataCPP
# PVCOMMON = /path/to/epics/pvCommonCPP
# EPICS_BASE = /path/to/epics/base
# If this example is built in a directory under pvDatabaseCPP,
# use the following definitions:
PVDATABASETEST = $(TOP)/../test
PVDATABASE = $(TOP)/..
-include $(TOP)/../configure/RELEASE.local
-include $(TOP)/../../RELEASE.local
# If you copied this example from pvDatabaseCPP to be built as a
# standalone TOP, adjust and use the following definitions:
#PVDATABASETEST = /path/to/epics/pvDatabaseCPP/testTop
#PVDATABASE = /path/to/epics/pvDatabaseCPP
#-include $(TOP)/../RELEASE.local
#-include $(TOP)/configure/RELEASE.local

View File

@@ -0,0 +1,6 @@
# RULES
include $(CONFIG)/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile

View File

@@ -0,0 +1,2 @@
#RULES.ioc
include $(CONFIG)/RULES.ioc

View File

@@ -0,0 +1,2 @@
#RULES_DIRS
include $(CONFIG)/RULES_DIRS

View File

@@ -0,0 +1,3 @@
#RULES_TOP
include $(CONFIG)/RULES_TOP

View File

@@ -1,4 +1,4 @@
TOP=../../../..
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE

View File

@@ -1,4 +1,4 @@
TOP = ../../..
TOP = ..
include $(TOP)/configure/CONFIG
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*))

View File

@@ -0,0 +1,43 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += exampleDatabase.dbd
#=============================
# build an ioc application
PROD_IOC += exampleDatabase
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
exampleDatabase_SRCS += exampleDatabase_registerRecordDeviceDriver.cpp
exampleDatabase_SRCS_DEFAULT += exampleDatabaseMain.cpp
exampleDatabase_SRCS_vxWorks += -nil-
# The following adds support from base/src/vxWorks
exampleDatabase_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
exampleDatabase_LIBS += exampleDatabase
exampleDatabase_LIBS += powerSupply
exampleDatabase_LIBS += pvDatabase
exampleDatabase_LIBS += pvaSrv
exampleDatabase_LIBS += pvAccess
exampleDatabase_LIBS += pvData
exampleDatabase_LIBS += Com
exampleDatabase_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -0,0 +1,7 @@
include "base.dbd"
include "PVAServerRegister.dbd"
include "registerChannelProviderLocal.dbd"
include "dbPv.dbd"
include "powerSupplyRegister.dbd"
registrar("exampleDatabaseRegister")
registrar("exampleMonitorPluginRegister")

View File

@@ -0,0 +1,33 @@
/*exampleDatabaseMain.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
*/
/* Author: Marty Kraimer */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "epicsExit.h"
#include "epicsThread.h"
#include "iocsh.h"
int main(int argc,char *argv[])
{
if(argc>=2) {
iocsh(argv[1]);
epicsThreadSleep(.2);
}
iocsh(NULL);
epicsExit(0);
return(0);
}

View File

@@ -0,0 +1,27 @@
< envPaths
cd ${TOP}
## Register all support components
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/dbStringArray.db","name=stringArray01")
dbLoadRecords("db/dbEnum.db","name=enum01")
dbLoadRecords("db/dbCounter.db","name=counter01");
cd ${TOP}/iocBoot/${IOC}
iocInit()
dbl
epicsThreadSleep(2.0)
exampleDatabase
exampleMonitorPlugin
startPVAServer
pvdbl

View File

@@ -0,0 +1,37 @@
TOP=..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
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 += pvDatabase
exampleDatabase_LIBS += pvAccess
exampleDatabase_LIBS += pvData
exampleDatabase_LIBS += Com
exampleDatabase_LIBS += $(EPICS_BASE_IOC_LIBS)
PROD_HOST += exampleDatabaseMain
exampleDatabaseMain_SRCS += exampleDatabaseMain.cpp
exampleDatabaseMain_LIBS += exampleDatabase
exampleDatabaseMain_LIBS += powerSupply
exampleDatabaseMain_LIBS += pvDatabase
exampleDatabaseMain_LIBS += pvAccess
exampleDatabaseMain_LIBS += pvData
exampleDatabaseMain_LIBS += Com
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -1,4 +1,4 @@
/*exampleServerCreateRecords.cpp */
/*exampleDatabase.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
@@ -22,12 +22,12 @@
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/powerSupplyRecordTest.h>
#include <pv/channelProviderLocal.h>
#include <pv/exampleCounter.h>
#include <pv/recordList.h>
#include <pv/traceRecord.h>
#include <pv/exampleServerCreateRecords.h>
#include <pv/powerSupply.h>
#include <pv/exampleDatabase.h>
using namespace std;
using std::tr1::static_pointer_cast;
@@ -40,42 +40,59 @@ static StandardFieldPtr standardField = getStandardField();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardPVFieldPtr standardPVField = getStandardPVField();
static PVStructurePtr createPowerSupply()
{
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));
}
static void createStructureArrayRecord(
PVDatabasePtr const &master,
ScalarType scalarType,
String const &recordName)
string const &recordName)
{
StructureConstPtr structure = standardField->scalar(
pvDouble,
String("value,alarm,timeStamp"));
StringArray names(2);
FieldConstPtrArray fields(2);
names[0] = "timeStamp";
names[0] = "name";
names[1] = "value";
fields[0] = standardField->timeStamp();
fields[1] = fieldCreate->createStructureArray(structure);
fields[0] = fieldCreate->createScalar(pvString);
fields[1] = fieldCreate->createScalar(pvString);
StringArray topNames(1);
FieldConstPtrArray topFields(1);
topNames[0] = "value";
topFields[0] = fieldCreate->createStructureArray(
fieldCreate->createStructure(names, fields));
StructureConstPtr top = fieldCreate->createStructure(topNames,topFields);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
static void createRegularUnionArrayRecord(
PVDatabasePtr const &master,
string const &recordName)
{
StringArray unionNames(2);
FieldConstPtrArray unionFields(2);
unionNames[0] = "string";
unionNames[1] = "stringArray";
unionFields[0] = fieldCreate->createScalar(pvString);
unionFields[1] = fieldCreate->createScalarArray(pvString);
StringArray names(1);
FieldConstPtrArray fields(1);
fields[0] = fieldCreate->createUnionArray(fieldCreate->createUnion(unionNames,unionFields));
names[0] = "value";
StructureConstPtr top = fieldCreate->createStructure(names,fields);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
static void createVariantUnionArrayRecord(
PVDatabasePtr const &master,
string const &recordName)
{
StringArray names(1);
FieldConstPtrArray fields(1);
fields[0] = fieldCreate->createVariantUnionArray();
names[0] = "value";
StructureConstPtr top = fieldCreate->createStructure(names,fields);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
@@ -86,10 +103,10 @@ static void createStructureArrayRecord(
static void createRecords(
PVDatabasePtr const &master,
ScalarType scalarType,
String const &recordNamePrefix,
String const &properties)
string const &recordNamePrefix,
string const &properties)
{
String recordName = recordNamePrefix;
string recordName = recordNamePrefix;
PVStructurePtr pvStructure = standardPVField->scalar(scalarType,properties);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
@@ -100,20 +117,17 @@ static void createRecords(
result = master->addRecord(pvRecord);
}
void ExampleServerCreateRecords::create()
void ExampleDatabase::create()
{
PVDatabasePtr master = PVDatabase::getMaster();
PVRecordPtr pvRecord;
String recordName;
string recordName;
bool result(false);
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
String properties;
recordName = "exampleCounter";
pvRecord = ExampleCounter::create(recordName);
result = master->addRecord(pvRecord);
string properties;
properties = "alarm,timeStamp";
createRecords(master,pvBoolean,"exampleBoolean",properties);
createRecords(master,pvByte,"exampleByte",properties);
@@ -122,14 +136,21 @@ void ExampleServerCreateRecords::create()
createRecords(master,pvLong,"exampleLong",properties);
createRecords(master,pvFloat,"exampleFloat",properties);
createRecords(master,pvDouble,"exampleDouble",properties);
createRecords(master,pvDouble,"exampleDouble01",properties);
createRecords(master,pvDouble,"exampleDouble02",properties);
createRecords(master,pvDouble,"exampleDouble03",properties);
createRecords(master,pvDouble,"exampleDouble04",properties);
createRecords(master,pvDouble,"exampleDouble05",properties);
createRecords(master,pvString,"exampleString",properties);
createStructureArrayRecord(master,pvDouble,"exampleStructureArray");
createStructureArrayRecord(master,"exampleStructureArray");
createRegularUnionArrayRecord(master,"exampleRegularUnionArray");
createVariantUnionArrayRecord(master,"exampleVariantUnionArray");
recordName = "examplePowerSupply";
PVStructurePtr pvStructure = createPowerSupply();
PowerSupplyRecordTestPtr psr =
PowerSupplyRecordTest::create(recordName,pvStructure);
PowerSupplyPtr psr =
PowerSupply::create(recordName,pvStructure);
if(psr.get()==NULL) {
cout << "PowerSupplyRecordTest::create failed" << endl;
cout << "PowerSupply::create failed" << endl;
return;
}
result = master->addRecord(psr);

View File

@@ -0,0 +1,38 @@
/* exampleDatabase.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 2013.07.24
*/
#ifndef EXAMPLEDATABASE_H
#define EXAMPLEDATABASE_H
#ifdef epicsExportSharedSymbols
# define exampledatabaseEpicsExportSharedSymbols
# undef epicsExportSharedSymbols
#endif
#include <shareLib.h>
#include <pv/pvDatabase.h>
#ifdef exampledatabaseEpicsExportSharedSymbols
# define epicsExportSharedSymbols
# undef exampledatabaseEpicsExportSharedSymbols
# include <shareLib.h>
#endif
namespace epics { namespace pvDatabase {
class epicsShareClass ExampleDatabase{
public:
static void create();
};
}}
#endif /* EXAMPLEDATABASE_H */

View File

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

View File

@@ -1,4 +1,4 @@
/*exampleServerMain.cpp */
/*exampleDatabaseMain.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
@@ -20,9 +20,11 @@
#include <iostream>
#include <pv/channelProviderLocal.h>
#include <pv/exampleServerCreateRecords.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;
@@ -34,14 +36,13 @@ int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
ExampleServerCreateRecords::create();
ExampleDatabase::create();
ExampleMonitorPlugin::create();
ServerContext::shared_pointer ctx =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleServer\n";
cout << "exampleDatabase\n";
PVStringArrayPtr pvNames = master->getRecordNames();
String buffer;
pvNames->toString(&buffer);
cout << "recordNames" << endl << buffer << endl;
cout << "recordNames" << endl << *pvNames << endl;
string str;
while(true) {
cout << "Type exit to stop: \n";
@@ -54,4 +55,3 @@ int main(int argc,char *argv[])
channelProvider->destroy();
return 0;
}

View File

@@ -1,4 +1,4 @@
/*exampleServer.cpp */
/*exampleDatabase.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
@@ -26,13 +26,14 @@
#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/exampleServerCreateRecords.h>
#include <epicsExport.h>
#include <pv/exampleDatabase.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
@@ -42,20 +43,22 @@ static const iocshArg testArg0 = { "prefix", iocshArgString };
static const iocshArg *testArgs[] = {
&testArg0};
static const iocshFuncDef exampleServerFuncDef = {
"exampleServerCreateRecords", 1, testArgs};
static void exampleServerCallFunc(const iocshArgBuf *args)
static const iocshFuncDef exampleDatabaseFuncDef = {
"exampleDatabase", 1, testArgs};
static void exampleDatabaseCallFunc(const iocshArgBuf *args)
{
char *prefix = args[0].sval;
ExampleServerCreateRecords::create();
ExampleDatabase::create();
}
static void exampleServerRegister(void)
static void exampleDatabaseRegister(void)
{
static int firstTime = 1;
if (firstTime) {
firstTime = 0;
iocshRegister(&exampleServerFuncDef, exampleServerCallFunc);
iocshRegister(&exampleDatabaseFuncDef, exampleDatabaseCallFunc);
}
}
epicsExportRegistrar(exampleServerRegister);
extern "C" {
epicsExportRegistrar(exampleDatabaseRegister);
}

View File

@@ -0,0 +1,99 @@
/* 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,4 +1,4 @@
/* exampleServerCreateRecords.h */
/* exampleMonitorPlugin.h */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
@@ -6,17 +6,19 @@
*/
/**
* @author mrk
* @date 2013.07.24
* @date 2014.04.16
*/
#ifndef EXAMPLESERVERCREATERECORDS_H
#define EXAMPLESERVERCREATERECORDS_H
#ifndef EXAMPLEMONITORPLUGIN_H
#define EXAMPLEMONITORPLUGIN_H
#include <shareLib.h>
#include <pv/pvDatabase.h>
#include <pv/monitorPlugin.h>
namespace epics { namespace pvDatabase {
class ExampleServerCreateRecords {
class epicsShareClass ExampleMonitorPlugin{
public:
static void create();
};
@@ -24,4 +26,4 @@ public:
}}
#endif /* EXAMPLESERVERCREATERECORDS_H */
#endif /* EXAMPLEMONITORPLUGIN_H */

View File

@@ -0,0 +1,64 @@
/*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);
}

16
exampleLink/Makefile Normal file
View File

@@ -0,0 +1,16 @@
#Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS += configure
DIRS += src
src_DEPEND_DIRS = configure
DIRS += ioc
ioc_DEPEND_DIRS = src
DIRS += iocBoot
include $(TOP)/configure/RULES_TOP

View File

@@ -0,0 +1,29 @@
# CONFIG - Load build configuration data
#
# Do not make changes to this file!
# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)
# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif
CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
# Override the Base definition:
INSTALL_LOCATION = $(TOP)
# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif

View File

@@ -0,0 +1,39 @@
# CONFIG_SITE
# Make any application-specific changes to the EPICS build
# configuration variables in this file.
#
# Host/target specific settings can be specified in files named
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
# CONFIG_SITE.Common.$(T_A)
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
# CHECK_RELEASE controls the consistency checking of the support
# applications pointed to by the RELEASE* files.
# Normally CHECK_RELEASE should be set to YES.
# Set CHECK_RELEASE to NO to disable checking completely.
# Set CHECK_RELEASE to WARN to perform consistency checking but
# continue building anyway if conflicts are found.
#CHECK_RELEASE = YES
# Set this when you only want to compile this application
# for a subset of the cross-compiled target architectures
# that Base is built for.
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</path/name/to/install/top>
# Set this when your IOC and the host use different paths
# to access the application. This will be needed to boot
# from a Microsoft FTP server or with some NFS mounts.
# You must rebuild in the iocBoot directory for this to
# take effect.
#IOCS_APPL_TOP = </IOC/path/to/application/top>
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local

Some files were not shown because too many files have changed in this diff Show More