9 Commits

Author SHA1 Message Date
Andrew Johnson bc9ac8422c Update version numbers for release 2020-05-28 15:49:41 -05:00
mrkraimer c3aec4e27b get ready for next epics7 release 2020-05-20 14:01:16 -04:00
Marty Kraimer 0abfeef5ed Merge pull request #65 from dirk-zimoch/CleanupWhitespace
Cleanup whitespace
2020-05-20 08:50:14 -04:00
zimoch 745119cf77 removed empty lines at end of file 2020-04-15 17:51:17 +02:00
zimoch 9f794721ab removed spaces at end of line 2020-04-15 17:49:54 +02:00
zimoch 8f21ac8b9d replaced tabs with spaces 2020-04-15 17:45:02 +02:00
Marty Kraimer 9add9daf85 Merge pull request #64 from epics-base/issue#63
fix issue 63; add PvaClientData::getSinglePVField; simplify getDouble…
2019-12-04 05:46:44 -05:00
mrkraimer aaacadb42d fix issue 63; add PvaClientData::getSinglePVField; simplify getDouble, putDouble, etc 2019-12-02 10:32:48 -05:00
Andrew Johnson 5961c83477 Incr version and set development flag after release 2019-11-01 12:28:27 -05:00
23 changed files with 189 additions and 346 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = pvaClientCPP
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 4.7.0 PROJECT_NUMBER = 4.7.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a
+1 -1
View File
@@ -2,7 +2,7 @@
EPICS_PVACLIENT_MAJOR_VERSION = 4 EPICS_PVACLIENT_MAJOR_VERSION = 4
EPICS_PVACLIENT_MINOR_VERSION = 7 EPICS_PVACLIENT_MINOR_VERSION = 7
EPICS_PVACLIENT_MAINTENANCE_VERSION = 0 EPICS_PVACLIENT_MAINTENANCE_VERSION = 1
# Development flag, set to zero for release versions # Development flag, set to zero for release versions
+6 -1
View File
@@ -1,7 +1,12 @@
# pvaClientCPP Module pwd# pvaClientCPP Module
This document summarizes the changes to the module between releases. This document summarizes the changes to the module between releases.
## Release 4.7.1 (EPICS 7.0.3.2 May 2020)
* support access to a union field that is a scalar or scalarArray
* fixed issues #62 and #63
## Release 4.7.0 (EPICS 7.0.3.1, Nov 2019) ## Release 4.7.0 (EPICS 7.0.3.1, Nov 2019)
* added JSON support for put and putGet * added JSON support for put and putGet
+2 -2
View File
@@ -36,7 +36,7 @@
#ifdef pvaClientEpicsExportSharedSymbols #ifdef pvaClientEpicsExportSharedSymbols
# define epicsExportSharedSymbols # define epicsExportSharedSymbols
# undef pvaClientEpicsExportSharedSymbols # undef pvaClientEpicsExportSharedSymbols
#endif #endif
#include <shareLib.h> #include <shareLib.h>
@@ -713,6 +713,7 @@ public:
static PvaClientDataPtr create(epics::pvData::StructureConstPtr const & structure); static PvaClientDataPtr create(epics::pvData::StructureConstPtr const & structure);
protected: protected:
PvaClientData(epics::pvData::StructureConstPtr const & structure); PvaClientData(epics::pvData::StructureConstPtr const & structure);
epics::pvData::PVFieldPtr getSinglePVField();
void checkValue(); void checkValue();
std::string messagePrefix; std::string messagePrefix;
private: private:
@@ -1859,4 +1860,3 @@ private:
* <a href = "../pvaClientCPP.html">pvaClientCPP.html</a> * <a href = "../pvaClientCPP.html">pvaClientCPP.html</a>
* *
*/ */
+1 -2
View File
@@ -21,7 +21,7 @@
#ifdef pvaClientMultiChannelEpicsExportSharedSymbols #ifdef pvaClientMultiChannelEpicsExportSharedSymbols
# define epicsExportSharedSymbols # define epicsExportSharedSymbols
# undef pvaClientMultiChannelEpicsExportSharedSymbols # undef pvaClientMultiChannelEpicsExportSharedSymbols
#endif #endif
@@ -615,4 +615,3 @@ private:
}} }}
#endif /* PVACLIENTMULTICHANNEL_H */ #endif /* PVACLIENTMULTICHANNEL_H */
-1
View File
@@ -231,4 +231,3 @@ size_t PvaClient::cacheSize()
} }
}} }}
+44 -112
View File
@@ -57,6 +57,30 @@ PvaClientData::PvaClientData(StructureConstPtr const & structure)
{ {
} }
PVFieldPtr PvaClientData::getSinglePVField()
{
if(PvaClient::getDebug()) cout << "PvaClientData::getSinglePVField\n";
PVStructurePtr pvStructure = getPVStructure();
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()==0) {
throw std::logic_error("PvaClientData::getSinglePVField() pvRequest for empty structure");
}
if(fieldPtrArray.size()!=1) {
PVFieldPtr pvValue = pvStructure->getSubField("value");
if(pvValue) {
Type type = pvValue->getField()->getType();
if(type!=epics::pvData::structure) return pvValue;
}
throw std::logic_error("PvaClientData::getSinglePVField() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type!=epics::pvData::structure) return pvField;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
void PvaClientData::checkValue() void PvaClientData::checkValue()
{ {
if(PvaClient::getDebug()) cout << "PvaClientData::checkValue\n"; if(PvaClient::getDebug()) cout << "PvaClientData::checkValue\n";
@@ -180,34 +204,12 @@ PVScalarArrayPtr PvaClientData::getScalarArrayValue()
double PvaClientData::getDouble() double PvaClientData::getDouble()
{ {
if(PvaClient::getDebug()) cout << "PvaClientData::getDouble\n"; if(PvaClient::getDebug()) cout << "PvaClientData::getDouble\n";
PVScalarPtr pvScalar; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalar) {
if(pvValue) { throw std::logic_error("PvaClientData::getDouble() did not find a scalar field");
Type type = pvValue->getField()->getType();
if(type==scalar) pvScalar = static_pointer_cast<PVScalar>(pvValue);
}
if(!pvScalar) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::getDouble() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalar) {
pvScalar = static_pointer_cast<PVScalar>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalar) {
throw std::logic_error(
"PvaClientData::getDouble() did not find a scalar field");
} }
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
ScalarType scalarType = pvScalar->getScalar()->getScalarType(); ScalarType scalarType = pvScalar->getScalar()->getScalarType();
if(scalarType==pvDouble) { if(scalarType==pvDouble) {
PVDoublePtr pvDouble = static_pointer_cast<PVDouble>(pvScalar); PVDoublePtr pvDouble = static_pointer_cast<PVDouble>(pvScalar);
@@ -223,70 +225,24 @@ double PvaClientData::getDouble()
string PvaClientData::getString() string PvaClientData::getString()
{ {
if(PvaClient::getDebug()) cout << "PvaClientData::getString\n"; if(PvaClient::getDebug()) cout << "PvaClientData::getString\n";
PVScalarPtr pvScalar; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalar) {
if(pvValue) { throw std::logic_error("PvaClientData::getString() did not find a scalar field");
Type type = pvValue->getField()->getType();
if(type==scalar) pvScalar = static_pointer_cast<PVScalar>(pvValue);
}
if(!pvScalar) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::getString() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalar) {
pvScalar = static_pointer_cast<PVScalar>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalar) {
throw std::logic_error(
"PvaClientData::getString() did not find a scalar field");
} }
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
return convert->toString(pvScalar); return convert->toString(pvScalar);
} }
shared_vector<const double> PvaClientData::getDoubleArray() shared_vector<const double> PvaClientData::getDoubleArray()
{ {
if(PvaClient::getDebug()) cout << "PvaClientData::getDoubleArray\n"; if(PvaClient::getDebug()) cout << "PvaClientData::getDoubleArray\n";
PVScalarArrayPtr pvScalarArray; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalarArray) {
if(pvValue) { throw std::logic_error("PvaClientData::getDoubleArray() did not find a scalarArray field");
Type type = pvValue->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvValue);
}
}
if(!pvScalarArray) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::getDoubleArray() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalarArray) {
throw std::logic_error(
"PvaClientData::getDoubleArray() did not find a scalarArray field");
} }
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
ScalarType scalarType = pvScalarArray->getScalarArray()->getElementType(); ScalarType scalarType = pvScalarArray->getScalarArray()->getElementType();
if(!ScalarTypeFunc::isNumeric(scalarType)) { if(!ScalarTypeFunc::isNumeric(scalarType)) {
throw std::logic_error( throw std::logic_error(
@@ -300,36 +256,12 @@ shared_vector<const double> PvaClientData::getDoubleArray()
shared_vector<const string> PvaClientData::getStringArray() shared_vector<const string> PvaClientData::getStringArray()
{ {
if(PvaClient::getDebug()) cout << "PvaClientData::getStringArray\n"; if(PvaClient::getDebug()) cout << "PvaClientData::getStringArray\n";
PVScalarArrayPtr pvScalarArray; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalarArray) {
if(pvValue) { throw std::logic_error("PvaClientData::getStringArray() did not find a scalarArray field");
Type type = pvValue->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvValue);
}
}
if(!pvScalarArray) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::getStringArray() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalarArray) {
throw std::logic_error(
"PvaClientData::getStringArray() did not find a scalarArray field");
} }
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
shared_vector<const string> retValue; shared_vector<const string> retValue;
pvScalarArray->getAs<const string>(retValue); pvScalarArray->getAs<const string>(retValue);
return retValue; return retValue;
+1 -1
View File
@@ -80,7 +80,7 @@ Status PvaClientMultiChannel::connect(double timeout)
Status status = Status::Ok; Status status = Status::Ok;
size_t numBad = 0; size_t numBad = 0;
for(size_t i=0; i< numChannel; ++i) { for(size_t i=0; i< numChannel; ++i) {
if(numBad==0) { if(numBad==0) {
status = pvaClientChannelArray[i]->waitConnect(timeout); status = pvaClientChannelArray[i]->waitConnect(timeout);
} else { } else {
status = pvaClientChannelArray[i]->waitConnect(.001); status = pvaClientChannelArray[i]->waitConnect(.001);
+20 -112
View File
@@ -74,34 +74,12 @@ PvaClientPutData::PvaClientPutData(StructureConstPtr const & structure)
void PvaClientPutData::putDouble(double value) void PvaClientPutData::putDouble(double value)
{ {
if(PvaClient::getDebug()) cout << "PvaClientPutData::putDouble\n"; if(PvaClient::getDebug()) cout << "PvaClientPutData::putDouble\n";
PVScalarPtr pvScalar; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalar) {
if(pvValue) { throw std::logic_error("PvaClientData::putDouble() did not find a scalar field");
Type type = pvValue->getField()->getType();
if(type==scalar) pvScalar = static_pointer_cast<PVScalar>(pvValue);
}
if(!pvScalar) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::putDouble() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalar) {
pvScalar = static_pointer_cast<PVScalar>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalar) {
throw std::logic_error(
"PvaClientData::putDouble() did not find a scalar field");
} }
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
ScalarType scalarType = pvScalar->getScalar()->getScalarType(); ScalarType scalarType = pvScalar->getScalar()->getScalarType();
if(scalarType==pvDouble) { if(scalarType==pvDouble) {
PVDoublePtr pvDouble = static_pointer_cast<PVDouble>(pvScalar); PVDoublePtr pvDouble = static_pointer_cast<PVDouble>(pvScalar);
@@ -118,70 +96,24 @@ void PvaClientPutData::putDouble(double value)
void PvaClientPutData::putString(std::string const & value) void PvaClientPutData::putString(std::string const & value)
{ {
if(PvaClient::getDebug()) cout << "PvaClientPutData::putString\n"; if(PvaClient::getDebug()) cout << "PvaClientPutData::putString\n";
PVScalarPtr pvScalar; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalar) {
if(pvValue) { throw std::logic_error("PvaClientData::putString() did not find a scalar field");
Type type = pvValue->getField()->getType();
if(type==scalar) pvScalar = static_pointer_cast<PVScalar>(pvValue);
}
if(!pvScalar) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::putString() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalar) {
pvScalar = static_pointer_cast<PVScalar>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalar) {
throw std::logic_error(
"PvaClientData::putString() did not find a scalar field");
} }
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
convert->fromString(pvScalar,value); convert->fromString(pvScalar,value);
} }
void PvaClientPutData::putDoubleArray(shared_vector<const double> const & value) void PvaClientPutData::putDoubleArray(shared_vector<const double> const & value)
{ {
if(PvaClient::getDebug()) cout << "PvaClientPutData::putDoubleArray\n"; if(PvaClient::getDebug()) cout << "PvaClientPutData::putDoubleArray\n";
PVScalarArrayPtr pvScalarArray; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalarArray) {
if(pvValue) { throw std::logic_error("PvaClientData::putDoubleArray() did not find a scalarArray field");
Type type = pvValue->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvValue);
}
}
if(!pvScalarArray) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::putDoubleArray() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalarArray) {
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalarArray) {
throw std::logic_error(
"PvaClientData::putDoubleArray() did not find a scalarArray field");
} }
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
ScalarType scalarType = pvScalarArray->getScalarArray()->getElementType(); ScalarType scalarType = pvScalarArray->getScalarArray()->getElementType();
if(!ScalarTypeFunc::isNumeric(scalarType)) { if(!ScalarTypeFunc::isNumeric(scalarType)) {
throw std::logic_error( throw std::logic_error(
@@ -193,36 +125,12 @@ void PvaClientPutData::putDoubleArray(shared_vector<const double> const & value)
void PvaClientPutData::putStringArray(shared_vector<const std::string> const & value) void PvaClientPutData::putStringArray(shared_vector<const std::string> const & value)
{ {
if(PvaClient::getDebug()) cout << "PvaClientPutData::putStringArray\n"; if(PvaClient::getDebug()) cout << "PvaClientPutData::putStringArray\n";
PVScalarArrayPtr pvScalarArray; PVFieldPtr pvField = getSinglePVField();
PVStructurePtr pvStructure = getPVStructure(); Type type = pvField->getField()->getType();
PVFieldPtr pvValue = pvStructure->getSubField("value"); if(type!=scalarArray) {
if(pvValue) { throw std::logic_error("PvaClientData::putStringArray() did not find a scalarArray field");
Type type = pvValue->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvValue);
}
}
if(!pvScalarArray) {
while(true) {
const PVFieldPtrArray fieldPtrArray(pvStructure->getPVFields());
if(fieldPtrArray.size()!=1) {
throw std::logic_error(
"PvaClientData::putStringArray() pvRequest for multiple fields");
}
PVFieldPtr pvField(fieldPtrArray[0]);
Type type = pvField->getField()->getType();
if(type==scalarArray) {
pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
break;
}
if(pvField->getField()->getType()!=epics::pvData::structure) break;
pvStructure = static_pointer_cast<PVStructure>(pvField);
}
}
if(!pvScalarArray) {
throw std::logic_error(
"PvaClientData::putStringArray() did not find a scalarArray field");
} }
PVScalarArrayPtr pvScalarArray = static_pointer_cast<PVScalarArray>(pvField);
pvScalarArray->putFrom<const string>(value); pvScalarArray->putFrom<const string>(value);
return; return;
} }