33 Commits

Author SHA1 Message Date
Ralph Lange
5f8fa26bf3 jenkins: Fix CloudBees hgweb job 2013-06-19 18:11:04 +02:00
Ralph Lange
a5c835cfeb jenkins: add CloudBees hgweb job to sync repo to SF webspace 2013-06-19 10:59:29 +02:00
Andrew Johnson
d2a649f5fa Fixed compiler warning, 2013-06-12 21:21:44 -05:00
Matej Sekoranja
476f18332a valueAlarm for numeric scalar arrays support 2013-05-31 21:15:54 +02:00
Andrew Johnson
a964e3668d Added jenkins/aps_build script 2013-05-30 17:32:15 -05:00
Marty Kraimer
69be072a07 added test 2013-05-17 19:33:16 -04:00
Marty Kraimer
a2ca21a1a6 changes to queue and to bitSetUtil. 2013-05-16 09:04:42 -04:00
Matej Sekoranja
0dd6f01ef6 direct, i.e. no-copy, de/serialization support 2013-04-12 21:54:11 +02:00
Matej Sekoranja
cd95b75563 gcc 4.7+ compiler warnings removed 2013-02-27 11:44:00 +01:00
Ralph Lange
4122e772c1 merge SF changes 2013-02-26 17:22:16 +01:00
Ralph Lange
2fbe99909c documentation: update Doxyfile 2013-02-26 17:21:28 +01:00
Ralph Lange
d4f3d6209c jenkins: fix URLs for dependencies 2013-02-26 17:20:52 +01:00
Ralph Lange
641a51aa4f Fix .hgignore to use patterns 2013-02-26 17:20:28 +01:00
Matej Sekoranja
67afe84593 mb moved to pvCommonCPP 2013-02-25 10:29:34 +01:00
Matej Sekoranja
66f7c90c51 merge 2013-02-22 21:30:01 +01:00
Matej Sekoranja
959117c391 mb portability, still to be ported to boost atomic 2013-02-22 21:27:26 +01:00
5e810c704f Missing library reference in Makefile 2013-02-21 15:50:57 +01:00
Matej Sekoranja
675243061d -Wextra compiler warnings fixed 2013-02-16 12:50:36 +01:00
Matej Sekoranja
246825d672 base 3.14 fix 2013-02-13 14:29:38 +01:00
Matej Sekoranja
aa1a67d6c1 added micro-benchmark 2013-02-13 14:18:42 +01:00
Matej Sekoranja
97b1848ba3 added array_at manip test 2013-02-11 10:30:30 +01:00
Matej Sekoranja
c4f6132aca added simple operators 'test', added <<= >>= operators to PVScalar 2013-02-08 22:45:04 +01:00
Matej Sekoranja
a0de4f126f operator<< for all PVField, indent and array_at manipulator 2013-02-07 22:52:16 +01:00
Ralph Lange
a8a96def97 jenkins: Publish documentation to .../tip in CloudBees build 2013-01-18 15:19:37 +01:00
Ralph Lange
eaddc30def Add doxygen to Cloudbees build (as local dependency) 2013-01-14 12:22:15 +01:00
Ralph Lange
aa17639e20 Comment out doxygen (which does not work on CloudBees) 2013-01-13 18:32:09 +01:00
Ralph Lange
58d7ad494b Add doxygen run to jenkins build job 2013-01-13 18:20:43 +01:00
Ralph Lange
2895f48bd6 Add build script for Jenkins on Cloudbees 2013-01-13 18:11:55 +01:00
Ralph Lange
8f6ea47501 configure: improved generic RELEASE file 2013-01-11 19:12:50 +01:00
Marty Kraimer
3eb6237343 missing '.' in "This version" and "Previous version" 2012-12-12 15:25:18 -05:00
Marty Kraimer
cb19940fa7 I forget to do an hg add on documentation/pvDataCPP_20121212.html 2012-12-12 15:17:44 -05:00
Marty Kraimer
4bc7e9c8fe several minor problems found while developing pvDatabaseCPP 2012-12-12 14:59:33 -05:00
dhickin
18ba24156c Added tag 2.0-BETA for changeset d70c5ad29163 2012-11-22 15:23:15 +00:00
46 changed files with 9390 additions and 741 deletions

View File

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

View File

@@ -4,3 +4,4 @@ d29d84f4c3f389f2accd497185b106c8541f95c9 1.1-SNAPSHOT
a29729ca0ecd60b66f2d997031d97911377e44a7 marchtest a29729ca0ecd60b66f2d997031d97911377e44a7 marchtest
9c59737f56e71aef641b70d0f72aa768fd7f8414 1.0.1-BETA 9c59737f56e71aef641b70d0f72aa768fd7f8414 1.0.1-BETA
4559c3de0cb4e3420e26272817f58bab005063ec 1.1-BETA 4559c3de0cb4e3420e26272817f58bab005063ec 1.1-BETA
d70c5ad29163306f50979a95b5aebbe9a93cfe76 2.0-BETA

1694
Doxyfile

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +1,25 @@
#RELEASE Location of external products # pvDataCPP RELEASE - Location of external support modules
# #
# IF YOU MAKE ANY CHANGES to this file you MUST at least run # IF YOU CHANGE this file or any file it includes you must
# "gnumake" in this directory afterwards; you usually need # subsequently do a "gnumake rebuild" in the application's
# to run "gnumake rebuild" in the application's top level # top level directory.
# directory each time this file is changed.
# #
# NOTE: The build does not check dependencies against files # The build process does not check dependencies against files
# that are outside this application, thus you should run # that are outside this application, thus you should also do a
# "gnumake distclean install" in the top directory each time # "gnumake rebuild" in the top level directory after EPICS_BASE
# EPICS_BASE, SNCSEQ, or any other external module defined # or any other external module pointed to below is rebuilt.
# in the RELEASE file is rebuilt.
# #
# Host/target specific settings can be specified in files named # Host- or target-specific settings can be given in files named
# RELEASE.$(EPICS_HOST_ARCH).Common # RELEASE.$(EPICS_HOST_ARCH).Common
# RELEASE.Common.$(T_A) # RELEASE.Common.$(T_A)
# RELEASE.$(EPICS_HOST_ARCH).$(T_A) # RELEASE.$(EPICS_HOST_ARCH).$(T_A)
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top # EPICS V4 Developers: Do not edit the locations in this file!
EPICS_BASE=/home/install/epics/base #
# Create a file RELEASE.local pointing to your EPICS_BASE
# Create a file RELEASE.local containing the # and PVCOMMON build directories, e.g.
# location of your EPICS_BASE, e.g. # EPICS_BASE = /home/install/epics/base
# EPICS_BASE=/home/install/epics/base # PVCOMMON = /home/install/epicsV4/pvCommonCPP
-include $(TOP)/configure/RELEASE.local -include $(TOP)/configure/RELEASE.local
-include $(TOP)/../RELEASE.local -include $(TOP)/../RELEASE.local

View File

@@ -37,7 +37,7 @@
<h1>EPICS pvDataCPP</h1> <h1>EPICS pvDataCPP</h1>
<!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. --> <!-- Maturity: Working Draft or Request for Comments, or Recommendation, and date. -->
<h2 class="nocount">EPICS v4 Working Group, Working Draft, 01-Oct-2012</h2> <h2 class="nocount">EPICS v4 Working Group, Working Draft, 16-May-2013</h2>
<dl> <dl>
<dt>Latest version:</dt> <dt>Latest version:</dt>
@@ -46,11 +46,11 @@
</dd> </dd>
<dt>This version:</dt> <dt>This version:</dt>
<dd><a <dd><a
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121026html">pvDataCPP_20121026html</a> href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20130516.html">pvDataCPP_20130516.html</a>
</dd> </dd>
<dt>Previous version:</dt> <dt>Previous version:</dt>
<dd><a <dd><a
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121001.html">pvDataCPP_20121001.html</a> href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121212.html">pvDataCPP_20121212.html</a>
</dd> </dd>
<dt>Editors:</dt> <dt>Editors:</dt>
<dd>Marty Kraimer, BNL</dd> <dd>Marty Kraimer, BNL</dd>
@@ -97,7 +97,9 @@ Control System (EPICS).</a></p>
<h2 class="nocount">Status of this Document</h2> <h2 class="nocount">Status of this Document</h2>
<p>This is the 01-Oct-2012 version of the C++ implementation of pvData.</p> <p>This is the 16-May-2013 version of the C++ implementation of pvData.
Since the last version changes were made to queue and to bitSetUtil.
</p>
<p> The text describes software which is a complete implementation of pvData as <p> The text describes software which is a complete implementation of pvData as
currently planned by the EPICS V4 Working Group. </p> </p> currently planned by the EPICS V4 Working Group. </p> </p>
@@ -865,8 +867,7 @@ typedef std::tr1::shared_ptr&lt;PostHandler&gt; PostHandlerPtr</pre>
<p>PostHandler is a class that must be implemented by any code that calls <p>PostHandler is a class that must be implemented by any code that calls
setPostHandler. It's single virtual method. postPut is called whenever setPostHandler. It's single virtual method. postPut is called whenever
PVField::postPut is called.</p> PVField::postPut is called.</p>
<pre>class PostHandler : <pre>class PostHandler
public std::tr1::enable_shared_from_this&lt;PostHandler&gt;
{ {
public: public:
POINTER_DEFINITIONS(PostHandler); POINTER_DEFINITIONS(PostHandler);
@@ -3037,6 +3038,7 @@ public:
~Lock(); ~Lock();
void lock(); void lock();
void unlock(); void unlock();
bool tryLock();
bool ownsLock() ; bool ownsLock() ;
... ...
};</pre> };</pre>
@@ -3179,9 +3181,9 @@ public:
int getNumberFree(); int getNumberFree();
int getNumberUsed(); int getNumberUsed();
queueElementPtr &amp; getFree(); queueElementPtr &amp; getFree();
void setUsed(queueElementPtr &amp;element); void setUsed(queueElementPtr const &amp;element);
queueElementPtr &amp; getUsed(); queueElementPtr &amp; getUsed();
void releaseUsed(queueElementPtr &amp;element); void releaseUsed(queueElementPtr const &amp;element);
... ...
};</pre> };</pre>
@@ -3619,7 +3621,7 @@ be used to schedule multiple callbacks. It has the methods:</p>
<p>The following is also provided:</p> <p>The following is also provided:</p>
<pre>class BitSetUtil : private NoDefaultMethods { <pre>class BitSetUtil : private NoDefaultMethods {
public: public:
static bool compress(BitSet *bitSet,PVStructure *pvStructure); static bool compress(BitSet const &amp;bitSet,PVStructure const &amp;pvStructure);
};</pre> };</pre>
<p>This provides functions that operate on a BitSet for a PVStructure. It <p>This provides functions that operate on a BitSet for a PVStructure. It

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

