more work on examples; documentation is only changed up to exampleServer

This commit is contained in:
Marty Kraimer
2014-02-06 16:46:47 -05:00
parent 94bd84211b
commit 9a798bc05a
81 changed files with 2361 additions and 605 deletions

View File

@ -7,5 +7,5 @@ db/
dbd/ dbd/
documentation/html documentation/html
envPaths envPaths
configure/.*\.local RELEASE.local
/O\..* /O\..*

View File

@ -0,0 +1,7 @@
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICS_BASE=/home/install/epics/base
PVCOMMON=/home/hg/pvCommonCPP
PVDATA=/home/hg/pvDataCPP
PVACCESS=/home/hg/pvAccessCPP

File diff suppressed because it is too large Load Diff

16
exampleDatabase/Makefile Normal file
View File

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

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

View File

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

View File

@ -0,0 +1,44 @@
# RELEASE - Location of external support modules
#
# IF YOU MAKE ANY CHANGES to this file you must subsequently
# do a "gnumake rebuild" in this application's top level
# directory.
#
# The build process does not check dependencies against files
# that are outside this application, thus you should 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)
#
# This file should ONLY define paths to other support modules,
# or include statements that pull in similar RELEASE files.
# Build settings that are NOT module paths should appear in a
# CONFIG_SITE file.
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
# If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
# EPICS_BASE usually appears last so other apps can override stuff:
# do not edit the locations in this file
# create RELEASE.local with the paths to your EPICS_BASE, PVDATA, and PVACCESS
# these default locations are needed for the BNL Jenkins server to work
# Set RULES here if you want to take build rules from somewhere
# other than EPICS_BASE:
#RULES=/path/to/epics/support/module/rules/x-y
# Leave these in for the Jenkins build at BNL to work
EPICS_BASE=/home/install/epics/base
PVDATA=/home/mrk/hg/pvDataCPP
PVACCESS=/home/mrk/hg/pvAccessCPP
# set your EPICS_BASE, PVDATA and PVACCESS paths in here
-include $(TOP)/../RELEASE.local
-include $(TOP)/configure/RELEASE.local

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,28 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#----------------------------------------------------
# Optimization of db files using dbst (DEFAULT: NO)
#DB_OPT = YES
#----------------------------------------------------
# Create and install (or just install)
# databases, templates, substitutions like this
DB += dbScalar.db
DB += dbInteger.db
DB += dbArray.db
DB += dbString.db
DB += dbStringArray.db
DB += dbEnum.db
DB += dbCounter.db
#----------------------------------------------------
# If <anyname>.db template is not named <anyname>*.template add
# <anyname>_TEMPLATE = <templatename>
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,9 @@
record(waveform, "$(name)")
{
field(NELM,"5")
field(NORD,"5")
field(FTVL,"$(type)")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
}

View File

