All PVScalar interfaces now implemented
This commit is contained in:
@@ -13,8 +13,6 @@ namespace epics { namespace pvData {
|
||||
|
||||
static String notImplemented("not implemented");
|
||||
|
||||
static Convert *convert = 0;
|
||||
|
||||
class PVFieldPvt {
|
||||
public:
|
||||
PVFieldPvt(PVStructure *parent,FieldConstPtr field);
|
||||
@@ -27,21 +25,15 @@ static String notImplemented("not implemented");
|
||||
epicsBoolean immutable;
|
||||
Requester *requester;
|
||||
PostHandler *postHandler;
|
||||
private:
|
||||
static void init();
|
||||
};
|
||||
|
||||
void PVFieldPvt::init()
|
||||
{
|
||||
convert = getConvert();
|
||||
}
|
||||
|
||||
PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field)
|
||||
: parent(parent),field(field),
|
||||
fieldOffset(0), nextFieldOffset(0),
|
||||
pvAuxInfo(0),
|
||||
immutable(epicsFalse),requester(0),postHandler(0)
|
||||
{
|
||||
delete pvAuxInfo;
|
||||
field->incReferenceCount();
|
||||
}
|
||||
|
||||
@@ -146,11 +138,17 @@ static String notImplemented("not implemented");
|
||||
|
||||
void PVField::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
if(pImpl->pvAuxInfo==0) return;
|
||||
pImpl->pvAuxInfo->toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
void PVField::computeOffset(PVField * pvField) {
|
||||
PVStructure *pvTop = pvField->getParent();
|
||||
Type type = pvField->getField()->getType();
|
||||
if(type!=structure) {
|
||||
pvField->pImpl->nextFieldOffset = 1;
|
||||
return;
|
||||
}
|
||||
if(pvTop==0) {
|
||||
pvTop = (PVStructure *)pvField;
|
||||
} else {
|
||||
|
||||
70
pvDataApp/factory/BasePVBoolean.h
Normal file
70
pvDataApp/factory/BasePVBoolean.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVBoolean.h*/
|
||||
#ifndef BASEPVBOOLEAN_H
|
||||
#define BASEPVBOOLEAN_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVBoolean::~PVBoolean() {}
|
||||
|
||||
class BasePVBoolean : public PVBoolean {
|
||||
public:
|
||||
BasePVBoolean(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVBoolean();
|
||||
virtual epicsBoolean get();
|
||||
virtual void put(epicsBoolean val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
epicsBoolean value;
|
||||
};
|
||||
|
||||
BasePVBoolean::BasePVBoolean(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVBoolean(parent,scalar),value(epicsFalse)
|
||||
{}
|
||||
|
||||
BasePVBoolean::~BasePVBoolean() {}
|
||||
|
||||
epicsBoolean BasePVBoolean::get() { return value;}
|
||||
|
||||
void BasePVBoolean::put(epicsBoolean val){value = val;}
|
||||
|
||||
void BasePVBoolean::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVBoolean::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVBoolean::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVBoolean::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVBoolean::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVBOOLEAN_H */
|
||||
70
pvDataApp/factory/BasePVByte.h
Normal file
70
pvDataApp/factory/BasePVByte.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVByte.h*/
|
||||
#ifndef BASEPVBYTE_H
|
||||
#define BASEPVBYTE_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVByte::~PVByte() {}
|
||||
|
||||
class BasePVByte : public PVByte {
|
||||
public:
|
||||
BasePVByte(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVByte();
|
||||
virtual epicsInt8 get();
|
||||
virtual void put(epicsInt8 val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
epicsInt8 value;
|
||||
};
|
||||
|
||||
BasePVByte::BasePVByte(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVByte(parent,scalar),value(0.0)
|
||||
{}
|
||||
|
||||
BasePVByte::~BasePVByte() {}
|
||||
|
||||
epicsInt8 BasePVByte::get() { return value;}
|
||||
|
||||
void BasePVByte::put(epicsInt8 val){value = val;}
|
||||
|
||||
void BasePVByte::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVByte::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVByte::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVByte::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVByte::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVBYTE_H */
|
||||
@@ -57,13 +57,13 @@ namespace epics { namespace pvData {
|
||||
|
||||
void BasePVDouble::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
convert->getString(buf,this,indentLevel);
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVDouble::equals(PVField *)
|
||||
epicsBoolean BasePVDouble::equals(PVField *pvField)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace epics { namespace pvData {
|
||||
|
||||
void BasePVDoubleArray::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
convert->getString(buf,this,indentLevel);
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVArray::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
|
||||
70
pvDataApp/factory/BasePVFloat.h
Normal file
70
pvDataApp/factory/BasePVFloat.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVFloat.h*/
|
||||
#ifndef BASEPVFLOAT_H
|
||||
#define BASEPVFLOAT_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVFloat::~PVFloat() {}
|
||||
|
||||
class BasePVFloat : public PVFloat {
|
||||
public:
|
||||
BasePVFloat(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVFloat();
|
||||
virtual float get();
|
||||
virtual void put(float val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
float value;
|
||||
};
|
||||
|
||||
BasePVFloat::BasePVFloat(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVFloat(parent,scalar),value(0.0)
|
||||
{}
|
||||
|
||||
BasePVFloat::~BasePVFloat() {}
|
||||
|
||||
float BasePVFloat::get() { return value;}
|
||||
|
||||
void BasePVFloat::put(float val){value = val;}
|
||||
|
||||
void BasePVFloat::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVFloat::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVFloat::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVFloat::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVFloat::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVFLOAT_H */
|
||||
70
pvDataApp/factory/BasePVInt.h
Normal file
70
pvDataApp/factory/BasePVInt.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVInt.h*/
|
||||
#ifndef BASEPVINT_H
|
||||
#define BASEPVINT_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVInt::~PVInt() {}
|
||||
|
||||
class BasePVInt : public PVInt {
|
||||
public:
|
||||
BasePVInt(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVInt();
|
||||
virtual epicsInt32 get();
|
||||
virtual void put(epicsInt32 val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
epicsInt32 value;
|
||||
};
|
||||
|
||||
BasePVInt::BasePVInt(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVInt(parent,scalar),value(0.0)
|
||||
{}
|
||||
|
||||
BasePVInt::~BasePVInt() {}
|
||||
|
||||
epicsInt32 BasePVInt::get() { return value;}
|
||||
|
||||
void BasePVInt::put(epicsInt32 val){value = val;}
|
||||
|
||||
void BasePVInt::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVInt::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVInt::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVInt::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVInt::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVINT_H */
|
||||
70
pvDataApp/factory/BasePVLong.h
Normal file
70
pvDataApp/factory/BasePVLong.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVLong.h*/
|
||||
#ifndef BASEPVLONG_H
|
||||
#define BASEPVLONG_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVLong::~PVLong() {}
|
||||
|
||||
class BasePVLong : public PVLong {
|
||||
public:
|
||||
BasePVLong(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVLong();
|
||||
virtual epicsInt64 get();
|
||||
virtual void put(epicsInt64 val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
epicsInt64 value;
|
||||
};
|
||||
|
||||
BasePVLong::BasePVLong(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVLong(parent,scalar),value(0.0)
|
||||
{}
|
||||
|
||||
BasePVLong::~BasePVLong() {}
|
||||
|
||||
epicsInt64 BasePVLong::get() { return value;}
|
||||
|
||||
void BasePVLong::put(epicsInt64 val){value = val;}
|
||||
|
||||
void BasePVLong::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVLong::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVLong::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVLong::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVLong::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVLONG_H */
|
||||
70
pvDataApp/factory/BasePVShort.h
Normal file
70
pvDataApp/factory/BasePVShort.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVShort.h*/
|
||||
#ifndef BASEPVSHORT_H
|
||||
#define BASEPVSHORT_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVShort::~PVShort() {}
|
||||
|
||||
class BasePVShort : public PVShort {
|
||||
public:
|
||||
BasePVShort(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVShort();
|
||||
virtual epicsInt16 get();
|
||||
virtual void put(epicsInt16 val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
epicsInt16 value;
|
||||
};
|
||||
|
||||
BasePVShort::BasePVShort(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVShort(parent,scalar),value(0.0)
|
||||
{}
|
||||
|
||||
BasePVShort::~BasePVShort() {}
|
||||
|
||||
epicsInt16 BasePVShort::get() { return value;}
|
||||
|
||||
void BasePVShort::put(epicsInt16 val){value = val;}
|
||||
|
||||
void BasePVShort::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVShort::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVShort::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVShort::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVShort::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVSHORT_H */
|
||||
70
pvDataApp/factory/BasePVString.h
Normal file
70
pvDataApp/factory/BasePVString.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*BasePVString.h*/
|
||||
#ifndef BASEPVSTRING_H
|
||||
#define BASEPVSTRING_H
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "AbstractPVField.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
PVString::~PVString() {}
|
||||
|
||||
class BasePVString : public PVString {
|
||||
public:
|
||||
BasePVString(PVStructure *parent,ScalarConstPtr scalar);
|
||||
virtual ~BasePVString();
|
||||
virtual String get();
|
||||
virtual void put(String val);
|
||||
virtual void serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher) ;
|
||||
virtual void deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher);
|
||||
virtual void toString(StringBuilder buf);
|
||||
virtual void toString(StringBuilder buf,int indentLevel);
|
||||
virtual epicsBoolean equals(PVField *pv) ;
|
||||
private:
|
||||
String value;
|
||||
};
|
||||
|
||||
BasePVString::BasePVString(PVStructure *parent,ScalarConstPtr scalar)
|
||||
: PVString(parent,scalar),value("")
|
||||
{}
|
||||
|
||||
BasePVString::~BasePVString() {}
|
||||
|
||||
String BasePVString::get() { return value;}
|
||||
|
||||
void BasePVString::put(String val){value = val;}
|
||||
|
||||
void BasePVString::serialize(ByteBuffer *pbuffer,
|
||||
SerializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVString::deserialize(ByteBuffer *pbuffer,
|
||||
DeserializableControl *pflusher)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
void BasePVString::toString(StringBuilder buf) {toString(buf,0);}
|
||||
|
||||
void BasePVString::toString(StringBuilder buf,int indentLevel)
|
||||
{
|
||||
getConvert()->getString(buf,this,indentLevel);
|
||||
PVField::toString(buf,indentLevel);
|
||||
}
|
||||
|
||||
epicsBoolean BasePVString::equals(PVField *pvField)
|
||||
{
|
||||
return getConvert()->equals(this,pvField);
|
||||
}
|
||||
|
||||
}}
|
||||
#endif /* BASEPVSTRING_H */
|
||||
@@ -15,6 +15,7 @@ static Convert* convert = 0;
|
||||
|
||||
static String notImplemented("not implemented");
|
||||
|
||||
static epicsBoolean convertEquals(PVField *a,PVField *b);
|
||||
static int convertFromByteArray(PVScalarArray *pv, int offset,
|
||||
int len,epicsInt8 from[], int fromOffset);
|
||||
static int convertToByteArray(PVScalarArray *pv, int offset,
|
||||
@@ -97,6 +98,11 @@ void Convert::getFullName(StringBuilder buf,PVField * pvField)
|
||||
}
|
||||
}
|
||||
|
||||
epicsBoolean Convert::equals(PVField *a,PVField *b)
|
||||
{
|
||||
return convertEquals(a,b);
|
||||
}
|
||||
|
||||
void Convert::getString(StringBuilder buf,PVField * pvField,int indentLevel)
|
||||
{
|
||||
convertToString(buf,pvField,indentLevel);
|
||||
@@ -732,6 +738,109 @@ void Convert::newLine(StringBuilder buffer, int indentLevel)
|
||||
for(int i=0; i<indentLevel; i++) *buffer += " ";
|
||||
}
|
||||
|
||||
static epicsBoolean scalarEquals(PVScalar *a,PVScalar *b)
|
||||
{
|
||||
ScalarType ascalarType = a->getScalar()->getScalarType();
|
||||
ScalarType bscalarType = b->getScalar()->getScalarType();
|
||||
if(ascalarType!=bscalarType) return epicsFalse;
|
||||
switch(ascalarType) {
|
||||
case pvBoolean: {
|
||||
PVBoolean *pa = (PVBoolean *)a;
|
||||
PVBoolean *pb = (PVBoolean *)b;
|
||||
epicsBoolean avalue = pa->get();
|
||||
epicsBoolean bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvByte: {
|
||||
PVByte *pa = (PVByte *)a;
|
||||
PVByte *pb = (PVByte *)b;
|
||||
epicsInt8 avalue = pa->get();
|
||||
epicsInt8 bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvShort: {
|
||||
PVShort *pa = (PVShort *)a;
|
||||
PVShort *pb = (PVShort *)b;
|
||||
epicsInt16 avalue = pa->get();
|
||||
epicsInt16 bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvInt: {
|
||||
PVInt *pa = (PVInt *)a;
|
||||
PVInt *pb = (PVInt *)b;
|
||||
epicsInt32 avalue = pa->get();
|
||||
epicsInt32 bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvLong: {
|
||||
PVLong *pa = (PVLong *)a;
|
||||
PVLong *pb = (PVLong *)b;
|
||||
epicsInt64 avalue = pa->get();
|
||||
epicsInt64 bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvFloat: {
|
||||
PVFloat *pa = (PVFloat *)a;
|
||||
PVFloat *pb = (PVFloat *)b;
|
||||
float avalue = pa->get();
|
||||
float bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvDouble: {
|
||||
PVDouble *pa = (PVDouble *)a;
|
||||
PVDouble *pb = (PVDouble *)b;
|
||||
double avalue = pa->get();
|
||||
double bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
case pvString: {
|
||||
PVString *pa = (PVString *)a;
|
||||
PVString *pb = (PVString *)b;
|
||||
String avalue = pa->get();
|
||||
String bvalue = pb->get();
|
||||
return ((avalue==bvalue) ? epicsTrue : epicsFalse);
|
||||
}
|
||||
}
|
||||
String message("should not get here");
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
|
||||
static epicsBoolean arrayEquals(PVScalarArray *a,PVScalarArray *b)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
static epicsBoolean structureArrayEquals(PVStructureArray *a,PVStructureArray *b)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
static epicsBoolean structureEquals(PVStructure *a,PVStructure *b)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
epicsBoolean convertEquals(PVField *a,PVField *b)
|
||||
{
|
||||
if(a==b) return epicsTrue;
|
||||
Type atype = a->getField()->getType();
|
||||
Type btype = b->getField()->getType();
|
||||
if(atype!=btype) return epicsFalse;
|
||||
if(atype==scalar) return scalarEquals((PVScalar *)a,(PVScalar *)b);
|
||||
if(atype==scalarArray) {
|
||||
return arrayEquals((PVScalarArray *)a,(PVScalarArray *)b);
|
||||
}
|
||||
if(atype==structureArray) {
|
||||
return structureArrayEquals(
|
||||
(PVStructureArray *)a,(PVStructureArray *)b);
|
||||
}
|
||||
if(atype==structure) {
|
||||
return structureEquals((PVStructure *)a,(PVStructure *)b);
|
||||
}
|
||||
String message("should not get here");
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
|
||||
int convertFromByteArray(PVScalarArray *pv, int offset, int len,epicsInt8 from[], int fromOffset)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
@@ -805,7 +914,78 @@ int convertToStringArray(PVScalarArray * pv, int offset, int len,String to[], in
|
||||
|
||||
void convertToString(StringBuilder buffer,PVField * pv,int indentLevel)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
Type type = pv->getField()->getType();
|
||||
if(type==scalarArray) {
|
||||
return convertArray(buffer,(PVScalarArray *)pv,indentLevel);
|
||||
}
|
||||
if(type==structure) {
|
||||
return convertStructure(buffer,(PVStructure*)pv,indentLevel);
|
||||
}
|
||||
if(type==structureArray) {
|
||||
return convertStructureArray(buffer,(PVStructureArray*)pv,indentLevel);
|
||||
}
|
||||
PVScalar *pvScalar = (PVScalar*)pv;
|
||||
switch(pvScalar->getScalar()->getScalarType()) {
|
||||
case pvBoolean: {
|
||||
PVBoolean *data = (PVBoolean*)pv;
|
||||
epicsBoolean value = data->get();
|
||||
if(value) {
|
||||
*buffer += "true";
|
||||
} else {
|
||||
*buffer += "false";
|
||||
}
|
||||
}
|
||||
return;
|
||||
case pvByte: {
|
||||
PVByte *data = (PVByte*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%d",(int)data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvShort: {
|
||||
PVShort *data = (PVShort*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%d",(int)data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvInt: {
|
||||
PVInt *data = (PVInt*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%d",(int)data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvLong: {
|
||||
PVLong *data = (PVLong*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%ld",(long int)data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvFloat: {
|
||||
PVFloat *data = (PVFloat*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%g",data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvDouble: {
|
||||
PVDouble *data = (PVDouble*)pv;
|
||||
char xxx[30];
|
||||
sprintf(xxx,"%lg",data->get());
|
||||
*buffer += xxx;
|
||||
}
|
||||
return;
|
||||
case pvString: {
|
||||
PVString *data = (PVString*)pv;
|
||||
*buffer += data->get();
|
||||
}
|
||||
return;
|
||||
default:
|
||||
*buffer += "unknown ScalarType";
|
||||
}
|
||||
}
|
||||
|
||||
void convertStructure(StringBuilder buffer,PVStructure *data,int indentLevel)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static DebugLevel debugLevel = highDebug;
|
||||
static DebugLevel debugLevel = lowDebug;
|
||||
static void newLine(StringBuilder buffer, int indentLevel)
|
||||
{
|
||||
*buffer += "\n";
|
||||
|
||||
@@ -8,7 +8,14 @@ INC += AbstractPVScalar.h
|
||||
INC += AbstractPVArray.h
|
||||
INC += AbstractPVScalarArray.h
|
||||
INC += BasePVStructure.h
|
||||
INC += BasePVBoolean.h
|
||||
INC += BasePVByte.h
|
||||
INC += BasePVShort.h
|
||||
INC += BasePVInt.h
|
||||
INC += BasePVLong.h
|
||||
INC += BasePVFloat.h
|
||||
INC += BasePVDouble.h
|
||||
INC += BasePVString.h
|
||||
INC += BasePVDoubleArray.h
|
||||
INC += BasePVStructure.h
|
||||
INC += BasePVStructureArray.h
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static PVDataCreate *pvDataCreate =0;
|
||||
|
||||
class PVAuxInfoPvt {
|
||||
public:
|
||||
PVAuxInfoPvt(PVField *pvField)
|
||||
@@ -26,10 +24,6 @@ namespace epics { namespace pvData {
|
||||
{ }
|
||||
|
||||
PVAuxInfo::~PVAuxInfo() { delete pImpl;}
|
||||
|
||||
void PVAuxInfo::init() {
|
||||
pvDataCreate = getPVDataCreate();
|
||||
}
|
||||
|
||||
PVField * PVAuxInfo::getPVField() {
|
||||
return pImpl->pvField;
|
||||
@@ -47,7 +41,7 @@ namespace epics { namespace pvData {
|
||||
ScalarTypeFunc::toString(&message,scalarType);
|
||||
pImpl->pvField->message(message,errorMessage);
|
||||
}
|
||||
PVScalar *pvScalar = pvDataCreate->createPVScalar(0,key,scalarType);
|
||||
PVScalar *pvScalar = getPVDataCreate()->createPVScalar(0,key,scalarType);
|
||||
pImpl->theMap.insert(std::pair<String,PVScalar * >(key, pvScalar));
|
||||
return pvScalar;
|
||||
|
||||
@@ -80,6 +74,7 @@ namespace epics { namespace pvData {
|
||||
*buf += key.c_str();
|
||||
*buf += " ";
|
||||
value->toString(buf);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -12,7 +12,14 @@
|
||||
#include "AbstractPVScalar.h"
|
||||
#include "AbstractPVArray.h"
|
||||
#include "AbstractPVScalarArray.h"
|
||||
#include "BasePVBoolean.h"
|
||||
#include "BasePVByte.h"
|
||||
#include "BasePVShort.h"
|
||||
#include "BasePVInt.h"
|
||||
#include "BasePVLong.h"
|
||||
#include "BasePVFloat.h"
|
||||
#include "BasePVDouble.h"
|
||||
#include "BasePVString.h"
|
||||
#include "AbstractPVArray.h"
|
||||
#include "BasePVDoubleArray.h"
|
||||
#include "BasePVStructure.h"
|
||||
@@ -70,8 +77,22 @@ namespace epics { namespace pvData {
|
||||
{
|
||||
ScalarType scalarType = scalar->getScalarType();
|
||||
switch(scalarType) {
|
||||
case pvBoolean:
|
||||
return new BasePVBoolean(parent,scalar);
|
||||
case pvByte:
|
||||
return new BasePVByte(parent,scalar);
|
||||
case pvShort:
|
||||
return new BasePVShort(parent,scalar);
|
||||
case pvInt:
|
||||
return new BasePVInt(parent,scalar);
|
||||
case pvLong:
|
||||
return new BasePVLong(parent,scalar);
|
||||
case pvFloat:
|
||||
return new BasePVFloat(parent,scalar);
|
||||
case pvDouble:
|
||||
return new BasePVDouble(parent,scalar);
|
||||
case pvString:
|
||||
return new BasePVString(parent,scalar);
|
||||
default:
|
||||
throw std::logic_error(notImplemented);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <lock.h>
|
||||
#include "pvIntrospect.h"
|
||||
#include "pvData.h"
|
||||
#include "convert.h"
|
||||
#include "standardField.h"
|
||||
|
||||
@@ -13,14 +15,18 @@ static String notImplemented("not implemented");
|
||||
|
||||
StandardField::~StandardField(){}
|
||||
|
||||
PVScalar * StandardField::scalarValue(ScalarType type)
|
||||
PVScalar * StandardField::scalarValue(ScalarType scalarType)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
ScalarConstPtr scalar = getFieldCreate()->createScalar(
|
||||
String("value"),scalarType);
|
||||
return getPVDataCreate()->createPVScalar(0,scalar);
|
||||
}
|
||||
|
||||
PVScalarArray * StandardField::scalarArrayValue(ScalarType elementType)
|
||||
{
|
||||
throw std::logic_error(notImplemented);
|
||||
ScalarArrayConstPtr scalarArray = getFieldCreate()->createScalarArray(
|
||||
String("value"),elementType);
|
||||
return getPVDataCreate()->createPVScalarArray(0,scalarArray);
|
||||
}
|
||||
|
||||
PVStructure * StandardField::scalarValue(ScalarType type,String properties)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#ifndef REQUESTER_H
|
||||
#define REQUESTER_H
|
||||
#include "pvIntrospect.h"
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
class Requester;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace epics { namespace pvData {
|
||||
Convert();
|
||||
~Convert();
|
||||
void getFullName(StringBuilder buf,PVField *pvField);
|
||||
epicsBoolean equals(PVField *a,PVField *b);
|
||||
void getString(StringBuilder buf,PVField * pvField,int indentLevel);
|
||||
void getString(StringBuilder buf,PVField *pvField);
|
||||
void fromString(PVScalar *pv, String from);
|
||||
|
||||
@@ -29,12 +29,16 @@ void testDouble() {
|
||||
}
|
||||
PVAuxInfo *auxInfo = pvValue->getPVAuxInfo();
|
||||
String stringName("string");
|
||||
pvScalar = auxInfo->createInfo(stringName,pvDouble);
|
||||
PVDouble *doubleInfo = dynamic_cast<PVDouble *>(pvScalar);
|
||||
PVScalar *pvAux = auxInfo->createInfo(stringName,pvDouble);
|
||||
PVDouble *doubleInfo = dynamic_cast<PVDouble *>(pvAux);
|
||||
doubleInfo->put(100.0);
|
||||
pvScalar = auxInfo->getInfo(stringName);
|
||||
pvAux = auxInfo->getInfo(stringName);
|
||||
buffer.clear();
|
||||
buffer += "stringInfo ";
|
||||
buffer += "auxInfo ";
|
||||
printf("\ncalling toString\n");
|
||||
printf("%s\n",buffer.c_str());
|
||||
buffer.clear();
|
||||
buffer += "pvScalar ";
|
||||
pvScalar->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
delete pvValue;
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "requester.h"
|
||||
#include "pvIntrospect.h"
|
||||
#include "pvData.h"
|
||||
#include "standardField.h"
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
@@ -15,16 +18,218 @@ static FieldCreate * pfieldCreate = 0;
|
||||
static PVDataCreate *pvDataCreate = 0;
|
||||
static String buffer("");
|
||||
|
||||
void testDouble() {
|
||||
printf("\ntestDouble\n");
|
||||
String valueName("value");
|
||||
ScalarConstPtr pscalar = pfieldCreate->createScalar(valueName,pvDouble);
|
||||
PVScalar *pvScalar = pvDataCreate->createPVScalar(0,pscalar);
|
||||
PVDouble *pvValue = (PVDouble *)pvScalar;
|
||||
double value = 2;
|
||||
void testBoolean() {
|
||||
printf("\ntestBoolean\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvBoolean);
|
||||
PVBoolean *pvValue = (PVBoolean *)pvScalar;
|
||||
epicsBoolean value = epicsTrue;
|
||||
pvValue->put(value);
|
||||
double getValue = pvValue->get();
|
||||
printf("put %lf get %lf\n",value,getValue);
|
||||
epicsBoolean getValue = pvValue->get();
|
||||
printf("put %s get %s\n",
|
||||
((value==epicsFalse) ? "false" : "true"),
|
||||
((getValue==epicsFalse) ? "false" : "true"));
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %s get %s\n",
|
||||
((value==epicsFalse) ? "false" : "true"),
|
||||
((getValue==epicsFalse) ? "false" : "true"));
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
PVScalar *other = getStandardField()->scalarValue(pvDouble);
|
||||
epicsBoolean isEqual = pvScalar->equals(other);
|
||||
printf("expect false isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testByte() {
|
||||
printf("\ntestByte\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvByte);
|
||||
PVByte *pvValue = (PVByte *)pvScalar;
|
||||
epicsInt8 value = 2;
|
||||
pvValue->put(value);
|
||||
int getValue = pvValue->get();
|
||||
printf("put %d get %d\n",value,getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %d get %d\n",value,getValue);
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
PVScalar *other = getStandardField()->scalarValue(pvDouble);
|
||||
epicsBoolean isEqual = pvScalar->equals(other);
|
||||
printf("expect false isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testShort() {
|
||||
printf("\ntestShort\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvShort);
|
||||
PVShort *pvValue = (PVShort *)pvScalar;
|
||||
epicsInt16 value = 2;
|
||||
pvValue->put(value);
|
||||
int getValue = pvValue->get();
|
||||
printf("put %d get %d\n",value,getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %d get %d\n",value,getValue);
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
PVScalar *other = getStandardField()->scalarValue(pvDouble);
|
||||
epicsBoolean isEqual = pvScalar->equals(other);
|
||||
printf("expect false isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testInt() {
|
||||
printf("\ntestInt\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvInt);
|
||||
PVInt *pvValue = (PVInt *)pvScalar;
|
||||
epicsInt32 value = 2;
|
||||
pvValue->put(value);
|
||||
int getValue = pvValue->get();
|
||||
printf("put %d get %d\n",value,getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %d get %d\n",value,getValue);
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
PVScalar *other = getStandardField()->scalarValue(pvDouble);
|
||||
epicsBoolean isEqual = pvScalar->equals(other);
|
||||
printf("expect false isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testLong() {
|
||||
printf("\ntestLong\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvLong);
|
||||
PVLong *pvValue = (PVLong *)pvScalar;
|
||||
epicsInt64 value = 2;
|
||||
pvValue->put(value);
|
||||
epicsInt64 getValue = pvValue->get();
|
||||
printf("put %ld get %ld\n",(long int)value,(long int)getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %ld get %ld\n",(long int)value,(long int)getValue);
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
PVScalar *other = getStandardField()->scalarValue(pvDouble);
|
||||
epicsBoolean isEqual = pvScalar->equals(other);
|
||||
printf("expect false isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testFloat() {
|
||||
printf("\ntestFloat\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvFloat);
|
||||
PVFloat *pvValue = (PVFloat *)pvScalar;
|
||||
float value = 2;
|
||||
pvValue->put(value);
|
||||
float getValue = pvValue->get();
|
||||
printf("put %f get %f\n",value,getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %f get %f\n",value,getValue);
|
||||
}
|
||||
@@ -50,6 +255,88 @@ void testDouble() {
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
epicsBoolean isEqual = pvScalar->equals(pvScalar);
|
||||
printf("expect true isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testDouble() {
|
||||
printf("\ntestDouble\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvDouble);
|
||||
PVDouble *pvValue = (PVDouble *)pvScalar;
|
||||
double value = 2;
|
||||
pvValue->put(value);
|
||||
double getValue = pvValue->get();
|
||||
printf("put %lf get %lf\n",value,getValue);
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %lf get %lf\n",value,getValue);
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
epicsBoolean isEqual = pvScalar->equals(pvScalar);
|
||||
printf("expect true isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
void testString() {
|
||||
printf("\ntestString\n");
|
||||
PVScalar *pvScalar = getStandardField()->scalarValue(pvString);
|
||||
PVString *pvValue = (PVString *)pvScalar;
|
||||
String value = "testString";
|
||||
pvValue->put(value);
|
||||
String getValue = pvValue->get();
|
||||
printf("put %s get %s\n",value.c_str(),getValue.c_str());
|
||||
if(value!=getValue) {
|
||||
fprintf(stderr,"ERROR getValue put %s get %s\n",
|
||||
value.c_str(),getValue.c_str());
|
||||
}
|
||||
FieldConstPtr field = pvValue->getField();
|
||||
buffer.clear();
|
||||
field->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
epicsBoolean isImmutable = pvValue->isImmutable();
|
||||
PVStructure *pvParent = pvValue->getParent();
|
||||
printf("immutable %s parent %p\n",
|
||||
((isImmutable==epicsFalse) ? "false" : "true"),
|
||||
pvParent);
|
||||
int offset = pvValue->getFieldOffset();
|
||||
int nextOffset = pvValue->getNextFieldOffset();
|
||||
int numberFields = pvValue->getNumberFields();
|
||||
printf("offset %d nextOffset %d numberFields %d\n",
|
||||
offset,nextOffset,numberFields);
|
||||
ScalarConstPtr scalar = dynamic_cast<ScalarConstPtr>(field);
|
||||
if(scalar!=field) {
|
||||
fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer += "value ";
|
||||
pvValue->toString(&buffer);
|
||||
printf("%s\n",buffer.c_str());
|
||||
pvScalar->message(String("this is a test message"),infoMessage);
|
||||
epicsBoolean isEqual = pvScalar->equals(pvScalar);
|
||||
printf("expect true isEqual %s\n",(isEqual ? "true" : "false"));
|
||||
delete pvValue;
|
||||
}
|
||||
|
||||
@@ -57,7 +344,14 @@ int main(int argc,char *argv[])
|
||||
{
|
||||
pfieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
testBoolean();
|
||||
testByte();
|
||||
testShort();
|
||||
testInt();
|
||||
testLong();
|
||||
testFloat();
|
||||
testDouble();
|
||||
testString();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user