Hi Gerrit,
On 11/3/23, 11:05 AM, "Tech-talk" <tech-talk-bounces at aps.anl.gov> wrote:
> Am Fri, 3 Nov 2023 08:50:33 -0700
> > One should not initialize the VAL field of a stringin record by setting
> > the INP field to a string
> > (or the VAL field of a stringout record by setting DOL), as the field
> > value might be interpreted as
> > a record name and the link as a channel access link.
> I see. But why is this written in the manual for stringin records then?
In recent EPICS 7 versions a stringin record can use a
JSON "const" link in its INP field to provide an initial constant string value, the older CONSTANT link type was limited to numeric values (see below). Even simpler though is just to set the VAL field in your .db file — this works fine as long as the INP
field isn't also set.
> > The INP field determines where the string input record gets its string. It
> > can be a database or channel access link, or a constant. If constant, the
> > VAL field is initialized with the constant and can be changed via dbPuts.
> This is not what I see when setting the INP field to a constant string
> value. Or does "constant" mean something different in this context?
By "constant" it means a numeric literal. The problem with supporting constant strings was that the IOC couldn't easily distinguish between some string values and the PV name of a local or Channel Access channel. More recently we added
the JSON link types which allow us to now be explicit that this is a constant string and not the name of some other record. We can also now use a JSON constant link to initialize an aai or waveform record with an array of values, which was not previously possible
at all.
> > Keep in mind that on records where INP expects a number, a constant
> > value is used to initialize VAL, but
> > a constant INP link is only processed at record initialization. Writing
> > a new value to INP via channel access
> > or dbput will not update the VAL field.
> This is also quite the opposite of what I get from the manual?!
Most record types only perform constant initialization of their VAL field from their INP link just once, at IOC initialization time. Writing to the INP field at run-time will still change the INP field itself, but if what you write is a
numeric literal it will be parsed as a CONSTANT link and the record process routine will ignore that and just use whatever is in the VAL field at the time. Note that my use of the field names INP and VAL above also applies to other pairs of fields in most
record types.
However, some record types such as the printf record (I think this is the only one in Base) do perform the constant initialization every time they process the record; this record type has a series of INP links but no equivalent to the VAL
field for each one where it could store the constant value from the link between process runs. That was deliberate, to allow the data type read through the link to not be fixed.
HTH,
- Andrew
--
Complexity comes for free, Simplicity you have to work for.