still more work on support

This commit is contained in:
mrkraimer
2019-06-06 09:52:39 -04:00
parent 9b000ffe6c
commit be701cc98a
8 changed files with 20 additions and 267 deletions

View File

@ -2,6 +2,10 @@
This document summarizes the changes to the module between releases. This document summarizes the changes to the module between releases.
## Master (June 2019)
support is a new feature
## Release 4.4.2 (EPICS 7.0.2.2, Apr 2019) ## Release 4.4.2 (EPICS 7.0.2.2, Apr 2019)
Formerly if a client makes a request for a subfield of a non structure field Formerly if a client makes a request for a subfield of a non structure field

View File

@ -36,7 +36,7 @@
<div class="head"> <div class="head">
<h1>pvDatabaseCPP</h1> <h1>pvDatabaseCPP</h1>
<h2 class="nocount">Release 4.4 - December 2018</h2> <h2 class="nocount">Release ? - June 2019</h2>
<h2 class="nocount">Abstract</h2> <h2 class="nocount">Abstract</h2>
@ -173,6 +173,21 @@ other functionality.</p>
</dd> </dd>
</dl> </dl>
<h3>support</h3>
<p>This creates records that have the following features:</p>
<dl>
<dt>value</dt>
<dd>
Each record has a value field the is a numeric scalar field.
In addition each has the following fields:
alarm,timeStamp,control,scalarAlarm, and display.
</dd>
<dt>support</dt>
<dd>
Each record uses the control and scalarAlarm support provided by pvDatabaseCPP.
</dd>
</dl>
<h2>iocshell commands</h2> <h2>iocshell commands</h2>
<p>Shell commands are made available via the standard DBD include mechanism <p>Shell commands are made available via the standard DBD include mechanism
provided by iocCore. provided by iocCore.

View File

@ -14,7 +14,6 @@ INC += pv/channelProviderLocal.h
INC += pv/pvDatabase.h INC += pv/pvDatabase.h
INC += pv/traceRecord.h INC += pv/traceRecord.h
INC += pv/removeRecord.h INC += pv/removeRecord.h
INC += pv/numericRecord.h
INC += pv/pvSupport.h INC += pv/pvSupport.h
INC += pv/controlSupport.h INC += pv/controlSupport.h
INC += pv/scalarAlarmSupport.h INC += pv/scalarAlarmSupport.h

View File

