more work on examples; documentation is only changed up to exampleServer
This commit is contained in:
@ -7,5 +7,5 @@ db/
|
||||
dbd/
|
||||
documentation/html
|
||||
envPaths
|
||||
configure/.*\.local
|
||||
RELEASE.local
|
||||
/O\..*
|
||||
|
7
configure/ExampleRELEASE.local
Normal file
7
configure/ExampleRELEASE.local
Normal 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
16
exampleDatabase/Makefile
Normal 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
|
||||
|
||||
|
29
exampleDatabase/configure/CONFIG
Normal file
29
exampleDatabase/configure/CONFIG
Normal 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
|
||||
|
39
exampleDatabase/configure/CONFIG_SITE
Normal file
39
exampleDatabase/configure/CONFIG_SITE
Normal file
@ -0,0 +1,39 @@
|
||||
# CONFIG_SITE
|
||||
|
||||
# Make any application-specific changes to the EPICS build
|
||||
# configuration variables in this file.
|
||||
#
|
||||
# Host/target specific settings can be specified in files named
|
||||
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
|
||||
# CONFIG_SITE.Common.$(T_A)
|
||||
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
|
||||
|
||||
# CHECK_RELEASE controls the consistency checking of the support
|
||||
# applications pointed to by the RELEASE* files.
|
||||
# Normally CHECK_RELEASE should be set to YES.
|
||||
# Set CHECK_RELEASE to NO to disable checking completely.
|
||||
# Set CHECK_RELEASE to WARN to perform consistency checking but
|
||||
# continue building anyway if conflicts are found.
|
||||
#CHECK_RELEASE = YES
|
||||
|
||||
# Set this when you only want to compile this application
|
||||
# for a subset of the cross-compiled target architectures
|
||||
# that Base is built for.
|
||||
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
|
||||
|
||||
# To install files into a location other than $(TOP) define
|
||||
# INSTALL_LOCATION here.
|
||||
#INSTALL_LOCATION=</path/name/to/install/top>
|
||||
|
||||
# Set this when your IOC and the host use different paths
|
||||
# to access the application. This will be needed to boot
|
||||
# from a Microsoft FTP server or with some NFS mounts.
|
||||
# You must rebuild in the iocBoot directory for this to
|
||||
# take effect.
|
||||
#IOCS_APPL_TOP = </IOC/path/to/application/top>
|
||||
|
||||
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
|
||||
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
|
||||
|
||||
-include $(TOP)/configure/CONFIG_SITE.local
|
||||
-include $(TOP)/../CONFIG.local
|
8
exampleDatabase/configure/Makefile
Normal file
8
exampleDatabase/configure/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
TOP=..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
TARGETS = $(CONFIG_TARGETS)
|
||||
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
|
||||
|
||||
include $(TOP)/configure/RULES
|
44
exampleDatabase/configure/RELEASE
Normal file
44
exampleDatabase/configure/RELEASE
Normal 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
|
6
exampleDatabase/configure/RULES
Normal file
6
exampleDatabase/configure/RULES
Normal file
@ -0,0 +1,6 @@
|
||||
# RULES
|
||||
|
||||
include $(CONFIG)/RULES
|
||||
|
||||
# Library should be rebuilt because LIBOBJS may have changed.
|
||||
$(LIBNAME): ../Makefile
|
2
exampleDatabase/configure/RULES.ioc
Normal file
2
exampleDatabase/configure/RULES.ioc
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES.ioc
|
||||
include $(CONFIG)/RULES.ioc
|
2
exampleDatabase/configure/RULES_DIRS
Normal file
2
exampleDatabase/configure/RULES_DIRS
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES_DIRS
|
||||
include $(CONFIG)/RULES_DIRS
|
3
exampleDatabase/configure/RULES_TOP
Normal file
3
exampleDatabase/configure/RULES_TOP
Normal file
@ -0,0 +1,3 @@
|
||||
#RULES_TOP
|
||||
include $(CONFIG)/RULES_TOP
|
||||
|
28
exampleDatabase/example/Db/Makefile
Normal file
28
exampleDatabase/example/Db/Makefile
Normal 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
|
||||
|
9
exampleDatabase/example/Db/dbArray.db
Normal file
9
exampleDatabase/example/Db/dbArray.db
Normal 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")
|
||||
}
|
20
exampleDatabase/example/Db/dbCounter.db
Normal file
20
exampleDatabase/example/Db/dbCounter.db
Normal 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")
|
||||
}
|
14
exampleDatabase/example/Db/dbEnum.db
Normal file
14
exampleDatabase/example/Db/dbEnum.db
Normal 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")
|
||||
}
|
16
exampleDatabase/example/Db/dbInteger.db
Normal file
16
exampleDatabase/example/Db/dbInteger.db
Normal 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")
|
||||
}
|
17
exampleDatabase/example/Db/dbScalar.db
Normal file
17
exampleDatabase/example/Db/dbScalar.db
Normal 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")
|
||||
}
|
3
exampleDatabase/example/Db/dbString.db
Normal file
3
exampleDatabase/example/Db/dbString.db
Normal file
@ -0,0 +1,3 @@
|
||||
record(stringout, "$(name)")
|
||||
{
|
||||
}
|
5
exampleDatabase/example/Db/dbStringArray.db
Normal file
5
exampleDatabase/example/Db/dbStringArray.db
Normal file
@ -0,0 +1,5 @@
|
||||
record(waveform, "${name}")
|
||||
{
|
||||
field(NELM,"5")
|
||||
field(FTVL,"STRING")
|
||||
}
|
8
exampleDatabase/example/Makefile
Normal file
8
exampleDatabase/example/Makefile
Normal 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
|
||||
|
40
exampleDatabase/example/src/Makefile
Normal file
40
exampleDatabase/example/src/Makefile
Normal 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
|
||||
|
3
exampleDatabase/example/src/exampleDatabaseInclude.dbd
Normal file
3
exampleDatabase/example/src/exampleDatabaseInclude.dbd
Normal file
@ -0,0 +1,3 @@
|
||||
include "base.dbd"
|
||||
include "PVAServerRegister.dbd"
|
||||
registrar("exampleDatabaseRegister")
|
57
exampleDatabase/example/src/exampleDatabaseMain.cpp
Normal file
57
exampleDatabase/example/src/exampleDatabaseMain.cpp
Normal 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;
|
||||
}
|
||||
|
7
exampleDatabase/iocBoot/Makefile
Normal file
7
exampleDatabase/iocBoot/Makefile
Normal 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
|
||||
|
5
exampleDatabase/iocBoot/exampleDatabase/Makefile
Normal file
5
exampleDatabase/iocBoot/exampleDatabase/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
TOP = ../..
|
||||
include $(TOP)/configure/CONFIG
|
||||
ARCH = $(EPICS_HOST_ARCH)
|
||||
TARGETS = envPaths
|
||||
include $(TOP)/configure/RULES.ioc
|
21
exampleDatabase/iocBoot/exampleDatabase/st.cmd
Normal file
21
exampleDatabase/iocBoot/exampleDatabase/st.cmd
Normal 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
|
38
exampleDatabase/src/Makefile
Normal file
38
exampleDatabase/src/Makefile
Normal 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
|
||||
|
138
exampleDatabase/src/exampleDatabase.cpp
Normal file
138
exampleDatabase/src/exampleDatabase.cpp
Normal 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;
|
||||
}
|
||||
|
27
exampleDatabase/src/exampleDatabase.h
Normal file
27
exampleDatabase/src/exampleDatabase.h
Normal 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 */
|
1
exampleDatabase/src/exampleDatabaseInclude.dbd
Normal file
1
exampleDatabase/src/exampleDatabaseInclude.dbd
Normal file
@ -0,0 +1 @@
|
||||
registrar("exampleDatabaseRegister")
|
60
exampleDatabase/src/exampleDatabaseMain.cpp
Normal file
60
exampleDatabase/src/exampleDatabaseMain.cpp
Normal 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;
|
||||
}
|
||||
|
60
exampleDatabase/src/exampleDatabaseRegister.cpp
Normal file
60
exampleDatabase/src/exampleDatabaseRegister.cpp
Normal 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);
|
8
exampleLink/configure/ExampleRELEASE.local
Normal file
8
exampleLink/configure/ExampleRELEASE.local
Normal 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
|
16
examplePowerSupply/Makefile
Normal file
16
examplePowerSupply/Makefile
Normal 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
|
||||
|
||||
|
29
examplePowerSupply/configure/CONFIG
Normal file
29
examplePowerSupply/configure/CONFIG
Normal 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
|
||||
|
39
examplePowerSupply/configure/CONFIG_SITE
Normal file
39
examplePowerSupply/configure/CONFIG_SITE
Normal file
@ -0,0 +1,39 @@
|
||||
# CONFIG_SITE
|
||||
|
||||
# Make any application-specific changes to the EPICS build
|
||||
# configuration variables in this file.
|
||||
#
|
||||
# Host/target specific settings can be specified in files named
|
||||
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
|
||||
# CONFIG_SITE.Common.$(T_A)
|
||||
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
|
||||
|
||||
# CHECK_RELEASE controls the consistency checking of the support
|
||||
# applications pointed to by the RELEASE* files.
|
||||
# Normally CHECK_RELEASE should be set to YES.
|
||||
# Set CHECK_RELEASE to NO to disable checking completely.
|
||||
# Set CHECK_RELEASE to WARN to perform consistency checking but
|
||||
# continue building anyway if conflicts are found.
|
||||
#CHECK_RELEASE = YES
|
||||
|
||||
# Set this when you only want to compile this application
|
||||
# for a subset of the cross-compiled target architectures
|
||||
# that Base is built for.
|
||||
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040
|
||||
|
||||
# To install files into a location other than $(TOP) define
|
||||
# INSTALL_LOCATION here.
|
||||
#INSTALL_LOCATION=</path/name/to/install/top>
|
||||
|
||||
# Set this when your IOC and the host use different paths
|
||||
# to access the application. This will be needed to boot
|
||||
# from a Microsoft FTP server or with some NFS mounts.
|
||||
# You must rebuild in the iocBoot directory for this to
|
||||
# take effect.
|
||||
#IOCS_APPL_TOP = </IOC/path/to/application/top>
|
||||
|
||||
INSTALL_INCLUDE = $(INSTALL_LOCATION)/include/pv
|
||||
USR_INCLUDES += -I $(INSTALL_LOCATION)/include
|
||||
|
||||
-include $(TOP)/configure/CONFIG_SITE.local
|
||||
-include $(TOP)/../CONFIG.local
|
8
examplePowerSupply/configure/ExampleRELEASE.local
Normal file
8
examplePowerSupply/configure/ExampleRELEASE.local
Normal 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
|
8
examplePowerSupply/configure/Makefile
Normal file
8
examplePowerSupply/configure/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
TOP=..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
TARGETS = $(CONFIG_TARGETS)
|
||||
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
|
||||
|
||||
include $(TOP)/configure/RULES
|
44
examplePowerSupply/configure/RELEASE
Normal file
44
examplePowerSupply/configure/RELEASE
Normal 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
|
6
examplePowerSupply/configure/RULES
Normal file
6
examplePowerSupply/configure/RULES
Normal file
@ -0,0 +1,6 @@
|
||||
# RULES
|
||||
|
||||
include $(CONFIG)/RULES
|
||||
|
||||
# Library should be rebuilt because LIBOBJS may have changed.
|
||||
$(LIBNAME): ../Makefile
|
2
examplePowerSupply/configure/RULES.ioc
Normal file
2
examplePowerSupply/configure/RULES.ioc
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES.ioc
|
||||
include $(CONFIG)/RULES.ioc
|
2
examplePowerSupply/configure/RULES_DIRS
Normal file
2
examplePowerSupply/configure/RULES_DIRS
Normal file
@ -0,0 +1,2 @@
|
||||
#RULES_DIRS
|
||||
include $(CONFIG)/RULES_DIRS
|
3
examplePowerSupply/configure/RULES_TOP
Normal file
3
examplePowerSupply/configure/RULES_TOP
Normal file
@ -0,0 +1,3 @@
|
||||
#RULES_TOP
|
||||
include $(CONFIG)/RULES_TOP
|
||||
|
28
examplePowerSupply/example/Db/Makefile
Normal file
28
examplePowerSupply/example/Db/Makefile
Normal 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
|
||||
|
9
examplePowerSupply/example/Db/dbArray.db
Normal file
9
examplePowerSupply/example/Db/dbArray.db
Normal 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")
|
||||
}
|
20
examplePowerSupply/example/Db/dbCounter.db
Normal file
20
examplePowerSupply/example/Db/dbCounter.db
Normal 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")
|
||||
}
|
14
examplePowerSupply/example/Db/dbEnum.db
Normal file
14
examplePowerSupply/example/Db/dbEnum.db
Normal 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")
|
||||
}
|
16
examplePowerSupply/example/Db/dbInteger.db
Normal file
16
examplePowerSupply/example/Db/dbInteger.db
Normal 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")
|
||||
}
|
17
examplePowerSupply/example/Db/dbScalar.db
Normal file
17
examplePowerSupply/example/Db/dbScalar.db
Normal 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")
|
||||
}
|
3
examplePowerSupply/example/Db/dbString.db
Normal file
3
examplePowerSupply/example/Db/dbString.db
Normal file
@ -0,0 +1,3 @@
|
||||
record(stringout, "$(name)")
|
||||
{
|
||||
}
|
5
examplePowerSupply/example/Db/dbStringArray.db
Normal file
5
examplePowerSupply/example/Db/dbStringArray.db
Normal file
@ -0,0 +1,5 @@
|
||||
record(waveform, "${name}")
|
||||
{
|
||||
field(NELM,"5")
|
||||
field(FTVL,"STRING")
|
||||
}
|
8
examplePowerSupply/example/Makefile
Normal file
8
examplePowerSupply/example/Makefile
Normal 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
|
||||
|
40
examplePowerSupply/example/src/Makefile
Normal file
40
examplePowerSupply/example/src/Makefile
Normal 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
|
||||
|
5
examplePowerSupply/example/src/powerSupplyInclude.dbd
Normal file
5
examplePowerSupply/example/src/powerSupplyInclude.dbd
Normal file
@ -0,0 +1,5 @@
|
||||
include "base.dbd"
|
||||
include "PVAServerRegister.dbd"
|
||||
include "registerChannelProviderLocal.dbd"
|
||||
include "dbPv.dbd"
|
||||
include "powerSupply.dbd"
|
31
examplePowerSupply/example/src/powerSupplyMain.cpp
Normal file
31
examplePowerSupply/example/src/powerSupplyMain.cpp
Normal 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);
|
||||
}
|
7
examplePowerSupply/iocBoot/Makefile
Normal file
7
examplePowerSupply/iocBoot/Makefile
Normal 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
|
||||
|
5
examplePowerSupply/iocBoot/powerSupply/Makefile
Normal file
5
examplePowerSupply/iocBoot/powerSupply/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
TOP = ../..
|
||||
include $(TOP)/configure/CONFIG
|
||||
ARCH = $(EPICS_HOST_ARCH)
|
||||
TARGETS = envPaths
|
||||
include $(TOP)/configure/RULES.ioc
|
23
examplePowerSupply/iocBoot/powerSupply/st.cmd
Normal file
23
examplePowerSupply/iocBoot/powerSupply/st.cmd
Normal 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
|
||||
|
38
examplePowerSupply/src/Makefile
Normal file
38
examplePowerSupply/src/Makefile
Normal 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
|
||||
|
179
examplePowerSupply/src/powerSupply.cpp
Normal file
179
examplePowerSupply/src/powerSupply.cpp
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
}}
|
58
examplePowerSupply/src/powerSupply.h
Normal file
58
examplePowerSupply/src/powerSupply.h
Normal 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 */
|
1
examplePowerSupply/src/powerSupplyInclude.dbd
Normal file
1
examplePowerSupply/src/powerSupplyInclude.dbd
Normal file
@ -0,0 +1 @@
|
||||
registrar("powerSupplyRegister")
|
68
examplePowerSupply/src/powerSupplyMain.cpp
Normal file
68
examplePowerSupply/src/powerSupplyMain.cpp
Normal 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;
|
||||
}
|
||||
|
69
examplePowerSupply/src/powerSupplyRegister.cpp
Normal file
69
examplePowerSupply/src/powerSupplyRegister.cpp
Normal 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);
|
8
exampleServer/configure/ExampleRELEASE.local
Normal file
8
exampleServer/configure/ExampleRELEASE.local
Normal 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
|
@ -29,7 +29,7 @@ exampleServer_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary
|
||||
exampleServer_LIBS += pvData pvAccess
|
||||
exampleServer_LIBS += pvDatabase
|
||||
exampleServer_LIBS += pvaSrv
|
||||
exampleServer_LIBS += exampleServerSupport
|
||||
exampleServer_LIBS += exampleServer
|
||||
exampleServer_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
#===========================
|
||||
|
@ -17,7 +17,7 @@ cd ${TOP}/iocBoot/${IOC}
|
||||
iocInit()
|
||||
dbl
|
||||
epicsThreadSleep(1.0)
|
||||
exampleServerCreateRecord pvaServer
|
||||
exampleServerCreateRecord exampleServer
|
||||
startPVAServer
|
||||
pvdbl
|
||||
|
||||
|
@ -9,17 +9,26 @@ include $(TOP)/configure/CONFIG
|
||||
# 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
|
||||
|
||||
INC += exampleServer.h
|
||||
|
||||
LIBRARY_IOC += exampleServerSupport
|
||||
exampleServerSupport_SRCS += exampleServer.cpp
|
||||
exampleServerSupport_SRCS += exampleServerRegister.cpp
|
||||
exampleServerSupport_LIBS += pvData
|
||||
exampleServerSupport_LIBS += pvAccess
|
||||
exampleServerSupport_LIBS += pvDatabase
|
||||
exampleServerSupport_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
LIBRARY_IOC += exampleServer
|
||||
exampleServer_SRCS += exampleServer.cpp
|
||||
exampleServer_SRCS += exampleServerRegister.cpp
|
||||
exampleServer_LIBS += pvData
|
||||
exampleServer_LIBS += pvAccess
|
||||
exampleServer_LIBS += pvDatabase
|
||||
exampleServer_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
#===========================
|
||||
|
||||
|
67
exampleServer/src/exampleServerMain.cpp
Normal file
67
exampleServer/src/exampleServerMain.cpp
Normal 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;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ LIBSRCS += PVAClientRegister.cpp
|
||||
SRC_DIRS += $(DATABASE)/special
|
||||
INC += recordList.h
|
||||
INC += traceRecord.h
|
||||
INC += powerSupplyRecordTest.h
|
||||
LIBSRCS += recordList.cpp
|
||||
LIBSRCS += traceRecord.cpp
|
||||
|
||||
|
@ -36,7 +36,7 @@ RecordListRecordPtr RecordListRecord::create(
|
||||
resFields[1] = fieldCreate->createScalarArray(pvString);
|
||||
StringArray topNames(2);
|
||||
FieldConstPtrArray topFields(2);
|
||||
topNames[0] = "arguments";
|
||||
topNames[0] = "argument";
|
||||
topFields[0] = fieldCreate->createStructure(argNames,argFields);
|
||||
topNames[1] = "result";
|
||||
topFields[1] = fieldCreate->createStructure(resNames,resFields);
|
||||
@ -69,10 +69,10 @@ bool RecordListRecord::init()
|
||||
{
|
||||
initPVRecord();
|
||||
PVStructurePtr pvStructure = getPVStructure();
|
||||
database = pvStructure->getStringField("arguments.database");
|
||||
database = pvStructure->getStringField("argument.database");
|
||||
if(database.get()==NULL) return false;
|
||||
regularExpression = pvStructure->getStringField(
|
||||
"arguments.regularExpression");
|
||||
"argument.regularExpression");
|
||||
if(regularExpression.get()==NULL) return false;
|
||||
status = pvStructure->getStringField("result.status");
|
||||
if(status.get()==NULL) return false;
|
||||
|
@ -25,7 +25,7 @@ TraceRecordPtr TraceRecord::create(
|
||||
PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
StringArray topNames(2);
|
||||
FieldConstPtrArray topFields(2);
|
||||
topNames[0] = "arguments";
|
||||
topNames[0] = "argument";
|
||||
topNames[1] = "result";
|
||||
StringArray argNames(2);
|
||||
FieldConstPtrArray argFields(2);
|
||||
@ -70,9 +70,9 @@ bool TraceRecord::init()
|
||||
{
|
||||
initPVRecord();
|
||||
PVStructurePtr pvStructure = getPVStructure();
|
||||
pvRecordName = pvStructure->getStringField("arguments.recordName");
|
||||
pvRecordName = pvStructure->getStringField("argument.recordName");
|
||||
if(pvRecordName==NULL) return false;
|
||||
pvLevel = pvStructure->getIntField("arguments.level");
|
||||
pvLevel = pvStructure->getIntField("argument.level");
|
||||
if(pvLevel==NULL) return false;
|
||||
pvResult = pvStructure->getStringField("result.status");
|
||||
if(pvResult==NULL) return false;
|
||||
|
@ -3,14 +3,17 @@ TOP=..
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_HOST += testPVCopy
|
||||
testPVCopy_SRCS += powerSupply.cpp
|
||||
testPVCopy_SRCS += testPVCopy.cpp
|
||||
testPVCopy_LIBS += pvDatabase pvAccess pvData Com
|
||||
|
||||
PROD_HOST += testPVRecord
|
||||
testPVRecord_SRCS += powerSupply.cpp
|
||||
testPVRecord_SRCS += testPVRecord.cpp
|
||||
testPVRecord_LIBS += pvDatabase pvAccess pvData Com
|
||||
|
||||
PROD_HOST += testExampleRecord
|
||||
testExampleRecord_SRCS += powerSupply.cpp
|
||||
testExampleRecord_SRCS += testExampleRecord.cpp
|
||||
testExampleRecord_LIBS += pvDatabase pvAccess pvData Com
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* powerSupplyRecordTest.h */
|
||||
/* powerSupply.cpp */
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvData is distributed subject to a Software License Agreement found
|
||||
@ -8,80 +8,74 @@
|
||||
* @author mrk
|
||||
* @date 2013.04.02
|
||||
*/
|
||||
#ifndef POWERSUPPLYRECORDTEST_H
|
||||
#define POWERSUPPLYRECORDTEST_H
|
||||
|
||||
#include <pv/pvDatabase.h>
|
||||
#include <pv/timeStamp.h>
|
||||
#include <pv/alarm.h>
|
||||
#include <pv/pvTimeStamp.h>
|
||||
#include <pv/pvAlarm.h>
|
||||
#include "powerSupply.h"
|
||||
#include <pv/standardField.h>
|
||||
#include <pv/standardPVField.h>
|
||||
|
||||
namespace epics { namespace pvDatabase {
|
||||
using namespace epics::pvData;
|
||||
|
||||
|
||||
class PowerSupplyRecordTest;
|
||||
typedef std::tr1::shared_ptr<PowerSupplyRecordTest> PowerSupplyRecordTestPtr;
|
||||
|
||||
class PowerSupplyRecordTest :
|
||||
public PVRecord
|
||||
PVStructurePtr createPowerSupply()
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(PowerSupplyRecordTest);
|
||||
static PowerSupplyRecordTestPtr create(
|
||||
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;
|
||||
};
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
StandardFieldPtr standardField = getStandardField();
|
||||
PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
|
||||
PowerSupplyRecordTestPtr PowerSupplyRecordTest::create(
|
||||
epics::pvData::String const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure)
|
||||
size_t nfields = 5;
|
||||
StringArray names;
|
||||
names.reserve(nfields);
|
||||
FieldConstPtrArray powerSupply;
|
||||
powerSupply.reserve(nfields);
|
||||
names.push_back("alarm");
|
||||
powerSupply.push_back(standardField->alarm());
|
||||
names.push_back("timeStamp");
|
||||
powerSupply.push_back(standardField->timeStamp());
|
||||
String properties("alarm,display");
|
||||
names.push_back("voltage");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
names.push_back("power");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
names.push_back("current");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
return pvDataCreate->createPVStructure(
|
||||
fieldCreate->createStructure(names,powerSupply));
|
||||
}
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
|
||||
PowerSupplyPtr PowerSupply::create(
|
||||
String const & recordName,
|
||||
PVStructurePtr const & pvStructure)
|
||||
{
|
||||
PowerSupplyRecordTestPtr pvRecord(
|
||||
new PowerSupplyRecordTest(recordName,pvStructure));
|
||||
PowerSupplyPtr pvRecord(
|
||||
new PowerSupply(recordName,pvStructure));
|
||||
if(!pvRecord->init()) pvRecord.reset();
|
||||
return pvRecord;
|
||||
}
|
||||
|
||||
PowerSupplyRecordTest::PowerSupplyRecordTest(
|
||||
epics::pvData::String const & recordName,
|
||||
epics::pvData::PVStructurePtr const & pvStructure)
|
||||
PowerSupply::PowerSupply(
|
||||
String const & recordName,
|
||||
PVStructurePtr const & pvStructure)
|
||||
: PVRecord(recordName,pvStructure)
|
||||
{
|
||||
}
|
||||
|
||||
PowerSupplyRecordTest::~PowerSupplyRecordTest()
|
||||
PowerSupply::~PowerSupply()
|
||||
{
|
||||
}
|
||||
|
||||
void PowerSupplyRecordTest::destroy()
|
||||
void PowerSupply::destroy()
|
||||
{
|
||||
PVRecord::destroy();
|
||||
}
|
||||
|
||||
bool PowerSupplyRecordTest::init()
|
||||
bool PowerSupply::init()
|
||||
{
|
||||
initPVRecord();
|
||||
epics::pvData::PVStructurePtr pvStructure = getPVStructure();
|
||||
epics::pvData::PVFieldPtr pvField;
|
||||
PVStructurePtr pvStructure = getPVStructure();
|
||||
PVFieldPtr pvField;
|
||||
bool result;
|
||||
pvField = pvStructure->getSubField("timeStamp");
|
||||
if(pvField.get()==NULL) {
|
||||
@ -103,7 +97,7 @@ bool PowerSupplyRecordTest::init()
|
||||
std::cerr << "no alarm" << std::endl;
|
||||
return false;
|
||||
}
|
||||
epics::pvData::String name;
|
||||
String name;
|
||||
name = "current.value";
|
||||
pvField = pvStructure->getSubField(name);
|
||||
if(pvField.get()==NULL) {
|
||||
@ -143,7 +137,7 @@ bool PowerSupplyRecordTest::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
void PowerSupplyRecordTest::process()
|
||||
void PowerSupply::process()
|
||||
{
|
||||
timeStamp.getCurrent();
|
||||
pvTimeStamp.set(timeStamp);
|
||||
@ -151,39 +145,37 @@ void PowerSupplyRecordTest::process()
|
||||
double power = pvPower->get();
|
||||
if(voltage<1e-3 && voltage>-1e-3) {
|
||||
alarm.setMessage("bad voltage");
|
||||
alarm.setSeverity(epics::pvData::majorAlarm);
|
||||
alarm.setSeverity(majorAlarm);
|
||||
pvAlarm.set(alarm);
|
||||
return;
|
||||
}
|
||||
double current = power/voltage;
|
||||
pvCurrent->put(current);
|
||||
alarm.setMessage("");
|
||||
alarm.setSeverity(epics::pvData::noAlarm);
|
||||
alarm.setSeverity(noAlarm);
|
||||
pvAlarm.set(alarm);
|
||||
}
|
||||
|
||||
void PowerSupplyRecordTest::put(double power,double voltage)
|
||||
void PowerSupply::put(double power,double voltage)
|
||||
{
|
||||
pvPower->put(power);
|
||||
pvVoltage->put(voltage);
|
||||
}
|
||||
|
||||
double PowerSupplyRecordTest::getPower()
|
||||
double PowerSupply::getPower()
|
||||
{
|
||||
return pvPower->get();
|
||||
}
|
||||
|
||||
double PowerSupplyRecordTest::getVoltage()
|
||||
double PowerSupply::getVoltage()
|
||||
{
|
||||
return pvVoltage->get();
|
||||
}
|
||||
|
||||
double PowerSupplyRecordTest::getCurrent()
|
||||
double PowerSupply::getCurrent()
|
||||
{
|
||||
return pvCurrent->get();
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif /* POWERSUPPLYRECORDTEST_H */
|
58
test/src/powerSupply.h
Normal file
58
test/src/powerSupply.h
Normal 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 */
|
@ -29,7 +29,7 @@
|
||||
#include <pv/standardPVField.h>
|
||||
#include <pv/pvData.h>
|
||||
#include <pv/pvAccess.h>
|
||||
#include <pv/powerSupplyRecordTest.h>
|
||||
#include "powerSupply.h"
|
||||
|
||||
using namespace std;
|
||||
using std::tr1::static_pointer_cast;
|
||||
@ -38,30 +38,6 @@ using namespace epics::pvAccess;
|
||||
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()
|
||||
@ -86,9 +62,9 @@ void test()
|
||||
pvRecord.reset();
|
||||
recordName = "powerSupplyExample";
|
||||
pvStructure.reset();
|
||||
PowerSupplyPtr psr;
|
||||
pvStructure = createPowerSupply();
|
||||
PowerSupplyRecordTestPtr psr =
|
||||
PowerSupplyRecordTest::create(recordName,pvStructure);
|
||||
psr = PowerSupply::create("powerSupply",pvStructure);
|
||||
if(psr.get()==NULL) {
|
||||
cout << "PowerSupplyRecordTest::create failed" << endl;
|
||||
return;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <pv/standardField.h>
|
||||
#include <pv/standardPVField.h>
|
||||
#include <pv/channelProviderLocal.h>
|
||||
#include <pv/powerSupplyRecordTest.h>
|
||||
#include "powerSupply.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
@ -73,32 +73,6 @@ static PVRecordPtr createScalarArray(
|
||||
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(
|
||||
String const & valueNameRecord,
|
||||
String const & valueNameCopy,
|
||||
@ -370,7 +344,7 @@ static void powerSupplyTest()
|
||||
{
|
||||
cout << endl << endl << "****powerSupplyTest****" << endl;
|
||||
RequesterPtr requester(new MyRequester("exampleTest"));
|
||||
PowerSupplyRecordTestPtr pvRecord;
|
||||
PowerSupplyPtr pvRecord;
|
||||
String request;
|
||||
PVStructurePtr pvRequest;
|
||||
PVRecordFieldPtr pvRecordField;
|
||||
@ -380,7 +354,8 @@ static void powerSupplyTest()
|
||||
String valueNameCopy;
|
||||
|
||||
CreateRequest::shared_pointer createRequest = CreateRequest::create();
|
||||
pvRecord = createPowerSupply("powerSupply");
|
||||
PVStructurePtr pv = createPowerSupply();
|
||||
pvRecord = PowerSupply::create("powerSupply",pv);
|
||||
valueNameRecord = request = "power.value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
builder.clear(); pvRequest->toString(&builder);
|
||||
|
@ -26,15 +26,13 @@
|
||||
#include <pv/standardField.h>
|
||||
#include <pv/standardPVField.h>
|
||||
#include <pv/pvData.h>
|
||||
#include <pv/pvAccess.h>
|
||||
#include <pv/pvCopy.h>
|
||||
#include <pv/powerSupplyRecordTest.h>
|
||||
#include "powerSupply.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvDatabase;
|
||||
|
||||
static PVRecordPtr createScalar(
|
||||
@ -57,32 +55,6 @@ static PVRecordPtr createScalarArray(
|
||||
return PVRecord::create(recordName,pvStructure);
|
||||
}
|
||||
|
||||
static PowerSupplyRecordTestPtr createPowerSupply(String const & recordName)
|
||||
{
|
||||
FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
StandardFieldPtr standardField = getStandardField();
|
||||
PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
size_t nfields = 5;
|
||||
StringArray names;
|
||||
names.reserve(nfields);
|
||||
FieldConstPtrArray powerSupply;
|
||||
powerSupply.reserve(nfields);
|
||||
names.push_back("alarm");
|
||||
powerSupply.push_back(standardField->alarm());
|
||||
names.push_back("timeStamp");
|
||||
powerSupply.push_back(standardField->timeStamp());
|
||||
String properties("alarm,display");
|
||||
names.push_back("voltage");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
names.push_back("power");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
names.push_back("current");
|
||||
powerSupply.push_back(standardField->scalar(pvDouble,properties));
|
||||
return PowerSupplyRecordTest::create(recordName,
|
||||
pvDataCreate->createPVStructure(
|
||||
fieldCreate->createStructure(names,powerSupply)));
|
||||
}
|
||||
|
||||
static void scalarTest()
|
||||
{
|
||||
cout << endl << endl << "****scalarTest****" << endl;
|
||||
@ -102,8 +74,9 @@ static void arrayTest()
|
||||
static void powerSupplyTest()
|
||||
{
|
||||
cout << endl << endl << "****powerSupplyTest****" << endl;
|
||||
PowerSupplyRecordTestPtr pvRecord;
|
||||
pvRecord = createPowerSupply("powerSupply");
|
||||
PVRecordPtr pvRecord;
|
||||
PVStructurePtr pv = createPowerSupply();
|
||||
pvRecord = PowerSupply::create("powerSupply",pv);
|
||||
pvRecord->destroy();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user