29
jenkins/aps_build Normal file
View File

@@ -0,0 +1,29 @@
# pvData C++ implementation
# Jenkins @ APS build script
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <Ralph.Lange@gmx.de> and Andrew Johnson <anj@aps.anl.gov>
# Copyright (C) 2013 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# All rights reserved. Use is subject to license terms.
###########################################
# Build
export EPICS_BASE=${HOME}/jobs/epics-base-3.14/workspace
export EPICS_HOST_ARCH=$(${EPICS_BASE}/startup/EpicsHostArch)
cat > configure/RELEASE.local << EOF
PVCOMMON=${HOME}/jobs/epics-pvCommon/workspace
EPICS_BASE=${EPICS_BASE}
EOF
make distclean all
###########################################
# Test
for t in bin/linux-x86_64/test*; do
$t
done

57
jenkins/cloudbees_build Normal file
View File

@@ -0,0 +1,57 @@
# pvData C++ implementation
# Jenkins @ Cloudbees build script
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <Ralph.Lange@gmx.de>
# Copyright (C) 2013 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# All rights reserved. Use is subject to license terms.
###########################################
# Fetch and unpack dependencies
export STUFF=/tmp/stuff
rm -fr ${STUFF}
mkdir -p ${STUFF}
cd ${STUFF}
wget -nv https://openepics.ci.cloudbees.com/job/Base-3.14.12.3_Build/lastSuccessfulBuild/artifact/baseR3.14.12.3.CB-dist.tar.gz
wget -nv https://openepics.ci.cloudbees.com/job/Doxygen-1.8.3_Build/lastSuccessfulBuild/artifact/doxygen-1.8.3.CB-dist.tar.gz
tar -xzf baseR3.14.12.3.CB-dist.tar.gz
tar -xzf doxygen-1.8.3.CB-dist.tar.gz
###########################################
# Build
cd ${WORKSPACE}
export EPICS_BASE=${STUFF}
export EPICS_HOST_ARCH=$(${EPICS_BASE}/startup/EpicsHostArch)
export LD_LIBRARY_PATH=${EPICS_BASE}/lib/${EPICS_HOST_ARCH}
export PATH=${STUFF}/bin:${PATH}
cat > configure/RELEASE.local << EOF
EPICS_BASE=${EPICS_BASE}
EOF
make distclean all
doxygen
###########################################
# Test
for t in bin/linux-x86_64/test*; do
$t
done
###########################################
# Create distribution
tar czf pvData.CB-dist.tar.gz lib include COPYRIGHT LICENSE
###########################################
# Publish documentation
rsync -aP --delete -e ssh documentation epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/htdocs/docbuild/pvDataCPP/tip

20
jenkins/cloudbees_hgweb Normal file
View File

@@ -0,0 +1,20 @@
# pvData C++ implementation
# Jenkins @ Cloudbees hgweb sync script
#
# Jenkins invokes scripts with the "-ex" option. So the build is considered a failure
# if any of the commands exits with a non-zero exit code.
#
# Author: Ralph Lange <Ralph.Lange@gmx.de>
# Copyright (C) 2013 Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
# All rights reserved. Use is subject to license terms.
###########################################
# Fetch complete repo
rm -fr hgweb
hg clone -U http://hg.code.sf.net/p/epics-pvdata/pvDataCPP hgweb
###########################################
# Sync into SF webspace
rsync -aqP --delete --exclude=\.hg/hgrc -e ssh hgweb/.hg epics-jenkins@web.sourceforge.net:/home/project-web/epics-pvdata/repos/pvDataCPP

View File

@@ -92,9 +92,7 @@ LIBSRCS += bitSetUtil.cpp
SRC_DIRS += $(PVDATA)/monitor SRC_DIRS += $(PVDATA)/monitor
INC += monitor.h INC += monitor.h
LIBRARY = pvData
LIBRARY=pvData
pvData_LIBS += Com pvData_LIBS += Com
include $(TOP)/configure/RULES include $(TOP)/configure/RULES

View File

@@ -2721,7 +2721,7 @@ void convertStructure(StringBuilder buffer,PVStructure const *data,int indentLev
} }
} }
void convertArray(StringBuilder buffer,PVScalarArray const * xxx,int indentLevel) void convertArray(StringBuilder buffer,PVScalarArray const * xxx,int /*indentLevel*/)
{ {
PVScalarArray *pv = const_cast<PVScalarArray *>(xxx); PVScalarArray *pv = const_cast<PVScalarArray *>(xxx);
ScalarArrayConstPtr array = pv->getScalarArray(); ScalarArrayConstPtr array = pv->getScalarArray();

View File

@@ -39,7 +39,7 @@ Field::~Field() {
} }
void Field::toString(StringBuilder buffer,int indentLevel) const{ void Field::toString(StringBuilder /*buffer*/,int /*indentLevel*/) const{
} }
@@ -54,7 +54,7 @@ struct ScalarArrayHashFunction {
}; };
struct StructureHashFunction { struct StructureHashFunction {
size_t operator() (const Structure& structure) const { return 0; } size_t operator() (const Structure& /*structure*/) const { return 0; }
// TODO // TODO
// final int PRIME = 31; // final int PRIME = 31;
// return PRIME * Arrays.hashCode(fieldNames) + Arrays.hashCode(fields); // return PRIME * Arrays.hashCode(fieldNames) + Arrays.hashCode(fields);
@@ -70,7 +70,7 @@ Scalar::Scalar(ScalarType scalarType)
Scalar::~Scalar(){} Scalar::~Scalar(){}
void Scalar::toString(StringBuilder buffer,int indentLevel) const{ void Scalar::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID(); *buffer += getID();
} }
@@ -94,7 +94,7 @@ String Scalar::getID() const
return idScalarLUT[scalarType]; return idScalarLUT[scalarType];
} }
const int8 Scalar::getTypeCodeLUT() const int8 Scalar::getTypeCodeLUT() const
{ {
static const int8 typeCodeLUT[] = { static const int8 typeCodeLUT[] = {
0x00, // pvBoolean 0x00, // pvBoolean
@@ -119,7 +119,7 @@ void Scalar::serialize(ByteBuffer *buffer, SerializableControl *control) const {
buffer->putByte(getTypeCodeLUT()); buffer->putByte(getTypeCodeLUT());
} }
void Scalar::deserialize(ByteBuffer *buffer, DeserializableControl *control) { void Scalar::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
// must be done via FieldCreate // must be done via FieldCreate
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead"); throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
} }
@@ -170,7 +170,7 @@ ScalarArray::ScalarArray(ScalarType elementType)
ScalarArray::~ScalarArray() {} ScalarArray::~ScalarArray() {}
const int8 ScalarArray::getTypeCodeLUT() const int8 ScalarArray::getTypeCodeLUT() const
{ {
static const int8 typeCodeLUT[] = { static const int8 typeCodeLUT[] = {
0x00, // pvBoolean 0x00, // pvBoolean
@@ -213,7 +213,7 @@ String ScalarArray::getID() const
return getIDScalarArrayLUT(); return getIDScalarArrayLUT();
} }
void ScalarArray::toString(StringBuilder buffer,int indentLevel) const{ void ScalarArray::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID(); *buffer += getID();
} }
@@ -222,7 +222,7 @@ void ScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) co
buffer->putByte(0x10 | getTypeCodeLUT()); buffer->putByte(0x10 | getTypeCodeLUT());
} }
void ScalarArray::deserialize(ByteBuffer *buffer, DeserializableControl *control) { void ScalarArray::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead"); throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
} }
@@ -252,7 +252,7 @@ void StructureArray::serialize(ByteBuffer *buffer, SerializableControl *control)
control->cachedSerialize(pstructure, buffer); control->cachedSerialize(pstructure, buffer);
} }
void StructureArray::deserialize(ByteBuffer *buffer, DeserializableControl *control) { void StructureArray::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead"); throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
} }
@@ -357,7 +357,7 @@ void Structure::serialize(ByteBuffer *buffer, SerializableControl *control) cons
serializeStructureField(this, buffer, control); serializeStructureField(this, buffer, control);
} }
void Structure::deserialize(ByteBuffer *buffer, DeserializableControl *control) { void Structure::deserialize(ByteBuffer */*buffer*/, DeserializableControl */*control*/) {
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead"); throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
} }

View File

@@ -97,4 +97,9 @@ PVArray::~PVArray()
pImpl->capacity = capacity; pImpl->capacity = capacity;
} }
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array)
{
return array.dumpValue(manip.stream, manip.index);
}
}} }}

View File