@ -1,66 +0,0 @@
/* numericRecord.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 2019.06.01
*/
#ifndef NUMERICRECORD_H
#define NUMERICRECORD_H
#include <shareLib.h>
#include <pv/channelProviderLocal.h>
#include <pv/controlSupport.h>
#include <pv/scalarAlarmSupport.h>
namespace epics { namespace pvDatabase {
class NumericRecord;
typedef std::tr1::shared_ptr<NumericRecord> NumericRecordPtr;
/**
* @brief support for control and scalarAlarm for a numeric scalar record
*
* This is support for a record with a top level field that has type scalar.
* It provides support for control and scalarAlarm
*/
class epicsShareClass NumericRecord :
public PVRecord
{
public:
POINTER_DEFINITIONS(NumericRecord);
/**
* Factory methods to create NumericRecord.
* @param recordName The name for the NumericRecord.
* @param scalarType The scalar type. It must be a numeric type.
* @return A shared pointer to NumericRecord..
*/
static NumericRecordPtr create(
std::string const & recordName,epics::pvData::ScalarType scalarType);
/**
* standard init method required by PVRecord
* @return true unless record name already exists.
*/
virtual bool init();
/**
* @brief Remove the record specified by recordName.
*/
virtual void process();
~NumericRecord();
private:
NumericRecord(
std::string const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
ControlSupportPtr controlSupport;
ScalarAlarmSupportPtr scalarAlarmSupport;
epics::pvData::PVBooleanPtr pvReset;
};
}}
#endif /* NUMERICRECORD_H */

View File

@ -4,12 +4,9 @@ SRC_DIRS += $(PVDATABASE_SRC)/special
LIBSRCS += traceRecord.cpp LIBSRCS += traceRecord.cpp
LIBSRCS += removeRecord.cpp LIBSRCS += removeRecord.cpp
LIBSRCS += numericRecord.cpp
DBD += traceRecordRegister.dbd DBD += traceRecordRegister.dbd
DBD += removeRecordRegister.dbd DBD += removeRecordRegister.dbd
DBD += numericRecordRegister.dbd
LIBSRCS += traceRecordRegister.cpp LIBSRCS += traceRecordRegister.cpp
LIBSRCS += removeRecordRegister.cpp LIBSRCS += removeRecordRegister.cpp
LIBSRCS += numericRecordRegister.cpp

View File

@ -1,96 +0,0 @@
/* numericRecord.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 2019.06.01
*/
#include <pv/pvDatabase.h>
#include <pv/convert.h>
#include <pv/standardField.h>
#include <pv/controlSupport.h>
#include <pv/scalarAlarmSupport.h>
#define epicsExportSharedSymbols
#include <pv/numericRecord.h>
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace std;
namespace epics { namespace pvDatabase {
NumericRecord::~NumericRecord()
{
cout << "NumericRecord::~NumericRecord()\n";
}
NumericRecordPtr NumericRecord::create(
std::string const & recordName,epics::pvData::ScalarType scalarType)
{
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StandardFieldPtr standardField = getStandardField();
StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
add("value",scalarType) ->
add("reset",pvBoolean) ->
add("alarm",standardField->alarm()) ->
add("timeStamp",standardField->timeStamp()) ->
add("display",standardField->display()) ->
add("control",standardField->control()) ->
add("scalarAlarm",ScalarAlarmSupport::scalarAlarm()) ->
createStructure();
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
NumericRecordPtr pvRecord(
new NumericRecord(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
NumericRecord::NumericRecord(
std::string const & recordName,
epics::pvData::PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure)
{
}
bool NumericRecord::init()
{
initPVRecord();
PVRecordPtr pvRecord = shared_from_this();
PVStructurePtr pvStructure(getPVStructure());
controlSupport = ControlSupport::create(pvRecord);
bool result = controlSupport->init(
pvStructure->getSubField("value"),pvStructure->getSubField("control"));
if(!result) return false;
scalarAlarmSupport = ScalarAlarmSupport::create(pvRecord);
result = scalarAlarmSupport->init(
pvStructure->getSubField("value"),
pvStructure->getSubField<PVStructure>("alarm"),
pvStructure->getSubField("scalarAlarm"));
if(!result) return false;
pvReset = getPVStructure()->getSubField<PVBoolean>("reset");
return true;
}
void NumericRecord::process()
{
if(pvReset->get()==true) {
pvReset->put(false);
controlSupport->reset();
scalarAlarmSupport->reset();
} else {
controlSupport->process();
scalarAlarmSupport->process();
}
PVRecord::process();
}
}}

View File

@ -1,99 +0,0 @@
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
/**
* @author mrk
* @date 2013.07.24
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <cantProceed.h>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <iocsh.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <epicsExport.h>
#include <pv/numericRecord.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
using namespace std;
static const iocshArg testArg0 = { "recordName", iocshArgString };
static const iocshArg testArg1 = { "scalarType", iocshArgString };
static const iocshArg *testArgs[] = {
&testArg0,&testArg1};
static const iocshFuncDef numericRecordFuncDef = {"numericRecordCreate", 2,testArgs};
static void numericRecordCallFunc(const iocshArgBuf *args)
{
char *recordName = args[0].sval;
if(!recordName) {
throw std::runtime_error("numericRecordCreate invalid number of arguments");
}
char *stype = args[1].sval;
epics::pvData::ScalarType scalarType = epics::pvData::pvDouble;
if(stype) {
string val(stype);
if(val.compare("pvByte")==0) {
scalarType = epics::pvData::pvByte;
} else if(val.compare("pvShort")==0) {
scalarType = epics::pvData::pvShort;
} else if(val.compare("pvInt")==0) {
scalarType = epics::pvData::pvInt;
} else if(val.compare("pvLong")==0) {
scalarType = epics::pvData::pvLong;
} else if(val.compare("pvFloat")==0) {
scalarType = epics::pvData::pvFloat;
} else if(val.compare("pvDouble")==0) {
scalarType = epics::pvData::pvDouble;
} else if(val.compare("pvUByte")==0) {
scalarType = epics::pvData::pvUByte;
} else if(val.compare("pvUShort")==0) {
scalarType = epics::pvData::pvUShort;
} else if(val.compare("pvUInt")==0) {
scalarType = epics::pvData::pvUInt;
} else if(val.compare("pvULong")==0) {
scalarType = epics::pvData::pvULong;
} else {
cout << val << " is not a numeric scalar type\n";
return;
}
}
NumericRecordPtr record = NumericRecord::create(recordName,scalarType);
bool result = PVDatabase::getMaster()->addRecord(record);
if(!result) cout << "recordname" << " not added" << endl;
}
static void numericRecordRegister(void)
{
static int firstTime = 1;
if (firstTime) {
firstTime = 0;
iocshRegister(&numericRecordFuncDef, numericRecordCallFunc);
}
}
extern "C" {
epicsExportRegistrar(numericRecordRegister);
}

View File

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