#*************************************************************************
# Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
#     National Laboratory.
# EPICS BASE is distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution.
#*************************************************************************


=title Long String Input Record (lsi)

The long string input record is used to retrieve an arbitrary ASCII string with
a maximum length of 32767 characters.

This record type was included in base.dbd beginning with epics-base 3.15.0.2 .

=head2 Parameter Fields

The record-specific fields are described below, grouped by functionality.

=recordtype lsi

=cut

recordtype(lsi) {

=head3 Scan Parameters

The long string input record has the standard fields for specifying under what
circumstances it will be processed.
These fields are listed in L<Scan Fields|dbCommonRecord/Scan Fields>.

=head3 Input Specification

The INP field determines where the long string input record obtains its string
from. 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.
Otherwise, the string is read from the specified location each time the record
is processed and placed in the VAL field. The maximum number of characters in
VAL is given by SIZV, and cannot be larger than 32767. In addition, the
appropriate device support module must be entered into the DTYP field.

=fields VAL, OVAL, SIZV, INP, DTYP

=cut

    include "dbCommon.dbd"
    %
    %/* Declare Device Support Entry Table */
    %struct lsiRecord;
    %typedef struct lsidset {
    %    dset common;
    %    long (*read_string)(struct lsiRecord *prec);
    %} lsidset;
    %#define HAS_lsidset
    %
    field(VAL,DBF_NOACCESS) {
        prompt("Current Value")
        asl(ASL0)
        pp(TRUE)
        special(SPC_DBADDR)
        extra("char *val")
        #=type STRING or CHAR[SIZV]
        #=read Yes
        #=write Yes
    }
    field(OVAL,DBF_NOACCESS) {
        prompt("Old Value")
        special(SPC_DBADDR)
        interest(3)
        extra("char *oval")
        #=type STRING or [SIZV]
        #=read Yes
        #=write No
    }
    field(SIZV,DBF_USHORT) {
        prompt("Size of buffers")
        promptgroup("40 - Input")
        special(SPC_NOMOD)
        interest(1)
        initial("41")
    }
    field(LEN,DBF_ULONG) {
        prompt("Length of VAL")
        special(SPC_NOMOD)
    }
    field(OLEN,DBF_ULONG) {
        prompt("Length of OVAL")
        special(SPC_NOMOD)
    }
    field(INP,DBF_INLINK) {
        prompt("Input Specification")
        promptgroup("40 - Input")
        interest(1)
    }

=head3 Monitor Parameters

These parameters are used to specify when the monitor post should be sent by the
C<monitor()> routine. There are two possible choices:

APST is used for archiver monitors and MPST  for all other type of monitors.

=fields MPST, APST

=cut

    field(MPST,DBF_MENU) {
        prompt("Post Value Monitors")
        promptgroup("80 - Display")
        interest(1)
        menu(menuPost)
    }
    field(APST,DBF_MENU) {
        prompt("Post Archive Monitors")
        promptgroup("80 - Display")
        interest(1)
        menu(menuPost)
    }

=head3 Operator Display Parameters

See L<Fields Common to All Record Types|dbCommonRecord/Operator Display
Parameters> for more on the record name (NAME) and description (DESC) fields.


=fields NAME, DESC

=head3 Alarm Parameters

The long string input record has the alarm parameters common to all record
types. L<Alarm Fields|dbCommonRecord/Alarm Fields> lists the fields related to
alarms that are common to all record types.

=head3 Run-time Parameters

The old value field (OVAL) of the long string input record is used to implement
value change monitors for VAL. If VAL is not equal to OVAL, then monitors are
triggered. LEN contains the length of the string in VAL, OLEN contains the
length of the string in OVAL.

=fields OVAL, LEN, OLEN

=head3 Simulation Mode Parameters

The following fields are used to operate the record in simulation mode.

If SIMM (fetched through SIML) is YES, the record is put in SIMS
severity and the value is fetched through SIOL.
SSCN sets a different SCAN mechanism to use in simulation mode.
SDLY sets a delay (in sec) that is used for asynchronous simulation
processing.

See L<Input Simulation Fields|dbCommonInput/Input Simulation Fields>
for more information on simulation mode and its fields.

=fields SIML, SIMM, SIOL, SIMS, SDLY, SSCN

=cut

    field(SIML,DBF_INLINK) {
        prompt("Simulation Mode Link")
        promptgroup("90 - Simulate")
        interest(1)
    }
    field(SIMM,DBF_MENU) {
        prompt("Simulation Mode")
        special(SPC_MOD)
        interest(1)
        menu(menuYesNo)
    }
    field(SIMS,DBF_MENU) {
        prompt("Simulation Mode Severity")
        promptgroup("90 - Simulate")
        interest(2)
        menu(menuAlarmSevr)
    }
    field(SIOL,DBF_INLINK) {
        prompt("Simulation Input Link")
        promptgroup("90 - Simulate")
        interest(1)
    }
    field(OLDSIMM,DBF_MENU) {
        prompt("Prev. Simulation Mode")
        special(SPC_NOMOD)
        interest(4)
        menu(menuSimm)
    }
    field(SSCN,DBF_MENU) {
        prompt("Sim. Mode Scan")
        promptgroup("90 - Simulate")
        interest(1)
        menu(menuScan)
        initial("65535")
    }
    field(SDLY,DBF_DOUBLE) {
        prompt("Sim. Mode Async Delay")
        promptgroup("90 - Simulate")
        interest(2)
        initial("-1.0")
    }
    %#include "callback.h"
    field(SIMPVT,DBF_NOACCESS) {
        prompt("Sim. Mode Private")
        special(SPC_NOMOD)
        interest(4)
        extra("epicsCallback            *simpvt")
    }
}



=head2 Device Support Interface

The record requires device support to provide an entry table (dset) which
defines the following members:

 typedef struct {
     long number;
     long (*report)(int level);
     long (*init)(int after);
     long (*init_record)(lsiRecord *prec);
     long (*get_ioint_info)(int cmd, lsiRecord *prec, IOSCANPVT *piosl);
     long (*read_string)(lsiRecord *prec);
 } lsidset;

The module must set C<number> to at least 5, and provide a pointer to its
C<read_string()> routine; the other function pointers may be C<NULL> if their
associated functionality is not required for this support layer.
Most device supports also provide an C<init_record()> routine to configure the
record instance and connect it to the hardware or driver support layer.

=head2 Device Support for Soft Records

A device support module for DTYP C<Soft Channel> is provided for retrieving
values from other records or other software components.

Device support for DTYP C<getenv> is provided for retrieving strings from
environment variables. C<INST_IO> addressing C<< @<environment variable> >> is
used on the C<INP> link field to select the desired environment variable.

=cut