@@ -62,7 +62,11 @@ template<typename T>
T BasePVScalar<T>::get() const { return value;} T BasePVScalar<T>::get() const { return value;}
template<typename T> template<typename T>
void BasePVScalar<T>::put(T val){value = val;} void BasePVScalar<T>::put(T val)
{
value = val;
PVField::postPut();
}
template<typename T> template<typename T>
void BasePVScalar<T>::serialize(ByteBuffer *pbuffer, void BasePVScalar<T>::serialize(ByteBuffer *pbuffer,
@@ -120,7 +124,11 @@ BasePVString::~BasePVString() {}
String BasePVString::get() const { return value;} String BasePVString::get() const { return value;}
void BasePVString::put(String val){value = val;} void BasePVString::put(String val)
{
value = val;
postPut();
}
void BasePVString::serialize(ByteBuffer *pbuffer, void BasePVString::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) const SerializableControl *pflusher) const
@@ -139,9 +147,9 @@ void BasePVString::serialize(ByteBuffer *pbuffer,
{ {
// check bounds // check bounds
const size_t length = /*(value == null) ? 0 :*/ value.length(); const size_t length = /*(value == null) ? 0 :*/ value.length();
if (offset < 0) offset = 0; /*if (offset < 0) offset = 0;
else if (offset > length) offset = length; else*/ if (offset > length) offset = length;
if (count < 0) count = length; //if (count < 0) count = length;
const size_t maxCount = length - offset; const size_t maxCount = length - offset;
if (count > maxCount) if (count > maxCount)
@@ -263,7 +271,7 @@ size_t DefaultPVArray<T>::get(size_t offset, size_t len, PVArrayData<T> &data)
size_t length = this->getLength(); size_t length = this->getLength();
if(offset+len > length) { if(offset+len > length) {
n = length-offset; n = length-offset;
if(n<0) n = 0; //if(n<0) n = 0;
} }
data.data = *value.get(); data.data = *value.get();
data.offset = offset; data.offset = offset;
@@ -323,14 +331,26 @@ template<typename T>
void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer, void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) { DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol); size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
// if (size>0) { pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T)); } // alignment if (size>0) { pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T)); }
if(size>=0) { //if(size>=0) {
// prepare array, if necessary // prepare array, if necessary
if(size>this->getCapacity()) this->setCapacity(size); if(size>this->getCapacity()) this->setCapacity(size);
// set new length // set new length
this->setLength(size); this->setLength(size);
// try to avoid deserializing from the buffer
// this is only possible if we do not need to do endian-swapping
if (!pbuffer->reverse<T>())
if (pcontrol->directDeserialize(pbuffer, (char*)(get()), size, sizeof(T)))
{
// inform about the change?
PVField::postPut();
return;
}
// retrieve value from the buffer // retrieve value from the buffer
size_t i = 0; size_t i = 0;
T * pvalue = get();
while(true) { while(true) {
/* /*
size_t maxIndex = min(size-i, (int)(pbuffer->getRemaining()/sizeof(T)))+i; size_t maxIndex = min(size-i, (int)(pbuffer->getRemaining()/sizeof(T)))+i;
@@ -338,7 +358,7 @@ void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer,
value[i] = pbuffer->get<T>(); value[i] = pbuffer->get<T>();
*/ */
size_t maxCount = min(size-i, (pbuffer->getRemaining()/sizeof(T))); size_t maxCount = min(size-i, (pbuffer->getRemaining()/sizeof(T)));
pbuffer->getArray(get()+i, maxCount); pbuffer->getArray(pvalue+i, maxCount);
i += maxCount; i += maxCount;
if(i<size) if(i<size)
@@ -348,7 +368,7 @@ void DefaultPVArray<T>::deserialize(ByteBuffer *pbuffer,
} }
// inform about the change? // inform about the change?
PVField::postPut(); PVField::postPut();
} //}
// TODO null arrays (size == -1) not supported // TODO null arrays (size == -1) not supported
} }
@@ -359,10 +379,10 @@ void DefaultPVArray<T>::serialize(ByteBuffer *pbuffer,
size_t length = this->getLength(); size_t length = this->getLength();
// check bounds // check bounds
if(offset<0) /*if(offset<0)
offset = 0; offset = 0;
else if(offset>length) offset = length; else*/ if(offset>length) offset = length;
if(count<0) count = length; //if(count<0) count = length;
size_t maxCount = length-offset; size_t maxCount = length-offset;
if(count>maxCount) count = maxCount; if(count>maxCount) count = maxCount;
@@ -370,8 +390,17 @@ void DefaultPVArray<T>::serialize(ByteBuffer *pbuffer,
// write // write
SerializeHelper::writeSize(count, pbuffer, pflusher); SerializeHelper::writeSize(count, pbuffer, pflusher);
//if (count == 0) return; pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T)); //if (count == 0) return; pcontrol->ensureData(sizeof(T)-1); pbuffer->align(sizeof(T));
// try to avoid copying into the buffer
// this is only possible if we do not need to do endian-swapping
if (!pbuffer->reverse<T>())
if (pflusher->directSerialize(pbuffer, (const char*)(get()+offset), count, sizeof(T)))
return;
size_t end = offset+count; size_t end = offset+count;
size_t i = offset; size_t i = offset;
T * pvalue = const_cast<T *>(get());
while(true) { while(true) {
/* /*
@@ -381,7 +410,6 @@ void DefaultPVArray<T>::serialize(ByteBuffer *pbuffer,
*/ */
size_t maxCount = min<int>(end-i, (int)(pbuffer->getRemaining()/sizeof(T))); size_t maxCount = min<int>(end-i, (int)(pbuffer->getRemaining()/sizeof(T)));
T * pvalue = const_cast<T *>(get());
pbuffer->putArray(pvalue+i, maxCount); pbuffer->putArray(pvalue+i, maxCount);
i += maxCount; i += maxCount;
@@ -398,7 +426,7 @@ template<>
void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer, void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) { DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol); size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
if(size>=0) { //if(size>=0) {
// prepare array, if necessary // prepare array, if necessary
if(size>getCapacity()) setCapacity(size); if(size>getCapacity()) setCapacity(size);
// set new length // set new length
@@ -411,7 +439,7 @@ void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
} }
// inform about the change? // inform about the change?
postPut(); postPut();
} //}
// TODO null arrays (size == -1) not supported // TODO null arrays (size == -1) not supported
} }
@@ -421,10 +449,10 @@ void DefaultPVArray<String>::serialize(ByteBuffer *pbuffer,
size_t length = getLength(); size_t length = getLength();
// check bounds // check bounds
if(offset<0) /*if(offset<0)
offset = 0; offset = 0;
else if(offset>length) offset = length; else*/ if(offset>length) offset = length;
if(count<0) count = length; //if(count<0) count = length;
size_t maxCount = length-offset; size_t maxCount = length-offset;
if(count>maxCount) count = maxCount; if(count>maxCount) count = maxCount;

View File

@@ -158,7 +158,7 @@ void PVField::renameField(String const & newName)
void PVField::postPut() void PVField::postPut()
{ {
if(postHandler!=NULL) postHandler->postPut(); if(postHandler.get()!=NULL) postHandler->postPut();
} }
void PVField::setPostHandler(PostHandlerPtr const &handler) void PVField::setPostHandler(PostHandlerPtr const &handler)
@@ -194,17 +194,34 @@ void PVField::toString(StringBuilder buf,int indentLevel)
if(pvAuxInfo.get()!=NULL) pvAuxInfo->toString(buf,indentLevel); if(pvAuxInfo.get()!=NULL) pvAuxInfo->toString(buf,indentLevel);
} }
std::ostream& PVField::dumpValue(std::ostream& o) const std::ostream& operator<<(std::ostream& o, const PVField& f)
{ {
// default implementation std::ostream& ro = f.dumpValue(o);
// each PVField class should implement it to avoid switch statement // TODO I do not want to call getPVAuxInfo() since it lazily creates a new instance of it
// and string reallocation //if (f.pvAuxInfo.get()!=NULL) ro << *(f.pvAuxInfo.get());
String tmp; return ro;
convert->getString(&tmp,this,0); };
return o << tmp;
}
std::ostream& operator<<(std::ostream& o, const PVField& f) { return f.dumpValue(o); }; namespace format
{
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
{
indent_value(os) = indent.level;
return os;
}
std::ostream& operator<<(std::ostream& os, indent const&)
{
long il = indent_value(os);
std::size_t spaces = static_cast<std::size_t>(il) * 4;
return os << std::string(spaces, ' ');
}
array_at_internal operator<<(std::ostream& str, array_at const& manip)
{
return array_at_internal(manip.index, str);
}
};
void PVField::computeOffset(const PVField * pvField) { void PVField::computeOffset(const PVField * pvField) {
const PVStructure * pvTop = pvField->getParent(); const PVStructure * pvTop = pvField->getParent();

View File

@@ -702,4 +702,31 @@ static PVFieldPtr findSubField(
return PVFieldPtr(); return PVFieldPtr();
} }
std::ostream& PVStructure::dumpValue(std::ostream& o) const
{
o << format::indent() << getStructure()->getID() << ' ' << getFieldName();
String extendsName = getExtendsStructureName();
if(extendsName.length()>0) {
o << " extends " << extendsName;
}
o << std::endl;
{
format::indent_scope s(o);
PVFieldPtrArray const & fieldsData = getPVFields();
if (fieldsData.size() != 0) {
size_t length = getStructure()->getNumberFields();
for(size_t i=0; i<length; i++) {
PVFieldPtr fieldField = fieldsData[i];
Type type = fieldField->getField()->getType();
if (type == scalar || type == scalarArray)
o << format::indent() << fieldField->getField()->getID() << ' ' << fieldField->getFieldName() << ' ' << *(fieldField.get()) << std::endl;
else
o << *(fieldField.get());
}
}
}
return o;
}
}} }}

View File

