Chapter D1: strtab – String Table Lookup

1.Introduction

The normal use for the string-table record is to convert integer numbers into strings. This function is similar to the mbbi-record. The conversion tables are loaded into the memory as individual object files or libs – limited by memory size only. For each raw value a string and an error severity can be defined. The tables can be reloaded without rebooting. They are found and connected to the record by searching the symbol table.

No device support routines are used. The input can be fetched via database or channel access links.

The strtab input fields fall into the following categories:

scan parameters

read and convert parameters

operator display parameters

alarm parameters

run-time and simulation mode parameters

2.Scan parameters

The string-table record has the standard fields for specifying under what circumstances it will be processed.

These fields are listed in Scan Fields, Chapter 2, 2. In addition, Scanning Specification, Chapter 1, 1, explains how these

fields are used. Note that I/O event scanning is not supported.

3.Read and Convert Parameters

The record’s input routine reads the value into RVAL (an integer), upon which the normal conversion process is undergone.As the first conversion step, RVAL is shifted right by SHFT number of bits and masked by MASK, obtained by NOBT. TAB contains the name of the table to be used. VAL is updated by the string from the table if the value of RVAL is defined in the table. Otherwise the value of RVAL is printed into VAL as a string. A further explanation follows.

Field / Summary / Type / DCT / Initial / Access / Modify / Rec Proc
Monitor / PP
VAL / Value Field / STRING[40] / Yes / Null / Yes / Yes / Yes / Yes
INP / Input Link / INLINK / Yes / 0 / Yes / Yes / N/A / No
RVAL / Raw Value / ULONG / No / 0 / Yes / Yes / Yes / Yes
TAB / Table Name / STRING[40] / Yes / Null / Yes / Yes / No / No
SHFT / Bit Shift / USHORT / Yes / 0 / Yes / Yes / No / No
NOBT / Number of Bits / SHORT / Yes / 0 / Yes / Yes / No / No

3.1 Input Specification

The INP field can specify a constant value, a channel access link, or a database link. If the INP link is constant, RVAL will be initialized with this value but can be changed at run-time via dbPutField or dbPutLink.

3.2 Conversion Related Fields

A conversion is always performed if not in simulation and the table is found.

TAB / The name of the conversion table loaded in memory.
SHFT / Number of bits to shift RVAL right.
NOBT / Number of bits used from RVAL.

The record processing routine performs the following algorithm:

If the table exists in memory:

1.rval = RVAL > SHFT

2.rval &= MASK (*)

If rval changed since last conversion or CVRQ(**) flag set:

3.Find the string in the table

4.If the string was found:

  • assign the string to VAL

Else:

  • print the string representation of RVAL into VAL

(*) SHFT and NOBT can be modified during run-time. If NOBT is modified, MASK will be recomputed using the special routine.

(**) explained later in chapter 7: special.

4.Operator Display Parameters

These parameters are used to present meaningful data to the operator. They display the value and other parameters of the strtab record either textually or graphically. In the string-table record no special parameters are used since the displayed text is taken from an external table.

Field / Summary / Type / DCT / Initial / Access / Modify / Rec Proc
Monitor / PP
NAME / Record Name / STRING[29] / Yes / 0 / Yes / No / No
DESC / Description / STRING[29] / Yes / Null / Yes / Yes / No / No

5.Alarm Parameters

The possible alarm state for string-table records are shown in this table:

UDF_ALARM / VAL is undefined after ioc_init or after changing the table
STATE_ALARM / A non-zero alarm is defined in the table or the state is undefined
COS_ALARM / RVAL has changed
SOFT_ALARM / SIMM has an undefined value
SIMM_ALARM / Record is in simuation mode
READ_ACCESS_ALARM / The table was not found

For each string in the table an alarm severity can be specified. For those raw values which are not defined in the table then the field UNSV defines the alarm severity. See the See Alarm Specification, Chapter 1, 4, for a complete explanation of discrete alarms and these fields. Alarm Fields, Chapter 2, 3, lists other fields related to a alarms that are common to all record types.

Field / Summary / Type / DCT / Initial / Access / Modify / Rec Proc
Monitor / PP
UNSV / UnknownState Severity / GBLCHOICE / Yes / 0 / Yes / Yes / No / Yes
COSV / Input Link / GBLCHOICE / Yes / 0 / Yes / Yes / No / Yes

6.Run-time and Simulation Mode Parameters

These parameters are used by the run-time code for processing the string-table. They are not configurable by the user. Only those for simulation can be changed during run-time.

The ORAW field is used to decide if a new search in the table should be started. OVAL and ORAW are used in the monitor routine, to decide if monitors for VAL or RVAL should be triggered.

PTAB contains the pointer to the table in memory if it was found. Otherwise it is NULL. The size of the table is loaded into NELM. Both parameters are stored by the connectTable routine of the record.

MASK was explained earlier in the section 3.2.

IXDF indicates that the current RVAL corresponds to a string in the table. STSV holds the alarm severity of this table element.

