add waveform demo
This commit is contained in:
5
iocBoot/iocwfdemo/Makefile
Normal file
5
iocBoot/iocwfdemo/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
TOP = ../..
|
||||
include $(TOP)/configure/CONFIG
|
||||
ARCH = linux-x86_64-debug
|
||||
TARGETS = envPaths
|
||||
include $(TOP)/configure/RULES.ioc
|
56
iocBoot/iocwfdemo/iq.db
Normal file
56
iocBoot/iocwfdemo/iq.db
Normal file
@ -0,0 +1,56 @@
|
||||
record(ao, "$(N)Rate") {
|
||||
field(VAL, "1.0")
|
||||
field(PINI, "YES")
|
||||
field(PREC, "3")
|
||||
field( OUT, "$(N)dly_.ODLY NPP")
|
||||
}
|
||||
|
||||
record(ao, "$(N)Delta") {
|
||||
field(VAL, "0.0")
|
||||
field(PINI, "YES")
|
||||
}
|
||||
|
||||
record(calc, "$(N)Phase:I") {
|
||||
field(PINI, "RUNNING")
|
||||
field(INPA, "$(N)Phase:I")
|
||||
field(CALC, "A+1")
|
||||
field( EGU, "rad")
|
||||
field(PREC, "3")
|
||||
field(FLNK, "$(N)Phase:Q")
|
||||
info(pdbGroup0, "$(N)iq|phas_i=VAL")
|
||||
#field(TPRO, "1")
|
||||
}
|
||||
|
||||
record(calc, "$(N)Phase:Q") {
|
||||
field(INPA, "$(N)Phase:I")
|
||||
field(INPB, "$(N)Delta NPP")
|
||||
field(CALC, "A+B")
|
||||
field( EGU, "rad")
|
||||
field(PREC, "3")
|
||||
field(FLNK, "$(N)I")
|
||||
info(pdbGroup0, "$(N)iq|phas_q=VAL")
|
||||
}
|
||||
|
||||
record(waveform, "$(N)I") {
|
||||
field(DTYP, "PDB Demo")
|
||||
field( INP, "$(N)Phase:I")
|
||||
field(FTVL, "DOUBLE")
|
||||
field(NELM, "500")
|
||||
field(FLNK, "$(N)Q")
|
||||
info(pdbGroup0, "$(N)iq|I=VAL")
|
||||
}
|
||||
|
||||
record(waveform, "$(N)Q") {
|
||||
field(DTYP, "PDB Demo")
|
||||
field( INP, "$(N)Phase:Q")
|
||||
field(FTVL, "DOUBLE")
|
||||
field(NELM, "500")
|
||||
field(FLNK, "$(N)dly_")
|
||||
info(pdbGroup0, "$(N)iq|Q=VAL")
|
||||
info(pdbTrigger,"$(N)iq|Q>*")
|
||||
}
|
||||
|
||||
record(calcout, "$(N)dly_") {
|
||||
field(ODLY, "1.0")
|
||||
field(OUT , "$(N)Phase:I.PROC CA")
|
||||
}
|
1205
iocBoot/iocwfdemo/qwfdemo.opi
Normal file
1205
iocBoot/iocwfdemo/qwfdemo.opi
Normal file
File diff suppressed because it is too large
Load Diff
5
iocBoot/iocwfdemo/st.cmd
Executable file
5
iocBoot/iocwfdemo/st.cmd
Executable file
@ -0,0 +1,5 @@
|
||||
#!../../bin/linux-x86_64-debug/softIocPVA
|
||||
|
||||
dbLoadRecords("iq.db","N=TST:")
|
||||
|
||||
iocInit()
|
@ -15,6 +15,7 @@ pdbcore_SRCS += pdb.cpp
|
||||
pdbcore_SRCS += pdbsingle.cpp
|
||||
pdbcore_SRCS += pdbgroup.cpp
|
||||
#pdbcore_SRCS += pvalink.cpp
|
||||
pdbcore_SRCS += demo.cpp
|
||||
|
||||
pdbcore_LIBS += pvAccess pvData Com
|
||||
|
||||
|
66
pdbApp/demo.cpp
Normal file
66
pdbApp/demo.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
#include <epicsMath.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbScan.h>
|
||||
#include <recGbl.h>
|
||||
#include <alarm.h>
|
||||
|
||||
#include <waveformRecord.h>
|
||||
#include <menuFtype.h>
|
||||
|
||||
#include <epicsExport.h>
|
||||
|
||||
namespace {
|
||||
|
||||
// pi/180
|
||||
static const double pi_180 = 0.017453292519943295;
|
||||
|
||||
int dummy;
|
||||
|
||||
long init_spin(waveformRecord *prec)
|
||||
{
|
||||
if(prec->ftvl==menuFtypeDOUBLE)
|
||||
prec->dpvt = &dummy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long process_spin(waveformRecord *prec)
|
||||
{
|
||||
const double freq = 360.0*pi_180/100; // rad/sample
|
||||
double phase = 0;
|
||||
double *val = static_cast<double*>(prec->bptr);
|
||||
|
||||
long ret = dbGetLink(&prec->inp, DBF_DOUBLE, &phase, 0, 0);
|
||||
if(ret) {
|
||||
(void)recGblSetSevr(prec, LINK_ALARM, INVALID_ALARM);
|
||||
return ret;
|
||||
}
|
||||
|
||||
phase *= pi_180; // deg -> rad
|
||||
|
||||
for(size_t i=0; i<prec->nelm; i++)
|
||||
val[i] = sin(freq*i+phase);
|
||||
|
||||
prec->nord = prec->nelm;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename REC>
|
||||
struct dset5
|
||||
{
|
||||
long count;
|
||||
long (*report)(int);
|
||||
long (*init)(int);
|
||||
long (*init_record)(REC *);
|
||||
long (*get_ioint_info)(int, REC *, IOSCANPVT*);
|
||||
long (*process)(REC *);
|
||||
};
|
||||
|
||||
dset5<waveformRecord> devWfPDBDemo = {5,0,0,&init_spin,0,&process_spin};
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
epicsExportAddress(dset, devWfPDBDemo);
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
registrar(QSRVRegistrar)
|
||||
#registrar(installPVAAddLinkHook)
|
||||
#link("pva", "lsetPVA")
|
||||
|
||||
# from demo.cpp
|
||||
device(waveform, CONSTANT, devWfPDBDemo, "PDB Demo")
|
||||
|
Reference in New Issue
Block a user