@@ -133,7 +133,7 @@ size_t PVStructureArray::get(
size_t length = getLength(); size_t length = getLength();
if(offset+len > length) { if(offset+len > length) {
n = length - offset; n = length - offset;
if(n<0) n = 0; //if(n<0) n = 0;
} }
data.data = *value.get(); data.data = *value.get();
data.offset = offset; data.offset = offset;
@@ -197,7 +197,7 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
void PVStructureArray::deserialize(ByteBuffer *pbuffer, void PVStructureArray::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) { DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol); size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
if(size>=0) { //if(size>=0) {
// prepare array, if necessary // prepare array, if necessary
if(size>getCapacity()) setCapacity(size); if(size>getCapacity()) setCapacity(size);
setLength(size); setLength(size);
@@ -217,7 +217,7 @@ void PVStructureArray::deserialize(ByteBuffer *pbuffer,
} }
} }
postPut(); postPut();
} //}
} }
void PVStructureArray::serialize(ByteBuffer *pbuffer, void PVStructureArray::serialize(ByteBuffer *pbuffer,
@@ -226,10 +226,10 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
size_t length = getLength(); size_t length = getLength();
// check bounds // check bounds
if(offset<0) /*if(offset<0)
offset = 0; offset = 0;
else if(offset>length) offset = length; else*/ if(offset>length) offset = length;
if(count<0) count = length; //if(count<0) count = length;
size_t maxCount = length-offset; size_t maxCount = length-offset;
if(count>maxCount) count = maxCount; if(count>maxCount) count = maxCount;
@@ -250,4 +250,27 @@ void PVStructureArray::serialize(ByteBuffer *pbuffer,
} }
} }
std::ostream& PVStructureArray::dumpValue(std::ostream& o) const
{
o << format::indent() << getStructureArray()->getID() << ' ' << getFieldName() << std::endl;
size_t length = getLength();
if (length > 0)
{
format::indent_scope s(o);
for (size_t i = 0; i < length; i++)
dumpValue(o, i);
}
return o;
}
std::ostream& PVStructureArray::dumpValue(std::ostream& o, std::size_t index) const
{
PVStructurePtrArray pvArray = *value.get();
PVStructurePtr pvStructure = pvArray[index];
return o << *(pvStructure.get());
return o;
}
}} }}

View File

