42 Commits

Author SHA1 Message Date
Michael Davidsaver 466d41ebb9 1.3.1 2021-06-30 10:05:36 -07:00
Michael Davidsaver d18e2219b3 pvalink: missing NULL check 2021-04-23 15:29:45 -07:00
Michael Davidsaver ff22538129 pdb: Create db_field_log for GETs 2021-03-17 13:22:42 -07:00
Michael Davidsaver 67e668795e test PDB get w/ filter 2021-03-17 13:22:42 -07:00
Michael Davidsaver 1ac2e6c809 ci: github actions add mingw 2021-03-17 12:47:34 -07:00
Michael Davidsaver 40b327cfcb testpvif 3.15 compat 2021-03-12 11:45:13 -08:00
Michael Davidsaver 20edb8fdf5 CI update 2021-03-12 11:09:26 -08:00
Michael Davidsaver babda345b4 ci: appveyor fix mingw builds 2021-03-12 09:59:02 -08:00
Michael Davidsaver 04fbaf5a2e fix LocalFL 2021-03-12 09:59:02 -08:00
Michael Davidsaver 3438fde276 test: cover server side filters 2021-03-12 09:59:02 -08:00
Simon Rose b515fd30ca Syncing softMain.cpp with epics-base 2021-03-12 07:09:22 -08:00
Michael Davidsaver ad8b77e19f Set next development version 2021-02-26 13:26:20 -08:00
Michael Davidsaver b8389ac6a1 1.3.0 2021-02-26 13:24:26 -08:00
Andrew Johnson d47008ee53 Update GHA config
Better job names
Upload .tap files as artifacts
2021-01-05 22:12:33 -06:00
Andrew Johnson a709854f0d Update .appveyor.yml for newer ci-tools
Also set the correct notification email address
2021-01-05 22:12:33 -06:00
Andrew Johnson 527afaf856 Merge pull request #35 from anjohnson/master
About to merge my yajl5 branch to 7.0
2021-01-05 21:37:48 -06:00
Michael Davidsaver d65af720d1 doc 2020-11-28 10:45:34 -08:00
Michael Davidsaver 503cf414be 3.15 compat 2020-11-28 10:45:34 -08:00
Michael Davidsaver 1682c991d2 use dbChannel* in builder 2020-11-28 10:45:34 -08:00
Michael Davidsaver c68c0038e6 store dbChannel* in builder 2020-11-28 10:45:34 -08:00
Michael Davidsaver b69c25feb6 pass dbChannel* to PVIFBuilder::create() 2020-11-28 10:45:34 -08:00
Michael Davidsaver eae493e732 delay PVIFBuilder::create 2020-11-28 10:45:34 -08:00
Michael Davidsaver 29d00e7e38 simplify 2020-11-28 10:45:34 -08:00
Michael Davidsaver 1335d75403 add dbLoadGroup() 2020-11-28 10:45:34 -08:00
Michael Davidsaver c32cc1ba3c combine group info() processing 2020-11-28 10:44:32 -08:00
Michael Davidsaver f5278ef4ac groups: move record name prepend into parser hooks
Also, accumulate config instead of replacing
2020-11-28 10:44:32 -08:00
Michael Davidsaver b9d3ad8f90 ci: travis-ci -> github actions 2020-11-28 10:44:32 -08:00
Andrew Johnson 0e772037ee Add -v (verbose) flag to softIocPVA
Only display the startup steps with -v
Print each step *before* running it, so any error messages follow.
2020-10-28 23:28:08 -05:00
Michael Davidsaver d100eac09e update README 2020-08-30 09:29:54 -07:00
Andrew Johnson 740aad6712 Modify test database to avoid break when json5 merged
No other changes will be needed when merging the json5 branch into
Base-7.0, these changes let testpvalink pass with and without it.
2020-08-09 00:55:51 -05:00
Michael Davidsaver c66f224602 Set next development version 2020-07-26 13:43:02 -07:00
Michael Davidsaver b1d28cca39 Update version numbers for release 2020-07-26 13:41:51 -07:00
Michael Davidsaver 50be5b6025 release notes 2020-07-11 14:08:26 -07:00
Michael Davidsaver 8e7a1ad295 checkDISP 2020-07-05 23:06:30 -07:00
Michael Davidsaver e894ae753f create second dbChannel for DBE_PROPERTY for groups 2020-07-05 23:06:30 -07:00
Michael Davidsaver 4559f483bf create second dbChannel for DBE_PROPERTY
Create second channel, and second set of filter states,
for subscription to DBE_PROPERTY.  Accommodate filters
which drop events.
2020-07-02 22:45:58 -07:00
Michael Davidsaver e843db5d27 softMain compat 2020-06-01 19:54:08 -07:00
Michael Davidsaver 8363c870bd adapt softMain as softIocPVA 2020-06-01 19:54:08 -07:00
Michael Davidsaver 9499137bb4 update softMain.cpp from Base circa 7.0.4 2020-06-01 19:54:08 -07:00
Michael Davidsaver c4798dc2bc shareLib.h cleanup 2020-06-01 18:22:08 -07:00
Michael Davidsaver 11eeed9d0c notes 2020-06-01 18:22:08 -07:00
Andrew Johnson 94d1eedc75 Set next development version 2020-05-28 16:26:01 -05:00
35 changed files with 999 additions and 566 deletions
+7 -6
View File
@@ -30,6 +30,7 @@ skip_commits:
files:
- 'documentation/*'
- '**/*.md'
- '.github/**'
# Build Configurations: dll/static, regular/debug
configuration:
@@ -48,7 +49,7 @@ environment:
CMP: vs2019
BASE: 7.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMP: mingw
CMP: gcc
BASE: 7.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMP: vs2017
@@ -66,15 +67,15 @@ platform:
#---------------------------------#
build_script:
- cmd: python .ci/appveyor/do.py prepare
- cmd: python .ci/appveyor/do.py build
- cmd: python .ci/cue.py prepare
- cmd: python .ci/cue.py build
test_script:
- cmd: python .ci/appveyor/do.py test
- cmd: python .ci/cue.py test
on_finish:
- ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- cmd: python .ci/appveyor/do.py build test-results -s
- cmd: python .ci/cue.py build test-results -s
#---------------------------------#
# debugging #
@@ -96,7 +97,7 @@ notifications:
- provider: Email
to:
- me@example.com
- core-talk@aps.anl.gov
on_build_success: false
- provider: GitHubPullRequest
+1 -1
Submodule .ci updated: ecb7e43660...3db08b5977
+179
View File
@@ -0,0 +1,179 @@
# .github/workflows/ci-scripts-build.yml for use with EPICS Base ci-scripts
# (see: https://github.com/epics-base/ci-scripts)
# This is YAML - indentation levels are crucial
# Workflow name
name: Base
# Trigger on pushes and PRs to any branch
on:
push:
paths-ignore:
- .appveyor.yml
pull_request:
env:
SETUP_PATH: .ci-local:.ci
EPICS_TEST_IMPRECISE_TIMING: YES
jobs:
build-base:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# Set environment variables from matrix parameters
env:
BASE: ${{ matrix.base }}
CMP: ${{ matrix.cmp }}
BCFG: ${{ matrix.configuration }}
WINE: ${{ matrix.wine }}
RTEMS: ${{ matrix.rtems }}
EXTRA: ${{ matrix.extra }}
TEST: ${{ matrix.test }}
strategy:
fail-fast: false
matrix:
# Job names also name artifacts, character limitations apply
include:
- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "7.0"
wine: "64"
name: "7.0 Ub-20 gcc-9 + MinGW"
- os: ubuntu-20.04
cmp: gcc
configuration: static
base: "7.0"
wine: "64"
name: "7.0 Ub-20 gcc-9 + MinGW, static"
- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "3.15"
wine: "64"
name: "3.15 Ub-20 gcc-9 + MinGW"
- os: ubuntu-20.04
cmp: gcc
configuration: static
base: "7.0"
extra: "CMD_CXXFLAGS=-std=c++11"
name: "7.0 Ub-20 gcc-9 C++11, static"
- os: ubuntu-16.04
cmp: clang
configuration: default
base: "7.0"
name: "7.0 Ub-16 clang-9"
- os: ubuntu-20.04
cmp: clang
configuration: default
base: "7.0"
extra: "CMD_CXXFLAGS=-std=c++11"
name: "7.0 Ub-20 clang-10 C++11"
- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "7.0"
rtems: "4.10"
name: "7.0 Ub-20 gcc-9 + RT-4.10"
- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "7.0"
rtems: "4.9"
name: "7.0 Ub-20 gcc-9 + RT-4.9"
- os: ubuntu-16.04
cmp: gcc-4.8
utoolchain: "4.8"
configuration: default
base: "7.0"
name: "7.0 Ub-16 gcc-4.8"
- os: ubuntu-16.04
cmp: gcc-4.9
utoolchain: "4.9"
configuration: default
base: "7.0"
name: "7.0 Ub-16 gcc-4.9"
- os: ubuntu-20.04
cmp: gcc-8
utoolchain: "8"
configuration: default
base: "7.0"
name: "7.0 Ub-20 gcc-8"
- os: ubuntu-20.04
cmp: clang
configuration: default
base: "7.0"
name: "7.0 Ub-20 clang-10"
- os: macos-latest
cmp: clang
configuration: default
base: "7.0"
name: "7.0 MacOS clang-12"
- os: windows-2019
cmp: vs2019
configuration: default
base: "7.0"
name: "7.0 Win2019 MSC-19"
- os: windows-2019
cmp: vs2019
configuration: static
base: "7.0"
name: "7.0 Win2019 MSC-19, static"
- os: windows-2019
cmp: gcc
configuration: static
base: "7.0"
name: "7.0 Win2019 mingw, static"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: ${{ matrix.base }}/${{ matrix.os }}/${{ matrix.cmp }}/${{ matrix.configuration }}/${{ matrix.wine }}${{ matrix.rtems }}/${{ matrix.extra }}/${{ hashFiles('.github/workflows/ci-scripts-build.yml') }}
- name: "apt-get install"
run: |
sudo apt-get update
sudo apt-get -y install qemu-system-x86 g++-mingw-w64-x86-64 gdb
if: runner.os == 'Linux'
- name: "apt-get install gcc-${{ matrix.utoolchain }}"
run: |
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y install g++-${{ matrix.utoolchain }}
if: matrix.utoolchain
- name: Prepare and compile dependencies
run: python .ci/cue.py prepare
- name: Build main module
run: python .ci/cue.py build
- name: Run main module tests
run: python .ci/cue.py test
- name: Upload tapfiles Artifact
uses: actions/upload-artifact@v2
with:
name: tapfiles ${{ matrix.name }}
path: '**/O.*/*.tap'
- name: Collect and show test results
run: python .ci/cue.py test-results
-108
View File
@@ -1,108 +0,0 @@
# .travis.yml for use with EPICS Base ci-scripts
# (see: https://github.com/epics-base/ci-scripts)
# This is YAML - indentation levels are crucial
language: cpp
compiler: gcc
dist: bionic
cache:
directories:
- $HOME/.cache
env:
global:
- SETUP_PATH=.ci-local:.ci
addons:
apt:
packages:
# for all EPICS builds
- libreadline6-dev
- libncurses5-dev
- perl
# for clang compiler
- clang
# for mingw builds (32bit and 64bit)
- g++-mingw-w64-i686
- g++-mingw-w64-x86-64
# for RTEMS cross builds
- qemu-system-x86
install:
- ./.ci/travis/prepare.sh
script:
- ./.ci/travis/build.sh
# If you need to do more during install and build,
# add a local directory to your module and do e.g.
# - ./.ci-local/travis/install-extras.sh
# Define build jobs
# Well-known variables to use
# SET source setup file
# EXTRA content will be added to make command line
# STATIC set to YES for static build (default: NO)
# TEST set to NO to skip running the tests (default: YES)
# VV set to make build scripts verbose (default: unset)
# Usually from setup files, but may be specified or overridden
# on a job line
# MODULES list of dependency modules
# BASE branch or release tag name of the EPICS Base to use
# <MODULE> branch or release tag for a specific module
# ... see README for setup file syntax description
jobs:
include:
# Different configurations of default gcc and clang
- env: BASE=7.0
- env: BASE=7.0
compiler: clang
- env: BASE=7.0 EXTRA="CMD_CXXFLAGS=-std=c++11"
- env: BASE=7.0 EXTRA="CMD_CXXFLAGS=-std=c++11"
compiler: clang
# Trusty: compiler versions very close to RHEL 7
- env: BASE=7.0
dist: trusty
- env: BASE=7.0 EXTRA="CMD_CXXFLAGS=-std=c++11"
dist: trusty
- env: BASE=3.15 EXTRA="CMD_CXXFLAGS=-std=c++11"
dist: trusty
# Cross-compilations to Windows using MinGW and WINE
- env: BASE=7.0 WINE=32 TEST=NO STATIC=YES
compiler: mingw
- env: BASE=7.0 WINE=64 TEST=NO STATIC=NO
compiler: mingw
# Other gcc versions (added as an extra package)
- env: BASE=7.0
compiler: gcc-6
addons: { apt: { packages: ["g++-6"], sources: ["ubuntu-toolchain-r-test"] } }
- env: BASE=7.0
compiler: gcc-7
addons: { apt: { packages: ["g++-7"], sources: ["ubuntu-toolchain-r-test"] } }
# MacOS build
- env: BASE=7.0
os: osx
compiler: clang
addons: { homebrew: { packages: ["re2c"], update: true } }
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = pva2pva
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 1.2.3
PROJECT_NUMBER = 1.3.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+3
View File
@@ -21,6 +21,9 @@ p2p
A PV Access gateway (aka proxy).
The 'p2p' executable.
The P2P gateway has been deprecated in favor of
[p4p.gw](https://mdavidsaver.github.io/p4p/gw.html).
Dependencies
------------
-2
View File
@@ -16,8 +16,6 @@
#include "weakmap.h"
#include "weakset.h"
#include <shareLib.h>
struct TestPV;
struct TestPVChannel;
struct TestPVMonitor;
+3 -3
View File
@@ -1,11 +1,11 @@
# Module (source) version
EPICS_QSRV_MAJOR_VERSION = 1
EPICS_QSRV_MINOR_VERSION = 2
EPICS_QSRV_MAINTENANCE_VERSION = 3
EPICS_QSRV_MINOR_VERSION = 3
EPICS_QSRV_MAINTENANCE_VERSION = 1
# ABI version
EPICS_QSRV_ABI_MAJOR_VERSION = 1
EPICS_QSRV_ABI_MINOR_VERSION = 1
EPICS_QSRV_ABI_MINOR_VERSION = 2
# Development flag, set to zero for release versions
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = pva2pva
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 1.2.3
PROJECT_NUMBER = 1.3.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+20 -1
View File
@@ -23,7 +23,9 @@ which is also the PV name.
So unlike records, the "field" of a group have a different meaning.
Group field names are _not_ part of the PV name.
A group definition is split among several records.
A group definition may be split among several records,
or included in separate JSON file(s).
For example of a group including two records is:
@code
@@ -43,6 +45,23 @@ record(ai, "rec:Y") {
}
@endcode
Or equivalently with separate .db file and .json files.
@code
# some .db
record(ai, "rec:X") {}
record(ai, "rec:Y") {}
@endcode
@code
{
"grp:name": {
"X": {+channel:"VAL"},
"Y": {+channel:"VAL"}
}
}
@endcode
This group, named "grp:name", has two fields "X" and "Y".
@code
+25
View File
@@ -2,6 +2,31 @@
@page release_notes Release Notes
Release 1.3.1 (June 2021)
=========================
- Bug Fixes
- Correct handling for server side filters.
- Changes
- Syncing softMain.cpp with epics-base
Release 1.3.0 (Feb 2021)
========================
- Changes
- Add dbLoadGroup() iocsh function to read group JSON definitions
from a file. Mappings in files must refer to full record names
instead of fields. eg. 'recname.VAL' instead of 'VAL'.
Release 1.2.4 (July 2020)
=========================
- Bug Fixes
- Fix stalled monitor when server side filter drops initial DBE_PROPERTY update.
- Respect DISP
- Changes
- Refreshed softIocPVA to match options in Base.
Release 1.2.3 (May 2020)
========================
-2
View File
@@ -14,8 +14,6 @@
#include "weakmap.h"
#include "weakset.h"
#include <shareLib.h>
struct ChannelCache;
struct ChannelCacheEntry;
struct MonitorUser;
-2
View File
@@ -3,8 +3,6 @@
#include <pv/pvAccess.h>
#include <shareLib.h>
#include "chancache.h"
struct GWChannel : public epics::pvAccess::Channel
-2
View File
@@ -5,8 +5,6 @@
#include <pv/pvAccess.h>
#include <shareLib.h>
typedef epicsGuard<epicsMutex> Guard;
typedef epicsGuardRelease<epicsMutex> UnGuard;
-2
View File
@@ -6,8 +6,6 @@
#include "chancache.h"
#include "channel.h"
#include <shareLib.h>
struct GWServerChannelProvider :
public epics::pvAccess::ChannelProvider,
public epics::pvAccess::ChannelFind,
+3 -1
View File
@@ -60,7 +60,9 @@ qsrv_LIBS += $(EPICS_BASE_IOC_LIBS)
FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION))
USR_CPPFLAGS += -DFINAL_LOCATION="\"$(FINAL_LOCATION)\""
# since we copy softMain.cpp from Base, use the same
# EPICS_BASE macro for our location
USR_CPPFLAGS += -DEPICS_BASE="\"$(FINAL_LOCATION)\""
PROD_IOC += softIocPVA
+15 -6
View File
@@ -26,6 +26,7 @@ typedef std::map<std::string, pvd::AnyScalar> options_t;
typedef std::map<std::string, options_t> config_t;
struct context {
const std::string chanprefix;
std::string msg;
std::string group, field, key;
unsigned depth; // number of '{'s
@@ -34,9 +35,13 @@ struct context {
// depth 2 - Group
// depth 3 - field
context() :depth(0u) {}
context(const std::string& chanprefix, GroupConfig& conf)
:chanprefix(chanprefix)
,depth(0u)
,conf(conf)
{}
GroupConfig conf;
GroupConfig& conf;
void can_assign()
{
@@ -69,7 +74,7 @@ struct context {
fld.type = value.ref<std::string>();
} else if(key=="+channel") {
fld.channel = value.ref<std::string>();
fld.channel = chanprefix + value.ref<std::string>();
} else if(key=="+id") {
fld.id = value.ref<std::string>();
@@ -217,6 +222,7 @@ struct handler {
}// namespace
void GroupConfig::parse(const char *txt,
const char *recname,
GroupConfig& result)
{
#ifndef EPICS_YAJL_VERSION
@@ -228,7 +234,12 @@ void GroupConfig::parse(const char *txt,
std::istringstream strm(txt);
context ctxt;
std::string chanprefix;
if(recname) {
chanprefix = recname;
chanprefix += '.';
}
context ctxt(chanprefix, result);
#ifndef EPICS_YAJL_VERSION
handler handle(yajl_alloc(&conf_cbs, &conf, NULL, &ctxt));
@@ -240,6 +251,4 @@ void GroupConfig::parse(const char *txt,
if(!pvd::yajl_parse_helper(strm, handle))
throw std::runtime_error(ctxt.msg);
ctxt.conf.swap(result);
}
+162 -103
View File
@@ -59,16 +59,14 @@ struct Splitter {
};
struct GroupMemberInfo {
// consumes builder
GroupMemberInfo(const std::string& a, const std::string& b, const std::tr1::shared_ptr<PVIFBuilder>& builder)
:pvname(a), pvfldname(b), builder(builder), putorder(0) {}
GroupMemberInfo() :putorder(0) {}
std::string pvname, // aka. name passed to dbChannelOpen()
pvfldname; // PVStructure sub-field
std::string structID; // ID to assign to sub-field
std::string type; // mapping type
typedef std::set<std::string> triggers_t;
triggers_t triggers; // names in GroupInfo::members_names which are post()d on events from pvfldname
std::tr1::shared_ptr<PVIFBuilder> builder; // not actually shared, but allows us to be copyable
int putorder;
bool operator<(const GroupMemberInfo& o) const {
@@ -100,9 +98,6 @@ struct PDBProcessor
typedef std::map<std::string, GroupInfo> groups_t;
groups_t groups;
std::string recbase;
GroupInfo *curgroup;
// validate trigger mappings and process into bit map form
void resolveTriggers()
{
@@ -177,8 +172,13 @@ struct PDBProcessor
}
}
PDBProcessor() : curgroup(NULL)
PDBProcessor()
{
#ifdef USE_MULTILOCK
GroupConfig conf;
#endif
// process info(Q:Group, ...)
for(pdbRecordIterator rec; !rec.done(); rec.next())
{
const char *json = rec.info("Q:group");
@@ -189,107 +189,154 @@ struct PDBProcessor
warned = true;
fprintf(stderr, "%s: ignoring info(Q:Group, ...\n", rec.name());
}
#else
#endif
if(PDBProviderDebug>2) {
fprintf(stderr, "%s: info(Q:Group, ...\n", rec.name());
}
#ifdef USE_MULTILOCK
try {
GroupConfig conf;
GroupConfig::parse(json, conf);
GroupConfig::parse(json, rec.name(), conf);
if(!conf.warning.empty())
fprintf(stderr, "%s: warning(s) from info(Q:group, ...\n%s", rec.name(), conf.warning.c_str());
recbase = rec.name();
recbase += ".";
for(GroupConfig::groups_t::const_iterator git=conf.groups.begin(), gend=conf.groups.end();
git!=gend; ++git)
{
const std::string& grpname = git->first;
const GroupConfig::Group& grp = git->second;
if(dbChannelTest(grpname.c_str())==0) {
fprintf(stderr, "%s : Error: Group name conflicts with record name. Ignoring...\n", grpname.c_str());
continue;
}
groups_t::iterator it = groups.find(grpname);
if(it==groups.end()) {
// lazy creation of group
std::pair<groups_t::iterator, bool> ins(groups.insert(std::make_pair(grpname, GroupInfo(grpname))));
it = ins.first;
}
curgroup = &it->second;
if(!grp.id.empty())
curgroup->structID = grp.id;
for(GroupConfig::Group::fields_t::const_iterator fit=grp.fields.begin(), fend=grp.fields.end();
fit!=fend; ++fit)
{
const std::string& fldname = fit->first;
const GroupConfig::Field& fld = fit->second;
GroupInfo::members_map_t::const_iterator oldgrp(curgroup->members_map.find(fldname));
if(oldgrp!=curgroup->members_map.end()) {
fprintf(stderr, "%s.%s Warning: ignoring duplicate mapping %s%s\n",
grpname.c_str(), fldname.c_str(),
recbase.c_str(), fld.channel.c_str());
continue;
}
std::tr1::shared_ptr<PVIFBuilder> builder(PVIFBuilder::create(fld.type));
curgroup->members.push_back(GroupMemberInfo(fld.channel.empty() ? fld.channel : recbase + fld.channel, fldname, builder));
curgroup->members.back().structID = fld.id;
curgroup->members.back().putorder = fld.putorder;
curgroup->members_map[fldname] = (size_t)-1; // placeholder see below
if(PDBProviderDebug>2) {
fprintf(stderr, " pdb map '%s.%s' <-> '%s'\n",
curgroup->name.c_str(),
curgroup->members.back().pvfldname.c_str(),
curgroup->members.back().pvname.c_str());
}
if(!fld.trigger.empty()) {
GroupInfo::triggers_t::iterator it = curgroup->triggers.find(fldname);
if(it==curgroup->triggers.end()) {
std::pair<GroupInfo::triggers_t::iterator, bool> ins(curgroup->triggers.insert(
std::make_pair(fldname, GroupInfo::triggers_set_t())));
it = ins.first;
}
Splitter sep(fld.trigger.c_str(), ',');
std::string target;
while(sep.snip(target)) {
curgroup->hastriggers = true;
it->second.insert(target);
}
}
}
if(grp.atomic_set) {
GroupInfo::tribool V = grp.atomic ? GroupInfo::True : GroupInfo::False;
if(curgroup->atomic!=GroupInfo::Unset && curgroup->atomic!=V)
fprintf(stderr, "%s Warning: pdb atomic setting inconsistent '%s'\n",
grpname.c_str(), curgroup->name.c_str());
curgroup->atomic=V;
if(PDBProviderDebug>2)
fprintf(stderr, " pdb atomic '%s' %s\n",
curgroup->name.c_str(), curgroup->atomic ? "YES" : "NO");
}
}
}catch(std::exception& e){
fprintf(stderr, "%s: Error parsing info(\"Q:group\", ... : %s\n",
rec.record()->name, e.what());
}
#endif // USE_MULTILOCK
#endif
}
// process group definition files
for(PDBProvider::group_files_t::const_iterator it(PDBProvider::group_files.begin()), end(PDBProvider::group_files.end());
it != end; ++it)
{
std::ifstream jfile(it->c_str());
if(!jfile.is_open()) {
fprintf(stderr, "Error opening \"%s\"\n", it->c_str());
continue;
}
std::vector<char> contents;
size_t pos=0u;
while(true) {
contents.resize(pos+1024u);
if(!jfile.read(&contents[pos], contents.size()-pos))
break;
pos += jfile.gcount();
}
if(jfile.bad() || !jfile.eof()) {
fprintf(stderr, "Error reading \"%s\"\n", it->c_str());
continue;
}
contents.push_back('\0');
const char *json = &contents[0];
if(PDBProviderDebug>2) {
fprintf(stderr, "Process dbGroup file \"%s\"\n", it->c_str());
}
#ifdef USE_MULTILOCK
try {
GroupConfig::parse(json, "", conf);
if(!conf.warning.empty())
fprintf(stderr, "warning(s) from dbGroup file \"%s\"\n%s", it->c_str(), conf.warning.c_str());
}catch(std::exception& e){
fprintf(stderr, "Error from dbGroup file \"%s\"\n%s", it->c_str(), e.what());
}
#endif
}
#ifdef USE_MULTILOCK
for(GroupConfig::groups_t::const_iterator git=conf.groups.begin(), gend=conf.groups.end();
git!=gend; ++git)
{
const std::string& grpname = git->first;
const GroupConfig::Group& grp = git->second;
try {
if(dbChannelTest(grpname.c_str())==0) {
fprintf(stderr, "%s : Error: Group name conflicts with record name. Ignoring...\n", grpname.c_str());
continue;
}
groups_t::iterator it = groups.find(grpname);
if(it==groups.end()) {
// lazy creation of group
std::pair<groups_t::iterator, bool> ins(groups.insert(std::make_pair(grpname, GroupInfo(grpname))));
it = ins.first;
}
GroupInfo *curgroup = &it->second;
if(!grp.id.empty())
curgroup->structID = grp.id;
for(GroupConfig::Group::fields_t::const_iterator fit=grp.fields.begin(), fend=grp.fields.end();
fit!=fend; ++fit)
{
const std::string& fldname = fit->first;
const GroupConfig::Field& fld = fit->second;
if(curgroup->members_map.find(fldname) != curgroup->members_map.end()) {
fprintf(stderr, "%s.%s Warning: ignoring duplicate mapping %s\n",
grpname.c_str(), fldname.c_str(),
fld.channel.c_str());
continue;
}
curgroup->members.push_back(GroupMemberInfo());
GroupMemberInfo& info = curgroup->members.back();
info.pvname = fld.channel;
info.pvfldname = fldname;
info.structID = fld.id;
info.putorder = fld.putorder;
info.type = fld.type;
curgroup->members_map[fldname] = (size_t)-1; // placeholder see below
if(PDBProviderDebug>2) {
fprintf(stderr, " pdb map '%s.%s' <-> '%s'\n",
curgroup->name.c_str(),
curgroup->members.back().pvfldname.c_str(),
curgroup->members.back().pvname.c_str());
}
if(!fld.trigger.empty()) {
GroupInfo::triggers_t::iterator it = curgroup->triggers.find(fldname);
if(it==curgroup->triggers.end()) {
std::pair<GroupInfo::triggers_t::iterator, bool> ins(curgroup->triggers.insert(
std::make_pair(fldname, GroupInfo::triggers_set_t())));
it = ins.first;
}
Splitter sep(fld.trigger.c_str(), ',');
std::string target;
while(sep.snip(target)) {
curgroup->hastriggers = true;
it->second.insert(target);
}
}
}
if(grp.atomic_set) {
GroupInfo::tribool V = grp.atomic ? GroupInfo::True : GroupInfo::False;
if(curgroup->atomic!=GroupInfo::Unset && curgroup->atomic!=V)
fprintf(stderr, "%s Warning: pdb atomic setting inconsistent '%s'\n",
grpname.c_str(), curgroup->name.c_str());
curgroup->atomic=V;
if(PDBProviderDebug>2)
fprintf(stderr, " pdb atomic '%s' %s\n",
curgroup->name.c_str(), curgroup->atomic ? "YES" : "NO");
}
}catch(std::exception& e){
fprintf(stderr, "Error processing Q:group \"%s\" : %s\n",
grpname.c_str(), e.what());
}
}
// re-sort GroupInfo::members to ensure the shorter names appear first
@@ -311,6 +358,7 @@ struct PDBProcessor
resolveTriggers();
// must not re-sort members after this point as resolveTriggers()
// has stored array indicies.
#endif
}
};
@@ -318,6 +366,8 @@ struct PDBProcessor
size_t PDBProvider::num_instances;
std::list<std::string> PDBProvider::group_files;
PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_pointer &)
{
/* Long view
@@ -405,10 +455,12 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin
chan.swap(temp);
}
std::tr1::shared_ptr<PVIFBuilder> pvifbuilder(PVIFBuilder::create(mem.type, chan.chan));
if(!parts.empty())
builder = mem.builder->dtype(builder, parts.back().name, chan);
builder = pvifbuilder->dtype(builder, parts.back().name);
else
builder = mem.builder->dtype(builder, "", chan);
builder = pvifbuilder->dtype(builder, "");
if(!parts.empty()) {
for(size_t j=0; j<parts.size()-1; j++)
@@ -419,8 +471,14 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin
members_map[mem.pvfldname] = J;
PDBGroupPV::Info& info = members[J];
DBCH chan2;
if(chan.chan && (ellCount(&chan.chan->pre_chain)>0 || ellCount(&chan.chan->post_chain)>0)) {
DBCH temp(mem.pvname);
info.chan2.swap(chan2);
}
info.allowProc = mem.putorder != std::numeric_limits<int>::min();
info.builder = PTRMOVE(mem.builder);
info.builder = PTRMOVE(pvifbuilder);
assert(info.builder.get());
info.attachment.swap(parts);
@@ -511,10 +569,11 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin
info.evt_VALUE.self = info.evt_PROPERTY.self = pv;
assert(info.chan);
info.pvif.reset(info.builder->attach(info.chan, pv->complete, info.attachment));
info.pvif.reset(info.builder->attach(pv->complete, info.attachment));
// TODO: don't need evt_PROPERTY for PVIF plain
info.evt_PROPERTY.create(event_context, info.chan, &pdb_group_event, DBE_PROPERTY);
dbChannel *pchan = info.chan2.chan ? info.chan2.chan : info.chan.chan;
info.evt_PROPERTY.create(event_context, pchan, &pdb_group_event, DBE_PROPERTY);
if(!info.triggers.empty()) {
info.evt_VALUE.create(event_context, info.chan, &pdb_group_event, DBE_VALUE|DBE_ALARM);
+4 -1
View File
@@ -8,7 +8,7 @@
#include "weakmap.h"
#include <shareLib.h>
#include <pv/qsrv.h>
struct PDBProvider;
@@ -64,6 +64,9 @@ struct QSRV_API PDBProvider : public epics::pvAccess::ChannelProvider,
dbEventCtx event_context;
typedef std::list<std::string> group_files_t;
static group_files_t group_files;
static size_t num_instances;
};
+8 -5
View File
@@ -334,7 +334,7 @@ PDBGroupPut::PDBGroupPut(const PDBGroupChannel::shared_pointer& channel,
{
PDBGroupPV::Info& info = channel->pv->members[i];
pvif[i].reset(info.builder->attach(info.chan, pvf, info.attachment));
pvif[i].reset(info.builder->attach(pvf, info.attachment));
}
}
@@ -355,7 +355,7 @@ void PDBGroupPut::put(pvd::PVStructure::shared_pointer const & value,
PDBGroupPV::Info& info = channel->pv->members[i];
if(!info.allowProc) continue;
putpvif[i].reset(info.builder->attach(info.chan, value, info.attachment));
putpvif[i].reset(info.builder->attach(value, info.attachment));
}
pvd::Status ret;
@@ -394,8 +394,10 @@ void PDBGroupPut::get()
changed->clear();
if(atomic) {
DBManyLocker L(channel->pv->locker);
for(size_t i=0; i<npvs; i++)
pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, NULL);
for(size_t i=0; i<npvs; i++) {
LocalFL FL(NULL, channel->pv->members[i].chan);
pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
}
} else {
for(size_t i=0; i<npvs; i++)
@@ -403,7 +405,8 @@ void PDBGroupPut::get()
PDBGroupPV::Info& info = channel->pv->members[i];
DBScanLocker L(dbChannelRecord(info.chan));
pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, NULL);
LocalFL FL(NULL, info.chan);
pvif[i]->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
}
}
//TODO: report unused fields as changed?
+3 -3
View File
@@ -17,8 +17,6 @@
#include "pvif.h"
#include "pdb.h"
#include <shareLib.h>
struct QSRV_API GroupConfig
{
struct QSRV_API Field {
@@ -61,7 +59,7 @@ struct QSRV_API GroupConfig
std::swap(warning, o.warning);
}
static void parse(const char *txt,
static void parse(const char *txt, const char *recname,
GroupConfig& result);
};
@@ -89,6 +87,8 @@ struct QSRV_API PDBGroupPV : public PDBPV
struct Info {
DBCH chan;
// used for DBE_PROPERTY subscription when chan has filters
DBCH chan2;
std::tr1::shared_ptr<PVIFBuilder> builder;
FieldName attachment;
typedef std::vector<size_t> triggers_t;
+15 -9
View File
@@ -96,19 +96,23 @@ void pdb_single_event(void *user_arg, struct dbChannel *chan,
PDBSinglePV::PDBSinglePV(DBCH& chan,
const PDBProvider::shared_pointer& prov)
:provider(prov)
,builder(new ScalarBuilder)
,builder(new ScalarBuilder(chan.chan))
,interested_iterating(false)
,evt_VALUE(this)
,evt_PROPERTY(this)
,hadevent_VALUE(false)
,hadevent_PROPERTY(false)
{
if(ellCount(&chan.chan->pre_chain) || ellCount(&chan.chan->post_chain)) {
DBCH temp(dbChannelName(chan.chan));
this->chan2.swap(temp);
}
this->chan.swap(chan);
fielddesc = std::tr1::static_pointer_cast<const pvd::Structure>(builder->dtype(this->chan));
fielddesc = std::tr1::static_pointer_cast<const pvd::Structure>(builder->dtype());
complete = pvd::getPVDataCreate()->createPVStructure(fielddesc);
FieldName temp;
pvif.reset(builder->attach(this->chan, complete, temp));
pvif.reset(builder->attach(complete, temp));
epics::atomic::increment(num_instances);
}
@@ -120,8 +124,9 @@ PDBSinglePV::~PDBSinglePV()
void PDBSinglePV::activate()
{
dbChannel *pchan = this->chan2.chan ? this->chan2.chan : this->chan.chan;
evt_VALUE.create(provider->event_context, this->chan, &pdb_single_event, DBE_VALUE|DBE_ALARM);
evt_PROPERTY.create(provider->event_context, this->chan, &pdb_single_event, DBE_PROPERTY);
evt_PROPERTY.create(provider->event_context, pchan, &pdb_single_event, DBE_PROPERTY);
}
pva::Channel::shared_pointer
@@ -303,7 +308,7 @@ PDBSinglePut::PDBSinglePut(const PDBSingleChannel::shared_pointer &channel,
,requester(requester)
,changed(new pvd::BitSet(channel->fielddesc->getNumberFields()))
,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc))
,pvif(channel->pv->builder->attach(channel->pv->chan, pvf, FieldName()))
,pvif(channel->pv->builder->attach(pvf, FieldName()))
,notifyBusy(0)
,doProc(PVIF::ProcPassive)
,doWait(false)
@@ -370,7 +375,7 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value,
// TODO: dbNotify doesn't allow us for force processing
// assume value may be a different struct each time
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName()));
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
unsigned mask = putpvif->dbe(*changed);
if(mask!=DBE_VALUE) {
@@ -392,10 +397,10 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value,
return; // skip notification
} else {
// assume value may be a different struct each time
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName()));
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
try{
DBScanLocker L(chan);
putpvif->get(*changed, doProc);
ret = putpvif->get(*changed, doProc);
}catch(std::runtime_error& e){
ret = pvd::Status::error(e.what());
@@ -421,7 +426,8 @@ void PDBSinglePut::get()
changed->clear();
{
DBScanLocker L(pvif->chan);
pvif->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, NULL);
LocalFL FL(NULL, pvif->chan);
pvif->put(*changed, DBE_VALUE|DBE_ALARM|DBE_PROPERTY, FL.pfl);
}
//TODO: report unused fields as changed?
changed->clear();
+2 -2
View File
@@ -16,8 +16,6 @@
#include "pvif.h"
#include "pdb.h"
#include <shareLib.h>
struct PDBSingleMonitor;
struct QSRV_API PDBSinglePV : public PDBPV
@@ -32,6 +30,8 @@ struct QSRV_API PDBSinglePV : public PDBPV
* is locked.
*/
DBCH chan;
// used for DBE_PROPERTY subscription when chan has filters
DBCH chan2;
PDBProvider::shared_pointer provider;
// only for use in pdb_single_event()
+3
View File
@@ -49,6 +49,9 @@ QSRV_API unsigned qsrvVersion(void);
/** returns QSRV_ABI_VERSION_INT captured at compilation time */
QSRV_API unsigned qsrvABIVersion(void);
QSRV_API
long dbLoadGroup(const char* fname);
QSRV_API void testqsrvWaitForLinkEvent(struct link *plink);
/** Call before testIocShutdownOk()
+3 -1
View File
@@ -89,7 +89,9 @@ pvd::PVField::const_shared_pointer pvaLink::getSubField(const char *name)
} else {
// we access a sub-struct
ret = lchan->op_mon.root->getSubField(fieldName);
if(ret->getField()->getType()!=pvd::structure) {
if(!ret) {
// noop
} else if(ret->getField()->getType()!=pvd::structure) {
// addressed sub-field isn't a sub-structure
if(strcmp(name, "value")!=0) {
// unless we are trying to fetch the "value", we fail here
+43 -30
View File
@@ -641,6 +641,14 @@ void findFormat(pvTimeAlarm& pvmeta, pdbRecordIterator& info, const epics::pvDat
}
}
pvd::Status checkDISP(dbChannel *chan)
{
dbCommon *prec = dbChannelRecord(chan);
pvd::Status ret;
if(prec->disp && dbChannelField(chan)!=&prec->disp)
ret = pvd::Status::error("Put Disabled");
return ret;
}
template<typename PVX, typename META>
struct PVIFScalarNumeric : public PVIF
@@ -698,7 +706,10 @@ struct PVIFScalarNumeric : public PVIF
virtual pvd::Status get(const epics::pvData::BitSet& mask, proc_t proc, bool permit) OVERRIDE FINAL
{
pvd::Status ret;
pvd::Status ret = checkDISP(chan);
if(!ret)
return ret;
bool newval = mask.logical_and(pvmeta.maskVALUEPut);
if(newval) {
if(permit)
@@ -764,7 +775,7 @@ short PVD2DBR(pvd::ScalarType pvt)
}
epics::pvData::FieldConstPtr
ScalarBuilder::dtype(dbChannel *channel)
ScalarBuilder::dtype()
{
short dbr = dbChannelFinalFieldType(channel);
const long maxelem = dbChannelFinalElements(channel);
@@ -819,7 +830,7 @@ ScalarBuilder::dtype(dbChannel *channel)
}
PVIF*
ScalarBuilder::attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fldname)
ScalarBuilder::attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname)
{
if(!channel)
throw std::runtime_error("+type:\"scalar\" requires +channel:");
@@ -906,7 +917,10 @@ struct PVIFPlain : public PVIF
virtual pvd::Status get(const epics::pvData::BitSet& mask, proc_t proc, bool permit) OVERRIDE FINAL
{
pvd::Status ret;
pvd::Status ret = checkDISP(chan);
if(!ret)
return ret;
bool newval = mask.get(fieldOffset);
if(newval) {
if(permit)
@@ -936,10 +950,11 @@ struct PVIFPlain : public PVIF
struct PlainBuilder : public PVIFBuilder
{
explicit PlainBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~PlainBuilder() {}
// fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL {
virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
const short dbr = dbChannelFinalFieldType(channel);
const long maxelem = dbChannelFinalElements(channel);
const pvd::ScalarType pvt = DBR2PVD(dbr);
@@ -956,8 +971,7 @@ struct PlainBuilder : public PVIFBuilder
// Attach to a structure instance.
// must be of the type returned by dtype().
// need not be the root structure
virtual PVIF* attach(dbChannel *channel,
const epics::pvData::PVStructurePtr& root,
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL
{
if(!channel)
@@ -976,10 +990,11 @@ struct PlainBuilder : public PVIFBuilder
struct AnyScalarBuilder : public PVIFBuilder
{
explicit AnyScalarBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~AnyScalarBuilder() {}
// fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL {
virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
(void)channel; //ignored
return pvd::getFieldCreate()->createVariantUnion();
}
@@ -987,8 +1002,7 @@ struct AnyScalarBuilder : public PVIFBuilder
// Attach to a structure instance.
// must be of the type returned by dtype().
// need not be the root structure
virtual PVIF* attach(dbChannel *channel,
const epics::pvData::PVStructurePtr& root,
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL
{
if(!channel)
@@ -1074,16 +1088,16 @@ struct PVIFMeta : public PVIF
struct MetaBuilder : public PVIFBuilder
{
explicit MetaBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~MetaBuilder() {}
// fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL {
virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
throw std::logic_error("Don't call me");
}
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld,
dbChannel *channel)
const std::string& fld) OVERRIDE FINAL
{
pvd::StandardFieldPtr std(pvd::getStandardField());
if(fld.empty()) {
@@ -1100,8 +1114,7 @@ struct MetaBuilder : public PVIFBuilder
// Attach to a structure instance.
// must be of the type returned by dtype().
// need not be the root structure
virtual PVIF* attach(dbChannel *channel,
const epics::pvData::PVStructurePtr& root,
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL
{
if(!channel)
@@ -1138,20 +1151,21 @@ struct PVIFProc : public PVIF
struct ProcBuilder : public PVIFBuilder
{
explicit ProcBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~ProcBuilder() {}
// fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL {
virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
throw std::logic_error("Don't call me");
}
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld,
dbChannel *channel) OVERRIDE FINAL
const std::string& fld) OVERRIDE FINAL
{
// invisible
return builder;
}
virtual PVIF* attach(dbChannel *channel,
const epics::pvData::PVStructurePtr& root,
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL
{
if(!channel)
@@ -1202,31 +1216,30 @@ pvd::Status PVIF::get(const epics::pvData::BitSet& mask, proc_t proc, bool permi
epics::pvData::FieldBuilderPtr
PVIFBuilder::dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string &fld,
dbChannel *channel)
const std::string &fld)
{
if(fld.empty())
throw std::runtime_error("Can't attach this +type to root");
throw std::runtime_error(SB()<<"Can't attach +type "<<typeid(*this).name()<<" to root");
epics::pvData::FieldConstPtr ftype(this->dtype(channel));
epics::pvData::FieldConstPtr ftype(this->dtype());
if(ftype)
builder = builder->add(fld, ftype);
return builder;
}
PVIFBuilder* PVIFBuilder::create(const std::string& type)
PVIFBuilder* PVIFBuilder::create(const std::string& type, dbChannel* chan)
{
if(type.empty() || type=="scalar")
return new ScalarBuilder;
return new ScalarBuilder(chan);
else if(type=="plain")
return new PlainBuilder;
return new PlainBuilder(chan);
else if(type=="any")
return new AnyScalarBuilder;
return new AnyScalarBuilder(chan);
else if(type=="meta")
return new MetaBuilder;
return new MetaBuilder(chan);
else if(type=="proc")
return new ProcBuilder;
return new ProcBuilder(chan);
else
throw std::runtime_error(std::string("Unknown +type=")+type);
}
+25 -9
View File
@@ -254,6 +254,7 @@ struct LocalFL
if(pfl) pfl = dbChannelRunPostChain(pchan, pfl);
}
}
this->pfl = pfl;
}
~LocalFL() {
if(ours) db_delete_field_log(pfl);
@@ -378,25 +379,39 @@ private:
PVIF& operator=(const PVIF&);
};
struct QSRV_API PVIFBuilder {
/** Factory for PVIF instances.
*
* Caller first passes a mapping type (eg. "scalar") to PVIFBuilder::create()
* to obtain a PVIFBuilder which may then by used to create PVIF instances
* for specific dbChannel.
*
* Caller than uses PVIFBuilder::dtype() to obtain (sub)Field descriptions.
* eg. more than one of these may be composed into an overall Structure description.
*
* Caller than creates a PVStructure and uses PVIFBuilder::attach() to
* build mappings for each dbChannel in the composed locations.
*/
struct QSRV_API PVIFBuilder
{
dbChannel* const channel;
virtual ~PVIFBuilder() {}
// fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) =0;
virtual epics::pvData::FieldConstPtr dtype() =0;
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld,
dbChannel *channel);
const std::string& fld);
// Attach to a structure instance.
// must be of the type returned by dtype().
// must be the root structure
virtual PVIF* attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fld) =0;
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fld) =0;
static PVIFBuilder* create(const std::string& name);
// entry point for Builder
static PVIFBuilder* create(const std::string& mapname, dbChannel* chan);
protected:
PVIFBuilder() {}
explicit PVIFBuilder(dbChannel* chan) : channel(chan) {}
private:
PVIFBuilder(const PVIFBuilder&);
PVIFBuilder& operator=(const PVIFBuilder&);
@@ -404,10 +419,11 @@ private:
struct QSRV_API ScalarBuilder : public PVIFBuilder
{
explicit ScalarBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~ScalarBuilder() {}
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL;
virtual PVIF* attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL;
virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL;
virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL;
};
+42
View File
@@ -46,8 +46,49 @@ void QSRVRegistrar_counters()
epics::registerRefCounter("PDBProvider", &PDBProvider::num_instances);
}
long dbLoadGroup(const char* fname)
{
try {
if(!fname) {
printf("dbLoadGroup(\"file.json\")\n"
"\n"
"Load additional DB group definitions from file.\n");
return 1;
}
#ifndef USE_MULTILOCK
static bool warned;
if(!warned) {
warned = true;
fprintf(stderr, "ignoring %s\n", fname);
}
#endif
if(fname[0]=='-') {
fname++;
if(fname[0]=='*' && fname[1]=='\0') {
PDBProvider::group_files.clear();
} else {
PDBProvider::group_files.remove(fname);
}
} else {
PDBProvider::group_files.remove(fname);
PDBProvider::group_files.push_back(fname);
}
return 0;
}catch(std::exception& e){
fprintf(stderr, "Error: %s\n", e.what());
return 1;
}
}
namespace {
void dbLoadGroupWrap(const char* fname)
{
(void)dbLoadGroup(fname);
}
void dbgl(int lvl, const char *pattern)
{
if(!pattern)
@@ -88,6 +129,7 @@ void QSRVRegistrar()
QSRVRegistrar_counters();
pva::ChannelProviderRegistry::servers()->addSingleton<PDBProvider>("QSRV");
epics::iocshRegister<int, const char*, &dbgl>("dbgl", "level", "pattern");
epics::iocshRegister<const char*, &dbLoadGroupWrap>("dbLoadGroup", "jsonfile");
}
} // namespace
+241 -207
View File
@@ -7,242 +7,276 @@
* found in the file LICENSE that is included with this distribution.
\*************************************************************************/
/* Copyed from EPICS Base 3.16 branch */
/* Author: Andrew Johnson Date: 2003-04-08 */
/* Author: Andrew Johnson Date: 2003-04-08 */
/* Usage:
* softIoc [-D softIoc.dbd] [-h] [-S] [-s] [-a ascf]
* [-m macro=value,macro2=value2] [-d file.db]
* [-x prefix] [st.cmd]
*
* If used the -D option must come first, and specify the
* path to the softIoc.dbd file. The compile-time install
* location is saved in the binary as a default.
*
* Usage information will be printed if -h is given, then
* the program will exit normally.
*
* The -S option prevents an interactive shell being started
* after all arguments have been processed.
*
* Previous versions accepted a -s option to cause a shell
* to be started; this option is still accepted but ignored
* since a command shell is now started by default.
*
* Access Security can be enabled with the -a option giving
* the name of the configuration file; if any macros were
* set with -m before the -a option was given, they will be
* used as access security substitution macros.
*
* Any number of -m and -d arguments can be interspersed;
* the macros are applied to the following .db files. Each
* later -m option causes earlier macros to be discarded.
*
* The -x option loads the softIocExit.db with the macro
* IOC set to the string provided. This database contains
* a subroutine record named $(IOC):exit which has its field
* SNAM set to "exit". When this record is processed, the
* subroutine that runs will call epicsExit() with the value
* of the field A determining whether the exit status is
* EXIT_SUCCESS if (A == 0.0) or EXIT_FAILURE (A != 0.0).
*
* A st.cmd file is optional. If any databases were loaded
* the st.cmd file will be run *after* iocInit. To perform
* iocsh commands before iocInit, all database loading must
* be performed by the script itself, or by the user from
* the interactive IOC shell.
*/
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include <stdexcept>
#include <epicsVersion.h>
#include <epicsGetopt.h>
#include "registryFunction.h"
#include "epicsThread.h"
#include "epicsExit.h"
#include "epicsStdio.h"
#include "epicsString.h"
#include "dbStaticLib.h"
#include "subRecord.h"
#include "dbAccess.h"
#include "asDbLib.h"
#include "iocInit.h"
#include "iocsh.h"
#include "osiFileName.h"
#include <pv/qsrv.h>
extern "C" int softIocPVA_registerRecordDeviceDriver(struct dbBase *pdbbase);
#ifdef __rtems__
#define DBD_FILE "dbd/softIocPVA.dbd"
#define EXIT_FILE "db/softIocExit.db"
#else
#define DBD_FILE FINAL_LOCATION "/dbd/softIocPVA.dbd"
#define EXIT_FILE FINAL_LOCATION "/db/softIocExit.db"
#ifndef EPICS_BASE
// so IDEs knows EPICS_BASE is a string constant
# define EPICS_BASE "/"
# error -DEPICS_BASE required
#endif
#ifdef VERSION_INT
#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1)
#define USE_EXIT_LATER
#if EPICS_VERSION_INT>=VERSION_INT(7,0,2,0)
# define USE_EXECDIR
#endif
#endif
const char *arg0;
const char *base_dbd = DBD_FILE;
const char *exit_db = EXIT_FILE;
#define DBD_BASE "dbd" OSI_PATH_SEPARATOR "softIocPVA.dbd"
#define EXIT_BASE "db" OSI_PATH_SEPARATOR "softIocExit.db"
#define DBD_FILE_REL ".." OSI_PATH_SEPARATOR ".." OSI_PATH_SEPARATOR DBD_BASE
#define EXIT_FILE_REL ".." OSI_PATH_SEPARATOR ".." OSI_PATH_SEPARATOR EXIT_BASE
#define DBD_FILE EPICS_BASE OSI_PATH_SEPARATOR DBD_BASE
#define EXIT_FILE EPICS_BASE OSI_PATH_SEPARATOR EXIT_BASE
namespace {
bool verbose = false;
static void exitSubroutine(subRecord *precord) {
#ifdef USE_EXIT_LATER
epicsExitLater((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
#else
epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
#endif
}
static void usage(int status) {
printf("Usage: %s [-D softIoc.dbd] [-h] [-S] [-a ascf]\n", arg0);
puts("\t[-m macro=value,macro2=value2] [-d file.db]");
puts("\t[-x prefix] [st.cmd]");
puts("Compiled-in path to softIocPVA.dbd is:");
printf("\t%s\n", base_dbd);
epicsExit(status);
void usage(const char *arg0, const std::string& base_dbd) {
std::cout<<"Usage: "<<arg0<<
" [-D softIocPVA.dbd] [-h] [-S] [-s] [-v] [-a ascf]\n"
"[-m macro=value,macro2=value2] [-d file.db]\n"
"[-x prefix] [st.cmd]\n"
"\n"
" -D <dbd> If used, must come first. Specify the path to the softIocPVA.dbdfile."
" The compile-time install location is saved in the binary as a default.\n"
"\n"
" -h Print this mesage and exit.\n"
"\n"
" -S Prevents an interactive shell being started.\n"
"\n"
" -s Previously caused a shell to be started. Now accepted and ignored.\n"
"\n"
" -v Verbose, display steps taken during startup.\n"
"\n"
" -a <acf> Access Security configuration file. Macro substitution is\n"
" performed.\n"
"\n"
" -G <json> DB Group definition file in JSON format.\n"
"\n"
" -m <MAC>=<value>,... Set/replace macro definitions used by subsequent -d and\n"
" -a.\n"
"\n"
" -d <db> Load records from file (dbLoadRecords). Macro substitution is\n"
" performed.\n"
"\n"
" -x <prefix> Load softIocExit.db. Provides a record \"<prefix>:exit\".\n"
" Put 0 to exit with success, or non-zero to exit with an error.\n"
"\n"
"Any number of -m and -d arguments can be interspersed; the macros are applied\n"
"to the following .db files. Each later -m option causes earlier macros to be\n"
"discarded.\n"
"\n"
"A st.cmd file is optional. If any databases were loaded the st.cmd file will\n"
"be run *after* iocInit. To perform iocsh commands before iocInit, all database\n"
"loading must be performed by the script itself, or by the user from the\n"
"interactive IOC shell.\n"
"\n"
"Compiled-in path to softIocPVA.dbd is:\n"
"\t"<<base_dbd.c_str()<<"\n";
}
void errIf(int ret, const std::string& msg)
{
if(ret)
throw std::runtime_error(msg);
}
bool lazy_dbd_loaded;
void lazy_dbd(const std::string& dbd_file) {
if(lazy_dbd_loaded) return;
lazy_dbd_loaded = true;
if (verbose)
std::cout<<"dbLoadDatabase(\""<<dbd_file<<"\")\n";
errIf(dbLoadDatabase(dbd_file.c_str(), NULL, NULL),
std::string("Failed to load DBD file: ")+dbd_file);
if (verbose)
std::cout<<"softIocPVA_registerRecordDeviceDriver(pdbbase)\n";
softIocPVA_registerRecordDeviceDriver(pdbbase);
registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);
}
} // namespace
int main(int argc, char *argv[])
{
char *dbd_file = const_cast<char*>(base_dbd);
char *macros = NULL;
char xmacro[PVNAME_STRINGSZ + 4];
int startIocsh = 1; /* default = start shell */
int loadedDb = 0;
arg0 = strrchr(*argv, '/');
if (!arg0) {
arg0 = *argv;
} else {
++arg0; /* skip the '/' */
}
--argc, ++argv;
/* Do this here in case the dbd file not available */
if (argc>0 && **argv=='-' && (*argv)[1]=='h') {
usage(EXIT_SUCCESS);
}
if (argc>1 && **argv=='-' && (*argv)[1]=='D') {
dbd_file = *++argv;
argc -= 2;
++argv;
}
if (dbLoadDatabase(dbd_file, NULL, NULL)) {
epicsExit(EXIT_FAILURE);
}
softIocPVA_registerRecordDeviceDriver(pdbbase);
registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);
try {
std::string dbd_file(DBD_FILE),
exit_file(EXIT_FILE),
macros, // scratch space for macros (may be given more than once)
xmacro;
bool interactive = true;
bool loadedDb = false;
bool ranScript = false;
while (argc>1 && **argv == '-') {
switch ((*argv)[1]) {
case 'a':
if (macros) asSetSubstitutions(macros);
asSetFilename(*++argv);
--argc;
break;
case 'd':
if (dbLoadRecords(*++argv, macros)) {
epicsExit(EXIT_FAILURE);
}
loadedDb = 1;
--argc;
break;
case 'h':
usage(EXIT_SUCCESS);
case 'm':
macros = *++argv;
--argc;
break;
case 'S':
startIocsh = 0;
break;
case 's':
break;
case 'x':
epicsSnprintf(xmacro, sizeof xmacro, "IOC=%s", *++argv);
if (dbLoadRecords(exit_db, xmacro)) {
epicsExit(EXIT_FAILURE);
}
loadedDb = 1;
--argc;
break;
default:
printf("%s: option '%s' not recognized\n", arg0, *argv);
usage(EXIT_FAILURE);
}
--argc;
++argv;
#ifdef USE_EXECDIR
// attempt to compute relative paths
{
std::string prefix;
char *cprefix = epicsGetExecDir();
if(cprefix) {
try {
prefix = cprefix;
free(cprefix);
} catch(...) {
free(cprefix);
throw;
}
}
dbd_file = prefix + DBD_FILE_REL;
exit_file = prefix + EXIT_FILE_REL;
}
#endif
int opt;
while ((opt = getopt(argc, argv, "ha:D:d:m:Ssx:G:v")) != -1) {
switch (opt) {
case 'h': /* Print usage */
usage(argv[0], dbd_file);
epicsExit(0);
return 0;
default:
usage(argv[0], dbd_file);
std::cerr<<"Unknown argument: -"<<char(opt)<<"\n";
epicsExit(2);
return 2;
case 'a':
lazy_dbd(dbd_file);
if (!macros.empty()) {
if (verbose)
std::cout<<"asSetSubstitutions(\""<<macros<<"\")\n";
if(asSetSubstitutions(macros.c_str()))
throw std::bad_alloc();
}
if (verbose)
std::cout<<"asSetFilename(\""<<optarg<<"\")\n";
if(asSetFilename(optarg))
throw std::bad_alloc();
break;
case 'D':
if(lazy_dbd_loaded) {
throw std::runtime_error("-D specified too late. softIocPVA.dbd already loaded.\n");
}
dbd_file = optarg;
break;
case 'd':
lazy_dbd(dbd_file);
if (verbose) {
std::cout<<"dbLoadRecords(\""<<optarg<<"\"";
if(!macros.empty())
std::cout<<", \""<<macros<<"\"";
std::cout<<")\n";
}
errIf(dbLoadRecords(optarg, macros.c_str()),
std::string("Failed to load: ")+optarg);
loadedDb = true;
break;
case 'm':
macros = optarg;
break;
case 'S':
interactive = false;
break;
case 's':
break; // historical
case 'v':
verbose = true;
break;
case 'x':
lazy_dbd(dbd_file);
xmacro = "IOC=";
xmacro += optarg;
errIf(dbLoadRecords(exit_file.c_str(), xmacro.c_str()),
std::string("Failed to load: ")+exit_file);
loadedDb = true;
break;
case 'G':
dbLoadGroup(optarg);
break;
}
}
lazy_dbd(dbd_file);
if(optind<argc) {
// run script
// ignore any extra positional args (historical)
if (verbose)
std::cout<<"# Begin "<<argv[optind]<<"\n";
errIf(iocsh(argv[optind]),
std::string("Error in ")+argv[optind]);
if (verbose)
std::cout<<"# End "<<argv[optind]<<"\n";
epicsThreadSleep(0.2);
ranScript = true; /* Assume the script has done any necessary initialization */
}
if (loadedDb) {
if (verbose)
std::cout<<"iocInit()\n";
iocInit();
epicsThreadSleep(0.2);
}
if(interactive) {
std::cout.flush();
std::cerr.flush();
if(iocsh(NULL)) {
epicsExit(1);
return 1;
}
} else {
if (loadedDb || ranScript) {
epicsThreadExitMain();
} else {
usage(argv[0], dbd_file);
std::cerr<<"Nothing to do!\n";
epicsExit(1);
return 1;
}
}
epicsExit(0);
return 0;
}catch(std::exception& e){
std::cerr<<"Error: "<<e.what()<<"\n";
epicsExit(2);
return 2;
}
if (argc>0 && **argv=='-') {
switch((*argv)[1]) {
case 'a':
case 'd':
case 'm':
case 'x':
printf("%s: missing argument to option '%s'\n", arg0, *argv);
usage(EXIT_FAILURE);
case 'h':
usage(EXIT_SUCCESS);
case 'S':
startIocsh = 0;
break;
case 's':
break;
default:
printf("%s: option '%s' not recognized\n", arg0, *argv);
usage(EXIT_FAILURE);
}
--argc;
++argv;
}
if (loadedDb) {
iocInit();
epicsThreadSleep(0.2);
}
/* run user's startup script */
if (argc>0) {
if (iocsh(*argv)) epicsExit(EXIT_FAILURE);
epicsThreadSleep(0.2);
loadedDb = 1; /* Give it the benefit of the doubt... */
}
/* start an interactive shell if it was requested */
if (startIocsh) {
iocsh(NULL);
} else {
if (loadedDb) {
epicsThreadExitMain();
} else {
printf("%s: Nothing to do!\n", arg0);
usage(EXIT_FAILURE);
}
}
epicsExit(EXIT_SUCCESS);
/*Note that the following statement will never be executed*/
return 0;
}
-2
View File
@@ -13,8 +13,6 @@
#include <pv/sharedPtr.h>
#include <shareLib.h>
struct WorkQueue : private epicsThreadRunable
{
typedef std::tr1::weak_ptr<epicsThreadRunable> value_type;
+4
View File
@@ -0,0 +1,4 @@
record (waveform, "TEST") {
field(FTVL, "SHORT")
field(NELM, "10")
}
+6 -5
View File
@@ -18,6 +18,7 @@ void test_parse()
" \"+atomic\":false,\n"
" \"fld\":{\n"
" \"+type\": \"simple\","
" \"+channel\": \"VAL\","
" \"+putorder\": -4"
" },\n"
" \"\":{\n"
@@ -29,7 +30,7 @@ void test_parse()
"}";
GroupConfig conf;
GroupConfig::parse(txt, conf);
GroupConfig::parse(txt, "rec", conf);
testOk(conf.warning.empty(), "Warnings: %s", conf.warning.c_str());
@@ -37,7 +38,7 @@ void test_parse()
testOk1(conf.groups["grpa"].atomic_set);
testEqual(conf.groups["grpa"].fields["fld"].type, "simple");
testEqual(conf.groups["grpa"].fields["fld"].channel, "");
testEqual(conf.groups["grpa"].fields["fld"].channel, "rec.VAL");
testEqual(conf.groups["grpa"].fields["fld"].putorder, -4);
testEqual(conf.groups["grpa"].fields[""].type, "top");
@@ -49,15 +50,15 @@ void test_fail()
{
GroupConfig conf;
testThrows(std::runtime_error, GroupConfig::parse("{", conf));
testThrows(std::runtime_error, GroupConfig::parse("{", "", conf));
}
{
GroupConfig conf;
testThrows(std::runtime_error, GroupConfig::parse("{\"G\":{\"F\":{\"K\":{}}}}", conf));
testThrows(std::runtime_error, GroupConfig::parse("{\"G\":{\"F\":{\"K\":{}}}}", "", conf));
}
{
GroupConfig conf;
testThrows(std::runtime_error, GroupConfig::parse("{\"G\":5}", conf));
testThrows(std::runtime_error, GroupConfig::parse("{\"G\":5}", "", conf));
}
}
+42 -1
View File
@@ -292,6 +292,45 @@ void testGroupMonitorTriggers(pvac::ClientProvider& client)
#endif
}
void testFilters(pvac::ClientProvider& client)
{
testDiag("test w/ server side filters");
pvd::shared_vector<const pvd::int16> expected;
{
pvd::shared_vector<pvd::int16> scratch(9);
scratch[0] = 9;
scratch[1] = 8;
scratch[2] = 7;
scratch[3] = 6;
scratch[4] = 5;
scratch[5] = 4;
scratch[6] = 3;
scratch[7] = 2;
scratch[8] = 1;
expected = pvd::freeze(scratch);
}
client.connect("TEST").put().set("value", expected).exec();
pvd::PVStructure::const_shared_pointer root(client.connect("TEST").get());
testFieldEqual<pvd::PVShortArray>(root, "value", expected);
root = client.connect("TEST.{\"arr\":{\"i\":2}}").get();
{
pvd::shared_vector<pvd::int16> scratch(5);
scratch[0] = 9;
scratch[1] = 7;
scratch[2] = 5;
scratch[3] = 3;
scratch[4] = 1;
expected = pvd::freeze(scratch);
}
testFieldEqual<pvd::PVShortArray>(root, "value", expected);
}
} // namespace
extern "C"
@@ -299,7 +338,7 @@ void p2pTestIoc_registerRecordDeviceDriver(struct dbBase *);
MAIN(testpdb)
{
testPlan(93);
testPlan(95);
try{
QSRVRegistrar_counters();
epics::RefSnapshot ref_before;
@@ -318,6 +357,7 @@ MAIN(testpdb)
#ifdef USE_MULTILOCK
testdbReadDatabase("testpdb-groups.db", NULL, NULL);
#endif
testdbReadDatabase("testfilters.db", NULL, NULL);
IOC.init();
@@ -333,6 +373,7 @@ MAIN(testpdb)
testSingleMonitor(client);
testGroupMonitor(client);
testGroupMonitorTriggers(client);
testFilters(client);
testEqual(epics::atomic::get(PDBProvider::num_instances), 1u);
}
+2 -2
View File
@@ -8,7 +8,7 @@ record(ai, "target:ai") {
}
record(int64in, "src:i1") {
field(INP, {pva:"target:i"})
field(INP, {"pva":"target:i"})
}
# used by testPut()
@@ -17,5 +17,5 @@ record(int64in, "target:i2") {
}
record(int64out, "src:o2") {
field(OUT, {pva:"target:i2"})
field(OUT, {"pva":"target:i2"})
}
+136 -48
View File
@@ -74,38 +74,56 @@ void testScalar()
testEqual(dbChannelFinalFieldType(chan_i64), DBR_INT64);
#endif
ScalarBuilder builder;
pvd::FieldConstPtr dtype_li(builder.dtype(chan_li));
pvd::PVStructurePtr root;
p2p::auto_ptr<PVIF> pvif_li;
#ifdef USE_INT64
pvd::FieldConstPtr dtype_i64(builder.dtype(chan_i64));
p2p::auto_ptr<PVIF> pvif_i64;
#endif
pvd::FieldConstPtr dtype_si(builder.dtype(chan_si));
pvd::FieldConstPtr dtype_ai(builder.dtype(chan_ai));
pvd::FieldConstPtr dtype_ai_rval(builder.dtype(chan_ai_rval));
pvd::FieldConstPtr dtype_mbbi(builder.dtype(chan_mbbi));
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li)
p2p::auto_ptr<PVIF> pvif_si;
p2p::auto_ptr<PVIF> pvif_ai;
p2p::auto_ptr<PVIF> pvif_ai_rval;
p2p::auto_ptr<PVIF> pvif_mbbi;
{
ScalarBuilder builder_li(chan_li);
#ifdef USE_INT64
->add("i64", dtype_i64)
ScalarBuilder builder_i64(chan_i64);
#endif
->add("si", dtype_si)
->add("ai", dtype_ai)
->add("ai_rval", dtype_ai_rval)
->add("mbbi", dtype_mbbi)
->createStructure());
ScalarBuilder builder_si(chan_si);
ScalarBuilder builder_ai(chan_ai);
ScalarBuilder builder_ai_rval(chan_ai_rval);
ScalarBuilder builder_mbbi(chan_mbbi);
pvd::PVStructurePtr root(pvd::getPVDataCreate()->createPVStructure(dtype_root));
pvd::FieldConstPtr dtype_li(builder_li.dtype());
#ifdef USE_INT64
pvd::FieldConstPtr dtype_i64(builder_i64.dtype());
#endif
pvd::FieldConstPtr dtype_si(builder_si.dtype());
pvd::FieldConstPtr dtype_ai(builder_ai.dtype());
pvd::FieldConstPtr dtype_ai_rval(builder_ai_rval.dtype());
pvd::FieldConstPtr dtype_mbbi(builder_mbbi.dtype());
p2p::auto_ptr<PVIF> pvif_li(builder.attach(chan_li, root, FieldName("li")));
#ifdef USE_INT64
p2p::auto_ptr<PVIF> pvif_i64(builder.attach(chan_i64, root, FieldName("i64")));
#endif
p2p::auto_ptr<PVIF> pvif_si(builder.attach(chan_si, root, FieldName("si")));
p2p::auto_ptr<PVIF> pvif_ai(builder.attach(chan_ai, root, FieldName("ai")));
p2p::auto_ptr<PVIF> pvif_ai_rval(builder.attach(chan_ai_rval, root, FieldName("ai_rval")));
p2p::auto_ptr<PVIF> pvif_mbbi(builder.attach(chan_mbbi, root, FieldName("mbbi")));
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li)
#ifdef USE_INT64
->add("i64", dtype_i64)
#endif
->add("si", dtype_si)
->add("ai", dtype_ai)
->add("ai_rval", dtype_ai_rval)
->add("mbbi", dtype_mbbi)
->createStructure());
root = pvd::getPVDataCreate()->createPVStructure(dtype_root);
pvif_li.reset(builder_li.attach(root, FieldName("li")));
#ifdef USE_INT64
pvif_i64.reset(builder_i64.attach(root, FieldName("i64")));
#endif
pvif_si.reset(builder_si.attach(root, FieldName("si")));
pvif_ai.reset(builder_ai.attach(root, FieldName("ai")));
pvif_ai_rval.reset(builder_ai_rval.attach(root, FieldName("ai_rval")));
pvif_mbbi.reset(builder_mbbi.attach(root, FieldName("mbbi")));
}
testShow()<<"Entire structure\n"<<root;
@@ -424,30 +442,37 @@ void testPlain()
DBCH chan_ai("test:ai");
DBCH chan_mbbi("test:mbbi");
p2p::auto_ptr<PVIFBuilder> builder;
pvd::PVStructurePtr root;
p2p::auto_ptr<PVIF> pvif_li;
p2p::auto_ptr<PVIF> pvif_si;
p2p::auto_ptr<PVIF> pvif_ai;
p2p::auto_ptr<PVIF> pvif_mbbi;
{
builder.reset(PVIFBuilder::create("plain"));
p2p::auto_ptr<PVIFBuilder> builder_li(PVIFBuilder::create("plain", chan_li));
p2p::auto_ptr<PVIFBuilder> builder_si(PVIFBuilder::create("plain", chan_si));
p2p::auto_ptr<PVIFBuilder> builder_ai(PVIFBuilder::create("plain", chan_ai));
p2p::auto_ptr<PVIFBuilder> builder_mbbi(PVIFBuilder::create("plain", chan_mbbi));
pvd::FieldConstPtr dtype_li(builder_li->dtype());
pvd::FieldConstPtr dtype_si(builder_si->dtype());
pvd::FieldConstPtr dtype_ai(builder_ai->dtype());
pvd::FieldConstPtr dtype_mbbi(builder_mbbi->dtype());
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li)
->add("si", dtype_si)
->add("ai", dtype_ai)
->add("mbbi", dtype_mbbi)
->createStructure());
root = pvd::getPVDataCreate()->createPVStructure(dtype_root);
pvif_li.reset(builder_li->attach(root, FieldName("li")));
pvif_si.reset(builder_si->attach(root, FieldName("si")));
pvif_ai.reset(builder_ai->attach(root, FieldName("ai")));
pvif_mbbi.reset(builder_mbbi->attach(root, FieldName("mbbi")));
}
pvd::FieldConstPtr dtype_li(builder->dtype(chan_li));
pvd::FieldConstPtr dtype_si(builder->dtype(chan_si));
pvd::FieldConstPtr dtype_ai(builder->dtype(chan_ai));
pvd::FieldConstPtr dtype_mbbi(builder->dtype(chan_mbbi));
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li)
->add("si", dtype_si)
->add("ai", dtype_ai)
->add("mbbi", dtype_mbbi)
->createStructure());
pvd::PVStructurePtr root(pvd::getPVDataCreate()->createPVStructure(dtype_root));
p2p::auto_ptr<PVIF> pvif_li(builder->attach(chan_li, root, FieldName("li")));
p2p::auto_ptr<PVIF> pvif_si(builder->attach(chan_si, root, FieldName("si")));
p2p::auto_ptr<PVIF> pvif_ai(builder->attach(chan_ai, root, FieldName("ai")));
p2p::auto_ptr<PVIF> pvif_mbbi(builder->attach(chan_mbbi, root, FieldName("mbbi")));
pvd::BitSet mask;
mask.clear();
@@ -521,11 +546,73 @@ void testPlain()
dbScanUnlock((dbCommon*)prec_mbbi);
}
void testFilters()
{
testDiag("testFilter");
#if EPICS_VERSION_INT < VERSION_INT(7, 0, 0, 0)
testSkip(5, "Needs Base >=7.0");
#else
TestIOC IOC;
testdbReadDatabase("p2pTestIoc.dbd", NULL, NULL);
p2pTestIoc_registerRecordDeviceDriver(pdbbase);
testdbReadDatabase("testfilters.db", NULL, NULL);
IOC.init();
static const epicsInt32 arr[] = {9, 8, 7, 6, 5, 4, 3, 2, 1};
testdbPutArrFieldOk("TEST", DBF_LONG, 9, arr);
#if EPICS_VERSION_INT > VERSION_INT(7, 0, 5, 0)
testdbGetArrFieldEqual("TEST", DBF_LONG, 10, 9, arr);
testdbGetArrFieldEqual("TEST.{\"arr\":{\"s\":5}}", DBF_LONG, 10, 4, arr+5);
static const epicsInt32 arr2[] = {9, 7, 5, 3, 1};
testdbGetArrFieldEqual("TEST.{\"arr\":{\"i\":2}}", DBF_LONG, 10, 5, arr2);
#else
testSkip(3, "dbUnitTest doesn't use dbChannel");
#endif
pvd::PVStructurePtr root;
p2p::auto_ptr<PVIF> pvif;
DBCH chan("TEST.{\"arr\":{\"i\":2}}");
ScalarBuilder builder(chan);
root = pvd::FieldBuilder::begin()
->add("dut", builder.dtype())
->createStructure()->build();
pvif.reset(builder.attach(root, FieldName("dut")));
LocalFL fl(0, chan.chan);
pvd::shared_vector<pvd::int16> scratch(5);
scratch[0] = 9;
scratch[1] = 7;
scratch[2] = 5;
scratch[3] = 3;
scratch[4] = 1;
pvd::shared_vector<const pvd::int16> expected(pvd::freeze(scratch));
dbCommon *prec = testdbRecordPtr("TEST");
dbScanLock(prec);
pvd::BitSet changed;
pvif->put(changed, DBE_VALUE, fl.pfl);
dbScanUnlock(prec);
testFieldEqual<pvd::PVShortArray>(root, "dut.value", expected);
#endif // >= 7.0
}
} // namespace
MAIN(testpvif)
{
testPlan(75
testPlan(80
#ifdef USE_INT64
+13
#endif
@@ -537,5 +624,6 @@ MAIN(testpvif)
#endif
testScalar();
testPlain();
testFilters();
return testDone();
}