added methods to show cache; tests moved to pvaClientTestCPP; doxygen changes

This commit is contained in:
Marty Kraimer
2015-06-26 07:05:41 -04:00
parent b1594e6b78
commit 87d5ca03f7
32 changed files with 605 additions and 1655 deletions

View File

@ -169,7 +169,7 @@ SHORT_NAMES = NO
# description.)
# The default value is: NO.
JAVADOC_AUTOBRIEF = NO
JAVADOC_AUTOBRIEF = YES
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If

View File

@ -3,10 +3,8 @@ TOP = .
include $(TOP)/configure/CONFIG
DIRS := $(DIRS) $(filter-out $(DIRS), configure)
DIRS := $(DIRS) $(filter-out $(DIRS), src)
DIRS := $(DIRS) $(filter-out $(DIRS), test)
DIRS := $(DIRS) $(filter-out $(DIRS), example)
EMBEDDED_TOPS := $(EMBEDDED_TOPS) $(filter-out $(EMBEDDED_TOPS), test)
EMBEDDED_TOPS := $(EMBEDDED_TOPS) $(filter-out $(EMBEDDED_TOPS), example)
define DIR_template
@ -19,7 +17,4 @@ define EMB_template
endef
$(foreach dir, $(EMBEDDED_TOPS),$(eval $(call EMB_template,$(dir))))
#exampleDatabase_DEPEND_DIRS += test
#examplePowerSupply_DEPEND_DIRS += test
include $(TOP)/configure/RULES_TOP

View File

@ -28,14 +28,16 @@
<h1>EPICS pvaClientCPP</h1>
<!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. -->
<h2 class="nocount">EPICS V4 Working Group, Working Draft,
29-May-2015</h2>
26-June-2015</h2>
<dl>
<dt>This version:</dt>
<dd><a
href="pvaClientCPP.html">pvaClientCPP.html
</a> </dd>
<dt>Latest version:</dt>
<dd>Still under revision</dd>
<dd><a
href="pvaClientCPP_20150626.html">pvaClientCPP_20150626.html
</a> </dd>
<dt>Previous version:</dt>
<dd><a
href="easyPVA_20150609.html">easyPVA_20150609.html</a>
@ -56,7 +58,6 @@ software support for high speed controls network communications used in EPICS ve
pvAccess provides a callback based interface, which can be hard to use.
pvaClient provides an interface that does not require callbacks even for monitors.
</p>
p>
pvaClientChannel provides many "convenience" methods to directly get and put
scalar and scalarArray data types.
Additional methods provide access to the full features of pvAccess.
@ -110,15 +111,20 @@ href="./html/index.html">doxygenDoc
</a>
</p>
<h2>Example Database</h2>
<p>The examples and tests require that an example pvAccess server is runnimg.
This distribution has a file <b>exampleDatabasePvaClient.zip</b>.
<p>The examples require that an example pvAccess server is runnimg.
To get the test database go to:</p>
<a
href="https://github.com/epics_base/pvaClientTestCPP/blob/master/database.zip">pvaClientTestCPP/database.zip
</a>
Then select "raw file" and You will be able to download the zip file.
<p>
When unzipped this is used to create an example IOC database.
</p>
<p>
After unzipping the file:
</p>
<pre>
cd configure
cd database/configure
cp ExampleRELEASE.local RELEASE.local
edit RELEASE.local
cd ..
@ -126,19 +132,13 @@ make
cd iocBoot/exampleDatabase
../../bin/&lt;arch:&gt;/exampleDatabase st.cmd
</pre>
<h2>Testing</h2>
<p>The tests will fail unless the example database is running.</p>
<p>Once it is running:</p>
<pre>
make runtests
</pre>
<h2>Examples</h2>
<p>Examples are in directory <b>pvaExample/src</b>.
<p>Examples are in directory <b>example/src</b>.
An example of how to run them is:</p>
<pre>
mrk&gt; pwd
/home/epicsv4/pvAccessCPP/pvaExample
mrk&gt; bin/linux-x86_64/examplepvaClientGet
/home/epicsv4/pvaClientCPP/example
mrk&gt; bin/linux-x86_64/examplePvaClientGet
</pre>
<p>The following is a brief description of each example.
In order to understand each example it