@@ -65,9 +65,10 @@ StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,
StructureConstPtr valueAlarm; StructureConstPtr valueAlarm;
Type type= field->getType(); Type type= field->getType();
while(gotValueAlarm) { while(gotValueAlarm) {
if(type==epics::pvData::scalar) { if(type==epics::pvData::scalar || type==epics::pvData::scalarArray) {
ScalarConstPtr scalar = static_pointer_cast<const Scalar>(field); ScalarType scalarType = (type==epics::pvData::scalar) ?
ScalarType scalarType = scalar->getScalarType(); static_pointer_cast<const Scalar>(field)->getScalarType() :
static_pointer_cast<const ScalarArray>(field)->getElementType();
switch(scalarType) { switch(scalarType) {
case pvBoolean: valueAlarm = booleanAlarmField; break; case pvBoolean: valueAlarm = booleanAlarmField; break;
case pvByte: valueAlarm = byteAlarmField; break; case pvByte: valueAlarm = byteAlarmField; break;

View File

@@ -331,7 +331,7 @@ namespace epics { namespace pvData {
return !(*this == set); return !(*this == set);
} }
void BitSet::toString(StringBuilder buffer, int indentLevel) const void BitSet::toString(StringBuilder buffer, int /*indentLevel*/) const
{ {
*buffer += '{'; *buffer += '{';
int32 i = nextSetBit(0); int32 i = nextSetBit(0);

View File

@@ -608,6 +608,24 @@ private:
bool _reverseFloatEndianess; bool _reverseFloatEndianess;
}; };
template<>
inline bool ByteBuffer::reverse<bool>()
{
return false;
}
template<>
inline bool ByteBuffer::reverse<int8>()
{
return false;
}
template<>
inline bool ByteBuffer::reverse<uint8>()
{
return false;
}
template<> template<>
inline bool ByteBuffer::reverse<float>() inline bool ByteBuffer::reverse<float>()
{ {

View File

@@ -44,6 +44,15 @@ public:
locked=false; locked=false;
} }
} }
bool tryLock()
{
if(locked) return true;
if(mutexPtr.tryLock()) {
locked = true;
return true;
}
return false;
}
bool ownsLock() const{return locked;} bool ownsLock() const{return locked;}
private: private:
Mutex &mutexPtr; Mutex &mutexPtr;

View File

@@ -29,9 +29,9 @@ public:
int getNumberFree(); int getNumberFree();
int getNumberUsed(); int getNumberUsed();
queueElementPtr & getFree(); queueElementPtr & getFree();
void setUsed(queueElementPtr &element); void setUsed(queueElementPtr const &element);
queueElementPtr & getUsed(); queueElementPtr & getUsed();
void releaseUsed(queueElementPtr &element); void releaseUsed(queueElementPtr const &element);
private: private:
queueElementPtr nullElement; queueElementPtr nullElement;
queueElementPtrArray elements; queueElementPtrArray elements;
@@ -92,7 +92,7 @@ std::tr1::shared_ptr<T> & Queue<T>::getFree()
} }
template <typename T> template <typename T>
void Queue<T>::setUsed(std::tr1::shared_ptr<T> &element) void Queue<T>::setUsed(std::tr1::shared_ptr<T> const &element)
{ {
if(element!=elements[nextSetUsed++]) { if(element!=elements[nextSetUsed++]) {
throw std::logic_error("not correct queueElement"); throw std::logic_error("not correct queueElement");
@@ -112,7 +112,7 @@ std::tr1::shared_ptr<T> & Queue<T>::getUsed()
} }
template <typename T> template <typename T>
void Queue<T>::releaseUsed(std::tr1::shared_ptr<T> &element) void Queue<T>::releaseUsed(std::tr1::shared_ptr<T> const &element)
{ {
if(element!=elements[nextReleaseUsed++]) { if(element!=elements[nextReleaseUsed++]) {
throw std::logic_error( throw std::logic_error(

View File

@@ -27,6 +27,8 @@ namespace epics { namespace pvData {
virtual void flushSerializeBuffer() =0; virtual void flushSerializeBuffer() =0;
virtual void ensureBuffer(std::size_t size) =0; virtual void ensureBuffer(std::size_t size) =0;
virtual void alignBuffer(std::size_t alignment) =0; virtual void alignBuffer(std::size_t alignment) =0;
virtual bool directSerialize(ByteBuffer *existingBuffer, const char* toSerialize,
std::size_t elementCount, std::size_t elementSize) = 0;
virtual void cachedSerialize(std::tr1::shared_ptr<const Field> const & field, ByteBuffer* buffer) = 0; virtual void cachedSerialize(std::tr1::shared_ptr<const Field> const & field, ByteBuffer* buffer) = 0;
}; };
@@ -35,6 +37,8 @@ namespace epics { namespace pvData {
virtual ~DeserializableControl(){} virtual ~DeserializableControl(){}
virtual void ensureData(std::size_t size) =0; virtual void ensureData(std::size_t size) =0;
virtual void alignData(std::size_t alignment) =0; virtual void alignData(std::size_t alignment) =0;
virtual bool directDeserialize(ByteBuffer *existingBuffer, char* deserializeTo,
std::size_t elementCount, std::size_t elementSize) = 0;
virtual std::tr1::shared_ptr<const Field> cachedDeserialize(ByteBuffer* buffer) = 0; virtual std::tr1::shared_ptr<const Field> cachedDeserialize(ByteBuffer* buffer) = 0;
}; };

View File

@@ -77,14 +77,14 @@ namespace epics {
void SerializeHelper::serializeSubstring(const String& value, void SerializeHelper::serializeSubstring(const String& value,
std::size_t offset, std::size_t count, ByteBuffer* buffer, std::size_t offset, std::size_t count, ByteBuffer* buffer,
SerializableControl* flusher) { SerializableControl* flusher) {
if(offset<0) /*if(offset<0)
offset = 0; offset = 0;
else if(offset>(std::size_t)value.length()) offset = value.length(); else*/ if(offset>value.length()) offset = value.length();
if(offset+count>(std::size_t)value.length()) count = value.length()-offset; if(offset+count>value.length()) count = value.length()-offset;
SerializeHelper::writeSize(count, buffer, flusher); SerializeHelper::writeSize(count, buffer, flusher);
if (count<=0) return; /*if (count<=0)*/ return;
std::size_t i = 0; std::size_t i = 0;
while(true) { while(true) {
std::size_t maxToWrite = min(count-i, buffer->getRemaining()); std::size_t maxToWrite = min(count-i, buffer->getRemaining());

View File

@@ -117,7 +117,7 @@ String Status::toString() const
return str; return str;
} }
void Status::toString(StringBuilder buffer, int indentLevel) const void Status::toString(StringBuilder buffer, int /*indentLevel*/) const
{ {
*buffer += "Status [type="; *buffer += "Status [type=";
*buffer += StatusTypeName[m_statusType]; *buffer += StatusTypeName[m_statusType];

View File

@@ -14,10 +14,74 @@
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <iostream>
#include <iomanip>
#include <pv/pvIntrospect.h> #include <pv/pvIntrospect.h>
#include <pv/requester.h> #include <pv/requester.h>
namespace epics { namespace pvData { namespace epics { namespace pvData {
namespace format {
struct indent_level
{
long level;
indent_level(long l) : level(l) {}
};
inline long& indent_value(std::ios_base& ios)
{
static int indent_index = std::ios_base::xalloc();
return ios.iword(indent_index);
}
std::ostream& operator<<(std::ostream& os, indent_level const& indent);
struct indent_scope
{
long saved_level;
std::ios_base& stream;
indent_scope(std::ios_base& ios) :
stream(ios)
{
long& l = indent_value(ios);
saved_level = l;
l = saved_level + 1;
}
~indent_scope()
{
indent_value(stream) = saved_level;
}
};
struct indent
{
};
std::ostream& operator<<(std::ostream& os, indent const&);
struct array_at
{
std::size_t index;
array_at(std::size_t ix) : index(ix) {}
};
struct array_at_internal
{
std::size_t index;
std::ostream& stream;
array_at_internal(std::size_t ix, std::ostream& str) : index(ix), stream(str) {}
};
array_at_internal operator<<(std::ostream& str, array_at const& manip);
};
class PVAuxInfo; class PVAuxInfo;
class PostHandler; class PostHandler;
@@ -75,6 +139,8 @@ typedef std::vector<PVStructurePtr>::const_iterator PVStructurePtrArray_const__i
* typedef for a pointer to a PVStructureArray. * typedef for a pointer to a PVStructureArray.
*/ */
typedef std::tr1::shared_ptr<PVStructureArray> PVStructureArrayPtr; typedef std::tr1::shared_ptr<PVStructureArray> PVStructureArrayPtr;
typedef std::vector<PVStructureArrayPtr> PVStructureArrayPtrArray;
typedef std::tr1::shared_ptr<PVStructureArrayPtrArray> PVStructureArrayPtrArrayPtr;
/** /**
* This class provides auxillary information about a PVField. * This class provides auxillary information about a PVField.
@@ -140,8 +206,7 @@ private:
/** /**
* This class is implemented by code that calls setPostHander * This class is implemented by code that calls setPostHander
*/ */
class PostHandler : class PostHandler
public std::tr1::enable_shared_from_this<PostHandler>
{ {
public: public:
POINTER_DEFINITIONS(PostHandler); POINTER_DEFINITIONS(PostHandler);
@@ -276,7 +341,7 @@ public:
* @param o output stream. * @param o output stream.
* @return The output stream. * @return The output stream.
*/ */
virtual std::ostream& dumpValue(std::ostream& o) const; virtual std::ostream& dumpValue(std::ostream& o) const = 0;
protected: protected:
PVField::shared_pointer getPtrSelf() PVField::shared_pointer getPtrSelf()
@@ -358,6 +423,20 @@ public:
return o << get(); return o << get();
} }
// get operator
// double value; doubleField >>= value;
void operator>>=(T& value) const
{
value = get();
}
// put operator
// double value = 12.8; doubleField <<= value;
void operator<<=(T value)
{
put(value);
}
protected: protected:
PVScalarValue(ScalarConstPtr const & scalar) PVScalarValue(ScalarConstPtr const & scalar)
: PVScalar(scalar) {} : PVScalar(scalar) {}
@@ -452,6 +531,9 @@ public:
* @param The capacity. * @param The capacity.
*/ */
virtual void setCapacity(std::size_t capacity) = 0; virtual void setCapacity(std::size_t capacity) = 0;
virtual std::ostream& dumpValue(std::ostream& o, std::size_t index) const = 0;
protected: protected:
PVArray(FieldConstPtr const & field); PVArray(FieldConstPtr const & field);
void setCapacityLength(std::size_t capacity,std::size_t length); void setCapacityLength(std::size_t capacity,std::size_t length);
@@ -460,6 +542,8 @@ private:
friend class PVDataCreate; friend class PVDataCreate;
}; };
std::ostream& operator<<(format::array_at_internal const& manip, const PVArray& array);
/** /**
* Class provided by caller of get * Class provided by caller of get
*/ */
@@ -504,8 +588,6 @@ public:
*/ */
const ScalarArrayConstPtr getScalarArray() const ; const ScalarArrayConstPtr getScalarArray() const ;
virtual std::ostream& dumpValue(std::ostream& o, size_t index) const = 0;
protected: protected:
PVScalarArray(ScalarArrayConstPtr const & scalarArray); PVScalarArray(ScalarArrayConstPtr const & scalarArray);
private: private:
@@ -607,6 +689,10 @@ public:
virtual pointer get() const { return &((*value.get())[0]); } virtual pointer get() const { return &((*value.get())[0]); }
virtual vector const & getVector() {return *value;} virtual vector const & getVector() {return *value;}
virtual shared_vector const & getSharedVector() {return value;} virtual shared_vector const & getSharedVector() {return value;}
virtual std::ostream& dumpValue(std::ostream& o) const;
virtual std::ostream& dumpValue(std::ostream& o, std::size_t index) const;
protected: protected:
PVStructureArray(StructureArrayConstPtr const & structureArray); PVStructureArray(StructureArrayConstPtr const & structureArray);
private: private:
@@ -815,6 +901,9 @@ public:
* @param pvFields The array of fields for the structure. * @param pvFields The array of fields for the structure.
*/ */
PVStructure(StructureConstPtr const & structure,PVFieldPtrArray const & pvFields); PVStructure(StructureConstPtr const & structure,PVFieldPtrArray const & pvFields);
virtual std::ostream& dumpValue(std::ostream& o) const;
private: private:
void fixParentStructure(); void fixParentStructure();
static PVFieldPtr nullPVField; static PVFieldPtr nullPVField;
@@ -895,7 +984,7 @@ public:
std::ostream& dumpValue(std::ostream& o) const std::ostream& dumpValue(std::ostream& o) const
{ {
o << "["; o << '[';
std::size_t len = getLength(); std::size_t len = getLength();
bool first = true; bool first = true;
for (std::size_t i = 0; i < len; i++) for (std::size_t i = 0; i < len; i++)
@@ -903,10 +992,10 @@ public:
if (first) if (first)
first = false; first = false;
else else
o << ","; o << ',';
dumpValue(o, i); dumpValue(o, i);
} }
return o << "]"; return o << ']';
} }
std::ostream& dumpValue(std::ostream& o, size_t index) const std::ostream& dumpValue(std::ostream& o, size_t index) const

View File

@@ -283,7 +283,7 @@ public:
protected: protected:
Scalar(ScalarType scalarType); Scalar(ScalarType scalarType);
private: private:
const int8 getTypeCodeLUT() const; int8 getTypeCodeLUT() const;
ScalarType scalarType; ScalarType scalarType;
friend class FieldCreate; friend class FieldCreate;
}; };
@@ -330,7 +330,7 @@ protected:
*/ */
virtual ~ScalarArray(); virtual ~ScalarArray();
private: private:
const int8 getTypeCodeLUT() const; int8 getTypeCodeLUT() const;
const String getIDScalarArrayLUT() const; const String getIDScalarArrayLUT() const;
ScalarType elementType; ScalarType elementType;
friend class FieldCreate; friend class FieldCreate;

View File

@@ -13,25 +13,31 @@
namespace epics { namespace pvData { namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
using std::size_t;
static bool checkBitSetPVField( static bool checkBitSetPVField(
PVField *pvField,BitSet *bitSet,int32 initialOffset) PVFieldPtr const &pvField,BitSetPtr const &bitSet,int32 initialOffset)
{ {
bool atLeastOneBitSet = false;
bool allBitsSet = true;
int32 offset = initialOffset; int32 offset = initialOffset;
int32 nbits = pvField->getNumberFields(); int32 nbits = pvField->getNumberFields();
if(nbits==1) return bitSet->get(offset); if(nbits==1) return bitSet->get(offset);
int32 nextSetBit = bitSet->nextSetBit(offset); int32 nextSetBit = bitSet->nextSetBit(offset);
if(nextSetBit>=(offset+nbits)) return false; if(nextSetBit>=(offset+nbits)) return false;
if(nextSetBit<0) return false;
if(bitSet->get(offset)) { if(bitSet->get(offset)) {
if(nbits>1) { if(nbits>1) {
for(int32 i=offset+1; i<offset+nbits; i++) bitSet->clear(i); for(int32 i=offset+1; i<offset+nbits; i++) bitSet->clear(i);
} }
return true; return true;
} }
PVStructure *pvStructure = static_cast<PVStructure *>(pvField);
bool atLeastOneBitSet = false;
bool allBitsSet = true;
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
offset = pvStructure->getFieldOffset() + 1;
while(offset<initialOffset + nbits) { while(offset<initialOffset + nbits) {
PVField *pvSubField = pvStructure->getSubField(offset).get(); PVFieldPtr pvSubField = pvStructure->getSubField(offset);
int32 nbitsNow = pvSubField->getNumberFields(); int32 nbitsNow = pvSubField->getNumberFields();
if(nbitsNow==1) { if(nbitsNow==1) {
if(bitSet->get(offset)) { if(bitSet->get(offset)) {
@@ -41,24 +47,16 @@ static bool checkBitSetPVField(
} }
offset++; offset++;
} else { } else {
offset++; bool result = checkBitSetPVField(pvSubField,bitSet,offset);
PVStructure *pvSubStructure = static_cast<PVStructure*>(pvField); if(result) {
PVFieldPtrArray pvSubStructureFields = atLeastOneBitSet = true;
pvSubStructure->getPVFields(); if(!bitSet->get(offset)) {
int num = pvSubStructure->getStructure()->getNumberFields();
for(int32 i=0; i<num; i++) {
PVField *pvSubSubField = pvSubStructureFields[i].get();
bool result = checkBitSetPVField(pvSubSubField,bitSet,offset);
if(result) {
atLeastOneBitSet = true;
if(!bitSet->get(offset)) {
allBitsSet = false;
}
} else {
allBitsSet = false; allBitsSet = false;
} }
offset += pvSubSubField->getNumberFields(); } else {
allBitsSet = false;
} }
offset += pvSubField->getNumberFields();
} }
} }
if(allBitsSet) { if(allBitsSet) {
@@ -72,7 +70,7 @@ static bool checkBitSetPVField(
return atLeastOneBitSet; return atLeastOneBitSet;
} }
bool BitSetUtil::compress(BitSet *bitSet,PVStructure *pvStructure) bool BitSetUtil::compress(BitSetPtr const &bitSet,PVStructurePtr const &pvStructure)
{ {
return checkBitSetPVField(pvStructure,bitSet,0); return checkBitSetPVField(pvStructure,bitSet,0);
} }

View File

@@ -17,7 +17,7 @@ namespace epics { namespace pvData {
class BitSetUtil : private NoDefaultMethods { class BitSetUtil : private NoDefaultMethods {
public: public:
static bool compress(BitSet *bitSet,PVStructure *pvStructure); static bool compress(BitSetPtr const &bitSet,PVStructurePtr const &pvStructure);
}; };
}} }}

1
pvDataCPP.config Normal file
View File

@@ -0,0 +1 @@
// ADD PREDEFINED MACROS HERE!

1
pvDataCPP.creator Normal file
View File

@@ -0,0 +1 @@
[General]

211
pvDataCPP.files Normal file
View File

@@ -0,0 +1,211 @@
configure/CONFIG
configure/CONFIG_SITE
configure/RELEASE
configure/RELEASE.local
configure/RULES
configure/RULES.ioc
configure/RULES_DIRS
configure/RULES_TOP
documentation/pvDataCPP.html
documentation/pvDataCPP_20120927.html
documentation/pvDataCPP_20121001.html
documentation/pvDataCPP_20121026.html
documentation/pvDataCPP_20121212.html
jenkins/cloudbees_build
pvDataApp/factory/Compare.cpp
pvDataApp/factory/Convert.cpp
pvDataApp/factory/factory.h
pvDataApp/factory/FieldCreateFactory.cpp
pvDataApp/factory/PVArray.cpp
pvDataApp/factory/PVAuxInfoImpl.cpp
pvDataApp/factory/PVDataCreateFactory.cpp
pvDataApp/factory/PVDataCreateFactory.cpp.orig
pvDataApp/factory/PVField.cpp
pvDataApp/factory/PVScalar.cpp
pvDataApp/factory/PVScalarArray.cpp
pvDataApp/factory/PVStructure.cpp
pvDataApp/factory/PVStructureArray.cpp
pvDataApp/factory/StandardField.cpp
pvDataApp/factory/StandardPVField.cpp
pvDataApp/factory/TypeFunc.cpp
pvDataApp/misc/bitSet.cpp
pvDataApp/misc/bitSet.h
pvDataApp/misc/byteBuffer.cpp
pvDataApp/misc/byteBuffer.h
pvDataApp/misc/destroyable.h
pvDataApp/misc/epicsException.cpp
pvDataApp/misc/epicsException.h
pvDataApp/misc/event.cpp
pvDataApp/misc/event.h
pvDataApp/misc/executor.cpp
pvDataApp/misc/executor.h
pvDataApp/misc/localStaticLock.cpp
pvDataApp/misc/localStaticLock.h
pvDataApp/misc/localStaticLock.h.orig
pvDataApp/misc/lock.h
pvDataApp/misc/messageQueue.cpp
pvDataApp/misc/messageQueue.h
pvDataApp/misc/noDefaultMethods.h
pvDataApp/misc/queue.h
pvDataApp/misc/requester.cpp
pvDataApp/misc/requester.h
pvDataApp/misc/requester.h.orig
pvDataApp/misc/serialize.h
pvDataApp/misc/serializeHelper.cpp
pvDataApp/misc/serializeHelper.h
pvDataApp/misc/sharedPtr.h
pvDataApp/misc/status.cpp
pvDataApp/misc/status.h
pvDataApp/misc/thread.h
pvDataApp/misc/timeFunction.cpp
pvDataApp/misc/timeFunction.h
pvDataApp/misc/timer.cpp
pvDataApp/misc/timer.h
pvDataApp/monitor/monitor.h
pvDataApp/O.linux-x86_64/alarm.d
pvDataApp/O.linux-x86_64/bitSet.d
pvDataApp/O.linux-x86_64/bitSetUtil.d
pvDataApp/O.linux-x86_64/byteBuffer.d
pvDataApp/O.linux-x86_64/Compare.d
pvDataApp/O.linux-x86_64/Convert.d
pvDataApp/O.linux-x86_64/epicsException.d
pvDataApp/O.linux-x86_64/event.d
pvDataApp/O.linux-x86_64/executor.d
pvDataApp/O.linux-x86_64/FieldCreateFactory.d
pvDataApp/O.linux-x86_64/libpvData.a
pvDataApp/O.linux-x86_64/libpvData.so
pvDataApp/O.linux-x86_64/localStaticLock.d
pvDataApp/O.linux-x86_64/messageQueue.d
pvDataApp/O.linux-x86_64/pvAlarm.d
pvDataApp/O.linux-x86_64/PVArray.d
pvDataApp/O.linux-x86_64/PVAuxInfoImpl.d
pvDataApp/O.linux-x86_64/pvControl.d
pvDataApp/O.linux-x86_64/PVDataCreateFactory.d
pvDataApp/O.linux-x86_64/pvDisplay.d
pvDataApp/O.linux-x86_64/pvEnumerated.d
pvDataApp/O.linux-x86_64/PVField.d
pvDataApp/O.linux-x86_64/PVScalar.d
pvDataApp/O.linux-x86_64/PVScalarArray.d
pvDataApp/O.linux-x86_64/PVStructure.d
pvDataApp/O.linux-x86_64/PVStructureArray.d
pvDataApp/O.linux-x86_64/pvTimeStamp.d
pvDataApp/O.linux-x86_64/requester.d
pvDataApp/O.linux-x86_64/serializeHelper.d
pvDataApp/O.linux-x86_64/StandardField.d
pvDataApp/O.linux-x86_64/StandardPVField.d
pvDataApp/O.linux-x86_64/status.d
pvDataApp/O.linux-x86_64/timeFunction.d
pvDataApp/O.linux-x86_64/timer.d
pvDataApp/O.linux-x86_64/timeStamp.d
pvDataApp/O.linux-x86_64/TypeFunc.d
pvDataApp/property/alarm.cpp
pvDataApp/property/alarm.h
pvDataApp/property/alarm.h.orig
pvDataApp/property/control.h
pvDataApp/property/display.h
pvDataApp/property/pvAlarm.cpp
pvDataApp/property/pvAlarm.h
pvDataApp/property/pvControl.cpp
pvDataApp/property/pvControl.h
pvDataApp/property/pvDisplay.cpp
pvDataApp/property/pvDisplay.h
pvDataApp/property/pvEnumerated.cpp
pvDataApp/property/pvEnumerated.h
pvDataApp/property/pvTimeStamp.cpp
pvDataApp/property/pvTimeStamp.h
pvDataApp/property/timeStamp.cpp
pvDataApp/property/timeStamp.h
pvDataApp/property/timeStamp.h.orig
pvDataApp/pv/convert.h
pvDataApp/pv/convert.h.orig
pvDataApp/pv/pvData.h
pvDataApp/pv/pvData.h.orig
pvDataApp/pv/pvIntrospect.h
pvDataApp/pv/pvIntrospect.h.orig
pvDataApp/pv/pvType.h
pvDataApp/pv/standardField.h
pvDataApp/pv/standardField.h.orig
pvDataApp/pv/standardPVField.h
pvDataApp/pv/standardPVField.h.orig
pvDataApp/pvMisc/bitSetUtil.cpp
pvDataApp/pvMisc/bitSetUtil.h
testApp/capi/O.linux-x86_64/libtestc.a
testApp/capi/O.linux-x86_64/libtestc.so
testApp/capi/O.linux-x86_64/testc.d
testApp/capi/testc.cpp
testApp/capi/testc.py
testApp/mb/O.linux-x86_64/mb_test
testApp/mb/O.linux-x86_64/mb_test.d
testApp/misc/O.linux-x86_64/testBaseException
testApp/misc/O.linux-x86_64/testBaseException.d
testApp/misc/O.linux-x86_64/testBitSet
testApp/misc/O.linux-x86_64/testBitSet.d
testApp/misc/O.linux-x86_64/testByteBuffer
testApp/misc/O.linux-x86_64/testByteBuffer.d
testApp/misc/O.linux-x86_64/testByteOrder
testApp/misc/O.linux-x86_64/testByteOrder.d
testApp/misc/O.linux-x86_64/testMessageQueue
testApp/misc/O.linux-x86_64/testMessageQueue.d
testApp/misc/O.linux-x86_64/testQueue
testApp/misc/O.linux-x86_64/testQueue.d
testApp/misc/O.linux-x86_64/testSerialization
testApp/misc/O.linux-x86_64/testSerialization.d
testApp/misc/O.linux-x86_64/testThread
testApp/misc/O.linux-x86_64/testThread.d
testApp/misc/O.linux-x86_64/testTimer
testApp/misc/O.linux-x86_64/testTimer.d
testApp/misc/O.linux-x86_64/testTimeStamp
testApp/misc/O.linux-x86_64/testTimeStamp.d
testApp/misc/testBaseException.cpp
testApp/misc/testBitSet.cpp
testApp/misc/testByteBuffer.cpp
testApp/misc/testByteOrder.cpp
testApp/misc/testMessageQueue.cpp
testApp/misc/testQueue.cpp
testApp/misc/testSerialization.cpp
testApp/misc/testThread.cpp
testApp/misc/testTimer.cpp
testApp/misc/testTimeStamp.cpp
testApp/monitor/O.linux-x86_64/testMonitor
testApp/monitor/O.linux-x86_64/testMonitor.d
testApp/monitor/testMonitor.cpp
testApp/property/O.linux-x86_64/testProperty
testApp/property/O.linux-x86_64/testProperty.d
testApp/property/testProperty.cpp
testApp/pv/O.linux-x86_64/testConvert
testApp/pv/O.linux-x86_64/testConvert.d
testApp/pv/O.linux-x86_64/testIntrospect
testApp/pv/O.linux-x86_64/testIntrospect.d
testApp/pv/O.linux-x86_64/testOperators
testApp/pv/O.linux-x86_64/testOperators.d
testApp/pv/O.linux-x86_64/testPVAppend
testApp/pv/O.linux-x86_64/testPVAppend.d
testApp/pv/O.linux-x86_64/testPVAuxInfo
testApp/pv/O.linux-x86_64/testPVAuxInfo.d
testApp/pv/O.linux-x86_64/testPVData
testApp/pv/O.linux-x86_64/testPVData.d
testApp/pv/O.linux-x86_64/testPVScalarArray
testApp/pv/O.linux-x86_64/testPVScalarArray.d
testApp/pv/O.linux-x86_64/testPVStructureArray
testApp/pv/O.linux-x86_64/testPVStructureArray.d
testApp/pv/O.linux-x86_64/testPVType
testApp/pv/O.linux-x86_64/testPVType.d
testApp/pv/O.linux-x86_64/testStandardField
testApp/pv/O.linux-x86_64/testStandardField.d
testApp/pv/O.linux-x86_64/testStandardPVField
testApp/pv/O.linux-x86_64/testStandardPVField.d
testApp/pv/testConvert.cpp
testApp/pv/testIntrospect.cpp
testApp/pv/testOperators.cpp
testApp/pv/testPVAppend.cpp
testApp/pv/testPVAuxInfo.cpp
testApp/pv/testPVData.cpp
testApp/pv/testPVScalarArray.cpp
testApp/pv/testPVStructureArray.cpp
testApp/pv/testPVType.cpp
testApp/pv/testStandardField.cpp
testApp/pv/testStandardPVField.cpp
COPYRIGHT
Doxyfile
LICENSE
README.html

6
pvDataCPP.includes Normal file
View File

@@ -0,0 +1,6 @@
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/factory
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/misc
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/monitor
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/property
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pv
/home/msekoranja/epicsV4/pvDataCPP/pvDataApp/pvMisc

View File

@@ -24,7 +24,7 @@ testByteBuffer_LIBS += pvData Com
PROD_HOST += testBaseException PROD_HOST += testBaseException
testBaseException_SRCS += testBaseException.cpp testBaseException_SRCS += testBaseException.cpp
testBaseException_LIBS += pvData testBaseException_LIBS += pvData Com
PROD_HOST += testSerialization PROD_HOST += testSerialization
testSerialization_SRCS += testSerialization.cpp testSerialization_SRCS += testSerialization.cpp

View File

@@ -27,11 +27,11 @@ struct Unroller
}; };
template<> template<>
void Unroller::unroll<0>(double d) { void Unroller::unroll<0>(double /*d*/) {
THROW_BASE_EXCEPTION("the root cause"); THROW_BASE_EXCEPTION("the root cause");
} }
void internalTestBaseException(int unused = 0) void internalTestBaseException(int /*unused*/ = 0)
{ {
try { try {
// NOTE: 5, 4, 3, 2, 1 calls will be optimized and not shown // NOTE: 5, 4, 3, 2, 1 calls will be optimized and not shown

View File

@@ -30,7 +30,7 @@
using namespace epics::pvData; using namespace epics::pvData;
static void testBasic(FILE * fd,FILE *auxfd ) { static void testBasic(FILE * fd,FILE */*auxfd*/) {
int queueSize = 3; int queueSize = 3;
StringArray messages; StringArray messages;
messages.reserve(5); messages.reserve(5);

View File

@@ -24,22 +24,24 @@
#include <pv/standardField.h> #include <pv/standardField.h>
#define BYTE_MAX_VALUE 127 #include <limits>
#define BYTE_MIN_VALUE -128
#define UBYTE_MAX_VALUE 255 #define BYTE_MAX_VALUE std::numeric_limits<int8>::max()
#define SHORT_MAX_VALUE 32767 #define BYTE_MIN_VALUE std::numeric_limits<int8>::min()
#define SHORT_MIN_VALUE -32768 #define UBYTE_MAX_VALUE std::numeric_limits<uint8>::max()
#define USHORT_MAX_VALUE 65535 #define SHORT_MAX_VALUE std::numeric_limits<int16>::max()
#define INT_MAX_VALUE 2147483647 #define SHORT_MIN_VALUE std::numeric_limits<int16>::min()
#define INT_MIN_VALUE (-INT_MAX_VALUE - 1) #define USHORT_MAX_VALUE std::numeric_limits<uint16>::max()
#define UINT_MAX_VALUE 4294967295ULL #define INT_MAX_VALUE std::numeric_limits<int32>::max()
#define LONG_MAX_VALUE 9223372036854775807LL #define INT_MIN_VALUE std::numeric_limits<int32>::min()
#define LONG_MIN_VALUE (-LONG_MAX_VALUE - 1LL) #define UINT_MAX_VALUE std::numeric_limits<uint32>::max()
#define ULONG_MAX_VALUE 18446744073709549999ULL #define LONG_MAX_VALUE std::numeric_limits<int64>::max()
#define FLOAT_MAX_VALUE 3.4028235E38 #define LONG_MIN_VALUE std::numeric_limits<int64>::min()
#define FLOAT_MIN_VALUE 1.4E-45 #define ULONG_MAX_VALUE std::numeric_limits<uint64>::max()
#define DOUBLE_MAX_VALUE 1.7976931348623157E308 #define FLOAT_MAX_VALUE std::numeric_limits<float>::max()
#define DOUBLE_MIN_VALUE 4.9E-324 #define FLOAT_MIN_VALUE std::numeric_limits<float>::min()
#define DOUBLE_MAX_VALUE std::numeric_limits<double>::max()
#define DOUBLE_MIN_VALUE std::numeric_limits<double>::min()
using namespace epics::pvData; using namespace epics::pvData;
@@ -54,13 +56,19 @@ public:
virtual void flushSerializeBuffer() { virtual void flushSerializeBuffer() {
} }
virtual void ensureBuffer(std::size_t size) { virtual void ensureBuffer(std::size_t /*size*/) {
} }
virtual void alignBuffer(std::size_t alignment) { virtual void alignBuffer(std::size_t alignment) {
buffer->align(alignment); buffer->align(alignment);
} }
virtual bool directSerialize(ByteBuffer */*existingBuffer*/, const char* /*toSerialize*/,
std::size_t /*elementCount*/, std::size_t /*elementSize*/)
{
return false;
}
virtual void cachedSerialize(std::tr1::shared_ptr<const Field> const & field, ByteBuffer* buffer) virtual void cachedSerialize(std::tr1::shared_ptr<const Field> const & field, ByteBuffer* buffer)
{ {
field->serialize(buffer, this); field->serialize(buffer, this);
@@ -76,13 +84,19 @@ public:
class DeserializableControlImpl : public DeserializableControl, class DeserializableControlImpl : public DeserializableControl,
public NoDefaultMethods { public NoDefaultMethods {
public: public:
virtual void ensureData(size_t size) { virtual void ensureData(size_t /*size*/) {
} }
virtual void alignData(size_t alignment) { virtual void alignData(size_t alignment) {
buffer->align(alignment); buffer->align(alignment);
} }
virtual bool directDeserialize(ByteBuffer */*existingBuffer*/, char* /*deserializeTo*/,
std::size_t /*elementCount*/, std::size_t /*elementSize*/)
{
return false;
}
virtual std::tr1::shared_ptr<const Field> cachedDeserialize(ByteBuffer* buffer) virtual std::tr1::shared_ptr<const Field> cachedDeserialize(ByteBuffer* buffer)
{ {
return getFieldCreate()->deserialize(buffer, this); return getFieldCreate()->deserialize(buffer, this);

View File

@@ -50,7 +50,7 @@ public:
printf("poll called\n"); printf("poll called\n");
return emptyElement; return emptyElement;
} }
virtual void release(MonitorElementPtr const & monitorElement) virtual void release(MonitorElementPtr const & /*monitorElement*/)
{ {
printf("release called\n"); printf("release called\n");
} }
@@ -70,7 +70,7 @@ static void testMonitor()
} }
int main(int argc,char *argv[]) int main(int, char **)
{ {
testMonitor(); testMonitor();
return(0); return(0);

View File

@@ -48,7 +48,7 @@ static String allProperties("alarm,timeStamp,display,control");
static PVStructurePtr doubleRecord; static PVStructurePtr doubleRecord;
static PVStructurePtr enumeratedRecord; static PVStructurePtr enumeratedRecord;
static void createRecords(FILE * fd,FILE *auxfd) static void createRecords(FILE * fd,FILE */*auxfd*/)
{ {
doubleRecord = standardPVField->scalar(pvDouble,allProperties); doubleRecord = standardPVField->scalar(pvDouble,allProperties);
if(debug) { if(debug) {
@@ -70,7 +70,7 @@ static void createRecords(FILE * fd,FILE *auxfd)
} }
} }
static void printRecords(FILE * fd,FILE *auxfd) static void printRecords(FILE * fd,FILE */*auxfd*/)
{ {
fprintf(fd,"doubleRecord\n"); fprintf(fd,"doubleRecord\n");
builder.clear(); builder.clear();
@@ -82,7 +82,7 @@ static void printRecords(FILE * fd,FILE *auxfd)
fprintf(fd,"%s\n",builder.c_str()); fprintf(fd,"%s\n",builder.c_str());
} }
static void testAlarm(FILE * fd,FILE *auxfd) static void testAlarm(FILE * fd,FILE */*auxfd*/)
{ {
if(debug) fprintf(fd,"testAlarm\n"); if(debug) fprintf(fd,"testAlarm\n");
Alarm alarm; Alarm alarm;
@@ -155,7 +155,7 @@ static void testTimeStamp(FILE * fd,FILE *auxfd)
fprintf(fd,"testTimeStamp PASSED\n"); fprintf(fd,"testTimeStamp PASSED\n");
} }
static void testControl(FILE * fd,FILE *auxfd) static void testControl(FILE * fd,FILE */*auxfd*/)
{ {
if(debug) fprintf(fd,"testControl\n"); if(debug) fprintf(fd,"testControl\n");
Control control; Control control;
@@ -182,7 +182,7 @@ static void testControl(FILE * fd,FILE *auxfd)
fprintf(fd,"testControl PASSED\n"); fprintf(fd,"testControl PASSED\n");
} }
static void testDisplay(FILE * fd,FILE *auxfd) static void testDisplay(FILE * fd,FILE */*auxfd*/)
{ {
if(debug) fprintf(fd,"testDisplay\n"); if(debug) fprintf(fd,"testDisplay\n");
Display display; Display display;
@@ -215,7 +215,7 @@ static void testDisplay(FILE * fd,FILE *auxfd)
fprintf(fd,"testDisplay PASSED\n"); fprintf(fd,"testDisplay PASSED\n");
} }
static void testEnumerated(FILE * fd,FILE *auxfd) static void testEnumerated(FILE * fd,FILE */*auxfd*/)
{ {
if(debug) fprintf(fd,"testEnumerated\n"); if(debug) fprintf(fd,"testEnumerated\n");
PVEnumerated pvEnumerated; PVEnumerated pvEnumerated;

View File

@@ -2,6 +2,10 @@ TOP=../..
include $(TOP)/configure/CONFIG include $(TOP)/configure/CONFIG
PROD_HOST += testBitSetUtil
testBitSetUtil_SRCS += testBitSetUtil.cpp
testBitSetUtil_LIBS += pvData Com
PROD_HOST += testIntrospect PROD_HOST += testIntrospect
testIntrospect_SRCS += testIntrospect.cpp testIntrospect_SRCS += testIntrospect.cpp
testIntrospect_LIBS += pvData Com testIntrospect_LIBS += pvData Com
@@ -42,6 +46,10 @@ PROD_HOST += testPVStructureArray
testPVStructureArray_SRCS += testPVStructureArray.cpp testPVStructureArray_SRCS += testPVStructureArray.cpp
testPVStructureArray_LIBS += pvData Com testPVStructureArray_LIBS += pvData Com
PROD_HOST += testOperators
testOperators_SRCS += testOperators.cpp
testOperators_LIBS += pvData Com
include $(TOP)/configure/RULES include $(TOP)/configure/RULES
#---------------------------------------- #----------------------------------------
# ADD RULES AFTER THIS LINE # ADD RULES AFTER THIS LINE

View File

@@ -0,0 +1,157 @@
/* testBitSetUtil.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/* Author: Marty Kraimer Date: 2013.05 */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <epicsAssert.h>
#include <epicsExit.h>
#include <pv/requester.h>
#include <pv/bitSetUtil.h>
#include <pv/convert.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
static bool debug = false;
static FieldCreatePtr fieldCreate;
static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder("");
static void test(FILE * fd)
{
if(debug) fprintf(fd,"\ntestBitSetUtil\n");
StringArray fieldNames;
PVFieldPtrArray pvFields;
fieldNames.reserve(5);
pvFields.reserve(5);
fieldNames.push_back("timeStamp");
fieldNames.push_back("alarm");
fieldNames.push_back("voltage");
fieldNames.push_back("power");
fieldNames.push_back("current");
pvFields.push_back(
pvDataCreate->createPVStructure(standardField->timeStamp()));
pvFields.push_back(
pvDataCreate->createPVStructure(standardField->alarm()));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
pvFields.push_back(
pvDataCreate->createPVStructure(
standardField->scalar(pvDouble,"alarm")));
PVStructurePtr pvs = pvDataCreate->createPVStructure(
fieldNames,pvFields);
builder.clear();
pvs->toString(&builder);
if(debug) fprintf(fd,"pvs\n%s\n",builder.c_str());
int32 nfields = pvs->getNumberFields();
BitSetPtr bitSet = BitSet::create(nfields);
for(int32 i=0; i<nfields; i++) bitSet->set(i);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
bitSet->clear();
PVFieldPtr pvField = pvs->getSubField("timeStamp");
int32 offsetTimeStamp = pvField->getFieldOffset();
pvField = pvs->getSubField("timeStamp.secondsPastEpoch");
int32 offsetSeconds = pvField->getFieldOffset();
pvField = pvs->getSubField("timeStamp.nanoSeconds");
int32 offsetNano = pvField->getFieldOffset();
pvField = pvs->getSubField("timeStamp.userTag");
int32 offsetUserTag = pvField->getFieldOffset();
bitSet->set(offsetSeconds);
BitSetUtil::compress(bitSet,pvs);
assert(bitSet->get(offsetSeconds)==true);
bitSet->set(offsetNano);
bitSet->set(offsetUserTag);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
BitSetUtil::compress(bitSet,pvs);
assert(bitSet->get(offsetSeconds)==false);
assert(bitSet->get(offsetTimeStamp)==true);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
bitSet->clear();
pvField = pvs->getSubField("current");
int32 offsetCurrent = pvField->getFieldOffset();
pvField = pvs->getSubField("current.value");
int32 offsetValue = pvField->getFieldOffset();
pvField = pvs->getSubField("current.alarm");
int32 offsetAlarm = pvField->getFieldOffset();
pvField = pvs->getSubField("current.alarm.severity");
int32 offsetSeverity = pvField->getFieldOffset();
pvField = pvs->getSubField("current.alarm.status");
int32 offsetStatus = pvField->getFieldOffset();
pvField = pvs->getSubField("current.alarm.message");
int32 offsetMessage = pvField->getFieldOffset();
bitSet->set(offsetValue);
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
assert(bitSet->get(offsetCurrent)==true);
bitSet->clear();
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) fprintf(fd,"bitSet\n%s\n",builder.c_str());
assert(bitSet->get(offsetAlarm)==true);
bitSet->clear();
fprintf(fd,"testBitSetUtil PASSED\n");
}
int main(int argc,char *argv[])
{
char *fileName = 0;
if(argc>1) fileName = argv[1];
FILE * fd = stdout;
if(fileName!=0 && fileName[0]!=0) {
fd = fopen(fileName,"w+");
}
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();
standardField = getStandardField();
standardPVField = getStandardPVField();
convert = getConvert();
test(fd);
return(0);
}

View File

@@ -0,0 +1,91 @@
/* testOperators.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: Matej Sekoranja Date: 2013.02 */
#include <iostream>
#include <pv/pvData.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <epicsAssert.h>
using namespace epics::pvData;
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardFieldPtr standardField = getStandardField();
static StandardPVFieldPtr standardPVField = getStandardPVField();
int main(int, char **)
{
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");
const double testDV = 12.8;
PVDoublePtr pvValue = pvStructure->getDoubleField("value");
*pvValue <<= testDV;
double dv;
*pvValue >>= dv;
assert(testDV == dv);
const std::string testSV = "test message";
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
*pvMessage <<= testSV;
std::string sv;
*pvMessage >>= sv;
assert(testSV == sv);
//
// to stream tests
//
std::cout << *pvValue << std::endl;
std::cout << *pvMessage << std::endl;
std::cout << *pvStructure << std::endl;
StringArray choices;
choices.reserve(3);
choices.push_back("one");
choices.push_back("two");
choices.push_back("three");
pvStructure = standardPVField->enumerated(choices, "alarm,timeStamp,valueAlarm");
std::cout << *pvStructure << std::endl;
pvStructure = standardPVField->scalarArray(pvDouble,"alarm,timeStamp");
std::cout << *pvStructure << std::endl;
double values[] = { 1.1, 2.2, 3.3 };
PVDoubleArrayPtr darray = std::tr1::dynamic_pointer_cast<PVDoubleArray>(pvStructure->getScalarArrayField("value", pvDouble));
darray->put(0, 3, values, 0);
std::cout << *darray << std::endl;
std::cout << format::array_at(1) << *darray << std::endl;
StructureConstPtr structure = standardField->scalar(pvDouble, "alarm,timeStamp");
pvStructure = standardPVField->structureArray(structure,"alarm,timeStamp");
size_t num = 2;
PVStructurePtrArray pvStructures;
pvStructures.reserve(num);
for(size_t i=0; i<num; i++) {
pvStructures.push_back(
pvDataCreate->createPVStructure(structure));
}
PVStructureArrayPtr pvStructureArray = pvStructure->getStructureArrayField("value");
pvStructureArray->put(0, num, pvStructures, 0);
std::cout << *pvStructure << std::endl;
return 0;
}

View File

@@ -77,7 +77,7 @@ static void testCreatePVStructure(FILE * fd)
fprintf(fd,"testCreatePVStructure PASSED\n"); fprintf(fd,"testCreatePVStructure PASSED\n");
} }
static void testPVScalarCommon(FILE * fd,String fieldName,ScalarType stype) static void testPVScalarCommon(FILE * fd,String /*fieldName*/,ScalarType stype)
{ {
PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype); PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype);
if(stype==pvBoolean) { if(stype==pvBoolean) {
@@ -91,7 +91,7 @@ static void testPVScalarCommon(FILE * fd,String fieldName,ScalarType stype)
} }
static void testPVScalarWithProperties( static void testPVScalarWithProperties(
FILE * fd,String fieldName,ScalarType stype) FILE * fd,String /*fieldName*/,ScalarType stype)
{ {
PVStructurePtr pvStructure; PVStructurePtr pvStructure;
bool hasValueAlarm = false; bool hasValueAlarm = false;
@@ -335,7 +335,7 @@ static void testPVScalar(FILE * fd) {
} }
static void testScalarArrayCommon(FILE * fd,String fieldName,ScalarType stype) static void testScalarArrayCommon(FILE * fd,String /*fieldName*/,ScalarType stype)
{ {
PVStructurePtr pvStructure = standardPVField->scalarArray( PVStructurePtr pvStructure = standardPVField->scalarArray(
stype,alarmTimeStamp); stype,alarmTimeStamp);

View File

@@ -35,7 +35,7 @@ static void print(String name)
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str()); if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
} }
int main(int argc,char *argv[]) int main(int, char **)
{ {
StructureConstPtr doubleValue = standardField->scalar(pvDouble, StructureConstPtr doubleValue = standardField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm"); "alarm,timeStamp,display,control,valueAlarm");

View File

@@ -37,7 +37,7 @@ static void print(String name)
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str()); if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
} }
int main(int argc,char *argv[]) int main(int, char **)
{ {
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble, PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm"); "alarm,timeStamp,display,control,valueAlarm");