merge feature/changesAfter3_0_2; resolve conflicts

This commit is contained in:
Marty Kraimer
2014-06-10 15:53:37 -04:00
parent 35429bf4df
commit 92be294bbf
87 changed files with 561 additions and 445 deletions

11
test/Makefile Normal file
View File

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

29
test/configure/CONFIG Normal file
View File

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

View File

@ -0,0 +1,39 @@
# CONFIG_SITE
# Make any application-specific changes to the EPICS build
# configuration variables in this file.
#
# Host/target specific settings can be specified in files named
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
# CONFIG_SITE.Common.$(T_A)
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
# CHECK_RELEASE controls the consistency checking of the support
# applications pointed to by the RELEASE* files.
# Normally CHECK_RELEASE should be set to YES.
# Set CHECK_RELEASE to NO to disable checking completely.
# Set CHECK_RELEASE to WARN to perform consistency checking but
# continue building anyway if conflicts are found.
#CHECK_RELEASE = YES
# Set this when you only want to compile this application
# for a subset of the cross-compiled target architectures
# that Base is built for.
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
# To install files into a location other than $(TOP) define
# INSTALL_LOCATION here.
#INSTALL_LOCATION=</path/name/to/install/top>
# Set this when your IOC and the host use different paths
# to access the application. This will be needed to boot
# from a Microsoft FTP server or with some NFS mounts.
# You must rebuild in the iocBoot directory for this to
# take effect.
#IOCS_APPL_TOP = </IOC/path/to/application/top>
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
-include $(TOP)/configure/CONFIG_SITE.local
-include $(TOP)/../CONFIG.local

8
test/configure/Makefile Normal file
View File

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

40
test/configure/RELEASE Normal file
View File

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

6
test/configure/RULES Normal file
View File

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

2
test/configure/RULES.ioc Normal file
View File

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

View File

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

3
test/configure/RULES_TOP Normal file
View File

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

37
test/src/Makefile Normal file
View File

@ -0,0 +1,37 @@
TOP=..
include $(TOP)/configure/CONFIG
DBD += powerSupplyRegister.dbd
INC += powerSupply.h
LIBRARY_IOC += powerSupply
powerSupply_SRCS += powerSupply.cpp
powerSupply_SRCS += powerSupplyRegister.cpp
powerSupply_LIBS += pvDatabase
powerSupply_LIBS += pvAccess
powerSupply_LIBS += pvData
powerSupply_LIBS += Com
powerSupply_LIBS += $(EPICS_BASE_IOC_LIBS)
PROD_HOST += testPVCopy
testPVCopy_SRCS += powerSupply.cpp
testPVCopy_SRCS += testPVCopy.cpp
testPVCopy_LIBS += pvDatabase pvAccess pvData Com
PROD_HOST += testPVRecord
testPVRecord_SRCS += powerSupply.cpp
testPVRecord_SRCS += testPVRecord.cpp
testPVRecord_LIBS += pvDatabase pvAccess pvData Com
PROD_HOST += testExampleRecord
testExampleRecord_SRCS += powerSupply.cpp
testExampleRecord_SRCS += testExampleRecord.cpp
testExampleRecord_LIBS += pvDatabase pvAccess pvData Com
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

181
test/src/powerSupply.cpp Normal file
View File