View File

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>EPICS pva</title>
<link rel="stylesheet" type="text/css"
href="http://epics-pvdata.sourceforge.net/base.css" />
<link rel="stylesheet" type="text/css"
href="http://epics-pvdata.sourceforge.net/epicsv4.css" />
<style type="text/css">
/*<![CDATA[*/
.about { margin-left: 3em; margin-right: 3em; font-size: .83em}
table { margin-left: auto; margin-right: auto }
.diagram { text-align: center; margin: 2.5em 0 }
body { margin-right: 10% }
/*]]>*/</style>
<!-- Script that generates the Table of Contents -->
<script type="text/javascript" src="http://epics-pvdata.sourceforge.net/script/tocgen.js"></script>
</head>
<body>
<div class="head">
<h1>EPICS pvaClientCPP</h1>
<!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. -->
<h2 class="nocount">EPICS V4 Working Group, Working Draft,
26-June-2015</h2>
<dl>
<dt>This version:</dt>
<dd><a
href="pvaClientCPP.html">pvaClientCPP.html
</a> </dd>
<dt>Latest version:</dt>
<dd><a
href="pvaClientCPP_20150626.html">pvaClientCPP_20150626.html
</a> </dd>
<dt>Previous version:</dt>
<dd><a
href="easyPVA_20150609.html">easyPVA_20150609.html</a>
</dd>
<dt>Editors:</dt>
<dd>Marty Kraimer, BNL</dd>
</dl>
<h2 class="nocount">Abstract</h2>
<p>pvaClient is a software library that provides to an EPICS client programmer, a friendly
client side programming interface to the data of an EPICS based control system. It is intended
for such uses as rapid development of ad hoc programs by controls engineers, or to provide
scientists a way to directly develop analytical applications.</p>
<p>Specifically, pvaClient provides a synchronous interface for pvAccess, which is the
software support for high speed controls network communications used in EPICS version 4.
pvAccess provides a callback based interface, which can be hard to use.
pvaClient provides an interface that does not require callbacks even for monitors.
</p>
pvaClientChannel provides many "convenience" methods to directly get and put
scalar and scalarArray data types.
Additional methods provide access to the full features of pvAccess.
</p>
<p>
pvaClientMultiChannel provides access to data from multiple channels.
It can be used directly by a client or via pvaClientMultiDouble or pvaClientNTMultiChannel.
pvaClientMultiDouble allows the client to get and put data to multiple channels.
But each channel must have a value field that is a numeric scalar.
pvaClientNTMultiChannel allows the client to get and put data to multiple channels.
Each channel must have a value field.
The data for the channels is presented via normative type NTMultiChannel.
</p>
<!-- last para of Abstract is boilerplate reference to EPICS -->
<p>For more information about EPICS generally, please refer to the home page of the <a
href="http://www.aps.anl.gov/epics/">Experimental Physics and Industrial
Control System</a>.</p>
<h2 class="nocount">Status of this Document and of the pvaClient Software</h2>
<p>pvaClientCPP is ready for use.</p>
</div> <!-- head -->
<div id="toc">
<h2 class="nocount">Table of Contents</h2>
</div>
<!-- Place what you would like in the Table of Contents, inside the contents div -->
<div id="contents" class="contents">
<hr />
<h2>Introduction</h2>
<p>pvaClient is a synchronous API for accessing PVData via PVAccess. It provides
an interface to many of the features provided by pvData and pvAccess.</p>
<p>This document describes the layout of the source files in this project.</p>
<p>
A user overview is available via
<a
href="./pvaClientOverview.html">pvaClientOverview.html
</a>
</p>
<p>
Doxygen documentation is available at
<a
href="./html/index.html">doxygenDoc
</a>
</p>
<h2>Example Database</h2>
<p>The examples require that an example pvAccess server is runnimg.
To get the test database go to:</p>
<a
href="https://github.com/epics_base/pvaClientTestCPP/blob/master/database.zip">pvaClientTestCPP/database.zip
</a>
Then select "raw file" and You will be able to download the zip file.
<p>
When unzipped this is used to create an example IOC database.
</p>
<p>
After unzipping the file:
</p>
<pre>
cd database/configure
cp ExampleRELEASE.local RELEASE.local
edit RELEASE.local
cd ..
make
cd iocBoot/exampleDatabase
../../bin/&lt;arch:&gt;/exampleDatabase st.cmd
</pre>
<h2>Examples</h2>
<p>Examples are in directory <b>example/src</b>.
An example of how to run them is:</p>
<pre>
mrk&gt; pwd
/home/epicsv4/pvaClientCPP/example
mrk&gt; bin/linux-x86_64/examplePvaClientGet
</pre>
<p>The following is a brief description of each example.
In order to understand each example it
helps to also look at the source for the example.</p>
<h2>examplePvaClientGet</h2>
<p>This has a number of examples:</p>
<dl>
<dt>exampleDouble</dt>
<dd>
This shows two methods for getting data from a channel that has a numeric
scalar value field.
</dd>
<dt>exampleDoubleArray</dt>
<dd>
This shows two methods for getting data from a channel that has a
double array value field.
</dd>
<dt>exampleCADouble</dt>
<dd>
This is like exampleDouble except it uses provider <b>ca</b>.
</dd>
<dt>exampleCADoubleArray</dt>
<dd>
This is like exampleDoubleArray except it uses provider <b>ca</b>.
</dd>
<dt>examplePowerSupply</dt>
<dd>
This is an example of getting data from a channel that does not
have a value field.
</dd>
</dl>
<h2>examplePvaClientMonitor</h2>
<p>This is an example of creating a monitor on a channel.
It monitors a channel that models a powerSupply, i. e. it is not a "standard" record.
It does not have a value field.
</p>
<p>After starting the example a change can be made to the powerSupply by issuing:</p>
<pre>
pvput -r "power.value,voltage.value" examplePowerSupply 6 6
</pre>
<h2>examplePvaClientPut</h2>
<p>This example gets and puts to channel exampleDouble.</p>
<h2>examplePvaClientProcess</h2>
<p>This example makes a process request to channel exampleDouble.</p>
<h2>helloWorldPutGet</h2>
<p>This is an example of issuing a channelPutGet.</p>
<h2>examplePvaClientMultiDouble</h2>
<p>This is an example of issuing gets and puts to multiple channels where each
channel has a numeric scalar value field.</p>
<h2>examplePvaClientNTMultiChannel</h2>
<p>This is an example of using NDMultiChannel to obtain data from multiple channels.
</p>
<h2>helloWorldRPC</h2>
<p>This is an example of issuing a channelRPC request.
It does <b>not</b> use pva.</p>
</div> <!-- class="contents" -->
</body>
</html>

View File

@ -84,8 +84,8 @@ PvaClientProcessPtr process = channel-&gt;createProcess();
process-&gt;process();
</pre>
<p><b>pvaExample</b> includes a number of examples.</p>
<p>pva does <b>not</b> provide support for:</p>
<p><b>pvClientCPP/example</b> includes a number of examples.</p>
<p>pvaClient does <b>not</b> provide support for:</p>
<dl>
<dt>ChannelArray</dt>
<dd>TBD</dd>
@ -103,7 +103,7 @@ PvaClientPtr pva = PvaClient::create();
<p>PvaClient has methods to create instances of <b>PvaClientChannel</b>.
The client can specify the provider name or use the default provider.
The client can manage it's own channels or can let pva cache channels.
The client can manage it's own channels or can let pvaClient cache channels.
An example of using the cached method is:</p>
<pre>
PvaClientChannelPtr pvaChannel = pva-&gt;channel("exampleDouble");

Binary file not shown.

View File

