interim commit
This commit is contained in:
@ -40,7 +40,7 @@ ExampleCounterPtr ExampleCounter::create(
|
|||||||
epics::pvData::String const & recordName)
|
epics::pvData::String const & recordName)
|
||||||
{
|
{
|
||||||
epics::pvData::PVStructurePtr pvStructure =
|
epics::pvData::PVStructurePtr pvStructure =
|
||||||
epics::pvData::getStandardPVField()->scalar(epics::pvData::pvDouble,"");
|
epics::pvData::getStandardPVField()->scalar(epics::pvData::pvLong,"timeStamp");
|
||||||
ExampleCounterPtr pvRecord(
|
ExampleCounterPtr pvRecord(
|
||||||
new ExampleCounter(recordName,pvStructure));
|
new ExampleCounter(recordName,pvStructure));
|
||||||
if(!pvRecord->init()) pvRecord.reset();
|
if(!pvRecord->init()) pvRecord.reset();
|
||||||
|
@ -75,14 +75,6 @@ public:
|
|||||||
static PVRecordPtr create(
|
static PVRecordPtr create(
|
||||||
epics::pvData::String const & recordName,
|
epics::pvData::String const & recordName,
|
||||||
epics::pvData::PVStructurePtr const & pvStructure);
|
epics::pvData::PVStructurePtr const & pvStructure);
|
||||||
/**
|
|
||||||
* The constructor.
|
|
||||||
* @param recordName The name of the record, which is also the channelName.
|
|
||||||
* @param pvStructure The top level structure.
|
|
||||||
*/
|
|
||||||
PVRecord(
|
|
||||||
epics::pvData::String const & recordName,
|
|
||||||
epics::pvData::PVStructurePtr const & pvStructure);
|
|
||||||
/**
|
/**
|
||||||
* The Destructor. Must be virtual.
|
* The Destructor. Must be virtual.
|
||||||
*/
|
*/
|
||||||
@ -227,6 +219,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void toString(epics::pvData::StringBuilder buf,int indentLevel);
|
void toString(epics::pvData::StringBuilder buf,int indentLevel);
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param recordName The name of the record
|
||||||
|
* @param pvStructure The top level PVStructutre
|
||||||
|
*/
|
||||||
|
PVRecord(
|
||||||
|
epics::pvData::String const & recordName,
|
||||||
|
epics::pvData::PVStructurePtr const & pvStructure);
|
||||||
/**
|
/**
|
||||||
* Initializes the base class. Must be called by derived classes.
|
* Initializes the base class. Must be called by derived classes.
|
||||||
*/
|
*/
|
||||||
@ -281,6 +281,10 @@ public:
|
|||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~PVRecordField();
|
virtual ~PVRecordField();
|
||||||
|
/**
|
||||||
|
* Release any resources used
|
||||||
|
*/
|
||||||
|
virtual void destroy();
|
||||||
/**
|
/**
|
||||||
* Get the parent.
|
* Get the parent.
|
||||||
* @return The parent.
|
* @return The parent.
|
||||||
@ -377,6 +381,10 @@ public:
|
|||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~PVRecordStructure();
|
virtual ~PVRecordStructure();
|
||||||
|
/**
|
||||||
|
* Release any resources used
|
||||||
|
*/
|
||||||
|
virtual void destroy();
|
||||||
/**
|
/**
|
||||||
* Get the sub fields.
|
* Get the sub fields.
|
||||||
* @return the array of PVRecordFieldPtr.
|
* @return the array of PVRecordFieldPtr.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
using std::tr1::static_pointer_cast;
|
using std::tr1::static_pointer_cast;
|
||||||
using namespace epics::pvData;
|
using namespace epics::pvData;
|
||||||
using namespace epics::pvAccess;
|
using namespace epics::pvAccess;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace epics { namespace pvDatabase {
|
namespace epics { namespace pvDatabase {
|
||||||
|
|
||||||
@ -85,6 +86,11 @@ void PVRecord::destroy()
|
|||||||
pvRecordClientList.clear();
|
pvRecordClientList.clear();
|
||||||
|
|
||||||
pvListenerList.clear();
|
pvListenerList.clear();
|
||||||
|
pvRecordStructure->destroy();
|
||||||
|
pvRecordStructure.reset();
|
||||||
|
convert.reset();
|
||||||
|
pvStructure.reset();
|
||||||
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +368,17 @@ void PVRecordField::init()
|
|||||||
pvField->setPostHandler(getPtrSelf());
|
pvField->setPostHandler(getPtrSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
PVRecordField::~PVRecordField() {}
|
PVRecordField::~PVRecordField()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PVRecordField::destroy()
|
||||||
|
{
|
||||||
|
pvRecord.reset();
|
||||||
|
parent.reset();
|
||||||
|
pvField.reset();
|
||||||
|
pvListenerList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
PVRecordStructurePtr PVRecordField::getParent() {return parent;}
|
PVRecordStructurePtr PVRecordField::getParent() {return parent;}
|
||||||
|
|
||||||
@ -435,7 +451,20 @@ PVRecordStructure::PVRecordStructure(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PVRecordStructure::~PVRecordStructure() {}
|
PVRecordStructure::~PVRecordStructure()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PVRecordStructure::destroy()
|
||||||
|
{
|
||||||
|
PVRecordFieldPtrArray::iterator iter;
|
||||||
|
PVRecordField::destroy();
|
||||||
|
for(iter = pvRecordFields->begin() ; iter !=pvRecordFields->end(); iter++) {
|
||||||
|
(*iter)->destroy();
|
||||||
|
}
|
||||||
|
pvRecordFields.reset();
|
||||||
|
pvStructure.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void PVRecordStructure::init()
|
void PVRecordStructure::init()
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,10 @@ PROD_HOST += testPVCopy
|
|||||||
testPVCopy_SRCS += testPVCopy.cpp
|
testPVCopy_SRCS += testPVCopy.cpp
|
||||||
testPVCopy_LIBS += pvDatabase pvAccess pvData Com
|
testPVCopy_LIBS += pvDatabase pvAccess pvData Com
|
||||||
|
|
||||||
|
PROD_HOST += testPVRecord
|
||||||
|
testPVRecord_SRCS += testPVRecord.cpp
|
||||||
|
testPVRecord_LIBS += pvDatabase pvAccess pvData Com
|
||||||
|
|
||||||
include $(TOP)/configure/RULES
|
include $(TOP)/configure/RULES
|
||||||
#----------------------------------------
|
#----------------------------------------
|
||||||
# ADD RULES AFTER THIS LINE
|
# ADD RULES AFTER THIS LINE
|
||||||
|
@ -309,6 +309,7 @@ static void scalarTest()
|
|||||||
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
||||||
valueNameCopy = "value";
|
valueNameCopy = "value";
|
||||||
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
||||||
|
pvRecord->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrayTest()
|
static void arrayTest()
|
||||||
@ -349,6 +350,7 @@ static void arrayTest()
|
|||||||
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
||||||
valueNameCopy = "value";
|
valueNameCopy = "value";
|
||||||
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
testPVScalarArray(pvDouble,valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
||||||
|
pvRecord->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void powerSupplyTest()
|
static void powerSupplyTest()
|
||||||
@ -397,6 +399,7 @@ static void powerSupplyTest()
|
|||||||
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
pvCopy = PVCopy::create(pvRecord,pvRequest,"");
|
||||||
valueNameCopy = "power.value";
|
valueNameCopy = "power.value";
|
||||||
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
testPVScalar(valueNameRecord,valueNameCopy,pvRecord,pvCopy);
|
||||||
|
pvRecord->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
|
117
test/pvCopy/testPVRecord.cpp
Normal file
117
test/pvCopy/testPVRecord.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*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/pvAccess.h>
|
||||||
|
#include <pv/pvCopy.h>
|
||||||
|
#include <pv/powerSupplyRecordTest.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using std::tr1::static_pointer_cast;
|
||||||
|
using namespace epics::pvData;
|
||||||
|
using namespace epics::pvAccess;
|
||||||
|
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 PowerSupplyRecordTestPtr createPowerSupply(String const & recordName)
|
||||||
|
{
|
||||||
|
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 PowerSupplyRecordTest::create(recordName,
|
||||||
|
pvDataCreate->createPVStructure(
|
||||||
|
fieldCreate->createStructure(names,powerSupply)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
PowerSupplyRecordTestPtr pvRecord;
|
||||||
|
pvRecord = createPowerSupply("powerSupply");
|
||||||
|
pvRecord->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
scalarTest();
|
||||||
|
//arrayTest();
|
||||||
|
//powerSupplyTest();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
51
test/server/exampleCounterMain.cpp
Normal file
51
test/server/exampleCounterMain.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*ExampleCounterMain.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 <pv/standardField.h>
|
||||||
|
#include <pv/standardPVField.h>
|
||||||
|
#include <pv/exampleCounter.h>
|
||||||
|
#include <pv/channelProviderLocal.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using std::tr1::static_pointer_cast;
|
||||||
|
using namespace epics::pvData;
|
||||||
|
using namespace epics::pvAccess;
|
||||||
|
using namespace epics::pvDatabase;
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
PVDatabasePtr master = PVDatabase::getMaster();
|
||||||
|
ChannelProviderLocalPtr channelProvider = ChannelProviderLocal::create();
|
||||||
|
String recordName("exampleCounter");
|
||||||
|
PVRecordPtr pvRecord = ExampleCounter::create(recordName);
|
||||||
|
bool result = master->addRecord(pvRecord);
|
||||||
|
cout << "result of addRecord " << recordName << " " << result << endl;
|
||||||
|
pvRecord.reset();
|
||||||
|
cout << "exampleServer\n";
|
||||||
|
string str;
|
||||||
|
while(true) {
|
||||||
|
cout << "Type exit to stop: \n";
|
||||||
|
getline(cin,str);
|
||||||
|
if(str.compare("exit")==0) break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user