@ -0,0 +1,181 @@
/* powerSupply.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.04.02
*/
#include "powerSupply.h"
#include <pv/standardField.h>
#include <pv/standardPVField.h>
namespace epics { namespace pvDatabase {
using namespace epics::pvData;
PVStructurePtr createPowerSupply()
{
FieldCreatePtr fieldCreate = getFieldCreate();
StandardFieldPtr standardField = getStandardField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
size_t nfields = 5;
StringArray names;
names.reserve(nfields);
FieldConstPtrArray powerSupply;
powerSupply.reserve(nfields);
names.push_back("alarm");
powerSupply.push_back(standardField->alarm());
names.push_back("timeStamp");
powerSupply.push_back(standardField->timeStamp());
String properties("alarm,display");
names.push_back("voltage");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("power");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("current");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
return pvDataCreate->createPVStructure(
fieldCreate->createStructure(names,powerSupply));
}
using namespace epics::pvData;
PowerSupplyPtr PowerSupply::create(
String const & recordName,
PVStructurePtr const & pvStructure)
{
PowerSupplyPtr pvRecord(
new PowerSupply(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
PowerSupply::PowerSupply(
String const & recordName,
PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure)
{
}
PowerSupply::~PowerSupply()
{
}
void PowerSupply::destroy()
{
PVRecord::destroy();
}
bool PowerSupply::init()
{
initPVRecord();
PVStructurePtr pvStructure = getPVStructure();
PVFieldPtr pvField;
bool result;
pvField = pvStructure->getSubField("timeStamp");
if(pvField.get()==NULL) {
std::cerr << "no timeStamp" << std::endl;
return false;
}
result = pvTimeStamp.attach(pvField);
if(!result) {
std::cerr << "no timeStamp" << std::endl;
return false;
}
pvField = pvStructure->getSubField("alarm");
if(pvField.get()==NULL) {
std::cerr << "no alarm" << std::endl;
return false;
}
result = pvAlarm.attach(pvField);
if(!result) {
std::cerr << "no alarm" << std::endl;
return false;
}
String name;
name = "current.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "current";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no current" << std::endl;
return false;
}
pvCurrent = pvStructure->getDoubleField(name);
if(pvCurrent.get()==NULL) return false;
name = "voltage.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "voltage";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no voltage" << std::endl;
return false;
}
pvVoltage = pvStructure->getDoubleField(name);
if(pvVoltage.get()==NULL) return false;
name = "power.value";
pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) {
name = "power";
pvField = pvStructure->getSubField(name);
}
if(pvField.get()==NULL) {
std::cerr << "no power" << std::endl;
return false;
}
pvPower = pvStructure->getDoubleField(name);
if(pvPower.get()==NULL) return false;
return true;
}
void PowerSupply::process()
{
timeStamp.getCurrent();
pvTimeStamp.set(timeStamp);
double voltage = pvVoltage->get();
double power = pvPower->get();
if(voltage<1e-3 && voltage>-1e-3) {
alarm.setMessage("bad voltage");
alarm.setSeverity(majorAlarm);
pvAlarm.set(alarm);
return;
}
double current = power/voltage;
pvCurrent->put(current);
alarm.setMessage("");
alarm.setSeverity(noAlarm);
pvAlarm.set(alarm);
}
void PowerSupply::put(double power,double voltage)
{
pvPower->put(power);
pvVoltage->put(voltage);
}
double PowerSupply::getPower()
{
return pvPower->get();
}
double PowerSupply::getVoltage()
{
return pvVoltage->get();
}
double PowerSupply::getCurrent()
{
return pvCurrent->get();
}
}}

60
test/src/powerSupply.h Normal file
View File

