update template
use waveform as long string use app. name in header and macro name
This commit is contained in:
@@ -32,7 +32,7 @@ TEMPLATES += top/exampleApp/Db/dbVersionExample.db
|
||||
TEMPLATES += top/exampleApp/Db/dbSubExample.db
|
||||
TEMPLATES += top/exampleApp/Db/user.substitutions
|
||||
TEMPLATES += top/exampleApp/src/Makefile
|
||||
TEMPLATES += top/exampleApp/src/devStringInGenVersion.c
|
||||
TEMPLATES += top/exampleApp/src/devGenVersion.c
|
||||
TEMPLATES += top/exampleApp/src/xxxRecord.dbd
|
||||
TEMPLATES += top/exampleApp/src/xxxRecord.c
|
||||
TEMPLATES += top/exampleApp/src/devXxxSoft.c
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
record(stringin, "$(user):version") {
|
||||
field(DTYP, "My Version")
|
||||
record(waveform, "$(user):version") {
|
||||
field(DTYP, "Module Version")
|
||||
field(DESC, "Module version")
|
||||
field(FTVL, "CHAR")
|
||||
field(NELM, "$(NELM=200)")
|
||||
field(PINI, "YES")
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ DBD += xxxSupport.dbd
|
||||
# Compile and add the code to the support library
|
||||
_APPNAME_Support_SRCS += xxxRecord.c
|
||||
_APPNAME_Support_SRCS += devXxxSoft.c
|
||||
_APPNAME_Support_SRCS += devStringInGenVersion.c
|
||||
_APPNAME_Support_SRCS += devGenVersion.c
|
||||
|
||||
# Link locally-provided code into the support library,
|
||||
# rather than directly into the IOC application.
|
||||
@@ -29,7 +29,9 @@ _APPNAME_Support_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
# Generate a header which defines a macro with a version string
|
||||
# with the date and time, or a revision id from VCS system if available
|
||||
GENVERSION = mymodversion.h
|
||||
GENVERSION = _APPNAME_Version.h
|
||||
# Macro name
|
||||
GENVERSIONMACRO = _APPNAME_VERSION
|
||||
|
||||
#=============================
|
||||
# Build the IOC application
|
||||
@@ -88,4 +90,4 @@ include $(TOP)/configure/RULES
|
||||
|
||||
# Dependency for the generated header
|
||||
# must be explicit
|
||||
devStringInGenVersion$(DEP): $(GENVERSION)
|
||||
devGenVersion$(DEP): $(GENVERSION)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
registrar(helloRegister)
|
||||
device(stringin,INST_IO,devSiMyModVersion,"My Version")
|
||||
device(waveform,INST_IO,devWfMyModVersion,"Module Version")
|
||||
|
||||
56
src/template/base/top/exampleApp/src/devGenVersion.c
Normal file
56
src/template/base/top/exampleApp/src/devGenVersion.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/* devGenVersion.c */
|
||||
/* Example device support providing the module version string as a charactor array (long string) */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "recGbl.h"
|
||||
#include "alarm.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "menuFtype.h"
|
||||
#include "waveformRecord.h"
|
||||
|
||||
#include "_APPNAME_Version.h"
|
||||
|
||||
/* must be last include */
|
||||
#include "epicsExport.h"
|
||||
|
||||
static long read_wf(waveformRecord *prec)
|
||||
{
|
||||
size_t N = strlen(_APPNAME_VERSION)+1;
|
||||
char *buf = prec->bptr;
|
||||
|
||||
if(prec->ftvl!=menuFtypeCHAR) {
|
||||
(void)recGblSetSevr(prec, READ_ALARM, INVALID_ALARM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(N>=prec->nelm)
|
||||
N = prec->nelm;
|
||||
prec->nord = N;
|
||||
|
||||
memcpy(buf, _APPNAME_VERSION, N);
|
||||
buf[prec->nelm-1] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_si;
|
||||
}devWfMyModVersion={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
read_wf,
|
||||
};
|
||||
epicsExportAddress(dset,devWfMyModVersion);
|
||||
@@ -1,47 +0,0 @@
|
||||
/* devStringIn.c */
|
||||
/* Example device support module for stringinRecord */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "recGbl.h"
|
||||
#include "alarm.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "stringinRecord.h"
|
||||
|
||||
#include "mymodversion.h"
|
||||
|
||||
/* must be last include */
|
||||
#include "epicsExport.h"
|
||||
|
||||
static long read_si(stringinRecord *prec)
|
||||
{
|
||||
size_t N = strlen(MODULEVERSION);
|
||||
if(N<sizeof(prec->val)) {
|
||||
strcpy(prec->val, MODULEVERSION);
|
||||
} else {
|
||||
/* Not enough space, so signal an alarm */
|
||||
(void)recGblSetSevr(prec, READ_ALARM, INVALID_ALARM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_si;
|
||||
}devSiMyModVersion={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
read_si,
|
||||
};
|
||||
epicsExportAddress(dset,devSiMyModVersion);
|
||||
Reference in New Issue
Block a user