diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 095b40c..fa4d6dd 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -2,6 +2,13 @@ This document summarizes the changes to the module between releases. +## Release 4.6.0 (EPICS 7.0.5.* April 2021) + +* Access Security is now supported. +* special has been revised and extended. +* addRecord, removeRecord, processRecord, and traceRecord are replaced by pvdbcr versions. +* support is DEPRECATED + ## Release 4.5.3 (EPICS 7.0.5 Feb 2021) * The previously deprecated destroy methods have been removed. diff --git a/documentation/TODO.md b/documentation/TODO.md deleted file mode 100644 index 8a6b69a..0000000 --- a/documentation/TODO.md +++ /dev/null @@ -1,8 +0,0 @@ -TODO -=========== - - -create more regression tests ----------------- - -Currently only some simple tests exist. Most of the testing has been via the examples diff --git a/documentation/pvDatabaseCPP.html b/documentation/pvDatabaseCPP.html index 5e38a06..f5f6721 100644 --- a/documentation/pvDatabaseCPP.html +++ b/documentation/pvDatabaseCPP.html @@ -4,72 +4,66 @@ - pvDatabaseCPP + EPICS pvDatabaseCPP - - + body { margin-right: 10% } +/*]]>*/ + + + +
-

pvDatabaseCPP

-

Release ? - TBD

-Latest update 2019.09.11. - +

EPICS pvDatabaseCPP

+

Release 4.6.0 - March 2021

Abstract

-

This document describes pvDatabaseCPP, -which is a framework for implementing a network accessible database of smart memory resident +

pvDatabase is a framework for implementing a network accessible database of smart memory resident records. Network access is via pvAccess. The data in each record is a top level PVStructure as defined by pvData. The framework includes a complete implementation of ChannelProvider as defined by pvAccess. The framework can be extended in order to create record instances that implements services. The minimum that an extension must provide is a top level PVStructure and a process method.

+

For more information about EPICS generally, please refer to the home page of the Experimental Physics and Industrial Control System.

-
- -
-

Table of Contents

-
+

-

Overview

+Documentation for pvDatabaseCPP is available at: + +pvDatabase + +

+

pvDatabaseCPP is one of the components of -EPICS Version 7 + +EPICS-7 +

This document is only a guide to help locate code and documentation related to pvDatabaseCPP +

+

It is intended for developers that want to use pvDatabaseCPP.

Developer Guide

@@ -79,204 +73,28 @@ href="https://mrkraimer.github.io/website/developerGuide/developerGuide.html"> developerGuide

-

This guide discusses all the components that are part of an EPICS V4 release. +

This guide provides an overview of the components that are part of an EPICS V4 release. Some understanding of the components and how they are related is necessary in order to develop code that uses pvDatabaseCPP. -In particular read everything related to pvDatabase. -

-

pvDatabase has plugin support, which is implemented in pvCopy. -pvCopy was originally implemented in pvDataCPP, -but pvDatabaseCPP now implements its own version and adds plugin support. -

-

-See - -pvRequest - -for details. -

-

The developerGuide discusses code in a way that applies to both CPP and C++. -For the descriptions of the CPP specific code consult the following sections. +In particular read everything related to pvaClient.

doxygen

doxygen documentation is available at doxgen +href="./html/index.html">doxygen

-

pvDatabaseCPP

-

include/pv

-

The header files that describe the various components implemented by pvDatabase. -

-
-
pvDatabase.h
-
- This describes PVRecord and PVDatabase. -
-
channelProviderLocal.h
-
- This describes a channel provider for PVDatabase -
-
pvSupport.h
-
- This is the base class for support attached to a field of a record. -
-
controlSupport.h
-
- This is support that implements control limits. -
-
scalarAlarmSupport.h
-
- This is support for a alarm limits for a scalar numeric field. -
-
processRecord.h
-
- This is a PVRecord that periodical processes a set of PVRecords in the local PVDatabase. -
-
addRecord.h
-
- This is a PVRecord that adds a new PVRecord to the local PVDatabase. -
-
removeRecord.h
-
- This is a PVRecord that removes a PVRecord in the local PVDatabase. -
-
traceRecord.h
-
- This is a PVRecord that sets the trace value for another PVRecord in the local PVDatabase. -
-
pvStructureCopy.h
-
- This is a facility that allows a client to access a subfield of the fields in a PVRecord. - It also provides record and field options an plugin support. -
-
pvPlugin.h
-
- This is the base class for a plugin attached to a record or field of PVRecord. -
-
pvArrayPlugin.h
-
- A plugin for accessing a subset of the elements in an array field. -
-
pvDeadbandPlugin.h
-
- A deadband plugin for monitors. -
-
pvTimestampPlugin.h
-
- A plugin for timeStamp. -
-
-

src/database

-

This has the code that implements pvDatabase and pvRecord.

-

src/pvAccess

-

This has the code for the channel provider for pvDatabase. -

-

src/support

-

This has the pvSupport code.

-

src/special

-

-This has the code for processRecord, addRecord, removeRecord, and traceRecord. -

-

src/copy

-

This has the code for pvStructureCopy and all the plugin support. -

exampleCPP

-

Example code is available as part of this release. +

Example code is available at exampleCPP

-

In particular look at the example code mentioned in the following sub-sections. +

In particular look at database, exampleLink, and helloPutGet.

-

database

-

This has many examples of how to create both soft records and records that implement -other functionality.

-
-
exampleDatabase.cpp
-
- This shows how to create soft records of each pvData type.
- In addition shows how to create instances of the following two records. -
-
exampleHelloRecord.cpp
-
- This is a simple "hello world" that is intentended to be used via a channelPutGet request. -
-
exampleHelloRPC.cpp
-
- This is a simple "hello world" that is intentended to be used via a channelRPC request. -
-
exampleDatabaseMain.cpp
-
- This shows how to create a standalone IOC. -
-
ioc and iocBoot
-
- This has code and examples to create a V3 IOC which also has a PVDatabase. -
-
-

exampleLink

-

This shows how to implement a record that has a link to another record

-
-
exampleMonitorLinkRecord
-
- This creates a monitor link to another record. -
-
exampleGetLinkRecord
-
- This creates a get link to another record. -
-
examplePutLinkRecord
-
- This creates a put link to another record. -
-
- -

support

-

This creates records that have the following features:

-
-
value
-
- 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. -
-
support
-
- Each record uses the control and scalarAlarm support provided by pvDatabaseCPP. -
-
-

-It also creates records that can be used by clients to show example of the plugin support. -

- -

iocshell commands

-

Shell commands are made available via the standard DBD include mechanism -provided by iocCore. -The following provide EPICS V4 shell commands:

-
-pvAccessCPP
-qsrv
-pvDatabaseCPP
-
- -

pvDatabaseCPP provides the following iocshell command.

