Move all under modules/database

This commit is contained in:
Ralph Lange
2018-06-19 11:31:13 +02:00
parent e613d685fd
commit 568c405165
562 changed files with 0 additions and 101 deletions
@@ -0,0 +1,20 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS BELOW HERE
# Install databases, templates & substitutions like this
DB += circle.db
DB += dbExample1.db
DB += dbExample2.db
DB += _APPNAME_Version.db
DB += dbSubExample.db
DB += user.substitutions
# If <anyname>.db template is not named <anyname>*.template add
# <anyname>_TEMPLATE = <templatename>
include $(TOP)/configure/RULES
#----------------------------------------
# ADD EXTRA GNUMAKE RULES BELOW HERE
@@ -0,0 +1,6 @@
record(lsi, "$(user):_APPNAME_:version") {
field(DTYP, "_APPNAME_ version")
field(DESC, "Version string")
field(SIZV, "$(SIZV=200)")
field(PINI, "YES")
}
@@ -0,0 +1,72 @@
record(ao, "$(user):circle:step") {
field(VAL , "1.0")
field(DRVL, "0.0")
field(DRVH, "359")
field(PINI, "YES")
}
record(ao, "$(user):circle:period") {
field(VAL , "1.0")
field(PINI, "YES")
field(OUT , "$(user):circle:tick.ODLY NPP")
}
record(calc, "$(user):circle:angle") {
field(PINI, "RUNNING") # bootstrap
field(INPA, "$(user):circle:angle NPP")
field(INPB, "$(user):circle:step NPP")
field(INPD, "360")
field(DESC, "Angle")
field(EGU , "deg")
field(LOLO, "45")
field(LOW , "135")
field(HIGH, "225")
field(HIHI, "315")
field(LLSV, "MAJOR")
field(LSV , "MINOR")
field(HSV , "MINOR")
field(HHSV, "MAJOR")
field(CALC, "C:=A+B;(C>=D)?C-D:C")
field(FLNK, "$(user):circle:x")
field(PREC, "3")
info(Q:group, {
"$(user):circle":{"angle": {+channel:"VAL"}},
"$(user):line":{"a": {+channel:"VAL"}}
})
alias("$(user):line:a")
}
record(calc, "$(user):circle:x") {
field(INPA, "$(user):circle:angle NPP")
field(CALC, "cos(A*PI/180)")
field(TSEL, "$(user):circle:angle.TIME")
field(FLNK, "$(user):circle:y")
field(PREC, "3")
info(Q:group, {
"$(user):circle":{"x": {+channel:"VAL"}}
})
}
record(calc, "$(user):circle:y") {
field(INPA, "$(user):circle:angle NPP")
field(CALC, "sin(A*PI/180)")
field(TSEL, "$(user):circle:angle.TIME")
field(PREC, "3")
field(FLNK, "$(user):line:b")
info(Q:group, {
"$(user):circle":{"y": {+channel:"VAL", +trigger:"*"}}
})
}
record(ai, "$(user):line:b") {
field(INP, "$(user):line:a NPP")
field(FLNK, "$(user):circle:tick")
info(Q:group, {
"$(user):line":{"b": {+channel:"VAL", +trigger:"*"}}
})
}
record(calcout, "$(user):circle:tick") {
field(ODLY, "1.0")
field(OUT , "$(user):circle:angle.PROC CA") # loop
}
@@ -0,0 +1,62 @@
record(ai, "$(user):aiExample")
{
field(DESC, "Analog input")
field(INP, "$(user):calcExample.VAL NPP NMS")
field(EGUF, "10")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "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")
}
record(calc, "$(user):calcExample")
{
field(DESC, "Counter")
field(SCAN,"1 second")
field(FLNK, "$(user):aiExample")
field(CALC, "(A<B)?(A+C):D")
field(INPA, "$(user):calcExample.VAL 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")
}
record(xxx, "$(user):xxxExample")
{
field(DESC, "xxx record")
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")
}
record(compress,"$(user):compressExample")
{
field(DESC, "Circular buffer")
field(INP,"$(user):aiExample.VAL CP NMS")
field(ALG,"Circular Buffer")
field(NSAM,"10")
field(HOPR,"10")
field(EGU,"Counts")
}
@@ -0,0 +1,40 @@
record(calc, "$(user):calcExample$(no)")
{
alias("$(user):calc$(no)")
field(DESC, "Counter No. $(no)")
field(SCAN,"$(scan)")
field(FLNK, "$(user):aiExample$(no)")
field(CALC, "(A<B)?(A+C):D")
field(INPA, "$(user):calcExample$(no).VAL 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")
}
record(ai, "$(user):aiExample$(no)")
{
field(DESC, "Analog input No. $(no)")
field(INP, "$(user):calcExample$(no).VAL NPP NMS")
field(EGUF, "10")
field(EGU, "Counts")
field(HOPR, "10")
field(LOPR, "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")
}
alias("$(user):aiExample$(no)","$(user):ai$(no)")
@@ -0,0 +1,13 @@
record(sub,"$(user):subExample")
{
field(INAM,"mySubInit")
field(SNAM,"mySubProcess")
}
record(aSub,"$(user):aSubExample")
{
field(INAM,"myAsubInit")
field(SNAM,"myAsubProcess")
field(FTA,"DOUBLE")
field(NOA,"10")
field(INPA,"$(user):compressExample CPP")
}
@@ -0,0 +1,16 @@
# Example substitutions file
file "db/circle.db" {
{ user = "_USER_" }
}
file "db/dbExample1.db" {
{ user = "_USER_" }
}
file db/dbExample2.db {
pattern { user, no, scan }
{ "_USER_", 1, "1 second" }
{ "_USER_", 2, "2 second" }
{ "_USER_", 3, "5 second" }
}
@@ -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
@@ -0,0 +1,99 @@
TOP=../..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS BELOW HERE
# Use typed rset structure (see 3.16.1 release notes)
USR_CPPFLAGS += -DUSE_TYPED_RSET
# xxxRecord.h will be created from xxxRecord.dbd
DBDINC += xxxRecord
# Install xxxSupport.dbd into <top>/dbd
DBD += xxxSupport.dbd
# Build an IOC support library
LIBRARY_IOC += _APPNAME_Support
# Compile and add code to the support library
_APPNAME_Support_SRCS += xxxRecord.c
_APPNAME_Support_SRCS += devXxxSoft.c
# Link locally-provided code into the support library,
# rather than directly into the IOC application, that
# causes problems on Windows DLL builds
_APPNAME_Support_SRCS += dbSubExample.c
_APPNAME_Support_SRCS += dev_APPNAME_Version.c
_APPNAME_Support_SRCS += _APPNAME_Hello.c
_APPNAME_Support_SRCS += initTrace.c
_APPNAME_Support_LIBS += $(EPICS_BASE_IOC_LIBS)
# Auto-generate a header file containing a version string.
# Version comes from the VCS if available, else date+time.
GENVERSION = _APPNAME_Version.h
# Macro name
GENVERSIONMACRO = _APPNAME_VERSION
# Build the IOC application
PROD_IOC = _APPNAME_
# _APPNAME_.dbd will be created and installed
DBD += _APPNAME_.dbd
# _APPNAME_.dbd will include these files:
_APPNAME__DBD += base.dbd
_APPNAME__DBD += xxxSupport.dbd
_APPNAME__DBD += dbSubExample.dbd
_APPNAME__DBD += dev_APPNAME_Version.dbd
_APPNAME__DBD += _APPNAME_Hello.dbd
_APPNAME__DBD += initTrace.dbd
# _APPNAME__registerRecordDeviceDriver.cpp derives from _APPNAME_.dbd
_APPNAME__SRCS += _APPNAME__registerRecordDeviceDriver.cpp
# Build the main IOC entry point where needed
_APPNAME__SRCS_DEFAULT += _APPNAME_Main.cpp
_APPNAME__SRCS_vxWorks += -nil-
# Link in the code from our support library
_APPNAME__LIBS += _APPNAME_Support
# To build SNL programs, SNCSEQ must be defined
# in the <top>/configure/RELEASE file
ifneq ($(SNCSEQ),)
# Build sncExample into _APPNAME_Support
sncExample_SNCFLAGS += +r
_APPNAME__DBD += sncExample.dbd
# A .stt sequence program is *not* pre-processed:
_APPNAME_Support_SRCS += sncExample.stt
_APPNAME_Support_LIBS += seq pv
_APPNAME__LIBS += seq pv
# Build sncProgram as a standalone program
PROD_HOST += sncProgram
sncProgram_SNCFLAGS += +m
# A .st sequence program *is* pre-processed:
sncProgram_SRCS += sncProgram.st
sncProgram_LIBS += seq pv
sncProgram_LIBS += $(EPICS_BASE_HOST_LIBS)
endif
# Link QSRV (pvAccess Server) if available
ifdef EPICS_QSRV_MAJOR_VERSION
_APPNAME__LIBS += qsrv
_APPNAME__LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
_APPNAME__DBD += PVAServerRegister.dbd
_APPNAME__DBD += qsrv.dbd
endif
# Finally link IOC to the EPICS Base libraries
_APPNAME__LIBS += $(EPICS_BASE_IOC_LIBS)
include $(TOP)/configure/RULES
#----------------------------------------
# ADD EXTRA GNUMAKE RULES BELOW HERE
# Explicit dependency needed for generated header file
dev_APPNAME_Version$(DEP): $(COMMON_DIR)/$(GENVERSION)
@@ -0,0 +1,31 @@
/* Example showing how to register a new command with iocsh */
#include <stdio.h>
#include <epicsExport.h>
#include <iocsh.h>
/* This is the command, which the vxWorks shell will call directly */
void hello(const char *name) {
if (name) {
printf("Hello %s, from _APPNAME_\n", name);
} else {
puts("Hello from _APPNAME_");
}
}
/* Information needed by iocsh */
static const iocshArg helloArg0 = {"name", iocshArgString};
static const iocshArg *helloArgs[] = {&helloArg0};
static const iocshFuncDef helloFuncDef = {"hello", 1, helloArgs};
/* Wrapper called by iocsh, selects the argument types that hello needs */
static void helloCallFunc(const iocshArgBuf *args) {
hello(args[0].sval);
}
/* Registration routine, runs at startup */
static void helloRegister(void) {
iocshRegister(&helloFuncDef, helloCallFunc);
}
epicsExportRegistrar(helloRegister);
@@ -0,0 +1 @@
registrar(helloRegister)
@@ -0,0 +1,23 @@
/* _APPNAME_Main.cpp */
/* Author: Marty Kraimer Date: 17MAR2000 */
#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);
}
@@ -0,0 +1,49 @@
#include <stdio.h>
#include <dbDefs.h>
#include <registryFunction.h>
#include <subRecord.h>
#include <aSubRecord.h>
#include <epicsExport.h>
int mySubDebug;
static long mySubInit(subRecord *precord)
{
if (mySubDebug)
printf("Record %s called mySubInit(%p)\n",
precord->name, (void*) precord);
return 0;
}
static long mySubProcess(subRecord *precord)
{
if (mySubDebug)
printf("Record %s called mySubProcess(%p)\n",
precord->name, (void*) precord);
return 0;
}
static long myAsubInit(aSubRecord *precord)
{
if (mySubDebug)
printf("Record %s called myAsubInit(%p)\n",
precord->name, (void*) precord);
return 0;
}
static long myAsubProcess(aSubRecord *precord)
{
if (mySubDebug)
printf("Record %s called myAsubProcess(%p)\n",
precord->name, (void*) precord);
return 0;
}
/* Register these symbols for use by IOC code: */
epicsExportAddress(int, mySubDebug);
epicsRegisterFunction(mySubInit);
epicsRegisterFunction(mySubProcess);
epicsRegisterFunction(myAsubInit);
epicsRegisterFunction(myAsubProcess);
@@ -0,0 +1,5 @@
variable(mySubDebug)
function(mySubInit)
function(mySubProcess)
function(myAsubInit)
function(myAsubProcess)
@@ -0,0 +1,58 @@
/* devXxxSoft.c */
/* Example device support module */
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "alarm.h"
#include "cvtTable.h"
#include "dbDefs.h"
#include "dbAccess.h"
#include "recGbl.h"
#include "recSup.h"
#include "devSup.h"
#include "link.h"
#include "xxxRecord.h"
#include "epicsExport.h"
/*Create the dset for devXxxSoft */
static long init_record();
static long read_xxx();
struct {
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_xxx;
}devXxxSoft={
5,
NULL,
NULL,
init_record,
NULL,
read_xxx,
};
epicsExportAddress(dset,devXxxSoft);
static long init_record(pxxx)
struct xxxRecord *pxxx;
{
if(recGblInitConstantLink(&pxxx->inp,DBF_DOUBLE,&pxxx->val))
pxxx->udf = FALSE;
return(0);
}
static long read_xxx(pxxx)
struct xxxRecord *pxxx;
{
long status;
status = dbGetLink(&(pxxx->inp),DBF_DOUBLE, &(pxxx->val),0,0);
/*If return was succesful then set undefined false*/
if(!status) pxxx->udf = FALSE;
return(0);
}
@@ -0,0 +1,38 @@
/* dev_APPNAME_Version.c */
/* Example device support for the lsi (long string input) record
* providing the module version string as the value
*/
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "devSup.h"
#include "lsiRecord.h"
#include "_APPNAME_Version.h"
/* must be last include */
#include "epicsExport.h"
const char version[] = _APPNAME_VERSION;
static long read_string(lsiRecord *prec)
{
size_t N = sizeof version;
char *buf = prec->val;
if (N > prec->sizv)
N = prec->sizv;
prec->len = N;
memcpy(buf, version, N);
buf[N - 1] = '\0';
return 0;
}
static lsidset dev_CSAFEAPPNAME_Version = {
5, NULL, NULL, NULL, NULL, read_string
};
epicsExportAddress(dset,dev_CSAFEAPPNAME_Version);
@@ -0,0 +1 @@
device(lsi,INST_IO,dev_CSAFEAPPNAME_Version,"_APPNAME_ version")
@@ -0,0 +1,39 @@
/* initTrace.c */
/*
* An initHook routine to trace the iocInit() process.
* Prints out the name of each state as it is reached.
*/
#include <stdio.h>
#include "initHooks.h"
#include "epicsExport.h"
#include "iocsh.h"
static void trace(initHookState state) {
printf("iocInit: Reached %s\n", initHookName(state));
}
int traceIocInit(void) {
static int done = 0;
if (done)
return -1;
done = 1;
initHookRegister(trace);
puts("iocInit will be traced");
return 0;
}
static const iocshFuncDef traceInitFuncDef = {"traceIocInit", 0, NULL};
static void traceInitFunc(const iocshArgBuf *args) {
traceIocInit();
}
static void initTraceRegister(void) {
iocshRegister(&traceInitFuncDef, traceInitFunc);
}
epicsExportRegistrar(initTraceRegister);
@@ -0,0 +1 @@
registrar(initTraceRegister)
@@ -0,0 +1 @@
registrar(sncExampleRegistrar)
@@ -0,0 +1,22 @@
program sncExample
double v;
assign v to "{user}:aiExample";
monitor v;
ss ss1 {
state init {
when (delay(10)) {
printf("sncExample: Startup delay over\n");
} state low
}
state low {
when (v > 5.0) {
printf("sncExample: Changing to high\n");
} state high
}
state high {
when (v <= 5.0) {
printf("sncExample: Changing to low\n");
} state low
}
}
@@ -0,0 +1 @@
#include "../sncExample.stt"
@@ -0,0 +1,273 @@
/* xxxRecord.c */
/* Example record support module */
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "epicsMath.h"
#include "alarm.h"
#include "dbAccess.h"
#include "recGbl.h"
#include "dbEvent.h"
#include "dbDefs.h"
#include "dbAccess.h"
#include "devSup.h"
#include "errMdef.h"
#include "recSup.h"
#include "special.h"
#define GEN_SIZE_OFFSET
#include "xxxRecord.h"
#undef GEN_SIZE_OFFSET
#include "epicsExport.h"
/* Create RSET - Record Support Entry Table */
#define report NULL
#define initialize NULL
static long init_record(struct dbCommon *, int);
static long process(struct dbCommon *);
#define special NULL
#define get_value NULL
#define cvt_dbaddr NULL
#define get_array_info NULL
#define put_array_info NULL
static long get_units(DBADDR *, char *);
static long get_precision(const DBADDR *, long *);
#define get_enum_str NULL
#define get_enum_strs NULL
#define put_enum_str NULL
static long get_graphic_double(DBADDR *, struct dbr_grDouble *);
static long get_control_double(DBADDR *, struct dbr_ctrlDouble *);
static long get_alarm_double(DBADDR *, struct dbr_alDouble *);
rset xxxRSET={
RSETNUMBER,
report,
initialize,
init_record,
process,
special,
get_value,
cvt_dbaddr,
get_array_info,
put_array_info,
get_units,
get_precision,
get_enum_str,
get_enum_strs,
put_enum_str,
get_graphic_double,
get_control_double,
get_alarm_double
};
epicsExportAddress(rset,xxxRSET);
typedef struct xxxset { /* xxx input dset */
long number;
DEVSUPFUN dev_report;
DEVSUPFUN init;
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_xxx;
}xxxdset;
static void checkAlarms(xxxRecord *prec);
static void monitor(xxxRecord *prec);
static long init_record(struct dbCommon *pcommon, int pass)
{
xxxRecord *prec = (xxxRecord *)pcommon;
xxxdset *pdset;
long status;
if (pass==0) return(0);
if(!(pdset = (xxxdset *)(prec->dset))) {
recGblRecordError(S_dev_noDSET,(void *)prec,"xxx: init_record");
return(S_dev_noDSET);
}
/* must have read_xxx function defined */
if( (pdset->number < 5) || (pdset->read_xxx == NULL) ) {
recGblRecordError(S_dev_missingSup,(void *)prec,"xxx: init_record");
return(S_dev_missingSup);
}
if( pdset->init_record ) {
if((status=(*pdset->init_record)(prec))) return(status);
}
return(0);
}
static long process(struct dbCommon *pcommon)
{
xxxRecord *prec = (xxxRecord *)pcommon;
xxxdset *pdset = (xxxdset *)(prec->dset);
long status;
unsigned char pact=prec->pact;
if( (pdset==NULL) || (pdset->read_xxx==NULL) ) {
prec->pact=TRUE;
recGblRecordError(S_dev_missingSup,(void *)prec,"read_xxx");
return(S_dev_missingSup);
}
/* pact must not be set until after calling device support */
status=(*pdset->read_xxx)(prec);
/* check if device support set pact */
if ( !pact && prec->pact ) return(0);
prec->pact = TRUE;
recGblGetTimeStamp(prec);
/* check for alarms */
checkAlarms(prec);
/* check event list */
monitor(prec);
/* process the forward scan link record */
recGblFwdLink(prec);
prec->pact=FALSE;
return(status);
}
static long get_units(DBADDR *paddr, char *units)
{
xxxRecord *prec=(xxxRecord *)paddr->precord;
strncpy(units,prec->egu,DB_UNITS_SIZE);
return(0);
}
static long get_precision(const DBADDR *paddr, long *precision)
{
xxxRecord *prec=(xxxRecord *)paddr->precord;
*precision = prec->prec;
if(paddr->pfield == (void *)&prec->val) return(0);
recGblGetPrec(paddr,precision);
return(0);
}
static long get_graphic_double(DBADDR *paddr,struct dbr_grDouble *pgd)
{
xxxRecord *prec=(xxxRecord *)paddr->precord;
int fieldIndex = dbGetFieldIndex(paddr);
if(fieldIndex == xxxRecordVAL
|| fieldIndex == xxxRecordHIHI
|| fieldIndex == xxxRecordHIGH
|| fieldIndex == xxxRecordLOW
|| fieldIndex == xxxRecordLOLO
|| fieldIndex == xxxRecordHOPR
|| fieldIndex == xxxRecordLOPR) {
pgd->upper_disp_limit = prec->hopr;
pgd->lower_disp_limit = prec->lopr;
} else recGblGetGraphicDouble(paddr,pgd);
return(0);
}
static long get_control_double(DBADDR *paddr,struct dbr_ctrlDouble *pcd)
{
xxxRecord *prec=(xxxRecord *)paddr->precord;
int fieldIndex = dbGetFieldIndex(paddr);
if(fieldIndex == xxxRecordVAL
|| fieldIndex == xxxRecordHIHI
|| fieldIndex == xxxRecordHIGH
|| fieldIndex == xxxRecordLOW
|| fieldIndex == xxxRecordLOLO) {
pcd->upper_ctrl_limit = prec->hopr;
pcd->lower_ctrl_limit = prec->lopr;
} else recGblGetControlDouble(paddr,pcd);
return(0);
}
static long get_alarm_double(DBADDR *paddr,struct dbr_alDouble *pad)
{
xxxRecord *prec=(xxxRecord *)paddr->precord;
int fieldIndex = dbGetFieldIndex(paddr);
if(fieldIndex == xxxRecordVAL) {
pad->upper_alarm_limit = prec->hhsv ? prec->hihi : epicsNAN;
pad->upper_warning_limit = prec->hsv ? prec->high : epicsNAN;
pad->lower_warning_limit = prec->lsv ? prec->low : epicsNAN;
pad->lower_alarm_limit = prec->llsv ? prec->lolo : epicsNAN;
} else recGblGetAlarmDouble(paddr,pad);
return(0);
}
static void checkAlarms(xxxRecord *prec)
{
double val;
float hyst, lalm, hihi, high, low, lolo;
unsigned short hhsv, llsv, hsv, lsv;
if(prec->udf == TRUE ){
recGblSetSevr(prec,UDF_ALARM,prec->udfs);
return;
}
hihi = prec->hihi; lolo = prec->lolo; high = prec->high; low = prec->low;
hhsv = prec->hhsv; llsv = prec->llsv; hsv = prec->hsv; lsv = prec->lsv;
val = prec->val; hyst = prec->hyst; lalm = prec->lalm;
/* alarm condition hihi */
if (hhsv && (val >= hihi || ((lalm==hihi) && (val >= hihi-hyst)))){
if (recGblSetSevr(prec,HIHI_ALARM,prec->hhsv)) prec->lalm = hihi;
return;
}
/* alarm condition lolo */
if (llsv && (val <= lolo || ((lalm==lolo) && (val <= lolo+hyst)))){
if (recGblSetSevr(prec,LOLO_ALARM,prec->llsv)) prec->lalm = lolo;
return;
}
/* alarm condition high */
if (hsv && (val >= high || ((lalm==high) && (val >= high-hyst)))){
if (recGblSetSevr(prec,HIGH_ALARM,prec->hsv)) prec->lalm = high;
return;
}
/* alarm condition low */
if (lsv && (val <= low || ((lalm==low) && (val <= low+hyst)))){
if (recGblSetSevr(prec,LOW_ALARM,prec->lsv)) prec->lalm = low;
return;
}
/* we get here only if val is out of alarm by at least hyst */
prec->lalm = val;
return;
}
static void monitor(xxxRecord *prec)
{
unsigned short monitor_mask;
double delta;
monitor_mask = recGblResetAlarms(prec);
/* check for value change */
delta = prec->mlst - prec->val;
if(delta<0.0) delta = -delta;
if (delta > prec->mdel) {
/* post events for value change */
monitor_mask |= DBE_VALUE;
/* update last value monitored */
prec->mlst = prec->val;
}
/* check for archive change */
delta = prec->alst - prec->val;
if(delta<0.0) delta = -delta;
if (delta > prec->adel) {
/* post events on value field for archive change */
monitor_mask |= DBE_LOG;
/* update last archive value monitored */
prec->alst = prec->val;
}
/* send out monitors connected to the value field */
if (monitor_mask){
db_post_events(prec,&prec->val,monitor_mask);
}
return;
}
@@ -0,0 +1,118 @@
recordtype(xxx) {
include "dbCommon.dbd"
field(VAL,DBF_DOUBLE) {
prompt("Current EGU Value")
promptgroup("40 - Input")
asl(ASL0)
pp(TRUE)
}
field(INP,DBF_INLINK) {
prompt("Input Specification")
promptgroup("40 - Input")
special(SPC_NOMOD)
interest(1)
}
field(PREC,DBF_SHORT) {
prompt("Display Precision")
promptgroup("80 - Display")
interest(1)
}
field(EGU,DBF_STRING) {
prompt("Engineering Units")
promptgroup("80 - Display")
interest(1)
size(16)
}
field(HOPR,DBF_FLOAT) {
prompt("High Operating Range")
promptgroup("80 - Display")
interest(1)
}
field(LOPR,DBF_FLOAT) {
prompt("Low Operating Range")
promptgroup("80 - Display")
interest(1)
}
field(HIHI,DBF_FLOAT) {
prompt("Hihi Alarm Limit")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
}
field(LOLO,DBF_FLOAT) {
prompt("Lolo Alarm Limit")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
}
field(HIGH,DBF_FLOAT) {
prompt("High Alarm Limit")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
}
field(LOW,DBF_FLOAT) {
prompt("Low Alarm Limit")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
}
field(HHSV,DBF_MENU) {
prompt("Hihi Severity")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
menu(menuAlarmSevr)
}
field(LLSV,DBF_MENU) {
prompt("Lolo Severity")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
menu(menuAlarmSevr)
}
field(HSV,DBF_MENU) {
prompt("High Severity")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
menu(menuAlarmSevr)
}
field(LSV,DBF_MENU) {
prompt("Low Severity")
promptgroup("70 - Alarm")
pp(TRUE)
interest(1)
menu(menuAlarmSevr)
}
field(HYST,DBF_DOUBLE) {
prompt("Alarm Deadband")
promptgroup("70 - Alarm")
interest(1)
}
field(ADEL,DBF_DOUBLE) {
prompt("Archive Deadband")
promptgroup("80 - Display")
interest(1)
}
field(MDEL,DBF_DOUBLE) {
prompt("Monitor Deadband")
promptgroup("80 - Display")
interest(1)
}
field(LALM,DBF_DOUBLE) {
prompt("Last Value Alarmed")
special(SPC_NOMOD)
interest(3)
}
field(ALST,DBF_DOUBLE) {
prompt("Last Value Archived")
special(SPC_NOMOD)
interest(3)
}
field(MLST,DBF_DOUBLE) {
prompt("Last Val Monitored")
special(SPC_NOMOD)
interest(3)
}
}
@@ -0,0 +1,2 @@
include "xxxRecord.dbd"
device(xxx,CONSTANT,devXxxSoft,"SoftChannel")