Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d565a89f0 | ||
|
|
c4a665ed82 | ||
|
|
a96ec158bc |
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e -x
|
||||
|
||||
# set RTEMS to eg. "4.9" or "4.10"
|
||||
# requires qemu, bison, flex, texinfo, install-info
|
||||
if [ -n "$RTEMS" ]
|
||||
then
|
||||
# find local qemu-system-i386
|
||||
export PATH="$HOME/.cache/qemu/usr/bin:$PATH"
|
||||
echo -n "Using QEMU: "
|
||||
type qemu-system-i386 || echo "Missing qemu"
|
||||
EXTRA=RTEMS_QEMU_FIXUPS=YES
|
||||
fi
|
||||
|
||||
make -j2 $EXTRA
|
||||
|
||||
if [ "$TEST" != "NO" ]
|
||||
then
|
||||
make tapfiles
|
||||
make -s test-results
|
||||
fi
|
||||
@@ -1,177 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e -x
|
||||
|
||||
CURDIR="$PWD"
|
||||
|
||||
QDIR="$HOME/.cache/qemu"
|
||||
|
||||
if [ -n "$RTEMS" -a "$TEST" = "YES" ]
|
||||
then
|
||||
git clone --quiet --branch vme --depth 10 https://github.com/mdavidsaver/qemu.git "$HOME/.build/qemu"
|
||||
cd "$HOME/.build/qemu"
|
||||
|
||||
HEAD=`git log -n1 --pretty=format:%H`
|
||||
echo "HEAD revision $HEAD"
|
||||
|
||||
[ -e "$HOME/.cache/qemu/built" ] && BUILT=`cat "$HOME/.cache/qemu/built"`
|
||||
echo "Cached revision $BUILT"
|
||||
|
||||
if [ "$HEAD" != "$BUILT" ]
|
||||
then
|
||||
echo "Building QEMU"
|
||||
git submodule --quiet update --init
|
||||
|
||||
install -d "$HOME/.build/qemu/build"
|
||||
cd "$HOME/.build/qemu/build"
|
||||
|
||||
"$HOME/.build/qemu/configure" --prefix="$HOME/.cache/qemu/usr" --target-list=i386-softmmu --disable-werror
|
||||
make -j2
|
||||
make install
|
||||
|
||||
echo "$HEAD" > "$HOME/.cache/qemu/built"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat << EOF > $CURDIR/configure/RELEASE.local
|
||||
EPICS_BASE=$HOME/.source/epics-base
|
||||
EOF
|
||||
|
||||
install -d "$HOME/.source"
|
||||
cd "$HOME/.source"
|
||||
|
||||
add_base_module() {
|
||||
MODULE=$1
|
||||
BRANCH=$2
|
||||
( cd epics-base/modules && \
|
||||
git clone --quiet --depth 5 --branch $MODULE/$BRANCH https://github.com/${REPOBASE:-epics-base}/epics-base.git $MODULE && \
|
||||
cd $MODULE && git log -n1 )
|
||||
}
|
||||
|
||||
add_gh_module() {
|
||||
MODULE=$1
|
||||
REPOOWNER=$2
|
||||
REPONAME=$3
|
||||
BRANCH=$4
|
||||
( cd epics-base/modules && \
|
||||
git clone --quiet --depth 5 --branch $BRANCH https://github.com/$REPOOWNER/$REPONAME.git $MODULE && \
|
||||
cd $MODULE && git log -n1 )
|
||||
}
|
||||
|
||||
add_gh_flat() {
|
||||
MODULE=$1
|
||||
REPOOWNER=$2
|
||||
REPONAME=$3
|
||||
BRANCH=$4
|
||||
MODULE_UC=$(echo $MODULE | tr 'a-z' 'A-Z')
|
||||
( git clone --quiet --depth 5 --branch $BRANCH https://github.com/$REPOOWNER/$REPONAME.git $MODULE && \
|
||||
cd $MODULE && git log -n1 )
|
||||
cat < $CURDIR/configure/RELEASE.local > $MODULE/configure/RELEASE.local
|
||||
cat << EOF >> $CURDIR/configure/RELEASE.local
|
||||
${MODULE_UC}=$HOME/.source/$MODULE
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "$BRBASE" ]
|
||||
then
|
||||
git clone --quiet --depth 5 --branch "$BRBASE" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base
|
||||
(cd epics-base && git log -n1 )
|
||||
add_gh_flat pvData ${REPOPVD:-epics-base} pvDataCPP ${BRPVD:-master}
|
||||
add_gh_flat pvAccess ${REPOPVA:-epics-base} pvAccessCPP ${BRPVA:-master}
|
||||
else
|
||||
git clone --quiet --depth 5 --branch core/"${BRCORE:-master}" https://github.com/${REPOBASE:-epics-base}/epics-base.git epics-base
|
||||
( cd epics-base && git log -n1 )
|
||||
add_base_module libcom "${BRLIBCOM:-master}"
|
||||
add_base_module ca "${BRCA:-master}"
|
||||
add_base_module database "${BRDATABASE:-master}"
|
||||
add_gh_module pvData ${REPOPVD:-epics-base} pvDataCPP ${BRPVD:-master}
|
||||
add_gh_module pvAccess ${REPOPVA:-epics-base} pvAccessCPP ${BRPVA:-master}
|
||||
fi
|
||||
|
||||
if [ -e $CURDIR/configure/RELEASE.local ]
|
||||
then
|
||||
cat $CURDIR/configure/RELEASE.local
|
||||
fi
|
||||
|
||||
EPICS_HOST_ARCH=`sh epics-base/startup/EpicsHostArch`
|
||||
|
||||
# requires wine and g++-mingw-w64-i686
|
||||
if [ "$WINE" = "32" ]
|
||||
then
|
||||
echo "Cross mingw32"
|
||||
sed -i -e '/CMPLR_PREFIX/d' epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw
|
||||
CMPLR_PREFIX=i686-w64-mingw32-
|
||||
EOF
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$STATIC" = "YES" ]
|
||||
then
|
||||
echo "Build static libraries/executables"
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
SHARED_LIBRARIES=NO
|
||||
STATIC_BUILD=YES
|
||||
EOF
|
||||
fi
|
||||
|
||||
case "$CMPLR" in
|
||||
clang)
|
||||
echo "Host compiler is clang"
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH
|
||||
GNU = NO
|
||||
CMPLR_CLASS = clang
|
||||
CC = clang
|
||||
CCC = clang++
|
||||
EOF
|
||||
|
||||
# hack
|
||||
sed -i -e 's/CMPLR_CLASS = gcc/CMPLR_CLASS = clang/' epics-base/configure/CONFIG.gnuCommon
|
||||
|
||||
clang --version
|
||||
;;
|
||||
*)
|
||||
echo "Host compiler is default"
|
||||
gcc --version
|
||||
;;
|
||||
esac
|
||||
|
||||
cat <<EOF >> epics-base/configure/CONFIG_SITE
|
||||
USR_CPPFLAGS += $USR_CPPFLAGS
|
||||
USR_CFLAGS += $USR_CFLAGS
|
||||
USR_CXXFLAGS += $USR_CXXFLAGS
|
||||
EOF
|
||||
|
||||
# set RTEMS to eg. "4.9" or "4.10"
|
||||
# requires qemu, bison, flex, texinfo, install-info
|
||||
if [ -n "$RTEMS" ]
|
||||
then
|
||||
echo "Cross RTEMS${RTEMS} for pc386"
|
||||
install -d /home/travis/.cache
|
||||
curl -L "https://github.com/mdavidsaver/rsb/releases/download/travis-20160306-2/rtems${RTEMS}-i386-trusty-20190306-2.tar.gz" \
|
||||
| tar -C /home/travis/.cache -xj
|
||||
|
||||
sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' epics-base/configure/os/CONFIG_SITE.Common.RTEMS
|
||||
cat << EOF >> epics-base/configure/os/CONFIG_SITE.Common.RTEMS
|
||||
RTEMS_VERSION=$RTEMS
|
||||
RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386
|
||||
EOF
|
||||
cat << EOF >> epics-base/configure/CONFIG_SITE
|
||||
CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386
|
||||
EOF
|
||||
|
||||
# find local qemu-system-i386
|
||||
export PATH="$HOME/.cache/qemu/usr/bin:$PATH"
|
||||
echo -n "Using QEMU: "
|
||||
type qemu-system-i386 || echo "Missing qemu"
|
||||
EXTRA=RTEMS_QEMU_FIXUPS=YES
|
||||
fi
|
||||
|
||||
make -j2 -C epics-base $EXTRA
|
||||
|
||||
if [ "$BRBASE" ]
|
||||
then
|
||||
make -j2 -C pvData $EXTRA
|
||||
make -j2 -C pvAccess $EXTRA
|
||||
fi
|
||||
28
.gitignore
vendored
28
.gitignore
vendored
@@ -1,17 +1,13 @@
|
||||
/cfg/
|
||||
/bin/
|
||||
/lib/
|
||||
/db/
|
||||
/dbd/
|
||||
/html/
|
||||
/include/
|
||||
/templates/
|
||||
/configure/*.local
|
||||
/documentation/html
|
||||
/documentation/*.tag
|
||||
O.*/
|
||||
/QtC-*
|
||||
bin/
|
||||
lib/
|
||||
doc/
|
||||
include/
|
||||
db/
|
||||
dbd/
|
||||
documentation/html
|
||||
documentation/*.tag
|
||||
envPaths
|
||||
*.orig
|
||||
*.log
|
||||
.*.swp
|
||||
configure/*.local
|
||||
!configure/ExampleRELEASE.local
|
||||
**/O.*
|
||||
QtC-*
|
||||
29
.travis.yml
29
.travis.yml
@@ -1,29 +0,0 @@
|
||||
sudo: false
|
||||
dist: trusty
|
||||
language: c++
|
||||
compiler:
|
||||
- gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libreadline6-dev
|
||||
- libncurses5-dev
|
||||
- perl
|
||||
- clang
|
||||
- g++-mingw-w64-i686
|
||||
install:
|
||||
- ./.ci/travis-prepare.sh
|
||||
script:
|
||||
- ./.ci/travis-build.sh
|
||||
env:
|
||||
- BRCORE=master BRLIBCOM=master BRPVD=master BRPVA=master
|
||||
- CMPLR=clang
|
||||
- USR_CXXFLAGS=-std=c++11
|
||||
- CMPLR=clang USR_CXXFLAGS=-std=c++11
|
||||
- WINE=32 TEST=NO STATIC=YES
|
||||
- WINE=32 TEST=NO STATIC=NO
|
||||
- RTEMS=4.10 TEST=NO
|
||||
- RTEMS=4.9 TEST=NO
|
||||
- BRBASE=3.16
|
||||
- BRBASE=3.15
|
||||
- BRBASE=3.14
|
||||
8
configure/ExampleRELEASE.local
Normal file
8
configure/ExampleRELEASE.local
Normal file
@@ -0,0 +1,8 @@
|
||||
EPICS4_DIR=/home/epicsv4/master
|
||||
|
||||
PVACCESS=${EPICS4_DIR}/pvAccessCPP
|
||||
PVDATA=${EPICS4_DIR}/pvDataCPP
|
||||
PVCOMMON=${EPICS4_DIR}/pvCommonCPP
|
||||
|
||||
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
|
||||
EPICS_BASE=/home/install/epics/base
|
||||
@@ -1,43 +1,27 @@
|
||||
# RELEASE - Location of external support modules
|
||||
# pvDatabaseCPP RELEASE - Location of external support modules
|
||||
#
|
||||
# IF YOU CHANGE ANY PATHS in this file or make API changes to
|
||||
# any modules it refers to, you should do a "make 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 EPICS build process does not check dependencies against
|
||||
# any files from outside the application, so it is safest to
|
||||
# rebuild it completely if any modules it depends on change.
|
||||
# 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!
|
||||
#
|
||||
# This file is parsed by both GNUmake and an EPICS Perl script,
|
||||
# so it may ONLY contain definititions of paths to other support
|
||||
# modules, variable definitions that are used in module paths,
|
||||
# and include statements that pull in other RELEASE files.
|
||||
# Variables may be used before their values have been set.
|
||||
# Build variables that are NOT used in paths should be set in
|
||||
# the CONFIG_SITE file.
|
||||
# Create a file RELEASE.local pointing to your PVASRV, PVACCESS,
|
||||
# PVDATA, PVCOMMON and EPICS_BASE build directories, e.g.
|
||||
# PVACCESS = /path/to/epics/pvAccessCPP
|
||||
# PVDATA = /path/to/epics/pvDataCPP
|
||||
# PVCOMMON = /path/to/epics/pvCommonCPP
|
||||
# EPICS_BASE = /path/to/epics/base
|
||||
|
||||
# Variables and paths to dependent modules:
|
||||
#MODULES = /path/to/modules
|
||||
#MYMODULE = $(MODULES)/my-module
|
||||
|
||||
# If building the EPICS modules individually, set these:
|
||||
#EPICS_PVACCESS = $(MODULES)/pvAccess
|
||||
#EPICS_PVDATA = $(MODULES)/pvData
|
||||
#EPICS_DATABASE = $(MODULES)/database
|
||||
#EPICS_CA = $(MODULES)/ca
|
||||
#EPICS_LIBCOM = $(MODULES)/libcom
|
||||
#EPICS_BASE = $(MODULES)/core
|
||||
|
||||
# Set RULES here if you want to use build rules from elsewhere:
|
||||
#RULES = $(MODULES)/build-rules
|
||||
|
||||
# These allow developers to override the RELEASE variable settings
|
||||
# without having to modify the configure/RELEASE file itself.
|
||||
-include $(TOP)/../RELEASE.local
|
||||
-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local
|
||||
-include $(TOP)/configure/RELEASE.local
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<div class="head">
|
||||
<h1>pvDatabaseCPP</h1>
|
||||
<h2 class="nocount">Release 4.2-SNAPSHOT - 2016.07.14</h2>
|
||||
<h2 class="nocount">Release 4.2.1 - 2016-08-26</h2>
|
||||
|
||||
|
||||
<h2 class="nocount">Abstract</h2>
|
||||
|
||||
@@ -21,21 +21,30 @@ installE4 () {
|
||||
local module=$1
|
||||
local branch=$2
|
||||
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE}/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz
|
||||
# If microbench version does not exist, try without
|
||||
if [ "${MB}" = "WITH_MICROBENCH" ]; then
|
||||
if ! wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE},MB=WITH_MICROBENCH/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz; then
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE},MB=NO_MICROBENCH/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz
|
||||
fi
|
||||
else
|
||||
wget -nv https://openepics.ci.cloudbees.com/job/e4-cpp-${module}-${branch}-build/BASE=${BASE},MB=NO_MICROBENCH/lastSuccessfulBuild/artifact/${module}.CB-dist.tar.gz
|
||||
fi
|
||||
tar -xzf ${module}.CB-dist.tar.gz
|
||||
}
|
||||
|
||||
###########################################
|
||||
# Defaults for EPICS Base
|
||||
# Defaults for EPICS Base and MB
|
||||
|
||||
DEFAULT_BASE=3.15.4
|
||||
BASE=${BASE:-${DEFAULT_BASE}}
|
||||
MB=${MB:-"NO_MICROBENCH"}
|
||||
|
||||
###########################################
|
||||
# Dependent module branches
|
||||
|
||||
PVDATA_BRANCH="master"
|
||||
PVACCESS_BRANCH="master"
|
||||
PVCOMMON_BRANCH="release-4.2"
|
||||
PVDATA_BRANCH="release-6.0"
|
||||
PVACCESS_BRANCH="release-5.0"
|
||||
|
||||
###########################################
|
||||
# Fetch and unpack dependencies
|
||||
@@ -49,6 +58,7 @@ cd ${STUFF}
|
||||
installTool Boost 1.61.0
|
||||
installTool Base ${BASE}
|
||||
|
||||
installE4 pvCommon ${PVCOMMON_BRANCH}
|
||||
installE4 pvData ${PVDATA_BRANCH}
|
||||
installE4 pvAccess ${PVACCESS_BRANCH}
|
||||
|
||||
|
||||
@@ -65,10 +65,9 @@ doxygen
|
||||
###########################################
|
||||
# Publish
|
||||
|
||||
if [ "${PUBLISH}" != "DONT" ]; then
|
||||
if [ "${PUBLISH}" != "NO" ]; then
|
||||
# Upload explicit dummy to ensure target directory exists
|
||||
echo "Created by CloudBees Jenkins upload job. Should be deleted as part of the job." > DUMMY
|
||||
rsync -q -e ssh DUMMY epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvDatabaseCPP/${PUBLISH}/
|
||||
|
||||
rsync -aqP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvDatabaseCPP/${PUBLISH}/
|
||||
fi
|
||||
|
||||
@@ -5,10 +5,11 @@ include $(TOP)/configure/CONFIG
|
||||
|
||||
PVDATABASE_SRC = $(TOP)/src
|
||||
|
||||
|
||||
LIBRARY += pvDatabase
|
||||
|
||||
# shared library ABI version.
|
||||
SHRLIB_VERSION ?= 4.3.0
|
||||
SHRLIB_VERSION ?= 4.2
|
||||
|
||||
INC += pv/channelProviderLocal.h
|
||||
INC += pv/pvDatabase.h
|
||||
@@ -19,7 +20,11 @@ include $(PVDATABASE_SRC)/database/Makefile
|
||||
include $(PVDATABASE_SRC)/pvAccess/Makefile
|
||||
include $(PVDATABASE_SRC)/special/Makefile
|
||||
|
||||
pvDatabase_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
|
||||
|
||||
pvDatabase_LIBS += pvAccess pvData Com
|
||||
pvDatabase_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
|
||||
@@ -21,21 +21,43 @@ using namespace std;
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
static PVDatabasePtr pvDatabaseMaster;
|
||||
|
||||
PVDatabasePtr PVDatabase::getMaster()
|
||||
{
|
||||
if(!pvDatabaseMaster) pvDatabaseMaster = PVDatabasePtr(new PVDatabase());
|
||||
return pvDatabaseMaster;
|
||||
static PVDatabasePtr master;
|
||||
static Mutex mutex;
|
||||
Lock xx(mutex);
|
||||
if(master.get()==NULL) {
|
||||
master = PVDatabasePtr(new PVDatabase());
|
||||
}
|
||||
return master;
|
||||
}
|
||||
|
||||
PVDatabase::PVDatabase()
|
||||
: isDestroyed(false)
|
||||
{
|
||||
}
|
||||
|
||||
PVDatabase::~PVDatabase()
|
||||
{
|
||||
cout << "PVDatabase::~PVDatabase()\n";
|
||||
destroy();
|
||||
}
|
||||
|
||||
void PVDatabase::destroy()
|
||||
{
|
||||
{
|
||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||
if(isDestroyed) {
|
||||
return;
|
||||
}
|
||||
isDestroyed = true;
|
||||
}
|
||||
for(PVRecordMap::iterator iter = recordMap.begin(); iter != recordMap.end(); iter++) {
|
||||
PVRecordPtr pvRecord = (*iter).second;
|
||||
if(pvRecord) {
|
||||
pvRecord->destroy();
|
||||
}
|
||||
}
|
||||
recordMap.clear();
|
||||
}
|
||||
|
||||
void PVDatabase::lock() {
|
||||
@@ -49,19 +71,23 @@ void PVDatabase::unlock() {
|
||||
PVRecordPtr PVDatabase::findRecord(string const& recordName)
|
||||
{
|
||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||
PVRecordPtr xxx;
|
||||
if(isDestroyed) {
|
||||
return xxx;
|
||||
}
|
||||
PVRecordMap::iterator iter = recordMap.find(recordName);
|
||||
if(iter!=recordMap.end()) {
|
||||
return (*iter).second;
|
||||
}
|
||||
return PVRecordPtr();
|
||||
return xxx;
|
||||
}
|
||||
|
||||
bool PVDatabase::addRecord(PVRecordPtr const & record)
|
||||
{
|
||||
if(record->getTraceLevel()>0) {
|
||||
cout << "PVDatabase::addRecord " << record->getRecordName() << endl;
|
||||
}
|
||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||
if(isDestroyed) {
|
||||
return false;
|
||||
}
|
||||
string recordName = record->getRecordName();
|
||||
PVRecordMap::iterator iter = recordMap.find(recordName);
|
||||
if(iter!=recordMap.end()) {
|
||||
@@ -74,10 +100,10 @@ bool PVDatabase::addRecord(PVRecordPtr const & record)
|
||||
|
||||
bool PVDatabase::removeRecord(PVRecordPtr const & record)
|
||||
{
|
||||
if(record->getTraceLevel()>0) {
|
||||
cout << "PVDatabase::removeRecord " << record->getRecordName() << endl;
|
||||
}
|
||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||
if(isDestroyed) {
|
||||
return false;
|
||||
}
|
||||
string recordName = record->getRecordName();
|
||||
PVRecordMap::iterator iter = recordMap.find(recordName);
|
||||
if(iter!=recordMap.end()) {
|
||||
@@ -93,6 +119,9 @@ PVStringArrayPtr PVDatabase::getRecordNames()
|
||||
{
|
||||
epicsGuard<epics::pvData::Mutex> guard(mutex);
|
||||
PVStringArrayPtr xxx;
|
||||
if(isDestroyed) {
|
||||
return xxx;
|
||||
}
|
||||
PVStringArrayPtr pvStringArray = static_pointer_cast<PVStringArray>
|
||||
(getPVDataCreate()->createPVScalarArray(pvString));
|
||||
size_t len = recordMap.size();
|
||||
|
||||
@@ -51,6 +51,7 @@ PVRecord::~PVRecord()
|
||||
if(traceLevel>0) {
|
||||
cout << "~PVRecord() " << recordName << endl;
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
void PVRecord::initPVRecord()
|
||||
@@ -112,7 +113,6 @@ void PVRecord::process()
|
||||
cout << "PVRecord::process() " << recordName << endl;
|
||||
}
|
||||
if(pvTimeStamp.isAttached()) {
|
||||
pvTimeStamp.get(timeStamp);
|
||||
timeStamp.getCurrent();
|
||||
pvTimeStamp.set(timeStamp);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,10 @@ public:
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~MonitorFactory();
|
||||
/**
|
||||
* @brief Destroy the monitor factory.
|
||||
*/
|
||||
virtual void destroy();
|
||||
/**
|
||||
* @brief Create a monitor on a record.
|
||||
*
|
||||
@@ -90,6 +94,7 @@ private:
|
||||
MonitorFactory();
|
||||
friend class MonitorLocal;
|
||||
friend epicsShareFunc MonitorFactoryPtr getMonitorFactory();
|
||||
bool isDestroyed;
|
||||
epics::pvData::Mutex mutex;
|
||||
};
|
||||
|
||||
@@ -104,15 +109,10 @@ epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
||||
*/
|
||||
class epicsShareClass ChannelProviderLocal :
|
||||
public epics::pvAccess::ChannelProvider,
|
||||
public epics::pvAccess::ChannelFind,
|
||||
public std::tr1::enable_shared_from_this<ChannelProviderLocal>
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(ChannelProviderLocal);
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
ChannelProviderLocal();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -120,8 +120,9 @@ public:
|
||||
/**
|
||||
* @brief Destroy the channel provider.
|
||||
*
|
||||
* Probably never called.
|
||||
*/
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
/**
|
||||
* @brief Returns the channel provider name.
|
||||
* @return <b>local</b>
|
||||
@@ -184,32 +185,17 @@ public:
|
||||
epics::pvAccess::ChannelRequester::shared_pointer const &channelRequester,
|
||||
short priority,
|
||||
std::string const &address);
|
||||
/**
|
||||
* @brief get trace level (0,1,2) means (nothing,lifetime,process)
|
||||
* @return the level
|
||||
*/
|
||||
int getTraceLevel() {return traceLevel;}
|
||||
/**
|
||||
* @brief set trace level (0,1,2) means (nothing,lifetime,process)
|
||||
* @param level The level
|
||||
*/
|
||||
void setTraceLevel(int level) {traceLevel = level;}
|
||||
/**
|
||||
* @brief ChannelFind method.
|
||||
*
|
||||
* @return pointer to self.
|
||||
*/
|
||||
virtual std::tr1::shared_ptr<ChannelProvider> getChannelProvider();
|
||||
/**
|
||||
* @brief ChannelFind method.
|
||||
*
|
||||
*/
|
||||
virtual void cancel();
|
||||
private:
|
||||
shared_pointer getPtrSelf()
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
ChannelProviderLocal();
|
||||
friend epicsShareFunc ChannelProviderLocalPtr getChannelProviderLocal();
|
||||
PVDatabasePtr pvDatabase;
|
||||
epics::pvData::Mutex mutex;
|
||||
int traceLevel;
|
||||
bool beingDestroyed;
|
||||
epics::pvAccess::ChannelFind::shared_pointer channelFinder;
|
||||
friend class ChannelProviderLocalRun;
|
||||
};
|
||||
|
||||
@@ -243,8 +229,12 @@ public:
|
||||
/**
|
||||
* @brief Destroy the channel.
|
||||
*
|
||||
* It cleans up all resources used to access the record.
|
||||
* Note that this assumes that client has destroyed any objects that
|
||||
* have been created for the channel like channelGet, etc.
|
||||
* The remote pvAccess server does this cleanup.
|
||||
*/
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
/**
|
||||
* @brief Detach from the record.
|
||||
*
|
||||
@@ -414,6 +404,7 @@ private:
|
||||
epics::pvAccess::ChannelRequester::shared_pointer requester;
|
||||
ChannelProviderLocalPtr provider;
|
||||
PVRecordPtr pvRecord;
|
||||
bool isDestroyed;
|
||||
epics::pvData::Mutex mutex;
|
||||
};
|
||||
|
||||
|
||||
@@ -264,6 +264,14 @@ protected:
|
||||
* Must be called by derived classes.
|
||||
*/
|
||||
void initPVRecord();
|
||||
/**
|
||||
* @brief Get shared pointer to self.
|
||||
* @return The shared pointer.
|
||||
*/
|
||||
PVRecordPtr getPtrSelf()
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
private:
|
||||
PVRecordFieldPtr findPVRecordField(
|
||||
PVRecordStructurePtr const & pvrs,
|
||||
@@ -496,6 +504,12 @@ public:
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~PVDatabase();
|
||||
/**
|
||||
* @brief Destroy the PVDatabase.
|
||||
*
|
||||
* For each record in the database the record is removed and it's destroy method is called.
|
||||
*/
|
||||
virtual void destroy();
|
||||
/**
|
||||
* Find a record.
|
||||
* An empty pointer is returned if the record is not in the database.
|
||||
@@ -527,6 +541,7 @@ private:
|
||||
void unlock();
|
||||
PVRecordMap recordMap;
|
||||
epics::pvData::Mutex mutex;
|
||||
bool isDestroyed;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
RemoveRecord(
|
||||
std::string const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure);
|
||||
PVDatabasePtr pvDatabase;
|
||||
epics::pvData::PVStringPtr pvRecordName;
|
||||
epics::pvData::PVStringPtr pvResult;
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ private:
|
||||
TraceRecord(
|
||||
std::string const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure);
|
||||
PVDatabasePtr pvDatabase;
|
||||
epics::pvData::PVStringPtr pvRecordName;
|
||||
epics::pvData::PVIntPtr pvLevel;
|
||||
epics::pvData::PVStringPtr pvResult;
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
virtual void process();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual void cancel(){}
|
||||
@@ -121,12 +121,14 @@ private:
|
||||
PVRecordPtr const &pvRecord,
|
||||
int nProcess)
|
||||
:
|
||||
isDestroyed(false),
|
||||
channelLocal(channelLocal),
|
||||
channelProcessRequester(channelProcessRequester),
|
||||
pvRecord(pvRecord),
|
||||
nProcess(nProcess)
|
||||
{
|
||||
}
|
||||
bool isDestroyed;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelProcessRequester::weak_pointer channelProcessRequester;
|
||||
PVRecordPtr pvRecord;
|
||||
@@ -172,10 +174,30 @@ ChannelProcessLocalPtr ChannelProcessLocal::create(
|
||||
return process;
|
||||
}
|
||||
|
||||
|
||||
void ChannelProcessLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelProcessLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChannelProcessLocal::process()
|
||||
{
|
||||
ChannelProcessRequester::shared_pointer requester = channelProcessRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->processDone(channelDestroyedStatus,getPtrSelf());
|
||||
return;
|
||||
}
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelProcessLocal::process";
|
||||
@@ -214,7 +236,7 @@ public:
|
||||
PVStructurePtr const & pvRequest,
|
||||
PVRecordPtr const &pvRecord);
|
||||
virtual void get();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual void cancel(){}
|
||||
@@ -236,6 +258,7 @@ private:
|
||||
PVRecordPtr const &pvRecord)
|
||||
:
|
||||
firstTime(true),
|
||||
isDestroyed(false),
|
||||
callProcess(callProcess),
|
||||
channelLocal(channelLocal),
|
||||
channelGetRequester(channelGetRequester),
|
||||
@@ -246,6 +269,7 @@ private:
|
||||
{
|
||||
}
|
||||
bool firstTime;
|
||||
bool isDestroyed;
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelGetRequester::weak_pointer channelGetRequester;
|
||||
@@ -299,10 +323,29 @@ ChannelGetLocalPtr ChannelGetLocal::create(
|
||||
}
|
||||
|
||||
|
||||
void ChannelGetLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelGetLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelGetLocal::get()
|
||||
{
|
||||
ChannelGetRequester::shared_pointer requester = channelGetRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->getDone(
|
||||
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
bitSet->clear();
|
||||
{
|
||||
@@ -355,7 +398,7 @@ public:
|
||||
PVRecordPtr const &pvRecord);
|
||||
virtual void put(PVStructurePtr const &pvStructure,BitSetPtr const &bitSet);
|
||||
virtual void get();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual void cancel(){}
|
||||
@@ -374,6 +417,7 @@ private:
|
||||
PVCopyPtr const &pvCopy,
|
||||
PVRecordPtr const &pvRecord)
|
||||
:
|
||||
isDestroyed(false),
|
||||
callProcess(callProcess),
|
||||
channelLocal(channelLocal),
|
||||
channelPutRequester(channelPutRequester),
|
||||
@@ -381,6 +425,7 @@ private:
|
||||
pvRecord(pvRecord)
|
||||
{
|
||||
}
|
||||
bool isDestroyed;
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelPutRequester::weak_pointer channelPutRequester;
|
||||
@@ -429,10 +474,29 @@ ChannelPutLocalPtr ChannelPutLocal::create(
|
||||
return put;
|
||||
}
|
||||
|
||||
void ChannelPutLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelPutLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelPutLocal::get()
|
||||
{
|
||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->getDone(
|
||||
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PVStructurePtr pvStructure = pvCopy->createPVStructure();
|
||||
BitSetPtr bitSet(new BitSet(pvStructure->getNumberFields()));
|
||||
@@ -461,6 +525,10 @@ void ChannelPutLocal::put(
|
||||
{
|
||||
ChannelPutRequester::shared_pointer requester = channelPutRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->putDone(channelDestroyedStatus,getPtrSelf());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
@@ -506,7 +574,7 @@ public:
|
||||
BitSetPtr const &putBitSet);
|
||||
virtual void getPut();
|
||||
virtual void getGet();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual void cancel(){}
|
||||
@@ -528,6 +596,7 @@ private:
|
||||
BitSetPtr const & getBitSet,
|
||||
PVRecordPtr const &pvRecord)
|
||||
:
|
||||
isDestroyed(false),
|
||||
callProcess(callProcess),
|
||||
channelLocal(channelLocal),
|
||||
channelPutGetRequester(channelPutGetRequester),
|
||||
@@ -538,6 +607,7 @@ private:
|
||||
pvRecord(pvRecord)
|
||||
{
|
||||
}
|
||||
bool isDestroyed;
|
||||
bool callProcess;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelPutGetRequester::weak_pointer channelPutGetRequester;
|
||||
@@ -598,11 +668,30 @@ ChannelPutGetLocalPtr ChannelPutGetLocal::create(
|
||||
}
|
||||
|
||||
|
||||
void ChannelPutGetLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelPutGetLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelPutGetLocal::putGet(
|
||||
PVStructurePtr const &pvPutStructure,BitSetPtr const &putBitSet)
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->putGetDone(
|
||||
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
{
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
@@ -629,6 +718,11 @@ void ChannelPutGetLocal::getPut()
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->getPutDone(
|
||||
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PVStructurePtr pvPutStructure = pvPutCopy->createPVStructure();
|
||||
BitSetPtr putBitSet(new BitSet(pvPutStructure->getNumberFields()));
|
||||
@@ -654,6 +748,11 @@ void ChannelPutGetLocal::getGet()
|
||||
{
|
||||
ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock();
|
||||
if(!requester) return;
|
||||
if(isDestroyed) {
|
||||
requester->getGetDone(
|
||||
channelDestroyedStatus,getPtrSelf(),nullPVStructure,nullBitSet);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getBitSet->clear();
|
||||
{
|
||||
@@ -693,6 +792,7 @@ public:
|
||||
ChannelRPCRequester::shared_pointer const & channelRPCRequester,
|
||||
Service::shared_pointer const & service,
|
||||
PVRecordPtr const & pvRecord) :
|
||||
isDestroyed(),
|
||||
channelLocal(channelLocal),
|
||||
channelRPCRequester(channelRPCRequester),
|
||||
service(service),
|
||||
@@ -707,6 +807,7 @@ public:
|
||||
{
|
||||
cout << "~ChannelRPCLocal()" << endl;
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
void processRequest(RPCService::shared_pointer const & service,
|
||||
@@ -718,6 +819,9 @@ public:
|
||||
ChannelRPCRequester::shared_pointer requester = channelRPCRequester.lock();
|
||||
if(!requester) return;
|
||||
requester->requestDone(status, getPtrSelf(), result);
|
||||
|
||||
if (isLastRequest.get())
|
||||
destroy();
|
||||
}
|
||||
|
||||
void processRequest(RPCServiceAsync::shared_pointer const & service,
|
||||
@@ -737,7 +841,7 @@ public:
|
||||
|
||||
virtual void cancel() {}
|
||||
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
|
||||
virtual void lock() {}
|
||||
|
||||
@@ -750,6 +854,7 @@ private:
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
AtomicBoolean isDestroyed;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelRPCRequester::weak_pointer channelRPCRequester;
|
||||
Service::shared_pointer service;
|
||||
@@ -885,6 +990,17 @@ void ChannelRPCLocal::request(PVStructurePtr const & pvArgument)
|
||||
}
|
||||
|
||||
|
||||
void ChannelRPCLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelRPCLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed.get() << endl;
|
||||
}
|
||||
isDestroyed.set();
|
||||
}
|
||||
|
||||
|
||||
typedef std::tr1::shared_ptr<PVArray> PVArrayPtr;
|
||||
|
||||
class ChannelArrayLocal :
|
||||
@@ -911,7 +1027,7 @@ public:
|
||||
size_t offset, size_t count, size_t stride);
|
||||
virtual void getLength();
|
||||
virtual void setLength(size_t length);
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void destroy();
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel()
|
||||
{return channelLocal;}
|
||||
virtual void cancel(){}
|
||||
@@ -930,6 +1046,7 @@ private:
|
||||
PVArrayPtr const &pvCopy,
|
||||
PVRecordPtr const &pvRecord)
|
||||
:
|
||||
isDestroyed(false),
|
||||
channelLocal(channelLocal),
|
||||
channelArrayRequester(channelArrayRequester),
|
||||
pvArray(pvArray),
|
||||
@@ -937,7 +1054,7 @@ private:
|
||||
pvRecord(pvRecord)
|
||||
{
|
||||
}
|
||||
|
||||
bool isDestroyed;
|
||||
ChannelLocalPtr channelLocal;
|
||||
ChannelArrayRequester::weak_pointer channelArrayRequester;
|
||||
PVArrayPtr pvArray;
|
||||
@@ -1030,11 +1147,29 @@ ChannelArrayLocalPtr ChannelArrayLocal::create(
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
void ChannelArrayLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "ChannelArrayLocal::destroy";
|
||||
cout << " destroyed " << isDestroyed << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelArrayLocal::getArray(size_t offset, size_t count, size_t stride)
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
if(!requester) return;
|
||||
|
||||
if(isDestroyed) {
|
||||
requester->getArrayDone(channelDestroyedStatus,getPtrSelf(),pvCopy);
|
||||
return;
|
||||
}
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelArrayLocal::getArray" << endl;
|
||||
@@ -1083,7 +1218,10 @@ void ChannelArrayLocal::putArray(
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
if(!requester) return;
|
||||
|
||||
if(isDestroyed) {
|
||||
requester->putArrayDone(channelDestroyedStatus,getPtrSelf());
|
||||
return;
|
||||
}
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelArrayLocal::putArray" << endl;
|
||||
@@ -1139,7 +1277,10 @@ void ChannelArrayLocal::setLength(size_t length)
|
||||
{
|
||||
ChannelArrayRequester::shared_pointer requester = channelArrayRequester.lock();
|
||||
if(!requester) return;
|
||||
|
||||
if(isDestroyed) {
|
||||
requester->setLengthDone(channelDestroyedStatus,getPtrSelf());
|
||||
return;
|
||||
}
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
{
|
||||
cout << "ChannelArrayLocal::setLength" << endl;
|
||||
@@ -1167,7 +1308,8 @@ ChannelLocal::ChannelLocal(
|
||||
:
|
||||
requester(requester),
|
||||
provider(provider),
|
||||
pvRecord(pvRecord)
|
||||
pvRecord(pvRecord),
|
||||
isDestroyed(false)
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0) {
|
||||
cout << "ChannelLocal::ChannelLocal()"
|
||||
@@ -1183,9 +1325,25 @@ ChannelLocal::~ChannelLocal()
|
||||
{
|
||||
cout << "~ChannelLocal()" << endl;
|
||||
}
|
||||
pvRecord->removePVRecordClient(getPtrSelf());
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ChannelLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0) {
|
||||
cout << "ChannelLocal::destroy()"
|
||||
<< " recordName " << pvRecord->getRecordName()
|
||||
<< " isDestroyed " << isDestroyed
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
isDestroyed = true;
|
||||
}
|
||||
pvRecord->removePVRecordClient(getPtrSelf());
|
||||
}
|
||||
|
||||
void ChannelLocal::detach(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
@@ -1223,6 +1381,10 @@ void ChannelLocal::message(
|
||||
<< " requester exists " << (requester ? "true" : "false")
|
||||
<< endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return;
|
||||
}
|
||||
if(requester) {
|
||||
requester->message(message,messageType);
|
||||
return;
|
||||
@@ -1240,6 +1402,8 @@ string ChannelLocal::getRemoteAddress()
|
||||
|
||||
Channel::ConnectionState ChannelLocal::getConnectionState()
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return Channel::DESTROYED;
|
||||
return Channel::CONNECTED;
|
||||
}
|
||||
|
||||
@@ -1255,6 +1419,8 @@ ChannelRequester::shared_pointer ChannelLocal::getChannelRequester()
|
||||
|
||||
bool ChannelLocal::isConnected()
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
* @date 2013.04
|
||||
*/
|
||||
|
||||
#include <epicsThread.h>
|
||||
|
||||
|
||||
#include <pv/serverContext.h>
|
||||
#include <pv/syncChannelFind.h>
|
||||
|
||||
@@ -30,67 +27,80 @@ using std::string;
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
|
||||
static string providerName("local");
|
||||
|
||||
|
||||
class LocalChannelProviderFactory;
|
||||
typedef std::tr1::shared_ptr<LocalChannelProviderFactory> LocalChannelProviderFactoryPtr;
|
||||
|
||||
static string providerName("local");
|
||||
static ChannelProviderLocalPtr channelProvider;
|
||||
|
||||
class LocalChannelProviderFactory : public ChannelProviderFactory
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
POINTER_DEFINITIONS(LocalChannelProviderFactory);
|
||||
virtual string getFactoryName() { return providerName;}
|
||||
static LocalChannelProviderFactoryPtr create(
|
||||
ChannelProviderLocalPtr const &channelProvider)
|
||||
{
|
||||
LocalChannelProviderFactoryPtr xxx(
|
||||
new LocalChannelProviderFactory(channelProvider));
|
||||
registerChannelProviderFactory(xxx);
|
||||
return xxx;
|
||||
}
|
||||
virtual ChannelProvider::shared_pointer sharedInstance()
|
||||
{
|
||||
if(!channelProvider) channelProvider = ChannelProviderLocalPtr(new ChannelProviderLocal());
|
||||
return channelProvider;
|
||||
}
|
||||
virtual ChannelProvider::shared_pointer newInstance()
|
||||
{
|
||||
cout << "LocalChannelProviderFactory::newInstance()\n";
|
||||
throw std::logic_error("newInstance not Implemented");
|
||||
}
|
||||
private:
|
||||
LocalChannelProviderFactory(
|
||||
ChannelProviderLocalPtr const &channelProvider)
|
||||
: channelProvider(channelProvider)
|
||||
{}
|
||||
ChannelProviderLocalPtr channelProvider;
|
||||
};
|
||||
|
||||
|
||||
ChannelProviderLocalPtr getChannelProviderLocal()
|
||||
{
|
||||
static int firstTime = 1;
|
||||
if (firstTime) {
|
||||
firstTime = 0;
|
||||
ChannelProviderFactory::shared_pointer factory(
|
||||
new LocalChannelProviderFactory());
|
||||
ChannelProviderRegistry::servers()->add(factory);
|
||||
static ChannelProviderLocalPtr channelProviderLocal;
|
||||
static Mutex mutex;
|
||||
Lock xx(mutex);
|
||||
if(!channelProviderLocal) {
|
||||
channelProviderLocal = ChannelProviderLocalPtr(
|
||||
new ChannelProviderLocal());
|
||||
ChannelProvider::shared_pointer xxx =
|
||||
dynamic_pointer_cast<ChannelProvider>(channelProviderLocal);
|
||||
channelProviderLocal->channelFinder =
|
||||
SyncChannelFind::shared_pointer(new SyncChannelFind(xxx));
|
||||
LocalChannelProviderFactoryPtr factory(LocalChannelProviderFactory::create(channelProviderLocal));
|
||||
|
||||
}
|
||||
ChannelProvider::shared_pointer channelProvider =
|
||||
ChannelProviderRegistry::servers()->getProvider(providerName);
|
||||
return std::tr1::dynamic_pointer_cast<ChannelProviderLocal>(channelProvider);
|
||||
return channelProviderLocal;
|
||||
}
|
||||
|
||||
ChannelProviderLocal::ChannelProviderLocal()
|
||||
: pvDatabase(PVDatabase::getMaster()),
|
||||
traceLevel(0)
|
||||
beingDestroyed(false)
|
||||
{
|
||||
}
|
||||
|
||||
ChannelProviderLocal::~ChannelProviderLocal()
|
||||
{
|
||||
if(traceLevel>0) {
|
||||
cout << "ChannelProviderLocal::~ChannelProviderLocal() \n";
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
std::tr1::shared_ptr<ChannelProvider> ChannelProviderLocal::getChannelProvider()
|
||||
void ChannelProviderLocal::destroy()
|
||||
{
|
||||
return shared_from_this();
|
||||
Lock xx(mutex);
|
||||
if(beingDestroyed) return;
|
||||
beingDestroyed = true;
|
||||
pvDatabase->destroy();
|
||||
pvDatabase.reset();
|
||||
}
|
||||
|
||||
void ChannelProviderLocal::cancel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
string ChannelProviderLocal::getProviderName()
|
||||
{
|
||||
return providerName;
|
||||
@@ -100,41 +110,35 @@ ChannelFind::shared_pointer ChannelProviderLocal::channelFind(
|
||||
string const & channelName,
|
||||
ChannelFindRequester::shared_pointer const &channelFindRequester)
|
||||
{
|
||||
if(traceLevel>1) {
|
||||
cout << "ChannelProviderLocal::channelFind " << "channelName" << endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
|
||||
if(pvRecord) {
|
||||
channelFindRequester->channelFindResult(
|
||||
Status::Ok,
|
||||
shared_from_this(),
|
||||
channelFinder,
|
||||
true);
|
||||
|
||||
} else {
|
||||
Status notFoundStatus(Status::STATUSTYPE_ERROR,"pv not found");
|
||||
channelFindRequester->channelFindResult(
|
||||
notFoundStatus,
|
||||
shared_from_this(),
|
||||
channelFinder,
|
||||
false);
|
||||
}
|
||||
return shared_from_this();
|
||||
return channelFinder;
|
||||
}
|
||||
|
||||
ChannelFind::shared_pointer ChannelProviderLocal::channelList(
|
||||
ChannelListRequester::shared_pointer const & channelListRequester)
|
||||
{
|
||||
if(traceLevel>1) {
|
||||
cout << "ChannelProviderLocal::channelList\n";
|
||||
}
|
||||
PVStringArrayPtr records;
|
||||
{
|
||||
Lock guard(mutex);
|
||||
records = pvDatabase->getRecordNames();
|
||||
}
|
||||
|
||||
channelListRequester->channelListResult(Status::Ok, shared_from_this(), records->view(), false);
|
||||
return shared_from_this();
|
||||
channelListRequester->channelListResult(Status::Ok, channelFinder, records->view(), false);
|
||||
return channelFinder;
|
||||
}
|
||||
|
||||
Channel::shared_pointer ChannelProviderLocal::createChannel(
|
||||
@@ -142,14 +146,11 @@ Channel::shared_pointer ChannelProviderLocal::createChannel(
|
||||
ChannelRequester::shared_pointer const &channelRequester,
|
||||
short priority)
|
||||
{
|
||||
if(traceLevel>1) {
|
||||
cout << "ChannelProviderLocal::createChannel " << "channelName" << endl;
|
||||
}
|
||||
Lock xx(mutex);
|
||||
PVRecordPtr pvRecord = pvDatabase->findRecord(channelName);
|
||||
if(pvRecord) {
|
||||
ChannelLocalPtr channel(new ChannelLocal(
|
||||
shared_from_this(),channelRequester,pvRecord));
|
||||
getPtrSelf(),channelRequester,pvRecord));
|
||||
channelRequester->channelCreated(
|
||||
Status::Ok,
|
||||
channel);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <epicsGuard.h>
|
||||
#include <pv/thread.h>
|
||||
#include <pv/bitSetUtil.h>
|
||||
#include <pv/queue.h>
|
||||
#include <pv/timeStamp.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
@@ -33,109 +34,32 @@ namespace epics { namespace pvDatabase {
|
||||
static MonitorPtr nullMonitor;
|
||||
static MonitorElementPtr NULLMonitorElement;
|
||||
static Status failedToCreateMonitorStatus(Status::STATUSTYPE_ERROR,"failed to create monitor");
|
||||
static Status wasDestroyedStatus(Status::STATUSTYPE_ERROR,"was destroyed");
|
||||
static Status alreadyStartedStatus(Status::STATUSTYPE_ERROR,"already started");
|
||||
static Status notStartedStatus(Status::STATUSTYPE_ERROR,"not started");
|
||||
static Status destroyedStatus(Status::STATUSTYPE_ERROR,"record is destroyed");
|
||||
|
||||
class MonitorElementQueue;
|
||||
|
||||
|
||||
typedef Queue<MonitorElement> MonitorElementQueue;
|
||||
typedef std::tr1::shared_ptr<MonitorElementQueue> MonitorElementQueuePtr;
|
||||
|
||||
class MonitorElementQueue
|
||||
{
|
||||
private:
|
||||
MonitorElementPtrArray elements;
|
||||
// TODO use size_t instead
|
||||
int size;
|
||||
int numberFree;
|
||||
int numberUsed;
|
||||
int nextGetFree;
|
||||
int nextSetUsed;
|
||||
int nextGetUsed;
|
||||
int nextReleaseUsed;
|
||||
public:
|
||||
POINTER_DEFINITIONS(MonitorElementQueue);
|
||||
|
||||
MonitorElementQueue(std::vector<MonitorElementPtr> monitorElementArray)
|
||||
: elements(monitorElementArray),
|
||||
size(monitorElementArray.size()),
|
||||
numberFree(size),
|
||||
numberUsed(0),
|
||||
nextGetFree(0),
|
||||
nextSetUsed(0),
|
||||
nextGetUsed(0),
|
||||
nextReleaseUsed(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~MonitorElementQueue() {}
|
||||
|
||||
void clear()
|
||||
{
|
||||
numberFree = size;
|
||||
numberUsed = 0;
|
||||
nextGetFree = 0;
|
||||
nextSetUsed = 0;
|
||||
nextGetUsed = 0;
|
||||
nextReleaseUsed = 0;
|
||||
}
|
||||
|
||||
MonitorElementPtr getFree()
|
||||
{
|
||||
if(numberFree==0) return MonitorElementPtr();
|
||||
numberFree--;
|
||||
int ind = nextGetFree;
|
||||
MonitorElementPtr queueElement = elements[nextGetFree++];
|
||||
if(nextGetFree>=size) nextGetFree = 0;
|
||||
return elements[ind];
|
||||
}
|
||||
|
||||
void setUsed(MonitorElementPtr const &element)
|
||||
{
|
||||
if(element!=elements[nextSetUsed++]) {
|
||||
throw std::logic_error("not correct queueElement");
|
||||
}
|
||||
numberUsed++;
|
||||
if(nextSetUsed>=size) nextSetUsed = 0;
|
||||
}
|
||||
|
||||
MonitorElementPtr getUsed()
|
||||
{
|
||||
if(numberUsed==0) return MonitorElementPtr();
|
||||
int ind = nextGetUsed;
|
||||
MonitorElementPtr queueElement = elements[nextGetUsed++];
|
||||
if(nextGetUsed>=size) nextGetUsed = 0;
|
||||
return elements[ind];
|
||||
}
|
||||
void releaseUsed(MonitorElementPtr const &element)
|
||||
{
|
||||
if(element!=elements[nextReleaseUsed++]) {
|
||||
throw std::logic_error(
|
||||
"not queueElement returned by last call to getUsed");
|
||||
}
|
||||
if(nextReleaseUsed>=size) nextReleaseUsed = 0;
|
||||
numberUsed--;
|
||||
numberFree++;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef std::tr1::shared_ptr<MonitorRequester> MonitorRequesterPtr;
|
||||
|
||||
|
||||
|
||||
class MonitorLocal :
|
||||
public Monitor,
|
||||
public PVListener,
|
||||
public std::tr1::enable_shared_from_this<MonitorLocal>
|
||||
{
|
||||
enum MonitorState {idle,active,destroyed};
|
||||
enum MonitorState {idle,active, destroyed};
|
||||
public:
|
||||
POINTER_DEFINITIONS(MonitorLocal);
|
||||
virtual ~MonitorLocal();
|
||||
virtual Status start();
|
||||
virtual Status stop();
|
||||
virtual MonitorElementPtr poll();
|
||||
virtual void destroy() EPICS_DEPRECATED {};
|
||||
virtual void detach(PVRecordPtr const & pvRecord){}
|
||||
virtual void destroy();
|
||||
virtual void detach(PVRecordPtr const & pvRecord){destroy();}
|
||||
virtual void release(MonitorElementPtr const & monitorElement);
|
||||
virtual void dataPut(PVRecordFieldPtr const & pvRecordField);
|
||||
virtual void dataPut(
|
||||
@@ -185,8 +109,25 @@ MonitorLocal::~MonitorLocal()
|
||||
{
|
||||
cout << "MonitorLocal::~MonitorLocal()" << endl;
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
void MonitorLocal::destroy()
|
||||
{
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "MonitorLocal::destroy state " << state << endl;
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(state==destroyed) return;
|
||||
}
|
||||
if(state==active) stop();
|
||||
{
|
||||
Lock xx(mutex);
|
||||
state = destroyed;
|
||||
}
|
||||
}
|
||||
|
||||
Status MonitorLocal::start()
|
||||
{
|
||||
@@ -196,8 +137,8 @@ Status MonitorLocal::start()
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(state==destroyed) return wasDestroyedStatus;
|
||||
if(state==active) return alreadyStartedStatus;
|
||||
if(state==destroyed) return destroyedStatus;
|
||||
}
|
||||
pvRecord->addListener(getPtrSelf(),pvCopy);
|
||||
epicsGuard <PVRecord> guard(*pvRecord);
|
||||
@@ -220,10 +161,10 @@ Status MonitorLocal::stop()
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(state==destroyed) return wasDestroyedStatus;
|
||||
if(state==idle) return notStartedStatus;
|
||||
if(state==destroyed) return destroyedStatus;
|
||||
state = idle;
|
||||
}
|
||||
}
|
||||
pvRecord->removeListener(getPtrSelf(),pvCopy);
|
||||
return Status::Ok;
|
||||
}
|
||||
@@ -263,10 +204,9 @@ void MonitorLocal::releaseActiveElement()
|
||||
{
|
||||
Lock xx(queueMutex);
|
||||
if(state!=active) return;
|
||||
pvCopy->updateCopyFromBitSet(activeElement->pvStructurePtr,activeElement->changedBitSet);
|
||||
if(activeElement->changedBitSet->nextSetBit(0)<0) return;
|
||||
MonitorElementPtr newActive = queue->getFree();
|
||||
if(!newActive) return;
|
||||
pvCopy->updateCopyFromBitSet(activeElement->pvStructurePtr,activeElement->changedBitSet);
|
||||
BitSetUtil::compress(activeElement->changedBitSet,activeElement->pvStructurePtr);
|
||||
BitSetUtil::compress(activeElement->overrunBitSet,activeElement->pvStructurePtr);
|
||||
queue->setUsed(activeElement);
|
||||
@@ -369,10 +309,6 @@ void MonitorLocal::unlisten(PVRecordPtr const & pvRecord)
|
||||
{
|
||||
cout << "PVCopyMonitor::unlisten\n";
|
||||
}
|
||||
{
|
||||
Lock xx(mutex);
|
||||
state = destroyed;
|
||||
}
|
||||
MonitorRequesterPtr requester = monitorRequester.lock();
|
||||
if(requester) {
|
||||
if(pvRecord->getTraceLevel()>1)
|
||||
@@ -381,6 +317,7 @@ void MonitorLocal::unlisten(PVRecordPtr const & pvRecord)
|
||||
}
|
||||
requester->unlisten(getPtrSelf());
|
||||
}
|
||||
pvRecord->removeListener(getPtrSelf(),pvCopy);
|
||||
}
|
||||
|
||||
|
||||
@@ -447,12 +384,18 @@ bool MonitorLocal::init(PVStructurePtr const & pvRequest)
|
||||
|
||||
|
||||
MonitorFactory::MonitorFactory()
|
||||
: isDestroyed(false)
|
||||
{
|
||||
}
|
||||
|
||||
MonitorFactory::~MonitorFactory()
|
||||
{
|
||||
}
|
||||
|
||||
void MonitorFactory::destroy()
|
||||
{
|
||||
Lock lock(mutex);
|
||||
isDestroyed = true;
|
||||
}
|
||||
|
||||
MonitorPtr MonitorFactory::createMonitor(
|
||||
@@ -461,6 +404,10 @@ MonitorPtr MonitorFactory::createMonitor(
|
||||
PVStructurePtr const & pvRequest)
|
||||
{
|
||||
Lock xx(mutex);
|
||||
if(isDestroyed) {
|
||||
monitorRequester->message("MonitorFactory is destroyed",errorMessage);
|
||||
return nullMonitor;
|
||||
}
|
||||
MonitorLocalPtr monitor(new MonitorLocal(
|
||||
monitorRequester,pvRecord));
|
||||
bool result = monitor->init(pvRequest);
|
||||
@@ -472,8 +419,8 @@ MonitorPtr MonitorFactory::createMonitor(
|
||||
}
|
||||
if(pvRecord->getTraceLevel()>0)
|
||||
{
|
||||
cout << "MonitorFactory::createMonitor"
|
||||
<< " recordName " << pvRecord->getRecordName() << endl;
|
||||
cout << "MonitorFactory::createMonitor";
|
||||
cout << " recordName " << pvRecord->getRecordName() << endl;
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
@@ -53,15 +53,18 @@ extern "C" void pvdbl(const iocshArgBuf *args)
|
||||
for(size_t i=0; i<xxx.size(); ++i) cout<< xxx[i] << endl;
|
||||
}
|
||||
|
||||
static void channelProviderLocalExitHandler(void* /*pPrivate*/) {
|
||||
getChannelProviderLocal()->destroy();
|
||||
}
|
||||
|
||||
static void registerChannelProviderLocal(void)
|
||||
{
|
||||
static int firstTime = 1;
|
||||
cout << "registerChannelProviderLocal firstTime " << (firstTime ? "true" : "false") << endl;
|
||||
if (firstTime) {
|
||||
firstTime = 0;
|
||||
iocshRegister(&pvdblFuncDef, pvdbl);
|
||||
getChannelProviderLocal();
|
||||
epicsAtExit(channelProviderLocalExitHandler, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ RemoveRecordPtr RemoveRecord::create(
|
||||
RemoveRecord::RemoveRecord(
|
||||
std::string const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure)
|
||||
: PVRecord(recordName,pvStructure)
|
||||
: PVRecord(recordName,pvStructure),
|
||||
pvDatabase(PVDatabase::getMaster())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ bool RemoveRecord::init()
|
||||
void RemoveRecord::process()
|
||||
{
|
||||
string name = pvRecordName->get();
|
||||
PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name);
|
||||
PVRecordPtr pvRecord = pvDatabase->findRecord(name);
|
||||
if(!pvRecord) {
|
||||
pvResult->put(name + " not found");
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,8 @@ TraceRecordPtr TraceRecord::create(
|
||||
TraceRecord::TraceRecord(
|
||||
std::string const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure)
|
||||
: PVRecord(recordName,pvStructure)
|
||||
: PVRecord(recordName,pvStructure),
|
||||
pvDatabase(PVDatabase::getMaster())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ bool TraceRecord::init()
|
||||
void TraceRecord::process()
|
||||
{
|
||||
string name = pvRecordName->get();
|
||||
PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name);
|
||||
PVRecordPtr pvRecord = pvDatabase->findRecord(name);
|
||||
if(!pvRecord) {
|
||||
pvResult->put(name + " not found");
|
||||
return;
|
||||
|
||||
@@ -5,9 +5,7 @@ include $(TOP)/configure/CONFIG
|
||||
|
||||
PVDATABASE_TEST = $(TOP)/test
|
||||
|
||||
PROD_LIBS += pvDatabase
|
||||
PROD_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
|
||||
PROD_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
PROD_LIBS += pvDatabase pvAccess pvData Com
|
||||
|
||||
include $(PVDATABASE_TEST)/src/Makefile
|
||||
|
||||
@@ -26,3 +24,5 @@ TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); pvDatabaseAllTests
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user