-
-
registerChannelProviderLocal
-
Including registerChannelProviderLocal.dbd as a dbd file automatically starts provider local - and also creates the pvdbl shell command. -
-
pvdbl
-
Provides a list of all the pvRecords in database master -
-
-

In addition any code that implements a PVRecord must implement an ioc command. -Look at the examples in exampleCPP/support to see how to implement shell commands.

- -
+ diff --git a/src/Makefile b/src/Makefile index 0e6db8c..e0cb91c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,11 +23,6 @@ INC += pv/pvDatabase.h INC += pv/channelProviderLocal.h -INC += pv/traceRecord.h -INC += pv/removeRecord.h -INC += pv/addRecord.h -INC += pv/processRecord.h - INC += pv/pvSupport.h INC += pv/controlSupport.h INC += pv/scalarAlarmSupport.h diff --git a/src/pv/addRecord.h b/src/pv/addRecord.h deleted file mode 100644 index ef3ed17..0000000 --- a/src/pv/addRecord.h +++ /dev/null @@ -1,63 +0,0 @@ -/* addRecord.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.18 - */ -#ifndef ADDRECORD_H -#define ADDRECORD_H - -#include - -#include - -namespace epics { namespace pvDatabase { - - -class AddRecord; -typedef std::tr1::shared_ptr AddRecordPtr; - -/** - * @brief Add another record in the same database. - * - * A record to add another record - * It is meant to be used via a channelPutGet request. - * The argument has one field: recordName. - * The result has a field named status. - */ -class epicsShareClass AddRecord : - public PVRecord -{ -public: - POINTER_DEFINITIONS(AddRecord); - /** - * Factory methods to create AddRecord. - * @param recordName The name for the AddRecord. - * @return A shared pointer to AddRecord.. - */ - static AddRecordPtr create( - std::string const & recordName); - /** - * standard init method required by PVRecord - * @return true unless record name already exists. - */ - virtual bool init(); - /** - * @brief Add the record specified by recordName. - */ - virtual void process(); -private: - AddRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure); - epics::pvData::PVStringPtr pvRecordName; - epics::pvData::PVStringPtr pvResult; -}; - -}} - -#endif /* ADDRECORD_H */ diff --git a/src/pv/channelProviderLocal.h b/src/pv/channelProviderLocal.h index 1670e2f..cc7d5f0 100644 --- a/src/pv/channelProviderLocal.h +++ b/src/pv/channelProviderLocal.h @@ -362,6 +362,12 @@ public: * @return true if client can write */ virtual bool canWrite(); + /** + * @brief determines if client can read + * + * @return true if client can read + */ + virtual bool canRead(); protected: shared_pointer getPtrSelf() { diff --git a/src/pv/processRecord.h b/src/pv/processRecord.h deleted file mode 100644 index 6607e93..0000000 --- a/src/pv/processRecord.h +++ /dev/null @@ -1,89 +0,0 @@ -/* processRecord.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.07 - */ -#ifndef PROCESSRECORD_H -#define PROCESSRECORD_H - -#include -#include -#include -#include - -#include - -namespace epics { namespace pvDatabase { - -typedef std::tr1::shared_ptr EpicsThreadPtr; - -class ProcessRecord; -typedef std::tr1::shared_ptr ProcessRecordPtr; - -/** - * @brief Process another record in the same database. - * - * A record to process another record - * It is meant to be used via a channelPutGet request. - * The argument has one field: recordName. - * The result has a field named status. - */ -class epicsShareClass ProcessRecord : - public PVRecord, - public epicsThreadRunable -{ -public: - POINTER_DEFINITIONS(ProcessRecord); - /** - * Factory methods to create ProcessRecord. - * @param recordName The name for the ProcessRecord. - * @param delay Delay time to wait between process requests. - * @return A shared pointer to ProcessRecord. - */ - static ProcessRecordPtr create( - std::string const & recordName,double delay); - /** - * standard init method required by PVRecord - * @return true unless record name already exists. - */ - virtual bool init(); - /** - * @brief Process the record specified by recordName. - */ - virtual void process(); - /** - * @brief The run method for the thread. - */ - virtual void run(); - /** - * @brief Start the thread - */ - void startThread(); - /** - * @brief Stop the thread - */ - void stop(); -private: - ProcessRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure,double delay); - double delay; - EpicsThreadPtr thread; - epics::pvData::Event runStop; - epics::pvData::Event runReturn; - PVDatabasePtr pvDatabase; - PVRecordMap pvRecordMap; - epics::pvData::PVStringPtr pvCommand; - epics::pvData::PVStringPtr pvRecordName; - epics::pvData::PVStringPtr pvResult; - epics::pvData::Mutex mutex; -}; - -}} - -#endif /* PROCESSRECORD_H */ diff --git a/src/pv/pvDatabase.h b/src/pv/pvDatabase.h index f21799d..a072466 100644 --- a/src/pv/pvDatabase.h +++ b/src/pv/pvDatabase.h @@ -248,6 +248,16 @@ public: * @return The name. */ std::string getAsGroup() const {return asGroup;} + /** + * @brief set access security level. + * @param level The level + */ + void setAsLevel(int level) {asLevel=level;} + /** + * @brief set access security group + * @param group The group name + */ + void setAsGroup(const std::string& group) {asGroup = group;} protected: /** * @brief Constructor diff --git a/src/pv/removeRecord.h b/src/pv/removeRecord.h deleted file mode 100644 index d101e1c..0000000 --- a/src/pv/removeRecord.h +++ /dev/null @@ -1,63 +0,0 @@ -/* removeRecord.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.18 - */ -#ifndef REMOVERECORD_H -#define REMOVERECORD_H - -#include - -#include - -namespace epics { namespace pvDatabase { - - -class RemoveRecord; -typedef std::tr1::shared_ptr RemoveRecordPtr; - -/** - * @brief Remove another record in the same database. - * - * A record to remove another record - * It is meant to be used via a channelPutGet request. - * The argument has one field: recordName. - * The result has a field named status. - */ -class epicsShareClass RemoveRecord : - public PVRecord -{ -public: - POINTER_DEFINITIONS(RemoveRecord); - /** - * Factory methods to create RemoveRecord. - * @param recordName The name for the RemoveRecord. - * @return A shared pointer to RemoveRecord.. - */ - static RemoveRecordPtr create( - std::string const & recordName); - /** - * 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(); -private: - RemoveRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure); - epics::pvData::PVStringPtr pvRecordName; - epics::pvData::PVStringPtr pvResult; -}; - -}} - -#endif /* REMOVERECORD_H */ diff --git a/src/pv/traceRecord.h b/src/pv/traceRecord.h deleted file mode 100644 index 6ec5525..0000000 --- a/src/pv/traceRecord.h +++ /dev/null @@ -1,66 +0,0 @@ -/* traceRecord.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.18 - */ -#ifndef TRACERECORD_H -#define TRACERECORD_H - -#include - -#include - - -namespace epics { namespace pvDatabase { - - -class TraceRecord; -typedef std::tr1::shared_ptr TraceRecordPtr; - -/** - * @brief Trace activity of PVRecord. - * - * A record to set the trace value for another record - * It is meant to be used via a channelPutGet request. - * The argument has two fields: recordName and level. - * The result has a field named status. - */ -class epicsShareClass TraceRecord : - public PVRecord -{ -public: - POINTER_DEFINITIONS(TraceRecord); - /** - * @brief Factory method to create TraceRecord. - * - * @param recordName The name for the TraceRecord. - * @return A shared pointer to TraceRecord.. - */ - static TraceRecordPtr create( - std::string const & recordName); - /** - * standard init method required by PVRecord - * @return true unless record name already exists. - */ - virtual bool init(); - /** - * @brief Set the trace level for record specified by recordName. - */ - virtual void process(); -private: - TraceRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure); - epics::pvData::PVStringPtr pvRecordName; - epics::pvData::PVIntPtr pvLevel; - epics::pvData::PVStringPtr pvResult; -}; - -}} - -#endif /* TRACERECORD_H */ diff --git a/src/pvAccess/channelLocal.cpp b/src/pvAccess/channelLocal.cpp index b63ac93..29fc625 100644 --- a/src/pvAccess/channelLocal.cpp +++ b/src/pvAccess/channelLocal.cpp @@ -329,6 +329,13 @@ void ChannelGetLocal::get() { ChannelGetRequester::shared_pointer requester = channelGetRequester.lock(); if(!requester) return; + ChannelLocalPtr channel(channelLocal.lock()); + if(!channel) throw std::logic_error("channel is deleted"); + if(!channel->canRead()) { + Status status = Status::error("ChannelGet::get is not allowed"); + requester->getDone(status,getPtrSelf(),PVStructurePtr(),BitSetPtr()); + return; + } PVRecordPtr pvr(pvRecord.lock()); if(!pvr) throw std::logic_error("pvRecord is deleted"); try { @@ -490,6 +497,13 @@ void ChannelPutLocal::get() { ChannelPutRequester::shared_pointer requester = channelPutRequester.lock(); if(!requester) return; + ChannelLocalPtr channel(channelLocal.lock()); + if(!channel) throw std::logic_error("channel is deleted"); + if(!channel->canRead()) { + Status status = Status::error("ChannelPut::get is not allowed"); + requester->getDone(status,getPtrSelf(),PVStructurePtr(),BitSetPtr()); + return; + } PVRecordPtr pvr(pvRecord.lock()); if(!pvr) throw std::logic_error("pvRecord is deleted"); try { @@ -521,8 +535,9 @@ void ChannelPutLocal::put( ChannelPutRequester::shared_pointer requester = channelPutRequester.lock(); if(!requester) return; ChannelLocalPtr channel(channelLocal.lock()); + if(!channel) throw std::logic_error("channel is deleted"); if(!channel->canWrite()) { - Status status = Status::error("Channel put is not allowed"); + Status status = Status::error("ChannelPut::put is not allowed"); requester->putDone(status,getPtrSelf()); return; } @@ -688,9 +703,10 @@ void ChannelPutGetLocal::putGet( ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock(); if(!requester) return; ChannelLocalPtr channel(channelLocal.lock()); - if(!channel->canWrite()) { - Status status = Status::error("Channel putGet is not allowed"); - requester->putGetDone(status,getPtrSelf(),pvGetStructure,getBitSet); + if(!channel) throw std::logic_error("channel is deleted"); + if(!channel->canWrite()||!channel->canRead() ) { + Status status = Status::error("ChannelPutGet::putGet is not allowed"); + requester->putGetDone(status,getPtrSelf(),PVStructurePtr(),BitSetPtr()); return; } PVRecordPtr pvr(pvRecord.lock()); @@ -721,6 +737,13 @@ void ChannelPutGetLocal::getPut() { ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock(); if(!requester) return; + ChannelLocalPtr channel(channelLocal.lock()); + if(!channel) throw std::logic_error("channel is deleted"); + if(!channel->canRead()) { + Status status = Status::error("ChannelPutGet::getPut is not allowed"); + requester->getPutDone(status,getPtrSelf(),PVStructurePtr(),BitSetPtr()); + return; + } PVRecordPtr pvr(pvRecord.lock()); if(!pvr) throw std::logic_error("pvRecord is deleted"); try { @@ -748,6 +771,13 @@ void ChannelPutGetLocal::getGet() { ChannelPutGetRequester::shared_pointer requester = channelPutGetRequester.lock(); if(!requester) return; + ChannelLocalPtr channel(channelLocal.lock()); + if(!channel) throw std::logic_error("channel is deleted"); + if(!channel->canRead()) { + Status status = Status::error("ChannelPutGet::getGet is not allowed"); + requester->getPutDone(status,getPtrSelf(),PVStructurePtr(),BitSetPtr()); + return; + } PVRecordPtr pvr(pvRecord.lock()); if(!pvr) throw std::logic_error("pvRecord is deleted"); try { @@ -1324,9 +1354,15 @@ bool ChannelLocal::canWrite() return false; } +bool ChannelLocal::canRead() +{ + if(!asActive || (asClientPvt && asCheckGet(asClientPvt))) { + return true; + } + return false; +} ChannelLocal::~ChannelLocal() { -// cout << "~ChannelLocal()" << endl; if(asMemberPvt) { asRemoveMember(&asMemberPvt); asMemberPvt = 0; diff --git a/src/special/Makefile b/src/special/Makefile index e928d8f..fe47e3e 100644 --- a/src/special/Makefile +++ b/src/special/Makefile @@ -2,17 +2,18 @@ SRC_DIRS += $(PVDATABASE_SRC)/special -LIBSRCS += traceRecord.cpp -LIBSRCS += removeRecord.cpp -LIBSRCS += addRecord.cpp -LIBSRCS += processRecord.cpp +DBD += pvdbcrTraceRecordRegister.dbd +DBD += pvdbcrRemoveRecordRegister.dbd +DBD += pvdbcrAddRecordRegister.dbd +DBD += pvdbcrProcessRecordRegister.dbd +DBD += pvdbcrScalarRegister.dbd +DBD += pvdbcrScalarArrayRegister.dbd +DBD += pvdbSpecialRegister.dbd -DBD += traceRecordRegister.dbd -DBD += removeRecordRegister.dbd -DBD += addRecordRegister.dbd -DBD += processRecordRegister.dbd +LIBSRCS += pvdbcrTraceRecordRegister.cpp +LIBSRCS += pvdbcrRemoveRecordRegister.cpp +LIBSRCS += pvdbcrAddRecordRegister.cpp +LIBSRCS += pvdbcrProcessRecordRegister.cpp +LIBSRCS += pvdbcrScalarRegister.cpp +LIBSRCS += pvdbcrScalarArrayRegister.cpp -LIBSRCS += traceRecordRegister.cpp -LIBSRCS += removeRecordRegister.cpp -LIBSRCS += addRecordRegister.cpp -LIBSRCS += processRecordRegister.cpp diff --git a/src/special/addRecordRegister.cpp b/src/special/addRecordRegister.cpp deleted file mode 100644 index 32e581b..0000000 --- a/src/special/addRecordRegister.cpp +++ /dev/null @@ -1,62 +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 -#include -#include -#include -#include -#include -#include -#include - -// The following must be the last include for code pvDatabase uses -#include -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/pvDatabase.h" -#include "pv/addRecord.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 *testArgs[] = { - &testArg0}; - -static const iocshFuncDef addRecordFuncDef = {"addRecordCreate", 1,testArgs}; - -static void addRecordCallFunc(const iocshArgBuf *args) -{ - char *recordName = args[0].sval; - if(!recordName) { - throw std::runtime_error("addRecordCreate invalid number of arguments"); - } - AddRecordPtr record = AddRecord::create(recordName); - bool result = PVDatabase::getMaster()->addRecord(record); - if(!result) cout << "recordname" << " not added" << endl; -} - -static void addRecordRegister(void) -{ - static int firstTime = 1; - if (firstTime) { - firstTime = 0; - iocshRegister(&addRecordFuncDef, addRecordCallFunc); - } -} - -extern "C" { - epicsExportRegistrar(addRecordRegister); -} diff --git a/src/special/addRecordRegister.dbd b/src/special/addRecordRegister.dbd deleted file mode 100644 index 3983cfb..0000000 --- a/src/special/addRecordRegister.dbd +++ /dev/null @@ -1 +0,0 @@ -registrar("addRecordRegister") diff --git a/src/special/processRecordRegister.cpp b/src/special/processRecordRegister.cpp deleted file mode 100644 index 5fb38ea..0000000 --- a/src/special/processRecordRegister.cpp +++ /dev/null @@ -1,67 +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 -#include -#include -#include -#include -#include -#include -#include - -// The following must be the last include for code pvDatabase uses -#include -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/pvDatabase.h" -#include "pv/processRecord.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 = { "delay", iocshArgDouble }; -static const iocshArg *testArgs[] = { - &testArg0,&testArg1}; - -static const iocshFuncDef processRecordFuncDef = {"processRecordCreate", 2,testArgs}; - -static void processRecordCallFunc(const iocshArgBuf *args) -{ - char *recordName = args[0].sval; - if(!recordName) { - throw std::runtime_error("processRecordCreate invalid number of arguments"); - } - double delay = args[1].dval; - if(delay<0.0) delay = 1.0; - ProcessRecordPtr record = ProcessRecord::create(recordName,delay); - bool result = PVDatabase::getMaster()->addRecord(record); - if(!result) cout << "recordname" << " not added" << endl; -} - -static void processRecordRegister(void) -{ - static int firstTime = 1; - if (firstTime) { - firstTime = 0; - iocshRegister(&processRecordFuncDef, processRecordCallFunc); - } -} - -extern "C" { - epicsExportRegistrar(processRecordRegister); -} diff --git a/src/special/processRecordRegister.dbd b/src/special/processRecordRegister.dbd deleted file mode 100644 index fd8f945..0000000 --- a/src/special/processRecordRegister.dbd +++ /dev/null @@ -1 +0,0 @@ -registrar("processRecordRegister") diff --git a/src/special/pvdbSpecialRegister.dbd b/src/special/pvdbSpecialRegister.dbd new file mode 100644 index 0000000..eb36e2e --- /dev/null +++ b/src/special/pvdbSpecialRegister.dbd @@ -0,0 +1,6 @@ +include "pvdbcrAddRecordRegister.dbd" +include "pvdbcrRemoveRecordRegister.dbd" +include "pvdbcrProcessRecordRegister.dbd" +include "pvdbcrTraceRecordRegister.dbd" +include "pvdbcrScalarRegister.dbd" +include "pvdbcrScalarArrayRegister.dbd" diff --git a/src/special/addRecord.cpp b/src/special/pvdbcrAddRecordRegister.cpp similarity index 50% rename from src/special/addRecord.cpp rename to src/special/pvdbcrAddRecordRegister.cpp index 51fe3e1..c8a69d1 100644 --- a/src/special/addRecord.cpp +++ b/src/special/pvdbcrAddRecordRegister.cpp @@ -1,45 +1,57 @@ -/* addRecord.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. +/* + * 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.04.18 + * @date 2021.03.12 */ - -#include -#include -#include -#include -#include - -#include -#include -#include +#include #include -#include +#include #include -#include +#include +#include +#include #include -#include #include - +// The following must be the last include for code exampleLink uses +#include #define epicsExportSharedSymbols #include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" #include "pv/pvDatabase.h" -#include "pv/addRecord.h" - using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; +using namespace epics::pvDatabase; using namespace std; -namespace epics { namespace pvDatabase { +class PvdbcrAddRecord; +typedef std::tr1::shared_ptr PvdbcrAddRecordPtr; -AddRecordPtr AddRecord::create( + +class epicsShareClass PvdbcrAddRecord : + public PVRecord +{ +private: + PvdbcrAddRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure); + PVStringPtr pvRecordName; + epics::pvData::PVStringPtr pvResult; +public: + POINTER_DEFINITIONS(PvdbcrAddRecord); + + static PvdbcrAddRecordPtr create( + std::string const & recordName); + virtual bool init(); + virtual void process(); +}; + +PvdbcrAddRecordPtr PvdbcrAddRecord::create( std::string const & recordName) { FieldCreatePtr fieldCreate = getFieldCreate(); @@ -55,20 +67,20 @@ AddRecordPtr AddRecord::create( endNested()-> createStructure(); PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); - AddRecordPtr pvRecord( - new AddRecord(recordName,pvStructure)); + PvdbcrAddRecordPtr pvRecord( + new PvdbcrAddRecord(recordName,pvStructure)); if(!pvRecord->init()) pvRecord.reset(); return pvRecord; } -AddRecord::AddRecord( +PvdbcrAddRecord::PvdbcrAddRecord( std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure) + PVStructurePtr const & pvStructure) : PVRecord(recordName,pvStructure) { } -bool AddRecord::init() +bool PvdbcrAddRecord::init() { initPVRecord(); PVStructurePtr pvStructure = getPVStructure(); @@ -79,7 +91,7 @@ bool AddRecord::init() return true; } -void AddRecord::process() +void PvdbcrAddRecord::process() { PVDataCreatePtr pvDataCreate = getPVDataCreate(); string name = pvRecordName->get(); @@ -113,5 +125,43 @@ void AddRecord::process() } } +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "asLevel", iocshArgInt }; +static const iocshArg arg2 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2}; -}} +static const iocshFuncDef pvdbcrAddRecordFuncDef = {"pvdbcrAddRecord", 3,args}; + +static void pvdbcrAddRecordCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrAddRecord recordName not specified"); + } + string recordName = string(sval); + int asLevel = args[1].ival; + string asGroup("DEFAULT"); + sval = args[2].sval; + if(sval) { + asGroup = string(sval); + } + PvdbcrAddRecordPtr record = PvdbcrAddRecord::create(recordName); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrAddRecordRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrAddRecordFuncDef, pvdbcrAddRecordCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrAddRecordRegister); +} diff --git a/src/special/pvdbcrAddRecordRegister.dbd b/src/special/pvdbcrAddRecordRegister.dbd new file mode 100644 index 0000000..65f7c9b --- /dev/null +++ b/src/special/pvdbcrAddRecordRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrAddRecordRegister") diff --git a/src/special/processRecord.cpp b/src/special/pvdbcrProcessRecordRegister.cpp similarity index 55% rename from src/special/processRecord.cpp rename to src/special/pvdbcrProcessRecordRegister.cpp index c93ea3f..bfac05c 100644 --- a/src/special/processRecord.cpp +++ b/src/special/pvdbcrProcessRecordRegister.cpp @@ -1,46 +1,70 @@ -/* processRecord.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. +/* + * 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.04.18 + * @date 2021.03.12 */ -#include #include +#include #include -#include -#include -#include -#include -#include -#include - #include -#include -#include -#include +#include +#include +#include #include -#include +#include +#include +#include #include -#include #include +#include #define epicsExportSharedSymbols #include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" #include "pv/pvDatabase.h" -#include "pv/processRecord.h" - -using std::tr1::static_pointer_cast; using namespace epics::pvData; using namespace epics::pvAccess; +using namespace epics::pvDatabase; using namespace std; -namespace epics { namespace pvDatabase { +typedef std::tr1::shared_ptr EpicsThreadPtr; +class PvdbcrProcessRecord; +typedef std::tr1::shared_ptr PvdbcrProcessRecordPtr; -ProcessRecordPtr ProcessRecord::create( +class epicsShareClass PvdbcrProcessRecord : + public PVRecord, + public epicsThreadRunable +{ +public: + POINTER_DEFINITIONS(PvdbcrProcessRecord); + static PvdbcrProcessRecordPtr create( + std::string const & recordName,double delay); + virtual bool init(); + virtual void process(); + virtual void run(); + void startThread(); + void stop(); +private: + PvdbcrProcessRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure,double delay); + double delay; + EpicsThreadPtr thread; + epics::pvData::Event runStop; + epics::pvData::Event runReturn; + PVDatabasePtr pvDatabase; + PVRecordMap pvRecordMap; + epics::pvData::PVStringPtr pvCommand; + epics::pvData::PVStringPtr pvRecordName; + epics::pvData::PVStringPtr pvResult; + epics::pvData::Mutex mutex; +}; + +PvdbcrProcessRecordPtr PvdbcrProcessRecord::create( std::string const & recordName,double delay) { FieldCreatePtr fieldCreate = getFieldCreate(); @@ -55,13 +79,13 @@ ProcessRecordPtr ProcessRecord::create( endNested()-> createStructure(); PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); - ProcessRecordPtr pvRecord( - new ProcessRecord(recordName,pvStructure,delay)); + PvdbcrProcessRecordPtr pvRecord( + new PvdbcrProcessRecord(recordName,pvStructure,delay)); if(!pvRecord->init()) pvRecord.reset(); return pvRecord; } -void ProcessRecord::startThread() +void PvdbcrProcessRecord::startThread() { thread = EpicsThreadPtr(new epicsThread( *this, @@ -71,14 +95,14 @@ void ProcessRecord::startThread() thread->start(); } -void ProcessRecord::stop() +void PvdbcrProcessRecord::stop() { runStop.signal(); runReturn.wait(); } -ProcessRecord::ProcessRecord( +PvdbcrProcessRecord::PvdbcrProcessRecord( std::string const & recordName, epics::pvData::PVStructurePtr const & pvStructure,double delay) : PVRecord(recordName,pvStructure), @@ -87,7 +111,7 @@ ProcessRecord::ProcessRecord( { } -bool ProcessRecord::init() +bool PvdbcrProcessRecord::init() { initPVRecord(); PVStructurePtr pvStructure = getPVStructure(); @@ -100,7 +124,7 @@ bool ProcessRecord::init() return true; } -void ProcessRecord::process() +void PvdbcrProcessRecord::process() { string recordName = pvRecordName->get(); string command = pvCommand->get(); @@ -135,7 +159,7 @@ void ProcessRecord::process() } } -void ProcessRecord::run() +void PvdbcrProcessRecord::run() { while(true) { if(runStop.tryWait()) { @@ -162,5 +186,46 @@ void ProcessRecord::run() } } +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "delay", iocshArgDouble }; +static const iocshArg arg2 = { "asLevel", iocshArgInt }; +static const iocshArg arg3 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2,&arg3}; -}} +static const iocshFuncDef pvdbcrProcessRecordFuncDef = {"pvdbcrProcessRecord", 4,args}; + +static void pvdbcrProcessRecordCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrProcessRecord recordName not specified"); + } + string recordName = string(sval); + double delay = args[1].dval; + if(delay<0.0) delay = 1.0; + int asLevel = args[2].ival; + string asGroup("DEFAULT"); + sval = args[3].sval; + if(sval) { + asGroup = string(sval); + } + PvdbcrProcessRecordPtr record = PvdbcrProcessRecord::create(recordName,delay); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrProcessRecordRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrProcessRecordFuncDef, pvdbcrProcessRecordCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrProcessRecordRegister); +} diff --git a/src/special/pvdbcrProcessRecordRegister.dbd b/src/special/pvdbcrProcessRecordRegister.dbd new file mode 100644 index 0000000..8948909 --- /dev/null +++ b/src/special/pvdbcrProcessRecordRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrProcessRecordRegister") diff --git a/src/special/pvdbcrRemoveRecordRegister.cpp b/src/special/pvdbcrRemoveRecordRegister.cpp new file mode 100644 index 0000000..561faa6 --- /dev/null +++ b/src/special/pvdbcrRemoveRecordRegister.cpp @@ -0,0 +1,140 @@ +/* + * Copyright information and license terms for this software can be + * found in the file LICENSE that is included with the distribution + */ + +/** + * @author mrk + * @date 2021.03.12 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#define epicsExportSharedSymbols +#include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" +#include "pv/pvDatabase.h" +using namespace epics::pvData; +using namespace epics::pvAccess; +using namespace epics::pvDatabase; +using namespace std; + +class PvdbcrRemoveRecord; +typedef std::tr1::shared_ptr PvdbcrRemoveRecordPtr; + + +class epicsShareClass PvdbcrRemoveRecord : + public PVRecord +{ +public: + POINTER_DEFINITIONS(PvdbcrRemoveRecord); + static PvdbcrRemoveRecordPtr create( + std::string const & recordName); + virtual bool init(); + virtual void process(); +private: + PvdbcrRemoveRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure); + epics::pvData::PVStringPtr pvRecordName; + epics::pvData::PVStringPtr pvResult; +}; + +PvdbcrRemoveRecordPtr PvdbcrRemoveRecord::create( + std::string const & recordName) +{ + FieldCreatePtr fieldCreate = getFieldCreate(); + PVDataCreatePtr pvDataCreate = getPVDataCreate(); + StructureConstPtr topStructure = fieldCreate->createFieldBuilder()-> + addNestedStructure("argument")-> + add("recordName",pvString)-> + endNested()-> + addNestedStructure("result") -> + add("status",pvString) -> + endNested()-> + createStructure(); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); + PvdbcrRemoveRecordPtr pvRecord( + new PvdbcrRemoveRecord(recordName,pvStructure)); + if(!pvRecord->init()) pvRecord.reset(); + return pvRecord; +} + +PvdbcrRemoveRecord::PvdbcrRemoveRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure) +: PVRecord(recordName,pvStructure) +{ +} + +bool PvdbcrRemoveRecord::init() +{ + initPVRecord(); + PVStructurePtr pvStructure = getPVStructure(); + pvRecordName = pvStructure->getSubField("argument.recordName"); + if(!pvRecordName) return false; + pvResult = pvStructure->getSubField("result.status"); + if(!pvResult) return false; + return true; +} + +void PvdbcrRemoveRecord::process() +{ + string name = pvRecordName->get(); + PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name); + if(!pvRecord) { + pvResult->put(name + " not found"); + return; + } + pvRecord->remove(); + pvResult->put("success"); +} + +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "asLevel", iocshArgInt }; +static const iocshArg arg2 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2}; + +static const iocshFuncDef pvdbcrRemoveRecordFuncDef = {"pvdbcrRemoveRecord", 3,args}; + +static void pvdbcrRemoveRecordCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrRemoveRecord recordName not specified"); + } + string recordName = string(sval); + int asLevel = args[1].ival; + string asGroup("DEFAULT"); + sval = args[2].sval; + if(sval) { + asGroup = string(sval); + } + PvdbcrRemoveRecordPtr record = PvdbcrRemoveRecord::create(recordName); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrRemoveRecordRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrRemoveRecordFuncDef, pvdbcrRemoveRecordCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrRemoveRecordRegister); +} diff --git a/src/special/pvdbcrRemoveRecordRegister.dbd b/src/special/pvdbcrRemoveRecordRegister.dbd new file mode 100644 index 0000000..99d21c5 --- /dev/null +++ b/src/special/pvdbcrRemoveRecordRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrRemoveRecordRegister") diff --git a/src/special/pvdbcrScalarArrayRegister.cpp b/src/special/pvdbcrScalarArrayRegister.cpp new file mode 100644 index 0000000..eb43c0b --- /dev/null +++ b/src/special/pvdbcrScalarArrayRegister.cpp @@ -0,0 +1,83 @@ +/* + * Copyright information and license terms for this software can be + * found in the file LICENSE that is included with the distribution + */ + +/** + * @author mrk + * @date 2021.03.12 + */ + + +/* Author: Marty Kraimer */ +#include +#include +#include +#include + +// The following must be the last include for code pvDatabase implements +#include +#define epicsExportSharedSymbols +#include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" +#include "pv/pvDatabase.h" +using namespace epics::pvData; +using namespace epics::pvDatabase; +using namespace std; + +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "scalarType", iocshArgString }; +static const iocshArg arg2 = { "asLevel", iocshArgInt }; +static const iocshArg arg3 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2,&arg3}; + +static const iocshFuncDef pvdbcrScalarArrayFuncDef = {"pvdbcrScalarArray", 4,args}; + +static void pvdbcrScalarArrayCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrScalarArrayCreate recordName not specified"); + } + string recordName = string(sval); + sval = args[1].sval; + if(!sval) { + throw std::runtime_error("pvdbcrScalarArrayCreate scalarType not specified"); + } + string scalarType = string(sval); + int asLevel = args[2].ival; + string asGroup("DEFAULT"); + sval = args[3].sval; + if(sval) { + asGroup = string(sval); + } + ScalarType st = epics::pvData::ScalarTypeFunc::getScalarType(scalarType); + FieldCreatePtr fieldCreate = getFieldCreate(); + StandardFieldPtr standardField = getStandardField(); + PVDataCreatePtr pvDataCreate = getPVDataCreate(); + StructureConstPtr top = fieldCreate->createFieldBuilder()-> + addArray("value",st) -> + add("timeStamp",standardField->timeStamp()) -> + add("alarm",standardField->alarm()) -> + createStructure(); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top); + PVRecordPtr record = PVRecord::create(recordName,pvStructure); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrScalarArrayRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrScalarArrayFuncDef, pvdbcrScalarArrayCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrScalarArrayRegister); +} diff --git a/src/special/pvdbcrScalarArrayRegister.dbd b/src/special/pvdbcrScalarArrayRegister.dbd new file mode 100644 index 0000000..db27b53 --- /dev/null +++ b/src/special/pvdbcrScalarArrayRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrScalarArrayRegister") diff --git a/src/special/pvdbcrScalarRegister.cpp b/src/special/pvdbcrScalarRegister.cpp new file mode 100644 index 0000000..c60de79 --- /dev/null +++ b/src/special/pvdbcrScalarRegister.cpp @@ -0,0 +1,80 @@ +/* + * Copyright information and license terms for this software can be + * found in the file LICENSE that is included with the distribution + */ + +/** + * @author mrk + * @date 2021.03.12 + */ +#include +#include +#include +#include + +// The following must be the last include for code pvDatabase implements +#include +#define epicsExportSharedSymbols +#include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" +#include "pv/pvDatabase.h" +using namespace epics::pvData; +using namespace epics::pvDatabase; +using namespace std; + +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "scalarType", iocshArgString }; +static const iocshArg arg2 = { "asLevel", iocshArgInt }; +static const iocshArg arg3 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2,&arg3}; + +static const iocshFuncDef pvdbcrScalarFuncDef = {"pvdbcrScalar", 4,args}; + +static void pvdbcrScalarCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrScalarArrayCreate recordName not specified"); + } + string recordName = string(sval); + sval = args[1].sval; + if(!sval) { + throw std::runtime_error("pvdbcrScalarArrayCreate scalarType not specified"); + } + string scalarType = string(sval); + int asLevel = args[2].ival; + string asGroup("DEFAULT"); + sval = args[3].sval; + if(sval) { + asGroup = string(sval); + } + ScalarType st = epics::pvData::ScalarTypeFunc::getScalarType(scalarType); + FieldCreatePtr fieldCreate = getFieldCreate(); + StandardFieldPtr standardField = getStandardField(); + PVDataCreatePtr pvDataCreate = getPVDataCreate(); + StructureConstPtr top = fieldCreate->createFieldBuilder()-> + add("value",st) -> + add("timeStamp",standardField->timeStamp()) -> + add("alarm",standardField->alarm()) -> + createStructure(); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top); + PVRecordPtr record = PVRecord::create(recordName,pvStructure); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrScalarRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrScalarFuncDef, pvdbcrScalarCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrScalarRegister); +} diff --git a/src/special/pvdbcrScalarRegister.dbd b/src/special/pvdbcrScalarRegister.dbd new file mode 100644 index 0000000..1202c71 --- /dev/null +++ b/src/special/pvdbcrScalarRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrScalarRegister") diff --git a/src/special/pvdbcrTraceRecordRegister.cpp b/src/special/pvdbcrTraceRecordRegister.cpp new file mode 100644 index 0000000..d5439e7 --- /dev/null +++ b/src/special/pvdbcrTraceRecordRegister.cpp @@ -0,0 +1,146 @@ +/* + * Copyright information and license terms for this software can be + * found in the file LICENSE that is included with the distribution + */ + +/** + * @author mrk + * @date 2021.03.12 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// The following must be the last include +#include +#define epicsExportSharedSymbols +#include "pv/pvStructureCopy.h" +#include "pv/channelProviderLocal.h" +#include "pv/pvDatabase.h" + +using namespace epics::pvData; +using namespace epics::pvAccess; +using namespace epics::pvDatabase; +using namespace std; + +class PvdbcrTraceRecord; +typedef std::tr1::shared_ptr PvdbcrTraceRecordPtr; + +class epicsShareClass PvdbcrTraceRecord : + public PVRecord +{ +public: + POINTER_DEFINITIONS(PvdbcrTraceRecord); + static PvdbcrTraceRecordPtr create( + std::string const & recordName); + virtual bool init(); + virtual void process(); +private: + PvdbcrTraceRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure); + epics::pvData::PVStringPtr pvRecordName; + epics::pvData::PVIntPtr pvLevel; + epics::pvData::PVStringPtr pvResult; +}; + +PvdbcrTraceRecordPtr PvdbcrTraceRecord::create( + std::string const & recordName) +{ + FieldCreatePtr fieldCreate = getFieldCreate(); + PVDataCreatePtr pvDataCreate = getPVDataCreate(); + StructureConstPtr topStructure = fieldCreate->createFieldBuilder()-> + addNestedStructure("argument")-> + add("recordName",pvString)-> + add("level",pvInt)-> + endNested()-> + addNestedStructure("result") -> + add("status",pvString) -> + endNested()-> + createStructure(); + PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); + PvdbcrTraceRecordPtr pvRecord( + new PvdbcrTraceRecord(recordName,pvStructure)); + if(!pvRecord->init()) pvRecord.reset(); + return pvRecord; +} + +PvdbcrTraceRecord::PvdbcrTraceRecord( + std::string const & recordName, + epics::pvData::PVStructurePtr const & pvStructure) +: PVRecord(recordName,pvStructure) +{ +} + + +bool PvdbcrTraceRecord::init() +{ + initPVRecord(); + PVStructurePtr pvStructure = getPVStructure(); + pvRecordName = pvStructure->getSubField("argument.recordName"); + if(!pvRecordName) return false; + pvLevel = pvStructure->getSubField("argument.level"); + if(!pvLevel) return false; + pvResult = pvStructure->getSubField("result.status"); + if(!pvResult) return false; + return true; +} + +void PvdbcrTraceRecord::process() +{ + string name = pvRecordName->get(); + PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name); + if(!pvRecord) { + pvResult->put(name + " not found"); + return; + } + pvRecord->setTraceLevel(pvLevel->get()); + pvResult->put("success"); +} + +static const iocshArg arg0 = { "recordName", iocshArgString }; +static const iocshArg arg1 = { "asLevel", iocshArgInt }; +static const iocshArg arg2 = { "asGroup", iocshArgString }; +static const iocshArg *args[] = {&arg0,&arg1,&arg2}; + +static const iocshFuncDef pvdbcrTraceRecordFuncDef = {"pvdbcrTraceRecord", 3,args}; + +static void pvdbcrTraceRecordCallFunc(const iocshArgBuf *args) +{ + char *sval = args[0].sval; + if(!sval) { + throw std::runtime_error("pvdbcrTraceRecord recordName not specified"); + } + string recordName = string(sval); + int asLevel = args[1].ival; + string asGroup("DEFAULT"); + sval = args[2].sval; + if(sval) { + asGroup = string(sval); + } + PvdbcrTraceRecordPtr record = PvdbcrTraceRecord::create(recordName); + record->setAsLevel(asLevel); + record->setAsGroup(asGroup); + PVDatabasePtr master = PVDatabase::getMaster(); + bool result = master->addRecord(record); + if(!result) cout << "recordname " << recordName << " not added" << endl; +} + +static void pvdbcrTraceRecordRegister(void) +{ + static int firstTime = 1; + if (firstTime) { + firstTime = 0; + iocshRegister(&pvdbcrTraceRecordFuncDef, pvdbcrTraceRecordCallFunc); + } +} + +extern "C" { + epicsExportRegistrar(pvdbcrTraceRecordRegister); +} diff --git a/src/special/pvdbcrTraceRecordRegister.dbd b/src/special/pvdbcrTraceRecordRegister.dbd new file mode 100644 index 0000000..c525320 --- /dev/null +++ b/src/special/pvdbcrTraceRecordRegister.dbd @@ -0,0 +1 @@ +registrar("pvdbcrTraceRecordRegister") diff --git a/src/special/removeRecord.cpp b/src/special/removeRecord.cpp deleted file mode 100644 index a5525a7..0000000 --- a/src/special/removeRecord.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* removeRecord.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.18 - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/pvDatabase.h" -#include "pv/removeRecord.h" - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace pvDatabase { - -RemoveRecordPtr RemoveRecord::create( - std::string const & recordName) -{ - FieldCreatePtr fieldCreate = getFieldCreate(); - PVDataCreatePtr pvDataCreate = getPVDataCreate(); - StructureConstPtr topStructure = fieldCreate->createFieldBuilder()-> - addNestedStructure("argument")-> - add("recordName",pvString)-> - endNested()-> - addNestedStructure("result") -> - add("status",pvString) -> - endNested()-> - createStructure(); - PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); - RemoveRecordPtr pvRecord( - new RemoveRecord(recordName,pvStructure)); - if(!pvRecord->init()) pvRecord.reset(); - return pvRecord; -} - -RemoveRecord::RemoveRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure) -: PVRecord(recordName,pvStructure) -{ -} - -bool RemoveRecord::init() -{ - initPVRecord(); - PVStructurePtr pvStructure = getPVStructure(); - pvRecordName = pvStructure->getSubField("argument.recordName"); - if(!pvRecordName) return false; - pvResult = pvStructure->getSubField("result.status"); - if(!pvResult) return false; - return true; -} - -void RemoveRecord::process() -{ - string name = pvRecordName->get(); - PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name); - if(!pvRecord) { - pvResult->put(name + " not found"); - return; - } - pvRecord->remove(); - pvResult->put("success"); -} - - -}} diff --git a/src/special/removeRecordRegister.cpp b/src/special/removeRecordRegister.cpp deleted file mode 100644 index c55f34a..0000000 --- a/src/special/removeRecordRegister.cpp +++ /dev/null @@ -1,62 +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 -#include -#include -#include -#include -#include -#include -#include - -// The following must be the last include for code pvDatabase uses -#include -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/pvDatabase.h" -#include "pv/removeRecord.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 *testArgs[] = { - &testArg0}; - -static const iocshFuncDef removeRecordFuncDef = {"removeRecordCreate", 1,testArgs}; - -static void removeRecordCallFunc(const iocshArgBuf *args) -{ - char *recordName = args[0].sval; - if(!recordName) { - throw std::runtime_error("removeRecordCreate invalid number of arguments"); - } - RemoveRecordPtr record = RemoveRecord::create(recordName); - bool result = PVDatabase::getMaster()->addRecord(record); - if(!result) cout << "recordname" << " not added" << endl; -} - -static void removeRecordRegister(void) -{ - static int firstTime = 1; - if (firstTime) { - firstTime = 0; - iocshRegister(&removeRecordFuncDef, removeRecordCallFunc); - } -} - -extern "C" { - epicsExportRegistrar(removeRecordRegister); -} diff --git a/src/special/removeRecordRegister.dbd b/src/special/removeRecordRegister.dbd deleted file mode 100644 index aff2356..0000000 --- a/src/special/removeRecordRegister.dbd +++ /dev/null @@ -1 +0,0 @@ -registrar("removeRecordRegister") diff --git a/src/special/traceRecord.cpp b/src/special/traceRecord.cpp deleted file mode 100644 index 1a32bcb..0000000 --- a/src/special/traceRecord.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* traceRecord.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.18 - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/channelProviderLocal.h" -#include "pv/traceRecord.h" - -using std::tr1::static_pointer_cast; -using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace std; - -namespace epics { namespace pvDatabase { - -TraceRecordPtr TraceRecord::create( - std::string const & recordName) -{ - FieldCreatePtr fieldCreate = getFieldCreate(); - PVDataCreatePtr pvDataCreate = getPVDataCreate(); - StructureConstPtr topStructure = fieldCreate->createFieldBuilder()-> - addNestedStructure("argument")-> - add("recordName",pvString)-> - add("level",pvInt)-> - endNested()-> - addNestedStructure("result") -> - add("status",pvString) -> - endNested()-> - createStructure(); - PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure); - TraceRecordPtr pvRecord( - new TraceRecord(recordName,pvStructure)); - if(!pvRecord->init()) pvRecord.reset(); - return pvRecord; -} - -TraceRecord::TraceRecord( - std::string const & recordName, - epics::pvData::PVStructurePtr const & pvStructure) -: PVRecord(recordName,pvStructure) -{ -} - - -bool TraceRecord::init() -{ - initPVRecord(); - PVStructurePtr pvStructure = getPVStructure(); - pvRecordName = pvStructure->getSubField("argument.recordName"); - if(!pvRecordName) return false; - pvLevel = pvStructure->getSubField("argument.level"); - if(!pvLevel) return false; - pvResult = pvStructure->getSubField("result.status"); - if(!pvResult) return false; - return true; -} - -void TraceRecord::process() -{ - string name = pvRecordName->get(); - PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name); - if(!pvRecord) { - pvResult->put(name + " not found"); - return; - } - pvRecord->setTraceLevel(pvLevel->get()); - pvResult->put("success"); -} - - -}} diff --git a/src/special/traceRecordRegister.cpp b/src/special/traceRecordRegister.cpp deleted file mode 100644 index 57d20f4..0000000 --- a/src/special/traceRecordRegister.cpp +++ /dev/null @@ -1,63 +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 -#include -#include -#include -#include -#include -#include -#include - -// The following must be the last include for code pvDatabase uses -#include -#define epicsExportSharedSymbols -#include "pv/pvStructureCopy.h" -#include "pv/pvDatabase.h" -#include "pv/traceRecord.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 *testArgs[] = { - &testArg0}; - -static const iocshFuncDef traceRecordFuncDef = {"traceRecordCreate", 1,testArgs}; - -static void traceRecordCallFunc(const iocshArgBuf *args) -{ - char *recordName = args[0].sval; - if(!recordName) { - throw std::runtime_error("traceRecordCreate invalid number of arguments"); - } - TraceRecordPtr record = TraceRecord::create(recordName); - bool result = PVDatabase::getMaster()->addRecord(record); - if(!result) cout << "recordname" << " not added" << endl; -} - -static void traceRecordRegister(void) -{ - static int firstTime = 1; - if (firstTime) { - firstTime = 0; - iocshRegister(&traceRecordFuncDef, traceRecordCallFunc); - } -} - -extern "C" { - epicsExportRegistrar(traceRecordRegister); -} diff --git a/src/special/traceRecordRegister.dbd b/src/special/traceRecordRegister.dbd deleted file mode 100644 index 4dde906..0000000 --- a/src/special/traceRecordRegister.dbd +++ /dev/null @@ -1 +0,0 @@ -registrar("traceRecordRegister") diff --git a/src/support/controlSupport.cpp b/src/support/controlSupport.cpp index 6a582ef..6dc7502 100644 --- a/src/support/controlSupport.cpp +++ b/src/support/controlSupport.cpp @@ -46,6 +46,7 @@ epics::pvData::StructureConstPtr ControlSupport::controlField(ScalarType scalarT ControlSupportPtr ControlSupport::create(PVRecordPtr const & pvRecord) { + cerr << "ControlSupport IS DEPRECATED\n"; ControlSupportPtr support(new ControlSupport(pvRecord)); return support; } diff --git a/src/support/scalarAlarmSupport.cpp b/src/support/scalarAlarmSupport.cpp index de592b7..b911bdf 100644 --- a/src/support/scalarAlarmSupport.cpp +++ b/src/support/scalarAlarmSupport.cpp @@ -48,6 +48,7 @@ epics::pvData::StructureConstPtr ScalarAlarmSupport::scalarAlarmField() ScalarAlarmSupportPtr ScalarAlarmSupport::create(PVRecordPtr const & pvRecord) { + cerr << "ScalarAlarmSupport IS DEPRECATED\n"; ScalarAlarmSupportPtr support(new ScalarAlarmSupport(pvRecord)); return support; }