@ -78,32 +78,67 @@ public:
void destroy() {
pvaClientChannelMap.clear();
}
PvaClientChannelPtr getChannel(string const & channelName);
PvaClientChannelPtr getChannel(
string const & channelName,
string const & providerName);
void addChannel(PvaClientChannelPtr const & pvaClientChannel);
void removeChannel(string const & channelName);
void removeChannel(string const & channelName,string const & providerName);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientChannelPtr> pvaClientChannelMap;
};
PvaClientChannelPtr PvaClientChannelCache::getChannel(string const & channelName)
PvaClientChannelPtr PvaClientChannelCache::getChannel(
string const & channelName,
string const & providerName)
{
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(channelName);
string name = channelName + providerName;
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(name);
if(iter!=pvaClientChannelMap.end()) return iter->second;
return PvaClientChannelPtr();
}
void PvaClientChannelCache::addChannel(PvaClientChannelPtr const & pvaClientChannel)
{
Channel::shared_pointer channel = pvaClientChannel->getChannel();
string name = channel->getChannelName()
+ channel->getProvider()->getProviderName();
pvaClientChannelMap.insert(std::pair<string,PvaClientChannelPtr>(
pvaClientChannel->getChannelName(),pvaClientChannel));
name,pvaClientChannel));
}
void PvaClientChannelCache::removeChannel(string const & channelName)
void PvaClientChannelCache::removeChannel(
string const & channelName,
string const & providerName)
{
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(channelName);
string name = channelName + providerName;
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(name);
if(iter!=pvaClientChannelMap.end()) pvaClientChannelMap.erase(iter);
}
void PvaClientChannelCache::showCache()
{
map<string,PvaClientChannelPtr>::iterator iter;
for(iter = pvaClientChannelMap.begin(); iter != pvaClientChannelMap.end(); ++iter)
{
PvaClientChannelPtr pvaChannel = iter->second;
Channel::shared_pointer channel = pvaChannel->getChannel();
string channelName = channel->getChannelName();
string providerName = channel->getProvider()->getProviderName();
cout << "channel " << channelName << " provider " << providerName << endl;
cout << " get and put cacheSize " << pvaChannel->cacheSize() << endl;
pvaChannel->showCache();
}
}
size_t PvaClientChannelCache::cacheSize()
{
return pvaClientChannelMap.size();
}
using namespace epics::pvaClient::pvaClientPvt;
PvaClientPtr PvaClient::create()
@ -149,6 +184,10 @@ void PvaClient::destroy()
string PvaClient:: getRequesterName()
{
static string name("pvaClient");
RequesterPtr req = requester.lock();
if(req) {
return req->getRequesterName();
}
return name;
}
@ -156,6 +195,11 @@ void PvaClient::message(
string const & message,
MessageType messageType)
{
RequesterPtr req = requester.lock();
if(req) {
req->message(message,messageType);
return;
}
cout << getMessageTypeName(messageType) << " " << message << endl;
}
@ -164,7 +208,8 @@ PvaClientChannelPtr PvaClient::channel(
std::string const & providerName,
double timeOut)
{
PvaClientChannelPtr pvaClientChannel = pvaClientChannelCache->getChannel(channelName);
PvaClientChannelPtr pvaClientChannel =
pvaClientChannelCache->getChannel(channelName,providerName);
if(pvaClientChannel) return pvaClientChannel;
pvaClientChannel = createChannel(channelName,providerName);
pvaClientChannel->connect(timeOut);
@ -172,16 +217,32 @@ PvaClientChannelPtr PvaClient::channel(
return pvaClientChannel;
}
PvaClientChannelPtr PvaClient::createChannel(string const & channelName)
{
return PvaClientChannel::create(getPtrSelf(),channelName);
}
PvaClientChannelPtr PvaClient::createChannel(string const & channelName, string const & providerName)
{
return PvaClientChannel::create(getPtrSelf(),channelName,providerName);
}
void PvaClient::setRequester(RequesterPtr const & requester)
{
this->requester = requester;
}
void PvaClient::clearRequester()
{
requester = Requester::weak_pointer();
}
void PvaClient::showCache()
{
pvaClientChannelCache->showCache();
}
size_t PvaClient::cacheSize()
{
return pvaClientChannelCache->cacheSize();
}
PvaClientMultiChannelPtr PvaClient::createMultiChannel(
epics::pvData::PVStringArrayPtr const & channelNames)
{

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,8 @@ public:
}
PvaClientGetPtr getGet(string const & request);
void addGet(string const & request,PvaClientGetPtr const & pvaClientGet);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientGetPtr> pvaClientGetMap;
};
@ -58,6 +60,20 @@ void PvaClientGetCache::addGet(string const & request,PvaClientGetPtr const & pv
request,pvaClientGet));
}
void PvaClientGetCache::showCache()
{
map<string,PvaClientGetPtr>::iterator iter;
for(iter = pvaClientGetMap.begin(); iter != pvaClientGetMap.end(); ++iter)
{
cout << " " << iter->first << endl;
}
}
size_t PvaClientGetCache::cacheSize()
{
return pvaClientGetMap.size();
}
class PvaClientPutCache
{
@ -69,6 +85,8 @@ public:
}
PvaClientPutPtr getPut(string const & request);
void addPut(string const & request,PvaClientPutPtr const & pvaClientPut);
void showCache();
size_t cacheSize();
private:
map<string,PvaClientPutPtr> pvaClientPutMap;
};
@ -91,6 +109,21 @@ void PvaClientPutCache::addPut(string const & request,PvaClientPutPtr const & pv
request,pvaClientPut));
}
void PvaClientPutCache::showCache()
{
map<string,PvaClientPutPtr>::iterator iter;
for(iter = pvaClientPutMap.begin(); iter != pvaClientPutMap.end(); ++iter)
{
cout << " " << iter->first << endl;
}
}
size_t PvaClientPutCache::cacheSize()
{
return pvaClientPutMap.size();
}
class ChannelRequesterImpl : public ChannelRequester
{
PvaClientChannel *pvaClientChannel;
@ -482,6 +515,19 @@ PvaClientMonitorPtr PvaClientChannel::createMonitor(PVStructurePtr const & pvR
return PvaClientMonitor::create(yyy,getPtrSelf(),channel,pvRequest);
}
void PvaClientChannel::showCache()
{
cout << " pvaClientGet" << endl;
pvaClientGetCache->showCache();
cout << " pvaClientPut" << endl;
pvaClientPutCache->showCache();
}
size_t PvaClientChannel::cacheSize()
{
return pvaClientGetCache->cacheSize() + pvaClientPutCache->cacheSize();
}
PvaClientChannelPtr PvaClientChannel::create(
PvaClientPtr const &pvaClient,

View File

@ -169,7 +169,7 @@ Status PvaClientGet::waitConnect()
return Status::Ok;
}
connectState = connectIdle;
return Status(Status::STATUSTYPE_ERROR,channelGetConnectStatus.getMessage());
return channelGetConnectStatus;
}
void PvaClientGet::get()
@ -209,7 +209,7 @@ Status PvaClientGet::waitGet()
if(channelGetStatus.isOK()) {
return Status::Ok;
}
return Status(Status::STATUSTYPE_ERROR,channelGetStatus.getMessage());
return channelGetStatus;
}
PvaClientGetDataPtr PvaClientGet::getData()
{

View File

@ -38,6 +38,8 @@ static string noArray("value is not an array");
static string noScalarArray("value is not a scalarArray");
static string notDoubleArray("value is not a doubleArray");
static string notStringArray("value is not a stringArray");
static string noAlarm("no alarm");
static string noTimeStamp("no timeStamp");
PvaClientMonitorDataPtr PvaClientMonitorData::create(StructureConstPtr const & structure)
{
@ -223,4 +225,38 @@ shared_vector<const string> PvaClientMonitorData::getStringArray()
}
Alarm PvaClientMonitorData::getAlarm()
{
if(!pvStructure) {
throw std::runtime_error(messagePrefix + noAlarm);
}
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("alarm");
if(!pvs) throw std::runtime_error(messagePrefix + noAlarm);
pvAlarm.attach(pvs);
if(pvAlarm.isAttached()) {
Alarm alarm;
pvAlarm.get(alarm);
pvAlarm.detach();
return alarm;
}
throw std::runtime_error(messagePrefix + noAlarm);
}
TimeStamp PvaClientMonitorData::getTimeStamp()
{
if(!pvStructure) {
throw std::runtime_error(messagePrefix + noTimeStamp);
}
PVStructurePtr pvs = pvStructure->getSubField<PVStructure>("timeStamp");
if(!pvs) throw std::runtime_error(messagePrefix + noTimeStamp);
pvTimeStamp.attach(pvs);
if(pvTimeStamp.isAttached()) {
TimeStamp timeStamp;
pvTimeStamp.get(timeStamp);
pvTimeStamp.detach();
return timeStamp;
}
throw std::runtime_error(messagePrefix + noTimeStamp);
}
}}

