Modify DBD variable keyword to allow both int and double variables.
This commit is contained in:
@@ -119,6 +119,13 @@ typedef struct dbText {
|
||||
char *text;
|
||||
}dbText;
|
||||
|
||||
typedef struct dbVariableDef {
|
||||
ELLNODE node;
|
||||
char *name;
|
||||
char *type;
|
||||
|
||||
}dbVariableDef;
|
||||
|
||||
typedef struct dbRecordType {
|
||||
ELLNODE node;
|
||||
ELLLIST attributeList; /*LIST head of attributes*/
|
||||
|
||||
@@ -64,7 +64,7 @@ static void dbDevice(char *recordtype,char *linktype,
|
||||
char *dsetname,char *choicestring);
|
||||
static void dbDriver(char *name);
|
||||
static void dbRegistrar(char *name);
|
||||
static void dbVariable(char *name);
|
||||
static void dbVariable(char *name, char *type);
|
||||
|
||||
static void dbBreakHead(char *name);
|
||||
static void dbBreakItem(char *value);
|
||||
@@ -758,23 +758,24 @@ static void dbRegistrar(char *name)
|
||||
ellAdd(&pdbbase->registrarList,&ptext->node);
|
||||
}
|
||||
|
||||
static void dbVariable(char *name)
|
||||
static void dbVariable(char *name, char *type)
|
||||
{
|
||||
dbText *ptext;
|
||||
dbVariableDef *pvar;
|
||||
GPHENTRY *pgphentry;
|
||||
|
||||
pgphentry = gphFind(pdbbase->pgpHash,name,&pdbbase->variableList);
|
||||
if(pgphentry) {
|
||||
return;
|
||||
}
|
||||
ptext = dbCalloc(1,sizeof(dbText));
|
||||
ptext->text = epicsStrDup(name);
|
||||
pgphentry = gphAdd(pdbbase->pgpHash,ptext->text,&pdbbase->variableList);
|
||||
pvar = dbCalloc(1,sizeof(dbVariableDef));
|
||||
pvar->name = epicsStrDup(name);
|
||||
pvar->type = epicsStrDup(type);
|
||||
pgphentry = gphAdd(pdbbase->pgpHash,pvar->name,&pdbbase->variableList);
|
||||
if(!pgphentry) {
|
||||
yyerrorAbort("gphAdd failed");
|
||||
}
|
||||
pgphentry->userPvt = ptext;
|
||||
ellAdd(&pdbbase->variableList,&ptext->node);
|
||||
pgphentry->userPvt = pvar;
|
||||
ellAdd(&pdbbase->variableList,&pvar->node);
|
||||
}
|
||||
|
||||
static void dbBreakHead(char *name)
|
||||
|
||||
@@ -567,6 +567,8 @@ void epicsShareAPI dbFreeBase(dbBase *pdbbase)
|
||||
devSup *pdevSupNext;
|
||||
dbText *ptext;
|
||||
dbText *ptextNext;
|
||||
dbVariableDef *pvar;
|
||||
dbVariableDef *pvarNext;
|
||||
drvSup *pdrvSup;
|
||||
drvSup *pdrvSupNext;
|
||||
brkTable *pbrkTable;
|
||||
@@ -674,13 +676,14 @@ void epicsShareAPI dbFreeBase(dbBase *pdbbase)
|
||||
free((void *)ptext);
|
||||
ptext = ptextNext;
|
||||
}
|
||||
ptext = (dbText *)ellFirst(&pdbbase->variableList);
|
||||
while(ptext) {
|
||||
ptextNext = (dbText *)ellNext(&ptext->node);
|
||||
ellDelete(&pdbbase->variableList,&ptext->node);
|
||||
free((void *)ptext->text);
|
||||
free((void *)ptext);
|
||||
ptext = ptextNext;
|
||||
pvar = (dbVariableDef *)ellFirst(&pdbbase->variableList);
|
||||
while(pvar) {
|
||||
pvarNext = (dbVariableDef *)ellNext(&pvar->node);
|
||||
ellDelete(&pdbbase->variableList,&pvar->node);
|
||||
free((void *)pvar->name);
|
||||
free((void *)pvar->type);
|
||||
free((void *)pvar);
|
||||
pvar = pvarNext;
|
||||
}
|
||||
pbrkTable = (brkTable *)ellFirst(&pdbbase->bptList);
|
||||
while(pbrkTable) {
|
||||
@@ -1175,15 +1178,15 @@ long epicsShareAPI dbWriteRegistrarFP(DBBASE *pdbbase,FILE *fp)
|
||||
|
||||
long epicsShareAPI dbWriteVariableFP(DBBASE *pdbbase,FILE *fp)
|
||||
{
|
||||
dbText *ptext;
|
||||
dbVariableDef *pvar;
|
||||
|
||||
if(!pdbbase) {
|
||||
fprintf(stderr,"pdbbase not specified\n");
|
||||
return(-1);
|
||||
}
|
||||
for(ptext = (dbText *)ellFirst(&pdbbase->variableList);
|
||||
ptext; ptext = (dbText *)ellNext(&ptext->node)) {
|
||||
fprintf(fp,"variable(%s)\n",ptext->text);
|
||||
for(pvar = (dbVariableDef *)ellFirst(&pdbbase->variableList);
|
||||
pvar; pvar = (dbVariableDef *)ellNext(&pvar->node)) {
|
||||
fprintf(fp,"variable(%s,%s)\n",pvar->name,pvar->type);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,12 @@ registrar: tokenREGISTRAR '(' tokenSTRING ')'
|
||||
variable: tokenVARIABLE '(' tokenSTRING ')'
|
||||
{
|
||||
if(dbStaticDebug>2) printf("variable %s\n",$3);
|
||||
dbVariable($3); dbmfFree($3);
|
||||
dbVariable($3,"int"); dbmfFree($3);
|
||||
}
|
||||
| tokenVARIABLE '(' tokenSTRING ',' tokenSTRING ')'
|
||||
{
|
||||
if(dbStaticDebug>2) printf("variable %s, %s\n",$3,$5);
|
||||
dbVariable($3,$5); dbmfFree($3); dbmfFree($5);
|
||||
};
|
||||
|
||||
break_head: '(' tokenSTRING ')'
|
||||
|
||||
@@ -36,7 +36,8 @@ while(<INP>) {
|
||||
/registrar\s*\(\s*(\w+)/;
|
||||
$registrar[$numberRegistrar++] = $1;
|
||||
}
|
||||
if (/variable\s*\(\s*(\w+)/) {
|
||||
if (/variable\s*\(\s*(\w+)\s*,\s*(\w+)/) {
|
||||
$varType{$1} = $2;
|
||||
push @variables, $1;
|
||||
}
|
||||
}
|
||||
@@ -145,11 +146,18 @@ if($numberRegistrar>0) {
|
||||
|
||||
if (@variables) {
|
||||
foreach $var (@variables) {
|
||||
print "epicsShareExtern int *p$var;\n";
|
||||
print "epicsShareExtern $varType{$var} *p$var;\n";
|
||||
}
|
||||
%iocshTypes = (
|
||||
'int' => 'iocshArgInt',
|
||||
'double' => 'iocshArgDouble'
|
||||
);
|
||||
print "static struct iocshVarDef vardefs[] = {\n";
|
||||
foreach $var (@variables) {
|
||||
print "\t{\"$var\", iocshArgInt, (void *)p$var},\n";
|
||||
$argType = $iocshTypes{$varType{$var}};
|
||||
die "Unknown variable type $varType{$var} for variable $var"
|
||||
unless $argType;
|
||||
print "\t{\"$var\", $argType, (void *)p$var},\n";
|
||||
}
|
||||
print "\t{NULL, iocshArgInt, NULL}\n};\n\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user