From 3cf2d9057f78ec7693b77f41f285e1d8a21bfe52 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 12 Jun 2014 14:47:42 -0500 Subject: [PATCH] Allow appended .db files to omit record type This .db file syntax is now legal, provided the named record already exists: record("*", "named") { field(VAL, 10) } --- documentation/RELEASE_NOTES.html | 19 +++++++++++++++++++ src/ioc/dbStatic/dbLexRoutines.c | 25 ++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index d20d9bc65..4e4845715 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -15,6 +15,25 @@ EPICS Base 3.15.0.x releases are not intended for use in production systems.

Changes between 3.15.0.1 and 3.15.0.2

+

Database field setting updates

+ +

A database (.db) file loaded by an IOC does not have to repeat the record +type of a record that has already been loaded. It may replace the first +parameter of the record(type, name) statement with an asterisk +character inside double-quotes, "*" instead. Thus the following is a +legal database file:

+ +
record(ao, "ao1") {}
+record("*", "ao1") {
+    field(VAL, 10)
+}
+ +

Note that database configuration tools will not be expected to have to +understand this syntax, which is provided for scripted and hand-coded database +and template instantiation only. Setting the IOC's dbRecordsOnceOnly +flag also makes this syntax illegal, since its purpose is to prevent +multiply-defined records from being collapsed into a single instance.

+

Added echo command to iocsh

The single argument string may contain escaped characters, which will be diff --git a/src/ioc/dbStatic/dbLexRoutines.c b/src/ioc/dbStatic/dbLexRoutines.c index 8c8ed7824..970bb9715 100644 --- a/src/ioc/dbStatic/dbLexRoutines.c +++ b/src/ioc/dbStatic/dbLexRoutines.c @@ -927,10 +927,26 @@ static void dbRecordHead(char *recordType, char *name, int visible) epicsPrintf("Bad character '%c' in record name \"%s\"\n", *badch, name); } + pdbentry = dbAllocEntry(pdbbase); if (ellCount(&tempList)) yyerrorAbort("dbRecordHead: tempList not empty"); allocTemp(pdbentry); + + if (recordType[0] == '*' && recordType[1] == 0) { + if (dbRecordsOnceOnly) + epicsPrintf("Record-type \"*\" not valid with dbRecordsOnceOnly\n"); + else { + status = dbFindRecord(pdbentry, name); + if (status == 0) + return; /* done */ + epicsPrintf("Record \"%s\" not found\n", name); + } + yyerror(NULL); + duplicate = TRUE; + return; + } + status = dbFindRecordType(pdbentry, recordType); if (status) { epicsPrintf("Record \"%s\" is of unknown type \"%s\"\n", @@ -938,10 +954,12 @@ static void dbRecordHead(char *recordType, char *name, int visible) yyerrorAbort(NULL); return; } - /*Duplicate records ok if the same type */ + + /*Duplicate records are ok if the same type */ + status = dbCreateRecord(pdbentry,name); - if (status==S_dbLib_recExists) { - if (strcmp(recordType, dbGetRecordTypeName(pdbentry))!=0) { + if (status == S_dbLib_recExists) { + if (strcmp(recordType, dbGetRecordTypeName(pdbentry)) != 0) { epicsPrintf("Record \"%s\" of type \"%s\" redefined with new type " "\"%s\"\n", name, dbGetRecordTypeName(pdbentry), recordType); yyerror(NULL); @@ -960,6 +978,7 @@ static void dbRecordHead(char *recordType, char *name, int visible) name, recordType); yyerrorAbort(NULL); } + if (visible) dbVisibleRecord(pdbentry); }