View File

@ -23,8 +23,7 @@ namespace epics { namespace pvaClient {
class PvaClientMultiDouble;
typedef std::tr1::shared_ptr<PvaClientMultiDouble> PvaClientMultiDoublePtr;
/**
* @brief Support for multiple channels where each channel has a value field that is a scalar double.
/** Support for multiple channels where each channel has a value field that is a scalar double.
* If any problems arise an exception is thrown.
*
* @author mrk
@ -33,8 +32,7 @@ class epicsShareClass PvaClientMultiDouble
{
public:
POINTER_DEFINITIONS(PvaClientMultiDouble);
/**
* @brief Create a PvaClientMultiDouble.
/** Create a PvaClientMultiDouble.
* @param &pvaClient Interface to PvaClient
* @param channelName PVStringArray of channelNames.
* @param timeout The timeout in seconds for connecting.
@ -46,21 +44,17 @@ public:
epics::pvData::PVStringArrayPtr const & channelName,
double timeout = 5.0,
std::string const & providerName = "pva");
/**
* @brief destructor
/** Destructor
*/
~PvaClientMultiDouble();
/**
* @brief destroy any resources used.
/** Destroy all resources used.
*/
void destroy();
/**
* @brief get the value of all the channels.
/** Get the value of all the channels.
* @return The data.
*/
epics::pvData::shared_vector<double> get();
/**
* @brief put a new value to each channel.
/** Put a new value to each channel.
* @param value The data.
*/
void put(epics::pvData::shared_vector<double> const &value);

View File

@ -23,8 +23,7 @@ namespace epics { namespace pvaClient {
class PvaClientNTMultiChannel;
typedef std::tr1::shared_ptr<PvaClientNTMultiChannel> PvaClientNTMultiChannelPtr;
/**
* @brief Support for multiple channels where each channel has a value field that
/** Support for multiple channels where each channel has a value field that
* is a scalar, scalarArray, or enumerated structure.
* The data is provided via normativeType NTMultiChannel.
* If any problems arise an exception is thrown.
@ -35,8 +34,7 @@ class epicsShareClass PvaClientNTMultiChannel
{
public:
POINTER_DEFINITIONS(PvaClientNTMultiChannel);
/**
* @brief Create a PvaClientNTMultiChannel.
/** Create a PvaClientNTMultiChannel.
* @param &pvaClient Interface to PvaClient
* @param channelName PVStringArray of channelNames.
* @param structure valid NTMultiChannel structure.
@ -50,26 +48,21 @@ public:
epics::pvData::StructureConstPtr const & structure,
double timeout = 5.0,
std::string const & providerName = "pva");
/**
* @brief destructor
/** Destructor
*/
~PvaClientNTMultiChannel();
/**
* @brief destroy any resources used.
/** Destroy all resources used.
*/
void destroy();
/**
* @brief get the value of all the channels.
/** Get the value of all the channels.
* @return The data.
*/
epics::nt::NTMultiChannelPtr get();
/**
* @brief put a new value to each channel.
/** Put a new value to each channel.
* @param value The data.
*/
void put(epics::nt::NTMultiChannelPtr const &value);
/**
* @brief Get the PvaClientMultiChannel.
/** Get the PvaClientMultiChannel.
* @return The interface.
*/
PvaClientMultiChannelPtr getPvaClientMultiChannel();

View File

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

View File

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

View File

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

View File

@ -1,7 +0,0 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
EASYPVA==${EPICSV4HOME}/easyPVACPP

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,57 +0,0 @@
# Makefile for the pvAccess tests
TOP = ..
include $(TOP)/configure/CONFIG
TESTPROD_HOST += pvaClientTestPutData
pvaClientTestPutData_SRCS = pvaClientTestPutData
testHarness_SRCS += pvaClientTestPutData.cpp
TESTS += pvaClientTestPutData
TESTPROD_HOST += pvaClientTestGetData
pvaClientTestGetData_SRCS = pvaClientTestGetData
testHarness_SRCS += pvaClientTestGetData.cpp
TESTS += pvaClientTestGetData
TESTPROD_HOST += pvaClientTestMonitorData
pvaClientTestMonitorData_SRCS = pvaClientTestMonitorData
testHarness_SRCS += pvaClientTestMonitorData.cpp
TESTS += pvaClientTestMonitorData
TESTPROD_HOST += pvaClientTestPutGetMonitor
pvaClientTestPutGetMonitor_SRCS = pvaClientTestPutGetMonitor
testHarness_SRCS += pvaClientTestPutGetMonitor.cpp
TESTS += pvaClientTestPutGetMonitor
TESTPROD_HOST += pvaClientTestPutGet
pvaClientTestPutGet_SRCS = pvaClientTestPutGet
testHarness_SRCS += pvaClientTestPutGet.cpp
TESTS += pvaClientTestPutGet
TESTPROD_HOST += pvaClientTestMultiDouble
pvaClientTestMultiDouble_SRCS = pvaClientTestMultiDouble
testHarness_SRCS += pvaClientTestMultiDouble.cpp
TESTS += pvaClientTestMultiDouble
TESTPROD_HOST += pvaClientTestNTMultiChannel
pvaClientTestNTMultiChannel_SRCS = pvaClientTestNTMultiChannel
testHarness_SRCS += pvaClientTestNTMultiChannel.cpp
TESTS += pvaClientTestNTMultiChannel
PROD_LIBS += pvaClient pvAccess pvData nt Com
testHarness_SRCS += pvaClientAllTests.c
PROD_vxWorks = vxTestHarness
vxTestHarness_SRCS += $(testHarness_SRCS)
TESTSPEC_vxWorks = vxTestHarness.$(MUNCH_SUFFIX); pvaClientAllTests
PROD_RTEMS += rtemsTestHarness
rtemsTestHarness_SRCS += rtemsTestHarness.c rtemsConfig.c
rtemsTestHarness_SRCS += $(testHarness_SRCS)
TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); pvaClientAllTests
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
include $(TOP)/configure/RULES

View File

@ -1,31 +0,0 @@
/*
* Run pvaClient tests as a batch.
*
* Do *not* include performance measurements here, they don't help to
* prove functionality (which is the point of this convenience routine).
*/
#include <stdio.h>
#include <epicsThread.h>
#include <epicsUnitTest.h>
int pvaClientTestGetData(void);
int pvaClientTestPutData(void);
int pvaClientTestMonitorData(void);
int pvaClientTestPutGetMonitor(void);
int pvaClientTestPutGet(void);
int pvaClientTestMultiDouble(void);
int pvaClientTestNTMultiChannel(void);
void easyAllTests(void)
{
testHarness();
runTest(pvaClientTestGetData);
runTest(pvaClientTestPutData);
runTest(pvaClientTestMonitorData);
runTest(pvaClientTestPutMonitor);
runTest(pvaClientTestPut);
runTest(pvaClientTestMultiDouble);
runTest(pvaClientTestNTMultiChannel);
}

View File

@ -1,155 +0,0 @@
/*pvaClientTestGetData.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/pvaClient.h>
#include <pv/bitSet.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
static PvaClientPtr pvaClient = PvaClient::create();
static FieldCreatePtr fieldCreate = getFieldCreate();
static StandardFieldPtr standardField = getStandardField();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
void testDouble()
{
cout << "\nstarting testDouble\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
add("value",pvDouble) ->
createStructure();
PvaClientGetDataPtr pvaData = PvaClientGetData::create(structure);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pvaData->getStructure());
BitSetPtr bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields()));
pvaData->setData(pvStructure,bitSet);
PVDoublePtr pvDouble = pvStructure->getSubField<PVDouble>("value");
size_t valueOffset = pvDouble->getFieldOffset();
BitSetPtr change = pvaData->getBitSet();
pvDouble->put(5.0);
change->set(pvDouble->getFieldOffset());
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==true,"isValueScalar");
testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getScalarValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getArrayValue();
} catch (std::runtime_error e) {
cout << "getArrayValue " << e.what() << endl;
}
try {
pvaData->getScalarArrayValue();
} catch (std::runtime_error e) {
cout << " getScalarArrayValue " << e.what() << endl;
}
cout << "as double " << pvaData->getDouble() << endl;
cout << "as string " << pvaData->getString() << endl;
try {
shared_vector<const double> value = pvaData->getDoubleArray();
} catch (std::runtime_error e) {
cout << " getDoubleArray " << e.what() << endl;
}
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
}
void testDoubleArray()
{
cout << "\nstarting testDoubleArray\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addArray("value",pvDouble) ->
createStructure();
PvaClientGetDataPtr pvaData = PvaClientGetData::create(structure);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(pvaData->getStructure());
BitSetPtr bitSet = BitSetPtr(new BitSet(pvStructure->getNumberFields()));
pvaData->setData(pvStructure,bitSet);
PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField<PVDoubleArray>("value");
BitSetPtr change = pvaData->getBitSet();
size_t valueOffset = pvalue->getFieldOffset();
size_t len = 5;
shared_vector<double> value(len);
for(size_t i=0; i<len; ++i) value[i] = i*10.0;
pvalue->replace(freeze(value));
change->set(valueOffset);
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==false,"isValueScalar");
testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getArrayValue()) result = true;
testOk(result==true,"getArrayValue");
result = false;
if(pvaData->getScalarArrayValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getScalarValue();
} catch (std::runtime_error e) {
cout << " getScalarValue " << e.what() << endl;
}
try {
cout << "as double " << pvaData->getDouble() << endl;
} catch (std::runtime_error e) {
cout << " getDouble " << e.what() << endl;
}
try {
string val = pvaData->getString();
} catch (std::runtime_error e) {
cout << " getString " << e.what() << endl;
}
cout << "as doubleArray " << pvaData->getDoubleArray() << endl;
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
}
MAIN(pvaClientTestGetData)
{
cout << "\nstarting pvaClientTestGetData\n";
testPlan(15);
testDouble();
testDoubleArray();
return 0;
}

View File

@ -1,153 +0,0 @@
/*pvaClientTestMonitorData.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/pvaClient.h>
#include <pv/bitSet.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
static PvaClientPtr pvaClient = PvaClient::create();
static FieldCreatePtr fieldCreate = getFieldCreate();
static StandardFieldPtr standardField = getStandardField();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
void testDouble()
{
cout << "\nstarting testDouble\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
add("value",pvDouble) ->
createStructure();
PvaClientMonitorDataPtr pvaData = PvaClientMonitorData::create(structure);
MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(pvaData->getStructure())));
pvaData->setData(monitorElement);
PVDoublePtr pvDouble = pvaData->getPVStructure()->getSubField<PVDouble>("value");
size_t valueOffset = pvDouble->getFieldOffset();
BitSetPtr change = pvaData->getChangedBitSet();
pvDouble->put(5.0);
change->set(pvDouble->getFieldOffset());
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==true,"isValueScalar");
testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getScalarValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getArrayValue();
} catch (std::runtime_error e) {
cout << "getArrayValue " << e.what() << endl;
}
try {
pvaData->getScalarArrayValue();
} catch (std::runtime_error e) {
cout << " getScalarArrayValue " << e.what() << endl;
}
cout << "as double " << pvaData->getDouble() << endl;
cout << "as string " << pvaData->getString() << endl;
try {
shared_vector<const double> value = pvaData->getDoubleArray();
} catch (std::runtime_error e) {
cout << " getDoubleArray " << e.what() << endl;
}
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
}
void testDoubleArray()
{
cout << "\nstarting testDoubleArray\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addArray("value",pvDouble) ->
createStructure();
PvaClientMonitorDataPtr pvaData = PvaClientMonitorData::create(structure);
MonitorElementPtr monitorElement(new MonitorElement(pvDataCreate->createPVStructure(pvaData->getStructure())));
pvaData->setData(monitorElement);
PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField<PVDoubleArray>("value");
BitSetPtr change = pvaData->getChangedBitSet();
size_t valueOffset = pvalue->getFieldOffset();
size_t len = 5;
shared_vector<double> value(len);
for(size_t i=0; i<len; ++i) value[i] = i*10.0;
pvalue->replace(freeze(value));
change->set(valueOffset);
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==false,"isValueScalar");
testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getArrayValue()) result = true;
testOk(result==true,"getArrayValue");
result = false;
if(pvaData->getScalarArrayValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getScalarValue();
} catch (std::runtime_error e) {
cout << " getScalarValue " << e.what() << endl;
}
try {
cout << "as double " << pvaData->getDouble() << endl;
} catch (std::runtime_error e) {
cout << " getDouble " << e.what() << endl;
}
try {
string val = pvaData->getString();
} catch (std::runtime_error e) {
cout << " getString " << e.what() << endl;
}
cout << "as doubleArray " << pvaData->getDoubleArray() << endl;
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
}
MAIN(pvaClientTestMonitorData)
{
cout << "\nstarting pvaClientTestMonitorData\n";
testPlan(15);
testDouble();
testDoubleArray();
return 0;
}

View File

@ -1,156 +0,0 @@
/*pvaClientTestMultiDouble.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/pvaClientMultiDouble.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
static void testGood(PvaClientPtr const &pvaClient)
{
bool isOk = true;
cout << "\nstarting testGood\n";
try {
PvaClientPtr pvaClient(PvaClient::create());
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "exampleDouble01";
channelNames[1] = "exampleDouble02";
channelNames[2] = "exampleDouble03";
channelNames[3] = "exampleDouble04";
channelNames[4] = "exampleDouble05";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames));
shared_vector<double> data = multiDouble->get();
cout << "initial " << data << endl;
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
multiDouble->put(data);
data = multiDouble->get();
cout << "final " << data << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
isOk = false;
}
testOk(isOk==true,"all channels double");
}
static void testGoodMixed(PvaClientPtr const &pvaClient)
{
bool isOk = true;
cout << "\nstarting testGoodMixed\n";
try {
PvaClientPtr pvaClient(PvaClient::create());
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "exampleByte";
channelNames[1] = "exampleShort";
channelNames[2] = "exampleInt";
channelNames[3] = "exampleFloat";
channelNames[4] = "exampleDouble";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames));
shared_vector<double> data = multiDouble->get();
cout << "initial " << data << endl;
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
multiDouble->put(data);
data = multiDouble->get();
cout << "final " << data << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
isOk = false;
}
testOk(isOk==true,"channels mixed type");
}
static void testChannelNotExist(PvaClientPtr const &pvaClient)
{
bool isOk = true;
cout << "\nstarting testChannelNotExist\n";
try {
PvaClientPtr pvaClient(PvaClient::create());
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "exampleDouble01";
channelNames[1] = "exampleDouble02";
channelNames[2] = "exampleDouble03";
channelNames[3] = "NoneExistChannel";
channelNames[4] = "exampleDouble05";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames));
shared_vector<double> data = multiDouble->get();
cout << "initial " << data << endl;
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
multiDouble->put(data);
data = multiDouble->get();
cout << "final " << data << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
isOk = false;
}
testOk(isOk==false,"channel not exist");
}
static void testNonNumeric(PvaClientPtr const &pvaClient)
{
bool isOk = true;
cout << "\nstarting testNonNumeric\n";
try {
PvaClientPtr pvaClient(PvaClient::create());
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "exampleDouble01";
channelNames[1] = "exampleDouble02";
channelNames[2] = "exampleDouble03";
channelNames[3] = "exampleDouble04";
channelNames[4] = "exampleDouble05Array";
PVStringArrayPtr pvNames =
getPVDataCreate()->createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
PvaClientMultiDoublePtr multiDouble(PvaClientMultiDouble::create(pvaClient,pvNames));
shared_vector<double> data = multiDouble->get();
cout << "initial " << data << endl;
for(size_t i=0; i<num; ++i) data[i] = data[i] + 1.1;
multiDouble->put(data);
data = multiDouble->get();
cout << "final " << data << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
isOk = false;
}
testOk(isOk==false,"channel not numeric");
}
MAIN(pvaClientTestMultiDouble)
{
cout << "\nstarting pvaClientTestMultiDouble\n";
testPlan(4);
PvaClientPtr pvaClient = PvaClient::create();
testGood(pvaClient);
testGoodMixed(pvaClient);
testChannelNotExist(pvaClient);
testNonNumeric(pvaClient);
cout << "done\n";
return 0;
}

View File

@ -1,132 +0,0 @@
/*pvaClientTestNTMultiChannel.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/pvaClientNTMultiChannel.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
using namespace epics::nt;
using std::tr1::static_pointer_cast;
static void testGood(PvaClientPtr const &pvaClient)
{
PVDataCreatePtr pvDataCreate(getPVDataCreate());
bool isOk = true;
cout << "\nstarting testGood\n";
try {
PvaClientPtr pvaClient(PvaClient::create());
size_t num = 5;
shared_vector<string> channelNames(num);
channelNames[0] = "exampleDouble";
channelNames[1] = "exampleDoubleArray";
channelNames[2] = "exampleString";
channelNames[3] = "exampleBoolean";
channelNames[4] = "exampleEnum";
PVStringArrayPtr pvNames = pvDataCreate->
createPVScalarArray<PVStringArray>();
pvNames->replace(freeze(channelNames));
NTMultiChannelBuilderPtr builder = NTMultiChannel::createBuilder();
StructureConstPtr structure = builder->
addTimeStamp()->
addSeverity() ->
addStatus() ->
addMessage() ->
addSecondsPastEpoch() ->
addNanoseconds() ->
addUserTag() ->
createStructure();
PvaClientNTMultiChannelPtr multi = PvaClientNTMultiChannel::create(
pvaClient,pvNames,structure);
NTMultiChannelPtr nt = multi->get();
for(size_t numtimes=0; numtimes<3; ++numtimes) {
PVUnionArrayPtr pvValue = nt->getPVStructure()->
getSubField<PVUnionArray>("value");
cout << "initial\n" << nt->getPVStructure() << endl;
shared_vector<PVUnionPtr> valueVector = pvValue->reuse();
for(size_t i=0; i<num; ++i)
{
PVFieldPtr pvField = valueVector[i]->get();
Type type = pvField->getField()->getType();
if(type==scalar) {
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
ScalarType scalarType = pvScalar->getScalar()->getScalarType();
if(ScalarTypeFunc::isNumeric(scalarType)) {
double oldValue = pvScalar->getAs<double>();
oldValue++;
pvScalar->putFrom<double>(oldValue);
} else if(scalarType==pvString) {
PVStringPtr pv = static_pointer_cast<PVString>(pvField);
string val = pv->get();
val += " added";
pv->put(val);
} else if(scalarType==pvBoolean) {
PVBooleanPtr pv = static_pointer_cast<PVBoolean>(pvField);
bool val = pv->get();
pv->put(!val);
}
} else if(type==scalarArray) {
PVScalarArrayPtr pv =
static_pointer_cast<PVScalarArray>(pvField);
ScalarType scalarType = pv->getScalarArray()->getElementType();
if(scalarType==pvDouble) {
PVDoubleArrayPtr pvd = static_pointer_cast<PVDoubleArray>(pv);
shared_vector<double> valvec = pvd->reuse();
if(valvec.capacity()==0) {
valvec.resize(4);
for(size_t i=0; i<valvec.size(); ++i) valvec[i] = i;
}
for(size_t i=0; i<valvec.size(); ++i) valvec[i] = valvec[i] + 1.0;
pvd->replace(freeze(valvec));
}
} else if(type==epics::pvData::structure) {
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
PVIntPtr pv = pvStructure->getSubField<PVInt>("index");
if(pv) {
PVStringArrayPtr choices = pvStructure->getSubField<PVStringArray>("choices");
if(choices) {
int32 nchoices = choices->getLength();
int32 oldval = pv->get();
int32 newval = (oldval==nchoices) ? 0 : ++oldval;
pv->put(newval);
}
}
}
}
pvValue->replace(freeze(valueVector));
multi->put(nt);
nt = multi->get();
}
cout << "final\n" << nt->getPVStructure() << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
isOk = false;
}
testOk(isOk==true,"no problems");
}
MAIN(pvaClientTestNTMultiChannel)
{
cout << "\nstarting pvaClientTestNTMultiChannel\n";
testPlan(1);
PvaClientPtr pvaClient = PvaClient::create();
testGood(pvaClient);
cout << "done\n";
return 0;
}

View File

@ -1,229 +0,0 @@
/*pvaClientTestPutData.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/pvaClient.h>
#include <pv/bitSet.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
static PvaClientPtr pvaClient = PvaClient::create();
static FieldCreatePtr fieldCreate = getFieldCreate();
static StandardFieldPtr standardField = getStandardField();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static void testPostPut()
{
cout << "\nstarting testPostPut\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addNestedStructure("power") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("voltage") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
addNestedStructure("current") ->
add("value",pvDouble) ->
add("alarm",standardField->alarm()) ->
endNested()->
createStructure();
PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure);
PVStructurePtr pvStructure = pvaData->getPVStructure();
BitSetPtr change = pvaData->getBitSet();
PVDoublePtr powerValue = pvStructure->getSubField<PVDouble>("power.value");
PVDoublePtr voltageValue = pvStructure->getSubField<PVDouble>("voltage.value");
PVDoublePtr currentValue = pvStructure->getSubField<PVDouble>("current.value");
size_t powerOffset = powerValue->getFieldOffset();
size_t voltageOffset = voltageValue->getFieldOffset();
size_t currentOffset = currentValue->getFieldOffset();
change->clear();
powerValue->put(1.0);
voltageValue->put(2.0);
currentValue->put(.5);
cout << "changed\n";
cout << pvaData->showChanged(cout) << endl;
testOk(change->cardinality()==3,"num set bits 3");
testOk(change->get(powerOffset)==true,"power changed");
testOk(change->get(voltageOffset)==true,"voltage changed");
testOk(change->get(currentOffset)==true,"current changed");
}
void testDouble()
{
cout << "\nstarting testDouble\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
add("value",pvDouble) ->
createStructure();
PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure);
PVDoublePtr pvDouble = pvaData->getPVStructure()->getSubField<PVDouble>("value");
pvDouble->put(5.0);
BitSetPtr change = pvaData->getBitSet();
size_t valueOffset = pvDouble->getFieldOffset();
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==true,"isValueScalar");
testOk(pvaData->isValueScalarArray()==false,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getScalarValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getArrayValue();
} catch (std::runtime_error e) {
cout << "getArrayValue " << e.what() << endl;
}
try {
pvaData->getScalarArrayValue();
} catch (std::runtime_error e) {
cout << " getScalarArrayValue " << e.what() << endl;
}
cout << "as double " << pvaData->getDouble() << endl;
cout << "as string " << pvaData->getString() << endl;
try {
shared_vector<const double> value = pvaData->getDoubleArray();
} catch (std::runtime_error e) {
cout << " getDoubleArray " << e.what() << endl;
}
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
pvaData->putDouble(5.0);
pvaData->putString("1e5");
try {
size_t len = 2;
shared_vector<double> val(len);
for(size_t i=0; i<len; ++i) val[i] = (i+1)*10.0;
pvaData->putDoubleArray(freeze(val));
} catch (std::runtime_error e) {
cout << " putDoubleArray " << e.what() << endl;
}
try {
size_t len = 2;
shared_vector<string> val(len);
val[0] = "one"; val[1] = "two";
pvaData->putStringArray(freeze(val));
} catch (std::runtime_error e) {
cout << " putStringArray " << e.what() << endl;
}
}
void testDoubleArray()
{
cout << "\nstarting testDoubleArray\n";
StructureConstPtr structure =
fieldCreate->createFieldBuilder()->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
addArray("value",pvDouble) ->
createStructure();
PvaClientPutDataPtr pvaData = PvaClientPutData::create(structure);
PVDoubleArrayPtr pvalue = pvaData->getPVStructure()->getSubField<PVDoubleArray>("value");
size_t len = 5;
shared_vector<double> value(len);
for(size_t i=0; i<len; ++i) value[i] = i*10.0;
pvalue->replace(freeze(value));
BitSetPtr change = pvaData->getBitSet();
size_t valueOffset = pvalue->getFieldOffset();
testOk(change->cardinality()==1,"num set bits 1");
testOk(change->get(valueOffset)==true,"value changed");
testOk(pvaData->hasValue()==true,"hasValue");
testOk(pvaData->isValueScalar()==false,"isValueScalar");
testOk(pvaData->isValueScalarArray()==true,"isValueScalarArray");
bool result;
result = false;
if(pvaData->getValue()) result = true;
testOk(result==true,"getValue");
result = false;
if(pvaData->getArrayValue()) result = true;
testOk(result==true,"getArrayValue");
result = false;
if(pvaData->getScalarArrayValue()) result = true;
testOk(result==true,"getScalarValue");
try {
pvaData->getScalarValue();
} catch (std::runtime_error e) {
cout << " getScalarValue " << e.what() << endl;
}
try {
cout << "as double " << pvaData->getDouble() << endl;
} catch (std::runtime_error e) {
cout << " getDouble " << e.what() << endl;
}
try {
string val = pvaData->getString();
} catch (std::runtime_error e) {
cout << " getString " << e.what() << endl;
}
cout << "as doubleArray " << pvaData->getDoubleArray() << endl;
try {
shared_vector<const string> value = pvaData->getStringArray();
} catch (std::runtime_error e) {
cout << " getStringArray " << e.what() << endl;
}
try {
pvaData->putDouble(5.0);
} catch (std::runtime_error e) {
cout << " putDouble " << e.what() << endl;
}
try {
pvaData->putString("1e5");
} catch (std::runtime_error e) {
cout << " putString " << e.what() << endl;
}
value = shared_vector<double>(len);
for(size_t i=0; i<len; ++i) value[i] = (i+1)* 2;
pvaData->putDoubleArray(freeze(value));
cout << "as doubleArray " << pvaData->getDoubleArray() << endl;
try {
size_t len = 2;
shared_vector<string> val(len);
val[0] = "one"; val[1] = "two";
pvaData->putStringArray(freeze(val));
cout << "as stringArray " << val << endl;
} catch (std::runtime_error e) {
cout << " putStringArray " << e.what() << endl;
}
}
MAIN(pvaClientTestPutData)
{
cout << "\nstarting pvaClientTestPutData\n";
testPlan(19);
testPostPut();
testDouble();
testDoubleArray();
return 0;
}

View File

@ -1,70 +0,0 @@
/*pvaClientTestPutGet.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/pvaClient.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
static void example(PvaClientPtr const &pvaClient)
{
cout << "\nstarting channelPutGet example\n";
try {
cout << "calling createChannel\n";
PvaClientChannelPtr pvaChannel = pvaClient->createChannel("examplePowerSupply");
cout << "calling connect\n";
pvaChannel->connect(2.0);
testOk(true==true,"connected");
cout << "calling createPutGet\n";
PvaClientPutGetPtr putGet = pvaChannel->createPutGet(
"putField(power.value,voltage.value)getField()");
cout << "calling getPutData\n";
PvaClientPutDataPtr putData = putGet->getPutData();
testOk(true==true,"put connected");
PVStructurePtr pvStructure = putData->getPVStructure();
PVDoublePtr power = pvStructure->getSubField<PVDouble>("power.value");
PVDoublePtr voltage = pvStructure->getSubField<PVDouble>("voltage.value");
power->put(5.0);
voltage->put(5.0);
putGet->putGet();
PvaClientGetDataPtr getData = putGet->getGetData();
pvStructure = getData->getPVStructure();
BitSetPtr bitSet = getData->getBitSet();
cout << "changed " << getData->showChanged(cout) << endl;
cout << "bitSet " << *bitSet << endl;
power->put(6.0);
putGet->putGet();
pvStructure = getData->getPVStructure();
bitSet = getData->getBitSet();
cout << "changed " << getData->showChanged(cout) << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
MAIN(pvaClientTestPutGet)
{
cout << "\nstarting pvaClientTestPutGet\n";
testPlan(2);
PvaClientPtr pvaClient = PvaClient::create();
example(pvaClient);
cout << "done\n";
return 0;
}

View File

@ -1,89 +0,0 @@
/*pvaClientTestPutGetMonitor.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <iostream>
#include <pv/pvaClient.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace std;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
class MyMonitor : public PvaClientMonitorRequester
{
public:
MyMonitor() {}
virtual ~MyMonitor() {}
virtual void event(PvaClientMonitorPtr monitor)
{
while(true) {
if(!monitor->poll()) return;
PvaClientMonitorDataPtr pvaData = monitor->getData();
cout << "changed\n";
pvaData->showChanged(cout);
cout << "overrun\n";
pvaData->showOverrun(cout);
monitor->releaseEvent();
}
}
};
static void exampleDouble(PvaClientPtr const &pvaClient)
{
cout << "\nstarting exampleDouble\n";
try {
cout << "long way\n";
PvaClientChannelPtr pvaChannel = pvaClient->createChannel("exampleDouble");
pvaChannel->connect(2.0);
testOk(true==true,"connected");
PvaClientPutPtr put = pvaChannel->createPut();
PvaClientPutDataPtr putData = put->getData();
testOk(true==true,"put connected");
PvaClientGetPtr get = pvaChannel->createGet();
PvaClientGetDataPtr getData = get->getData();
testOk(true==true,"get connected");
PvaClientMonitorRequesterPtr requester(new MyMonitor());
PvaClientMonitorPtr monitor = pvaChannel->monitor(requester);
testOk(true==true,"monitor connected");
double out;
double in;
for(size_t i=0 ; i< 5; ++i) {
out = i;
putData->putDouble(out);
put->put();
get->get();
in = getData->getDouble();
cout << "out " << out << " in " << in << endl;
}
PvaClientProcessPtr process = pvaChannel->createProcess();
process->connect();
process->process();
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
MAIN(pvaClientTestPutGetMonitor)
{
cout << "\nstarting pvaClientTestPutGetMonitor\n";
testPlan(4);
PvaClientPtr pvaClient = PvaClient::create();
exampleDouble(pvaClient);
cout << "done\n";
return 0;
}