@ -0,0 +1,60 @@
/* powerSupply.h */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.04.02
*/
#ifndef POWERSUPPLY_H
#define POWERSUPPLY_H
#include <shareLib.h>
#include <pv/pvDatabase.h>
#include <pv/timeStamp.h>
#include <pv/alarm.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAlarm.h>
namespace epics { namespace pvDatabase {
epicsShareExtern epics::pvData::PVStructurePtr createPowerSupply();
class PowerSupply;
typedef std::tr1::shared_ptr<PowerSupply> PowerSupplyPtr;
class PowerSupply :
public PVRecord
{
public:
POINTER_DEFINITIONS(PowerSupply);
static PowerSupplyPtr create(
epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
virtual ~PowerSupply();
virtual void destroy();
virtual bool init();
virtual void process();
void put(double power,double voltage);
double getPower();
double getVoltage();
double getCurrent();
private:
PowerSupply(epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
epics::pvData::PVDoublePtr pvCurrent;
epics::pvData::PVDoublePtr pvPower;
epics::pvData::PVDoublePtr pvVoltage;
epics::pvData::PVAlarm pvAlarm;
epics::pvData::PVTimeStamp pvTimeStamp;
epics::pvData::Alarm alarm;
epics::pvData::TimeStamp timeStamp;
};
}}
#endif /* POWERSUPPLY_H */

View File

@ -0,0 +1,69 @@
/*powerSupplyRegister.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.07.24
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <cantProceed.h>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <iocsh.h>
#include <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <pv/powerSupply.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
using std::cout;
using std::endl;
static const iocshArg testArg0 = { "recordName", iocshArgString };
static const iocshArg *testArgs[] = {
&testArg0};
static const iocshFuncDef powerSupplyFuncDef = {
"powerSupplyCreateRecord", 1, testArgs};
static void powerSupplyCallFunc(const iocshArgBuf *args)
{
char *recordName = args[0].sval;
PVStructurePtr pv = createPowerSupply();
PowerSupplyPtr record = PowerSupply::create(recordName,pv);
bool result = PVDatabase::getMaster()->addRecord(record);
if(!result) cout << "recordname" << " not added" << endl;
}
static void powerSupplyRegister(void)
{
static int firstTime = 1;
if (firstTime) {
firstTime = 0;
iocshRegister(&powerSupplyFuncDef, powerSupplyCallFunc);
}
}
epicsExportRegistrar(powerSupplyRegister);

View File

@ -0,0 +1 @@
registrar("powerSupplyRegister")

View File

@ -0,0 +1,118 @@
/*testExampleRecordMain.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <epicsExport.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include "powerSupply.h"
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
void test()
{
StandardPVFieldPtr standardPVField = getStandardPVField();
String properties;
ScalarType scalarType;
String recordName;
properties = "alarm,timeStamp";
scalarType = pvDouble;
recordName = "exampleDouble";
PVStructurePtr pvStructure;
pvStructure = standardPVField->scalar(scalarType,properties);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
{
pvRecord->lock();
pvRecord->process();
pvRecord->unlock();
}
cout << "processed exampleDouble " << endl;
pvRecord->destroy();
pvRecord.reset();
recordName = "powerSupplyExample";
pvStructure.reset();
PowerSupplyPtr psr;
pvStructure = createPowerSupply();
psr = PowerSupply::create("powerSupply",pvStructure);
if(psr.get()==NULL) {
cout << "PowerSupplyRecordTest::create failed" << endl;
return;
}
pvStructure.reset();
double voltage,power,current;
{
psr->lock();
voltage = psr->getVoltage();
power = psr->getPower();
current = psr->getCurrent();
psr->unlock();
}
cout << "initial ";
cout << " voltage " << voltage ;
cout << " power " << power;
cout << " current " << current;
cout << endl;
voltage = 1.0;
power = 1.0;
cout << "before put ";
cout << " voltage " << voltage ;
cout << " power " << power;
cout << endl;
{
psr->lock();
psr->put(power,voltage);
psr->process();
psr->unlock();
}
{
psr->lock();
cout << "after put ";
cout << " voltage " << psr->getVoltage() ;
cout << " power " << psr->getPower();
cout << " current " << psr->getCurrent();
cout << endl;
psr->unlock();
}
PVDatabasePtr pvDatabase = PVDatabase::getMaster();
pvDatabase->addRecord(psr);
psr.reset();
pvDatabase->destroy();
}
int main(int argc,char *argv[])
{
test();
return 0;
}

381
test/src/testPVCopy.cpp Normal file
View File

@ -0,0 +1,381 @@
/*testPVCopyMain.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/channelProviderLocal.h>
#include "powerSupply.h"
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
class MyRequester;
typedef std::tr1::shared_ptr<MyRequester> MyRequesterPtr;
class MyRequester : public Requester {
public:
POINTER_DEFINITIONS(MyRequester);
MyRequester(String const &requesterName)
: requesterName(requesterName)
{}
virtual ~MyRequester() {}
virtual String getRequesterName() { return requesterName;}
virtual void message(String const & message,MessageType messageType)
{
cout << message << endl;
}
private:
String requesterName;
};
static PVRecordPtr createScalar(
String const & recordName,
ScalarType scalarType,
String const & properties)
{
PVStructurePtr pvStructure = getStandardPVField()->scalar(scalarType,properties);
return PVRecord::create(recordName,pvStructure);
}
static PVRecordPtr createScalarArray(
String const & recordName,
ScalarType scalarType,
String const & properties)
{
PVStructurePtr pvStructure = getStandardPVField()->scalarArray(scalarType,properties);
return PVRecord::create(recordName,pvStructure);
}
static void testPVScalar(
String const & valueNameRecord,
String const & valueNameCopy,
PVRecordPtr const & pvRecord,
PVCopyPtr const & pvCopy)
{
PVStructurePtr pvStructureRecord;
PVStructurePtr pvStructureCopy;
PVFieldPtr pvField;
PVScalarPtr pvValueRecord;
PVScalarPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
ConvertPtr convert = getConvert();
cout << endl;
pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
pvField = pvStructureRecord->getSubField(valueNameRecord);
pvValueRecord = static_pointer_cast<PVScalar>(pvField);
convert->fromDouble(pvValueRecord,.04);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
cout << "structure from copy" << endl << builder << endl;
pvStructureCopy = pvCopy->createPVStructure();
pvField = pvStructureCopy->getSubField(valueNameCopy);
pvValueCopy = static_pointer_cast<PVScalar>(pvField);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy);
cout << endl;
convert->fromDouble(pvValueRecord,.06);
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy);
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
offset = pvCopy->getCopyOffset(pvValueRecord);
cout << "getCopyOffset() " << offset;
cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset();
cout << " pvValueRecord->getOffset() " << pvValueRecord->getFieldOffset();
cout << " bitSet " << builder;
cout << endl;
bitSet->clear();
convert->fromDouble(pvValueRecord,1.0);
builder.clear();
bitSet->toString(&builder);
cout << "before updateCopyFromBitSet";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << builder;
cout << endl;
bitSet->set(0);
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
cout << "after updateCopyFromBitSet";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << builder;
cout << endl;
convert->fromDouble(pvValueCopy,2.0);
bitSet->set(0);
cout << "before updateMaster";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << builder;
cout << endl;
pvCopy->updateMaster(pvStructureCopy,bitSet);
cout << "after updateMaster";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << builder;
cout << endl;
}
static void testPVScalarArray(
ScalarType scalarType,
String const & valueNameRecord,
String const & valueNameCopy,
PVRecordPtr const & pvRecord,
PVCopyPtr const & pvCopy)
{
PVStructurePtr pvStructureRecord;
PVStructurePtr pvStructureCopy;
PVScalarArrayPtr pvValueRecord;
PVScalarArrayPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
size_t n = 5;
shared_vector<double> values(n);
cout << endl;
pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
pvValueRecord = pvStructureRecord->getScalarArrayField(valueNameRecord,scalarType);
for(size_t i=0; i<n; i++) values[i] = i;
const shared_vector<const double> xxx(freeze(values));
pvValueRecord->putFrom(xxx);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
cout << "structure from copy" << endl << builder << endl;
pvStructureCopy = pvCopy->createPVStructure();
pvValueCopy = pvStructureCopy->getScalarArrayField(valueNameCopy,scalarType);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
builder.clear(); pvValueCopy->toString(&builder);
cout << "after initCopy pvValueCopy " << builder << endl;
cout << endl;
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + .06;
const shared_vector<const double> yyy(freeze(values));
pvValueRecord->putFrom(yyy);
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
builder.clear(); pvValueCopy->toString(&builder);
cout << "after put(i+ .06) pvValueCopy " << builder << endl;
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
offset = pvCopy->getCopyOffset(pvValueRecord);
cout << "getCopyOffset() " << offset;
cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset();
cout << " pvValueRecord->getOffset() " << pvValueRecord->getFieldOffset();
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
bitSet->clear();
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + 1.0;
const shared_vector<const double> zzz(freeze(values));
pvValueRecord->putFrom(zzz);
builder.clear();
bitSet->toString(&builder);
cout << "before updateCopyFromBitSet";
builder.clear(); pvValueRecord->toString(&builder);
cout << " recordValue " << builder << endl;
builder.clear(); pvValueCopy->toString(&builder);
cout << " copyValue " << builder << endl;
cout << " bitSet " << builder;
builder.clear();
bitSet->toString(&builder);
cout << endl;
bitSet->set(0);
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
cout << "after updateCopyFromBitSet";
builder.clear(); pvValueRecord->toString(&builder);
cout << " recordValue " << builder << endl;
builder.clear(); pvValueCopy->toString(&builder);
cout << " copyValue " << builder << endl;
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + 2.0;
const shared_vector<const double> ttt(freeze(values));
pvValueRecord->putFrom(ttt);
bitSet->set(0);
cout << "before updateMaster";
builder.clear(); pvValueRecord->toString(&builder);
cout << " recordValue " << builder << endl;
builder.clear(); pvValueCopy->toString(&builder);
cout << " copyValue " << builder << endl;
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
pvCopy->updateMaster(pvStructureCopy,bitSet);
cout << "after updateMaster";
builder.clear(); pvValueRecord->toString(&builder);
cout << " recordValue " << builder << endl;
builder.clear(); pvValueCopy->toString(&builder);
cout << " copyValue " << builder << endl;
builder.clear();
bitSet->toString(&builder);
cout << " bitSet " << builder;
cout << endl;
}
static void scalarTest()
{
cout << endl << endl << "****scalarTest****" << endl;
RequesterPtr requester(new MyRequester("exampleTest"));
PVRecordPtr pvRecord;
String request;
PVStructurePtr pvRequest;
PVCopyPtr pvCopy;
String builder;
String valueNameRecord;
String valueNameCopy;
pvRecord = createScalar("doubleRecord",pvDouble,"alarm,timeStamp,display");
valueNameRecord = request = "value";
CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,value";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
pvRecord->destroy();
}
static void arrayTest()
{
cout << endl << endl << "****arrayTest****" << endl;
RequesterPtr requester(new MyRequester("exampleTest"));
PVRecordPtr pvRecord;
String request;
PVStructurePtr pvRequest;
PVCopyPtr pvCopy;
String builder;
String valueNameRecord;
String valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvRecord = createScalarArray("doubleArrayRecord",pvDouble,"alarm,timeStamp");
valueNameRecord = request = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,value";
valueNameRecord = "value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "value";
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
pvRecord->destroy();
}
static void powerSupplyTest()
{
cout << endl << endl << "****powerSupplyTest****" << endl;
RequesterPtr requester(new MyRequester("exampleTest"));
PowerSupplyPtr pvRecord;
String request;
PVStructurePtr pvRequest;
PVCopyPtr pvCopy;
String builder;
String valueNameRecord;
String valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create("powerSupply",pv);
valueNameRecord = request = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,voltage.value,power.value,current.value";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
request = "alarm,timeStamp,voltage{value,alarm},power{value,alarm,display},current.value";
valueNameRecord = "power.value";
pvRequest = createRequest->createRequest(request);
cout << "request " << request << endl << "pvRequest" << pvRequest->dumpValue(cout) << endl ;
pvCopy = PVCopy::create(pvRecord->getPVRecordStructure()->getPVStructure(),pvRequest,"");
valueNameCopy = "power.value";
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
pvRecord->destroy();
}
int main(int argc,char *argv[])
{
scalarTest();
arrayTest();
powerSupplyTest();
return 0;
}

90
test/src/testPVRecord.cpp Normal file
View File

@ -0,0 +1,90 @@
/*testPVRecordMain.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/pvData.h>
#include <pv/pvCopy.h>
#include "powerSupply.h"
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvDatabase;
static PVRecordPtr createScalar(
String const & recordName,
ScalarType scalarType,
String const & properties)
{
PVStructurePtr pvStructure = getStandardPVField()->scalar(scalarType,properties);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
pvStructure.reset();
return pvRecord;
}
static PVRecordPtr createScalarArray(
String const & recordName,
ScalarType scalarType,
String const & properties)
{
PVStructurePtr pvStructure = getStandardPVField()->scalarArray(scalarType,properties);
return PVRecord::create(recordName,pvStructure);
}
static void scalarTest()
{
cout << endl << endl << "****scalarTest****" << endl;
PVRecordPtr pvRecord;
pvRecord = createScalar("doubleRecord",pvDouble,"alarm,timeStamp.display");
pvRecord->destroy();
}
static void arrayTest()
{
cout << endl << endl << "****arrayTest****" << endl;
PVRecordPtr pvRecord;
pvRecord = createScalarArray("doubleArrayRecord",pvDouble,"alarm,timeStamp");
pvRecord->destroy();
}
static void powerSupplyTest()
{
cout << endl << endl << "****powerSupplyTest****" << endl;
PVRecordPtr pvRecord;
PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create("powerSupply",pv);
pvRecord->destroy();
}
int main(int argc,char *argv[])
{
scalarTest();
arrayTest();
powerSupplyTest();
return 0;
}