Field / Summary / Type / DCT / Initial / Access / Modify / Rec Proc
Monitor / PP
OVAL / Old Value / STRING[40] / Yes / 0 / Yes / No / No / No
PTAB / Address of Table / NOACCESS / No / 0 / No / No / No / No
NELM / Number of Elements / USHORT / No / 0 / Yes / No / No / No
ORAW / Old Raw Value / ULONG / No / 0 / Yes / No / No / No
ORVL / Old Masked Raw Value / ULONG / No / 0 / Yes / No / No / No
MASK / Mask / ULONG / No / 0 / Yes / No / No / No
STSV / ActiveState Severity / GBLCHOICE / No / 0 / Yes / No / No / No
IXDF / Index Defined / USHORT / No / FALSE / Yes / No / No / No
CVRQ / Conversion Request / USHORT / No / TRUE / Yes / Yes / No / Yes

The following fields are used to operate the strin-table record in the simulation mode. See Chapter 3, Fields Common to Many Record Types, for more information on these fields.

Field / Summary / Type / DCT / Initial / Access / Modify / Rec Proc
Monitor / PP
SIOL / Simulation Value Location / INLINK / Yes / 0 / Yes / Yes / N/A / No
SVAL / Simualtion Value / STRING[40] / No / 0 / Yes / Yes / No / No
SIML / Simualtion Mode Location / INLINK / Yes / 0 / Yes / Yes / N/A / No
SIMM / Simualtion Mode / GBLCHOICE / No / 0 / Yes / Yes / No / No
SIMS / Simualtion Mode Alarm Severity / GBLCHOICE / Yes / 0 / Yes / Yes / No / No

7.Record Support routines

init_record

This routine initializes SIMM if SIML is a constant or creates a channel access link if SIML is PV_LINK. If SIOL is PV_LINK a channel access link is created.

Next, it calls connectTable to find the conversion table with the name given by the TAB field in the symbol table.

Finally the MASK field is initialized by calling initMask.

process

See next section.

special

If the table name is changed (i.e. after reloading a new file) connectTable is called once again. Additionally IXDF is cleared and CVRQ is set to force a new conversion.

If NOBT is changed, the MASK field is calculated new by calling initMask.

After each change of fields wich triggers the special routine, the process routine is called.

8.Record Processing

The process routine implements the following algorithm:

1.set PACT = TRUE.

2.readValue is called

See Input Records, Chapter 3, 2 for more information. There is no device support, so dbGetLink is called directly delivering the value into RVAL.

3.update the records timestamp.

If readValue returned 0 (convert, no simulation):

4.check if the table is defined. If not: raise READ_ACCESS_ALARM.

If table is defined:

5.reset UDF flag.

6.raise the COS_ALARM if the masked rval has changed.

7.do the conversion (see Chapter 3.2)

  • set IXDF flag to TRUE (FALSE) if (if not) the number was found in the table.

8.Check alarms according to table value stored in STSV or UNSV if no string is defined.

9.Check to see if monitors should be invoked.

  • VAL is monitored on value change or alarm.
  • RVAL is moitored on value change.

10.Scan forward link, set PACT FALSE and return.

9.Device Support

Sorry – no device support

10.Table Library

The source code of the tables to use with the strtabRecord should be located in …/DesyBase/src/lib/strtab/. An other possibility is placing it near the application in vxBoot/ioc/.. which has some advantages but also some disadvantages.

The tables are written in a c-language file which must be compiled the normal way for the ioc architecture. The file must include the header-file strtabRecordTypes.h which is shared with the strtabRecord. The file alarm.h is needed for defining the state severities as text instead of numbers.

The file must look like this:

#include <strtabRecordTypes.h>

#include <alarm.h>

<any number of table definitions>

The format of a table in the file is like this:

LOCAL tabTable_t strtab_<Name>_Table = {

{ <Index>, "<Text>", <Alarm_Severity> },

......

};

tabHeader_t strtab<Name> = {

sizeof(strtab_<Name>_Table)/sizeof(tabElement_t),

strtab_<Name>_Table

};

<Name>must be replaced by the name of the table, which is used in the TAB-field of the record.

<Index>is a number between 0 and 2147483647. If this number is found in the RVAL-field, the record will copy the text (<Text>) into VAL and set the alarm severity to what is defined in <Alarm_Severity>. If the alarm is not NO_ALARM, the STAT becomes “STATE_ALARM”.

<Text>a string of up to 40 characters, to be filled into the VAL-field if RVAL is equal to the index.

<Alarm_Severity>either NO_ALARM, MINOR_ALARM, MAJOR_ALARM or INVALID_ALARM.

Example:

#include <strtabRecordTypes.h>

#include <alarm.h>

LOCAL tabTable_t strtab_MKK_CTV_Table = {

{ 0, "Lokaler Stillstand", MINOR_ALARM},

{ 1, "Auto: Warten auf Kuehlanforderung", NO_ALARM},

{ 3, "Auto: Warten auf Wasserstroemung Verdampfer", NO_ALARM}

};

tabHeader_t strtabMKK_CTV = {

sizeof(strtab_MKK_CTV_Table)/sizeof(tabElement_t),

strtab_MKK_CTV_Table

};