@ -0,0 +1,20 @@
record(calc, "${name}")
{
field(DESC, "Counter")
field(SCAN,"1 second")
field(CALC, "(A<B)?(A+C):D")
field(INPA, "${name} NPP NMS")
field(INPB, "9")
field(INPC, "1")
field(INPD, "0")
field(EGU, "Counts")
field(HOPR, "10")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,14 @@
record(mbbo, "$(name)")
{
field(NOBT,"2")
field(ZRVL,"0")
field(ONVL,"1")
field(TWVL,"2")
field(THVL,"3")
field(ZRST,"zero")
field(ONST,"one")
field(TWST,"two")
field(THST,"three")
field(TWSV,"MINOR")
field(THSV,"MAJOR")
}

View File

@ -0,0 +1,16 @@
record($(type), "$(name)")
{
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
field(DRVH, "9")
field(DRVL, "0")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,17 @@
record($(type), "$(name)")
{
field(PREC, "1")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
field(DRVH, "9.9")
field(DRVL, "-0.1")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,3 @@
record(stringout, "$(name)")
{
}

View File

@ -0,0 +1,5 @@
record(waveform, "${name}")
{
field(NELM,"5")
field(FTVL,"STRING")
}

View File

@ -0,0 +1,8 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*))
include $(TOP)/configure/RULES_DIRS

View File

@ -0,0 +1,40 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += exampleDatabase.dbd
#=============================
# build an ioc application
PROD_IOC += exampleDatabase
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
exampleDatabase_SRCS += exampleDatabase_registerRecordDeviceDriver.cpp
exampleDatabase_SRCS_DEFAULT += exampleDatabaseMain.cpp
exampleDatabase_SRCS_vxWorks += -nil-
# The following adds support from base/src/vxWorks
exampleDatabase_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
exampleDatabase_LIBS += pvData pvAccess
exampleDatabase_LIBS += pvDatabase
exampleDatabase_LIBS += pvaSrv
exampleDatabase_LIBS += exampleDatabase
exampleDatabase_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,3 @@
include "base.dbd"
include "PVAServerRegister.dbd"
registrar("exampleDatabaseRegister")

View File

@ -0,0 +1,57 @@
/*exampleDatabaseMain.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 <vector>
#include <iostream>
#include <pv/channelProviderLocal.h>
#include <pv/exampleDatabase.h>
#include <pv/serverContext.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 = getChannelProviderLocal();
ExampleDatabase::create();
ServerContext::shared_pointer ctx =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleDatabase\n";
PVStringArrayPtr pvNames = master->getRecordNames();
String buffer;
pvNames->toString(&buffer);
cout << "recordNames" << endl << buffer << endl;
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
ctx->destroy();
epicsThreadSleep(1.0);
channelProvider->destroy();
return 0;
}

View File

@ -0,0 +1,7 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard example*)
include $(EPICS_BASE)/configure/RULES_DIRS

View File

@ -0,0 +1,5 @@
TOP = ../..
include $(TOP)/configure/CONFIG
ARCH = $(EPICS_HOST_ARCH)
TARGETS = envPaths
include $(TOP)/configure/RULES.ioc

View File

@ -0,0 +1,21 @@
< envPaths
cd ${TOP}
## Register all support components
dbLoadDatabase("dbd/exampleDatabase.dbd")
exampleDatabase_registerRecordDeviceDriver(pdbbase)
## Load record instances
dbLoadRecords("db/dbScalar.db","name=double01,type=ao")
dbLoadRecords("db/dbStringArray.db","name=stringArray01")
dbLoadRecords("db/dbEnum.db","name=enum01")
dbLoadRecords("db/dbCounter.db","name=counter01");
cd ${TOP}/iocBoot/${IOC}
iocInit()
dbl
epicsThreadSleep(2.0)
exampleDatabase
startPVAServer
pvdbl

View File

@ -0,0 +1,38 @@
TOP=..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
PROD_HOST += exampleDatabaseMain
exampleDatabaseMain_SRCS += exampleDatabaseMain.cpp
exampleDatabaseMain_LIBS += Com
exampleDatabaseMain_LIBS += pvData
exampleDatabaseMain_LIBS += pvAccess
exampleDatabaseMain_LIBS += pvDatabase
exampleDatabaseMain_LIBS += exampleDatabase
DBD += exampleDatabase.dbd
INC += exampleDatabase.h
LIBRARY_IOC += exampleDatabase
exampleDatabase_SRCS += exampleDatabase.cpp
exampleDatabase_SRCS += exampleDatabaseRegister.cpp
exampleDatabase_LIBS += pvData
exampleDatabase_LIBS += pvAccess
exampleDatabase_LIBS += pvDatabase
exampleDatabase_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,138 @@
/*exampleDatabase.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 <vector>
#include <iostream>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/powerSupplyRecordTest.h>
#include <pv/channelProviderLocal.h>
#include <pv/recordList.h>
#include <pv/traceRecord.h>
#include <pv/exampleDatabase.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
static FieldCreatePtr fieldCreate = getFieldCreate();
static StandardFieldPtr standardField = getStandardField();
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardPVFieldPtr standardPVField = getStandardPVField();
static PVStructurePtr createPowerSupply()
{
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));
}
static void createStructureArrayRecord(
PVDatabasePtr const &master,
ScalarType scalarType,
String const &recordName)
{
StructureConstPtr structure = standardField->scalar(
pvDouble,
String("value,alarm,timeStamp"));
StringArray names(2);
FieldConstPtrArray fields(2);
names[0] = "timeStamp";
names[1] = "value";
fields[0] = standardField->timeStamp();
fields[1] = fieldCreate->createStructureArray(structure);
StructureConstPtr top = fieldCreate->createStructure(names,fields);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(top);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}
static void createRecords(
PVDatabasePtr const &master,
ScalarType scalarType,
String const &recordNamePrefix,
String const &properties)
{
String recordName = recordNamePrefix;
PVStructurePtr pvStructure = standardPVField->scalar(scalarType,properties);
PVRecordPtr pvRecord = PVRecord::create(recordName,pvStructure);
bool result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
recordName += "Array";
pvStructure = standardPVField->scalarArray(scalarType,properties);
pvRecord = PVRecord::create(recordName,pvStructure);
result = master->addRecord(pvRecord);
}
void ExampleDatabase::create()
{
PVDatabasePtr master = PVDatabase::getMaster();
PVRecordPtr pvRecord;
String recordName;
bool result(false);
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
String properties;
properties = "alarm,timeStamp";
createRecords(master,pvBoolean,"exampleBoolean",properties);
createRecords(master,pvByte,"exampleByte",properties);
createRecords(master,pvShort,"exampleShort",properties);
createRecords(master,pvInt,"exampleInt",properties);
createRecords(master,pvLong,"exampleLong",properties);
createRecords(master,pvFloat,"exampleFloat",properties);
createRecords(master,pvDouble,"exampleDouble",properties);
createRecords(master,pvString,"exampleString",properties);
createStructureArrayRecord(master,pvDouble,"exampleStructureArray");
recordName = "examplePowerSupply";
PVStructurePtr pvStructure = createPowerSupply();
PowerSupplyRecordTestPtr psr =
PowerSupplyRecordTest::create(recordName,pvStructure);
if(psr.get()==NULL) {
cout << "PowerSupplyRecordTest::create failed" << endl;
return;
}
result = master->addRecord(psr);
if(!result) cout<< "record " << recordName << " not added" << endl;
recordName = "laptoprecordListPGRPC";
pvRecord = RecordListRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
}

View File

@ -0,0 +1,27 @@
/* exampleDatabase.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.07.24
*/
#ifndef EXAMPLEDATABASE_H
#define EXAMPLEDATABASE_H
#include <pv/pvDatabase.h>
namespace epics { namespace pvDatabase {
class ExampleDatabase{
public:
static void create();
};
}}
#endif /* EXAMPLEDATABASE_H */

View File

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

View File

@ -0,0 +1,60 @@
/*exampleDatabaseMain.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 <vector>
#include <iostream>
#include <pv/channelProviderLocal.h>
#include <pv/exampleDatabase.h>
#include <pv/serverContext.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 = getChannelProviderLocal();
ExampleDatabase::create();
ServerContext::shared_pointer ctx =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleDatabase\n";
PVStringArrayPtr pvNames = master->getRecordNames();
String buffer;
pvNames->toString(&buffer);
cout << "recordNames" << endl << buffer << endl;
PVRecordPtr pvRecord = master->findRecord("laptoprecordListPGRPC");
PVStructurePtr pvStructure = pvRecord->getPVRecordStructure()->getPVStructure();
cout << "PVStructure" << endl << pvStructure->dumpValue(cout) << endl;
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
ctx->destroy();
epicsThreadSleep(1.0);
channelProvider->destroy();
return 0;
}

View File

@ -0,0 +1,60 @@
/*exampleDatabase.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 <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/exampleDatabase.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
static const iocshArg testArg0 = { "prefix", iocshArgString };
static const iocshArg *testArgs[] = {
&testArg0};
static const iocshFuncDef exampleDatabaseFuncDef = {
"exampleDatabase", 1, testArgs};
static void exampleDatabaseCallFunc(const iocshArgBuf *args)
{
ExampleDatabase::create();
}
static void exampleDatabaseRegister(void)
{
static int firstTime = 1;
if (firstTime) {
firstTime = 0;
iocshRegister(&exampleDatabaseFuncDef, exampleDatabaseCallFunc);
}
}
epicsExportRegistrar(exampleDatabaseRegister);

View File

@ -0,0 +1,8 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
PVDATABASE=${EPICSV4HOME}/pvDatabaseCPP
PVASRV=${EPICSV4HOME}/pvaSrv

View File

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

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

View File

@ -0,0 +1,8 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
PVDATABASE=${EPICSV4HOME}/pvDatabaseCPP
PVASRV=${EPICSV4HOME}/pvaSrv

View File

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

View File

@ -0,0 +1,44 @@
# RELEASE - Location of external support modules
#
# IF YOU MAKE ANY CHANGES to this file you must subsequently
# do a "gnumake rebuild" in this application's top level
# directory.
#
# The build process does not check dependencies against files
# that are outside this application, thus you should 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)
#
# This file should ONLY define paths to other support modules,
# or include statements that pull in similar RELEASE files.
# Build settings that are NOT module paths should appear in a
# CONFIG_SITE file.
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
# If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
# EPICS_BASE usually appears last so other apps can override stuff:
# do not edit the locations in this file
# create RELEASE.local with the paths to your EPICS_BASE, PVDATA, and PVACCESS
# these default locations are needed for the BNL Jenkins server to work
# Set RULES here if you want to take build rules from somewhere
# other than EPICS_BASE:
#RULES=/path/to/epics/support/module/rules/x-y
# Leave these in for the Jenkins build at BNL to work
EPICS_BASE=/home/install/epics/base
PVDATA=/home/mrk/hg/pvDataCPP
PVACCESS=/home/mrk/hg/pvAccessCPP
# set your EPICS_BASE, PVDATA and PVACCESS paths in here
-include $(TOP)/../RELEASE.local
-include $(TOP)/configure/RELEASE.local

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,28 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#----------------------------------------------------
# Optimization of db files using dbst (DEFAULT: NO)
#DB_OPT = YES
#----------------------------------------------------
# Create and install (or just install)
# databases, templates, substitutions like this
DB += dbScalar.db
DB += dbInteger.db
DB += dbArray.db
DB += dbString.db
DB += dbStringArray.db
DB += dbEnum.db
DB += dbCounter.db
#----------------------------------------------------
# If <anyname>.db template is not named <anyname>*.template add
# <anyname>_TEMPLATE = <templatename>
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,9 @@
record(waveform, "$(name)")
{
field(NELM,"5")
field(NORD,"5")
field(FTVL,"$(type)")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
}

View File

@ -0,0 +1,20 @@
record(calc, "${name}")
{
field(DESC, "Counter")
field(SCAN,"1 second")
field(CALC, "(A<B)?(A+C):D")
field(INPA, "${name} NPP NMS")
field(INPB, "9")
field(INPC, "1")
field(INPD, "0")
field(EGU, "Counts")
field(HOPR, "10")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,14 @@
record(mbbo, "$(name)")
{
field(NOBT,"2")
field(ZRVL,"0")
field(ONVL,"1")
field(TWVL,"2")
field(THVL,"3")
field(ZRST,"zero")
field(ONST,"one")
field(TWST,"two")
field(THST,"three")
field(TWSV,"MINOR")
field(THSV,"MAJOR")
}

View File

@ -0,0 +1,16 @@
record($(type), "$(name)")
{
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
field(DRVH, "9")
field(DRVL, "0")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,17 @@
record($(type), "$(name)")
{
field(PREC, "1")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "0")
field(DRVH, "9.9")
field(DRVL, "-0.1")
field(HIHI, "8")
field(HIGH, "6")
field(LOW, "4")
field(LOLO, "2")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
field(LSV, "MINOR")
field(LLSV, "MAJOR")
}

View File

@ -0,0 +1,3 @@
record(stringout, "$(name)")
{
}

View File

@ -0,0 +1,5 @@
record(waveform, "${name}")
{
field(NELM,"5")
field(FTVL,"STRING")
}

View File

@ -0,0 +1,8 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*))
DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*))
include $(TOP)/configure/RULES_DIRS

View File

@ -0,0 +1,40 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += powerSupply.dbd
#=============================
# build an ioc application
PROD_IOC += powerSupply
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
powerSupply_SRCS += powerSupply_registerRecordDeviceDriver.cpp
powerSupply_SRCS_DEFAULT += powerSupplyMain.cpp
powerSupply_SRCS_vxWorks += -nil-
# The following adds support from base/src/vxWorks
powerSupply_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
powerSupply_LIBS += pvData pvAccess
powerSupply_LIBS += pvDatabase
powerSupply_LIBS += pvaSrv
powerSupply_LIBS += powerSupply
powerSupply_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,5 @@
include "base.dbd"
include "PVAServerRegister.dbd"
include "registerChannelProviderLocal.dbd"
include "dbPv.dbd"
include "powerSupply.dbd"

View File

@ -0,0 +1,31 @@
/* powerSupplyMain.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
*/
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "epicsExit.h"
#include "epicsThread.h"
#include "iocsh.h"
int main(int argc,char *argv[])
{
if(argc>=2) {
iocsh(argv[1]);
epicsThreadSleep(.2);
}
iocsh(NULL);
epicsExit(0);
return(0);
}

View File

@ -0,0 +1,7 @@
TOP = ..
include $(TOP)/configure/CONFIG
DIRS += $(wildcard *ioc*)
DIRS += $(wildcard as*)
DIRS += $(wildcard power*)
include $(EPICS_BASE)/configure/RULES_DIRS

View File

@ -0,0 +1,5 @@
TOP = ../..
include $(TOP)/configure/CONFIG
ARCH = $(EPICS_HOST_ARCH)
TARGETS = envPaths
include $(TOP)/configure/RULES.ioc

View File

@ -0,0 +1,23 @@
< envPaths
cd ${TOP}
## Register all support components
dbLoadDatabase("dbd/powerSupply.dbd")
powerSupply_registerRecordDeviceDriver(pdbbase)
## Load record instances
dbLoadRecords("db/dbScalar.db","name=pvdouble,type=ao")
dbLoadRecords("db/dbArray.db","name=pvdoubleArray,type=DOUBLE")
dbLoadRecords("db/dbStringArray.db","name=pvstringArray")
dbLoadRecords("db/dbEnum.db","name=pvenum")
dbLoadRecords("db/dbCounter.db","name=pvcounter");
cd ${TOP}/iocBoot/${IOC}
iocInit()
dbl
epicsThreadSleep(1.0)
powerSupplyCreateRecord powerSupply
startPVAServer
pvdbl

View File

@ -0,0 +1,38 @@
TOP=..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
PROD_HOST += powerSupplyMain
powerSupplyMain_SRCS += powerSupplyMain.cpp
powerSupplyMain_LIBS += Com
powerSupplyMain_LIBS += pvData
powerSupplyMain_LIBS += pvAccess
powerSupplyMain_LIBS += pvDatabase
powerSupplyMain_LIBS += powerSupply
DBD += powerSupply.dbd
INC += powerSupply.h
LIBRARY_IOC += powerSupply
powerSupply_SRCS += powerSupply.cpp
powerSupply_SRCS += powerSupplyRegister.cpp
powerSupply_LIBS += pvData
powerSupply_LIBS += pvAccess
powerSupply_LIBS += pvDatabase
powerSupply_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@ -0,0 +1,179 @@
/* 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 <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/powerSupply.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));
}
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();
}
}}

View File

@ -0,0 +1,58 @@
/* 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 <pv/pvDatabase.h>
#include <pv/timeStamp.h>
#include <pv/alarm.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAlarm.h>
namespace epics { namespace pvDatabase {
extern 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 @@
registrar("powerSupplyRegister")

View File

@ -0,0 +1,68 @@
/*powerSupplyMain.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/powerSupply.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.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 = getChannelProviderLocal();
PVRecordPtr pvRecord;
bool result(false);
String recordName;
recordName = "powerSupply";
PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create(recordName,pv);
result = master->addRecord(pvRecord);
cout << "result of addRecord " << recordName << " " << result << endl;
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
pvRecord.reset();
ServerContext::shared_pointer pvaServer =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "powerSupply\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
pvaServer->shutdown();
epicsThreadSleep(1.0);
pvaServer->destroy();
channelProvider->destroy();
return 0;
}

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,8 @@
EPICS_BASE=/home/install/epics/base
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
EPICSV4HOME=/home/hg
PVCOMMON=${EPICSV4HOME}/pvCommonCPP
PVDATA=${EPICSV4HOME}/pvDataCPP
PVACCESS=${EPICSV4HOME}/pvAccessCPP
PVDATABASE=${EPICSV4HOME}/pvDatabaseCPP
PVASRV=${EPICSV4HOME}/pvaSrv

View File

@ -29,7 +29,7 @@ exampleServer_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
exampleServer_LIBS += pvData pvAccess exampleServer_LIBS += pvData pvAccess
exampleServer_LIBS += pvDatabase exampleServer_LIBS += pvDatabase
exampleServer_LIBS += pvaSrv exampleServer_LIBS += pvaSrv
exampleServer_LIBS += exampleServerSupport exampleServer_LIBS += exampleServer
exampleServer_LIBS += $(EPICS_BASE_IOC_LIBS) exampleServer_LIBS += $(EPICS_BASE_IOC_LIBS)
#=========================== #===========================

View File

@ -17,7 +17,7 @@ cd ${TOP}/iocBoot/${IOC}
iocInit() iocInit()
dbl dbl
epicsThreadSleep(1.0) epicsThreadSleep(1.0)
exampleServerCreateRecord pvaServer exampleServerCreateRecord exampleServer
startPVAServer startPVAServer
pvdbl pvdbl

View File

@ -9,17 +9,26 @@ include $(TOP)/configure/CONFIG
# Build an IOC support library # Build an IOC support library
# #
PROD_HOST += exampleServerMain
exampleServerMain_SRCS += exampleServerMain.cpp
exampleServerMain_LIBS += Com
exampleServerMain_LIBS += pvData
exampleServerMain_LIBS += pvAccess
exampleServerMain_LIBS += pvDatabase
exampleServerMain_LIBS += exampleServer
DBD += exampleServer.dbd DBD += exampleServer.dbd
INC += exampleServer.h INC += exampleServer.h
LIBRARY_IOC += exampleServerSupport LIBRARY_IOC += exampleServer
exampleServerSupport_SRCS += exampleServer.cpp exampleServer_SRCS += exampleServer.cpp
exampleServerSupport_SRCS += exampleServerRegister.cpp exampleServer_SRCS += exampleServerRegister.cpp
exampleServerSupport_LIBS += pvData exampleServer_LIBS += pvData
exampleServerSupport_LIBS += pvAccess exampleServer_LIBS += pvAccess
exampleServerSupport_LIBS += pvDatabase exampleServer_LIBS += pvDatabase
exampleServerSupport_LIBS += $(EPICS_BASE_IOC_LIBS) exampleServer_LIBS += $(EPICS_BASE_IOC_LIBS)
#=========================== #===========================

View File

@ -0,0 +1,67 @@
/*ExampleServerMain.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/exampleServer.h>
#include <pv/traceRecord.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
using namespace epics::exampleServer;
int main(int argc,char *argv[])
{
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
PVRecordPtr pvRecord;
bool result(false);
String recordName;
recordName = "exampleServer";
pvRecord = ExampleServer::create(recordName);
result = master->addRecord(pvRecord);
cout << "result of addRecord " << recordName << " " << result << endl;
recordName = "traceRecordPGRPC";
pvRecord = TraceRecord::create(recordName);
result = master->addRecord(pvRecord);
if(!result) cout<< "record " << recordName << " not added" << endl;
pvRecord.reset();
ServerContext::shared_pointer pvaServer =
startPVAServer(PVACCESS_ALL_PROVIDERS,0,true,true);
cout << "exampleServer\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
pvaServer->shutdown();
epicsThreadSleep(1.0);
pvaServer->destroy();
channelProvider->destroy();
return 0;
}

View File

@ -33,7 +33,6 @@ LIBSRCS += PVAClientRegister.cpp
SRC_DIRS += $(DATABASE)/special SRC_DIRS += $(DATABASE)/special
INC += recordList.h INC += recordList.h
INC += traceRecord.h INC += traceRecord.h
INC += powerSupplyRecordTest.h
LIBSRCS += recordList.cpp LIBSRCS += recordList.cpp
LIBSRCS += traceRecord.cpp LIBSRCS += traceRecord.cpp

View File

@ -36,7 +36,7 @@ RecordListRecordPtr RecordListRecord::create(
resFields[1] = fieldCreate->createScalarArray(pvString); resFields[1] = fieldCreate->createScalarArray(pvString);
StringArray topNames(2); StringArray topNames(2);
FieldConstPtrArray topFields(2); FieldConstPtrArray topFields(2);
topNames[0] = "arguments"; topNames[0] = "argument";
topFields[0] = fieldCreate->createStructure(argNames,argFields); topFields[0] = fieldCreate->createStructure(argNames,argFields);
topNames[1] = "result"; topNames[1] = "result";
topFields[1] = fieldCreate->createStructure(resNames,resFields); topFields[1] = fieldCreate->createStructure(resNames,resFields);
@ -69,10 +69,10 @@ bool RecordListRecord::init()
{ {
initPVRecord(); initPVRecord();
PVStructurePtr pvStructure = getPVStructure(); PVStructurePtr pvStructure = getPVStructure();
database = pvStructure->getStringField("arguments.database"); database = pvStructure->getStringField("argument.database");
if(database.get()==NULL) return false; if(database.get()==NULL) return false;
regularExpression = pvStructure->getStringField( regularExpression = pvStructure->getStringField(
"arguments.regularExpression"); "argument.regularExpression");
if(regularExpression.get()==NULL) return false; if(regularExpression.get()==NULL) return false;
status = pvStructure->getStringField("result.status"); status = pvStructure->getStringField("result.status");
if(status.get()==NULL) return false; if(status.get()==NULL) return false;

View File

@ -25,7 +25,7 @@ TraceRecordPtr TraceRecord::create(
PVDataCreatePtr pvDataCreate = getPVDataCreate(); PVDataCreatePtr pvDataCreate = getPVDataCreate();
StringArray topNames(2); StringArray topNames(2);
FieldConstPtrArray topFields(2); FieldConstPtrArray topFields(2);
topNames[0] = "arguments"; topNames[0] = "argument";
topNames[1] = "result"; topNames[1] = "result";
StringArray argNames(2); StringArray argNames(2);
FieldConstPtrArray argFields(2); FieldConstPtrArray argFields(2);
@ -70,9 +70,9 @@ bool TraceRecord::init()
{ {
initPVRecord(); initPVRecord();
PVStructurePtr pvStructure = getPVStructure(); PVStructurePtr pvStructure = getPVStructure();
pvRecordName = pvStructure->getStringField("arguments.recordName"); pvRecordName = pvStructure->getStringField("argument.recordName");
if(pvRecordName==NULL) return false; if(pvRecordName==NULL) return false;
pvLevel = pvStructure->getIntField("arguments.level"); pvLevel = pvStructure->getIntField("argument.level");
if(pvLevel==NULL) return false; if(pvLevel==NULL) return false;
pvResult = pvStructure->getStringField("result.status"); pvResult = pvStructure->getStringField("result.status");
if(pvResult==NULL) return false; if(pvResult==NULL) return false;

View File

@ -3,14 +3,17 @@ TOP=..
include $(TOP)/configure/CONFIG include $(TOP)/configure/CONFIG
PROD_HOST += testPVCopy PROD_HOST += testPVCopy
testPVCopy_SRCS += powerSupply.cpp
testPVCopy_SRCS += testPVCopy.cpp testPVCopy_SRCS += testPVCopy.cpp
testPVCopy_LIBS += pvDatabase pvAccess pvData Com testPVCopy_LIBS += pvDatabase pvAccess pvData Com
PROD_HOST += testPVRecord PROD_HOST += testPVRecord
testPVRecord_SRCS += powerSupply.cpp
testPVRecord_SRCS += testPVRecord.cpp testPVRecord_SRCS += testPVRecord.cpp
testPVRecord_LIBS += pvDatabase pvAccess pvData Com testPVRecord_LIBS += pvDatabase pvAccess pvData Com
PROD_HOST += testExampleRecord PROD_HOST += testExampleRecord
testExampleRecord_SRCS += powerSupply.cpp
testExampleRecord_SRCS += testExampleRecord.cpp testExampleRecord_SRCS += testExampleRecord.cpp
testExampleRecord_LIBS += pvDatabase pvAccess pvData Com testExampleRecord_LIBS += pvDatabase pvAccess pvData Com

View File

@ -1,4 +1,4 @@
/* powerSupplyRecordTest.h */ /* powerSupply.cpp */
/** /**
* Copyright - See the COPYRIGHT that is included with this distribution. * Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found * EPICS pvData is distributed subject to a Software License Agreement found
@ -8,80 +8,74 @@
* @author mrk * @author mrk
* @date 2013.04.02 * @date 2013.04.02
*/ */
#ifndef POWERSUPPLYRECORDTEST_H
#define POWERSUPPLYRECORDTEST_H
#include <pv/pvDatabase.h> #include "powerSupply.h"
#include <pv/timeStamp.h> #include <pv/standardField.h>
#include <pv/alarm.h> #include <pv/standardPVField.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAlarm.h>
namespace epics { namespace pvDatabase { namespace epics { namespace pvDatabase {
using namespace epics::pvData;
PVStructurePtr createPowerSupply()
class PowerSupplyRecordTest;
typedef std::tr1::shared_ptr<PowerSupplyRecordTest> PowerSupplyRecordTestPtr;
class PowerSupplyRecordTest :
public PVRecord
{ {
public: FieldCreatePtr fieldCreate = getFieldCreate();
POINTER_DEFINITIONS(PowerSupplyRecordTest); StandardFieldPtr standardField = getStandardField();
static PowerSupplyRecordTestPtr create( PVDataCreatePtr pvDataCreate = getPVDataCreate();
epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
virtual ~PowerSupplyRecordTest();
virtual void destroy();
virtual bool init();
virtual void process();
void put(double power,double voltage);
double getPower();
double getVoltage();
double getCurrent();
private:
PowerSupplyRecordTest(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;
};
PowerSupplyRecordTestPtr PowerSupplyRecordTest::create( size_t nfields = 5;
epics::pvData::String const & recordName, StringArray names;
epics::pvData::PVStructurePtr const & pvStructure) 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)
{ {
PowerSupplyRecordTestPtr pvRecord( PowerSupplyPtr pvRecord(
new PowerSupplyRecordTest(recordName,pvStructure)); new PowerSupply(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset(); if(!pvRecord->init()) pvRecord.reset();
return pvRecord; return pvRecord;
} }
PowerSupplyRecordTest::PowerSupplyRecordTest( PowerSupply::PowerSupply(
epics::pvData::String const & recordName, String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure) PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure) : PVRecord(recordName,pvStructure)
{ {
} }
PowerSupplyRecordTest::~PowerSupplyRecordTest() PowerSupply::~PowerSupply()
{ {
} }
void PowerSupplyRecordTest::destroy() void PowerSupply::destroy()
{ {
PVRecord::destroy(); PVRecord::destroy();
} }
bool PowerSupplyRecordTest::init() bool PowerSupply::init()
{ {
initPVRecord(); initPVRecord();
epics::pvData::PVStructurePtr pvStructure = getPVStructure(); PVStructurePtr pvStructure = getPVStructure();
epics::pvData::PVFieldPtr pvField; PVFieldPtr pvField;
bool result; bool result;
pvField = pvStructure->getSubField("timeStamp"); pvField = pvStructure->getSubField("timeStamp");
if(pvField.get()==NULL) { if(pvField.get()==NULL) {
@ -103,7 +97,7 @@ bool PowerSupplyRecordTest::init()
std::cerr << "no alarm" << std::endl; std::cerr << "no alarm" << std::endl;
return false; return false;
} }
epics::pvData::String name; String name;
name = "current.value"; name = "current.value";
pvField = pvStructure->getSubField(name); pvField = pvStructure->getSubField(name);
if(pvField.get()==NULL) { if(pvField.get()==NULL) {
@ -143,7 +137,7 @@ bool PowerSupplyRecordTest::init()
return true; return true;
} }
void PowerSupplyRecordTest::process() void PowerSupply::process()
{ {
timeStamp.getCurrent(); timeStamp.getCurrent();
pvTimeStamp.set(timeStamp); pvTimeStamp.set(timeStamp);
@ -151,39 +145,37 @@ void PowerSupplyRecordTest::process()
double power = pvPower->get(); double power = pvPower->get();
if(voltage<1e-3 && voltage>-1e-3) { if(voltage<1e-3 && voltage>-1e-3) {
alarm.setMessage("bad voltage"); alarm.setMessage("bad voltage");
alarm.setSeverity(epics::pvData::majorAlarm); alarm.setSeverity(majorAlarm);
pvAlarm.set(alarm); pvAlarm.set(alarm);
return; return;
} }
double current = power/voltage; double current = power/voltage;
pvCurrent->put(current); pvCurrent->put(current);
alarm.setMessage(""); alarm.setMessage("");
alarm.setSeverity(epics::pvData::noAlarm); alarm.setSeverity(noAlarm);
pvAlarm.set(alarm); pvAlarm.set(alarm);
} }
void PowerSupplyRecordTest::put(double power,double voltage) void PowerSupply::put(double power,double voltage)
{ {
pvPower->put(power); pvPower->put(power);
pvVoltage->put(voltage); pvVoltage->put(voltage);
} }
double PowerSupplyRecordTest::getPower() double PowerSupply::getPower()
{ {
return pvPower->get(); return pvPower->get();
} }
double PowerSupplyRecordTest::getVoltage() double PowerSupply::getVoltage()
{ {
return pvVoltage->get(); return pvVoltage->get();
} }
double PowerSupplyRecordTest::getCurrent() double PowerSupply::getCurrent()
{ {
return pvCurrent->get(); return pvCurrent->get();
} }
}} }}
#endif /* POWERSUPPLYRECORDTEST_H */

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

@ -0,0 +1,58 @@
/* 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 <pv/pvDatabase.h>
#include <pv/timeStamp.h>
#include <pv/alarm.h>
#include <pv/pvTimeStamp.h>
#include <pv/pvAlarm.h>
namespace epics { namespace pvDatabase {
extern 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

@ -29,7 +29,7 @@
#include <pv/standardPVField.h> #include <pv/standardPVField.h>
#include <pv/pvData.h> #include <pv/pvData.h>
#include <pv/pvAccess.h> #include <pv/pvAccess.h>
#include <pv/powerSupplyRecordTest.h> #include "powerSupply.h"
using namespace std; using namespace std;
using std::tr1::static_pointer_cast; using std::tr1::static_pointer_cast;
@ -38,30 +38,6 @@ using namespace epics::pvAccess;
using namespace epics::pvDatabase; using namespace epics::pvDatabase;
static 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));
}
void test() void test()
@ -86,9 +62,9 @@ void test()
pvRecord.reset(); pvRecord.reset();
recordName = "powerSupplyExample"; recordName = "powerSupplyExample";
pvStructure.reset(); pvStructure.reset();
PowerSupplyPtr psr;
pvStructure = createPowerSupply(); pvStructure = createPowerSupply();
PowerSupplyRecordTestPtr psr = psr = PowerSupply::create("powerSupply",pvStructure);
PowerSupplyRecordTest::create(recordName,pvStructure);
if(psr.get()==NULL) { if(psr.get()==NULL) {
cout << "PowerSupplyRecordTest::create failed" << endl; cout << "PowerSupplyRecordTest::create failed" << endl;
return; return;

View File

@ -26,7 +26,7 @@
#include <pv/standardField.h> #include <pv/standardField.h>
#include <pv/standardPVField.h> #include <pv/standardPVField.h>
#include <pv/channelProviderLocal.h> #include <pv/channelProviderLocal.h>
#include <pv/powerSupplyRecordTest.h> #include "powerSupply.h"
using namespace std; using namespace std;
@ -73,32 +73,6 @@ static PVRecordPtr createScalarArray(
return PVRecord::create(recordName,pvStructure); 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 testPVScalar( static void testPVScalar(
String const & valueNameRecord, String const & valueNameRecord,
String const & valueNameCopy, String const & valueNameCopy,
@ -370,7 +344,7 @@ static void powerSupplyTest()
{ {
cout << endl << endl << "****powerSupplyTest****" << endl; cout << endl << endl << "****powerSupplyTest****" << endl;
RequesterPtr requester(new MyRequester("exampleTest")); RequesterPtr requester(new MyRequester("exampleTest"));
PowerSupplyRecordTestPtr pvRecord; PowerSupplyPtr pvRecord;
String request; String request;
PVStructurePtr pvRequest; PVStructurePtr pvRequest;
PVRecordFieldPtr pvRecordField; PVRecordFieldPtr pvRecordField;
@ -380,7 +354,8 @@ static void powerSupplyTest()
String valueNameCopy; String valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create(); CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvRecord = createPowerSupply("powerSupply"); PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create("powerSupply",pv);
valueNameRecord = request = "power.value"; valueNameRecord = request = "power.value";
pvRequest = createRequest->createRequest(request); pvRequest = createRequest->createRequest(request);
builder.clear(); pvRequest->toString(&builder); builder.clear(); pvRequest->toString(&builder);

View File

@ -26,15 +26,13 @@
#include <pv/standardField.h> #include <pv/standardField.h>
#include <pv/standardPVField.h> #include <pv/standardPVField.h>
#include <pv/pvData.h> #include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvCopy.h> #include <pv/pvCopy.h>
#include <pv/powerSupplyRecordTest.h> #include "powerSupply.h"
using namespace std; using namespace std;
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::pvDatabase; using namespace epics::pvDatabase;
static PVRecordPtr createScalar( static PVRecordPtr createScalar(
@ -57,32 +55,6 @@ static PVRecordPtr createScalarArray(
return PVRecord::create(recordName,pvStructure); 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() static void scalarTest()
{ {
cout << endl << endl << "****scalarTest****" << endl; cout << endl << endl << "****scalarTest****" << endl;
@ -102,8 +74,9 @@ static void arrayTest()
static void powerSupplyTest() static void powerSupplyTest()
{ {
cout << endl << endl << "****powerSupplyTest****" << endl; cout << endl << endl << "****powerSupplyTest****" << endl;
PowerSupplyRecordTestPtr pvRecord; PVRecordPtr pvRecord;
pvRecord = createPowerSupply("powerSupply"); PVStructurePtr pv = createPowerSupply();
pvRecord = PowerSupply::create("powerSupply",pv);
pvRecord->destroy(); pvRecord->destroy();
} }