Chapter 8. Database Structure

Table of Contents

1. General Information
2. Data Point Definition Tables
2.1. LabelRec Table
2.2. DescRec Table
2.3. Message Tables
2.4. DataRec Table
3. Button Tables
4. Data Point Definition Key Tables
4.1. RefKeys Table *
4.2. DKeys Table
4.3. CrKeys Table
4.4. CtKeys Table
4.5. OwnKeys Table
4.6. ScaKeys Table
4.7. DevKeys Table
4.8. DrvKeys Table
4.9. CmdKeys Table *
4.10. QueKeys Table *
5. Display Page Tables
5.1. PgKeys Table
5.2. CrtText Table
5.3. CrtFixed Table
5.4. CrtDCpnt Table
5.5. CrtBut Table
5.6. CrtICpnt Table
6. Display Page Key Tables
6.1. DFkeys Table
6.2. IconKeys Table
7. Interlock Tables
7.1. ChkList Table
7.2. ChkPoint Table
7.3. ChkAct Table
7.4. ChkAlarm Table
7.5. CPtype Field Usage
8. Numeric Processor Tables
8.1. NumList Table
8.2. NumPoint Table
8.3. NPtype Field Usage
9. Interlock and Numeric Processor Key Tables
9.1. CPTkeys Table
9.2. NPTkeys Table
10. CAMAC Interface Wiring Tables
10.1. JackRec Table
10.2. RPrecord Table
10.3. Zrecord Table
10.4. Trecord Table
11. CAMAC Interface Wiring Information Key Tables
11.1. ColKeys Table
11.2. BusKeys Table
11.3. JkKeys Table
12. Report Usage
12.1. Invoking Reports
12.2. Printing Reports
13. Report Formats
13.1. Label report
13.2. RecId and Module report
13.3. JackRec report
13.4. RPrecord report
13.5. Zrecord report
13.6. Rpanel report
13.7. Zpanel report
14. BuildMB Process
15. Table Translation
16. Using SQL
17. Database Construction Tools

1. General Information

The Postgres[3] database manager is used to construct and maintain the control system database. In addition, it is used to generate the wire lists needed to assemble the CAMAC interfaces.

All of the relevant information needed to build the control system database is entered via SQL[4] into the Postgres database.

After the database is entered into Postgres, each one of the tables needed by the accelerator control system is extracted from the Postgres database via SQL queries. They are then processed by other programs to translate the information into a format used by the runtime system.

This manual gives definitions for the fields in the tables maintained by the Postgres database and how they are related to each other.

A bold field name indicates the primary key. In some cases the table is keyed by more than one field. This is called a composite key. An italicized field name indicates an alternate (candidate) key. An alternate key is a field that can be used to uniquely identify a record (row, tuple) in a table in place of the primary key. This means that it must remain a unique value for each record, just like a primary key.

2. Data Point Definition Tables

The LabelRec, DescRec and DataRec tables all work together to provide a definition of the data points in the control system.

More information concerning the use of the Label and RefName fields can be obtained in the operators manual in the section titled "Organization of machine parameters in the Control System Database".

2.1. LabelRec Table

The LabelRec table defines a list of valid device names.

Label

Identifier for the device/group. (e.g. FC 01-1)

Name

String describing the device. (e.g. Faraday Cup)

Lcomm

Comments field.

PartNum

Not in use. The intention was to associate a part number for a controller with a label and print the information on the wire lists.

2.2. DescRec Table

This table provides a view of individual parameters for a device. The bit field to be viewed comes from the DataRec table.

The current binary parameter values are located in DataRec.DataVal. A record in this table allows the word and the bit field within the word to be located, masked and right justified. Other fields determine how the value obtained is converted to a physical value and formatted for display.

A parameter value is extracted from the runtime database using DataCvt(). The scaled value is checked against the limit fields (PhyMin and PhyMax) and is returned along with an error code that indicates whether the value is within limits.

If the parameter is used for control, a field specifies the method for control input. See the section titled "CtKeys" for more information. A check is made to see if the writer is attempting to write a value within acceptable limits and if the writer has permission to write into the database through this record.

Label

First half of the tag name. (e.g. FC 01-1)

Validated by LabelRec.Label.

RefName

Second half of the tag name. (e.g. PosSC)

Validated by RefKeys.RefName.

Llabel

Specifies a logical (symbolic) link to another Label.

LRefName

Specifies a logical (symbolic) link to another RefName. Causes the rest of the fields to be ignored and the fields of the linked Label/RefName pair to be used. It is highly recommended that all of the ignored fields be set to the equivalent of nil or 0. This is due to a possible future overriding capability. Using the same power supply for two pieces of equipment might be an example use for this. (e.g. EQ TX-1 PwrSC might link to CPS TX-1 PwrSC)

Units

An eight char field containing the physical units string. (e.g. KV, V, A, G, or T)

DataType

Data conversion key.

Validated by Dkeys.DtNme.

See the section titled "DataTypes."

CrtKey

Display format key.

Validated by CrKeys.CrNme.

See the section titled "CrtKeys."

CtlKey

Modify control format key. Determines how a mouse, keyboard, or other input device affects a parameter.

Validated by CtKeys.CtNme.

See the section titled "CtlKeys."

Owner

Name of the task that owns the record.

Validated by OwnKeys.OwnNme.

See the section titled "OwnKeys."

WpermD

Write permissions.

See the section titled "Write Permissions."

ScaKey

Database scaling key. Used by the auto-scaling program(s).

Validated by ScaKeys.ScaNme.

See the section titled "ScaKey."

Message

When the value of DataType field is Ldisp this field specifies a message table.

Validated by checking MsgKeys.MsgNme.

See the section titled "MsgKeys."

SpanMin

The minimum physical(hardware) value of the parameter. This is used to calculate M and B.

See the section titled "BuildMB."

SpanMax

The maximum physical(hardware) value of the parameter. This is used to calculate M and B.

See the section titled "BuildMB."

PhyMin

The minimum virtual(software) value of the parameter. Used in the runtime database to determine if an attempted write or read is within bounds.

PhyMax

The maximum virtual(software) value of the parameter. Used in the runtime database to determine if an attempted write or read is within bounds.

IncVal

Used in most CtlKeys to determine step(increment) size of a change. In most cases this value is created automatically by the BuildMB process.

See the section titled "BuildMB."

M

Conversion coefficient 1. In most cases this value is created automatically by the BuildMB process.

See the section titled "BuildMB."

B

Conversion coefficient 2. In most cases this value is created automatically by the BuildMB process.

See the section titled "BuildMB."

DRkey

Used to determine how to treat the extracted binary field.

See the section titled "DRkey Usage."

Size

Size of the extracted binary field in bits.

Offset

Offset into the binary word from which to extract the binary field.

Addr

RecId of the corresponding binary field in the DataRec table.

Validated by DataRec.RecId.

Dcomm

Comments field.

MBconvKey

Enables automatic calculation of the M and B values.

MBsetIncKey

Enables automatic calculation of the SetInc value.

2.2.1. DataTypes

See datatypes(7) in the AccelNET manual pages for a list of valid datatypes.

2.2.2. CrtKeys

See crtkeys(7) in the AccelNET manual pages for a list of valid crt keys.

2.2.3. CtlKeys

See ctlkeys(7) in the AccelNET manual pages for a list of valid control keys.

2.2.4. Write Permissions

See write_perm(7) in the AccelNET manual pages for an explanation of the write permissions.

2.2.5. ScaKeys

See scakeys(7) in the AccelNET manual pages for a list of valid scaling keys.

2.2.6. DRkey Usage

The DRkey is a one character field that specifies how to interpret the extracted binary field.

The values of the field and their meanings are as follows:

Treat the extracted field as an unsigned number.

I

Treat the extracted field as a signed number. The minimum value of the integer is -(2^(size-1)). The maximum value of the integer is 2^(size-1)-1. For example, if size = 12 the integer has a range of -2048 to 2047.

P

Treat the extracted field as in 'I.' Negative values are treated as zero.

N

Treat the extracted field as in 'I.' Positive values are treated as zero.

2.2.7. SpanMin and SpanMax Usage

SpanMin and SpanMax are used to calculate the values of the data conversion coefficients M and B. SpanMin is the physical value that corresponds to the minimum binary value of the data point. SpanMax corresponds to the maximum binary value. DescRec.DataType, DescRec.Size, DescRec.DRkey and DataRec.DTkey all play a role in the process.

Calculation of the coefficients is carried out by a family of programs that traverse the database and calculate the values for all of the records at one time. Each member of the program family is responsible for handling one value of DataType. Not all of the possible values of DataType are supported. See the section titled "BuildMB" for more information.

2.3. Message Tables

The message tables are used in conjunction with the Ldisp datatype. A message is provided in a table for each possible value of the data point. The value of the data point and the message type are used as an index into the table.

The runtime data conversion and formatting process is split into two pieces. The first part is concerned with obtaining the physical value of the data point. The second part is the display formatting.

The goal of the Postgres implementation is to allow the collection of information needed to create and maintain the message tables. This has been done by creating two tables (MsgKeys and MsgTbl) for message table management. These tables also exist in the runtime system.

The DescRec table contains a field (Message) that associates a message list with it. The field is used only with DescRecs that have DataType = Ldisp. DescRecs with other DataType values have "NullMsg" entered into the Message field as a place holder.

The messages to be displayed are entered in the MsgTbl. There should be an entry for each possible value of the data point even if not all values are expected to occur. This is done to prevent any unexpected behavior. Each entry in the table must have a unique value of MsgVal for a given MGown (Postgres enforces this).

During runtime, the Message field from the DescRec table is used as MsgNme/MGown. A value is extracted from the DataRec table using information stored in the DescRec entry. The resulting value is checked against PhyMin and PhyMax and becomes MsgVal. A list of messages is traversed looking for a matching MGown/MsgVal pair to determine which message to use (MsgText). If no match is found, '*overrange*' is used.

The DataVal field from the DataRec table is used as MsgVal to retreive the particular message (MsgText) from the MsgTbl referenced by MGown and MsgVal.

The MsgKeys table allows each message list to be given a name by which it is referred to in the DescRec.Message field. (e.g. "PwrMsgSC", "PwrMsgSR")

Note

It is necessary for the value of CrtKey to be 'Lmsg' to display the messages.

2.3.1. MsgKeys Table

This table defines a message list and its size.

MsgNme

Name of the message list.

MsgSize

Number of messages in the list.

Comments

Comments field.

2.3.2. MsgTbl Table

This table contains the text for all messages in all of the message lists.

MGown

List that this message record belongs to.

Validated by MsgKeys.MsgNme.

MsgVal

Index of the message in the list.

MsgText

Message text.

2.4. DataRec Table

The DataRec table defines a record where data is stored. Usually this record is associated with the data acquisition hardware, however, this is not always the case. There are quite a few places in the control system where information is acquired, rescaled, or otherwise processed to obtain new results. Total beam energy calculation or magnet field strength deviation might be examples of this.

There are also many places where a number is read into the system and never written out to any hardware. Examples might be charge state, desired magnet field strength, or desired particle mass.

RecId

A serial number used to identify the record.

DevType

Used by the I/O software to determine the type of hardware I/O transactions to perform in order to obtain data from (or write to) the device.

Validated by DevKeys.DevTypeK.

See the section titled "DevType."

Driver

Data acquisition group.

Validated by DrvKeys.DrvNme.

Crate

First part of the hardware address. In CAMAC this is the crate number that is set on the actual crate. This value is also used for grouping/sorting of reports.

Slot

Second part of the hardware address. In CAMAC this is the slot number. This value is also used for grouping/sorting of reports.

ChanNo

Third part of the hardware address. In a CAMAC A/D converter this is the channel number. The software that builds the I/O transactions for a module interprets this for a given device. This value is also used for grouping/sorting of reports.

Dither

Number of bits to mask off for dither reduction. Used by the analog read service.

DTkey

Format of the DataVal, PrevVal and SaveVal fields. 'I' is an integer field, 'F' is a floating point field.

DataVal

Present/current value.

PrevVal

Previous/last value.

SaveVal

Value saved by operator command.

DTcomm

Comments field.

2.4.1. DevType

See devkeys(7) in the AccelNET manual pages for a list of valid device keys.

2.4.2. Driver

See drvkeys(7) in the AccelNET manual pages for a list of valid driver keys.

2.4.3. DTkey

There are three possible values for DTkey.

Floating point value (signed).

U

Integer value (unsigned).

N

Negated integer value (unsigned). This key is rarely used. It simply negates the binary value after it is extracted when converting to a physical value using a DescRec.

3. Button Tables

The button tables (BoxRec and PadRec) have been deprecated and are slated for obsolete status. The original function of these tables was to provide touch screen or other alternative input support.

4. Data Point Definition Key Tables

These tables are used to validate fields of other tables in the database. The following is true unless marked with an asterisk (*). These tables should not be modified by the user. The tables will only change if new functionality is added to AccelNET.

4.1. RefKeys Table *

Table of RefName definitions.

RefNme

The RefName.

RefVal

An integer value for the RefName. Used to sort Desc records in the Label report.

RefDesc

Comments field.

RefAttNme

A more descriptive name.

4.2. DKeys Table

Table of DataType definitions.

DtNme

The DataType name.

DtVal

An integer value for the DataType.

DtDesc

Comments field.

4.3. CrKeys Table

Table of display key (CrtKey) definitions.

CrNme

The display key name.

CrVal

An integer value for the display key.

CrDesc

Comments field.

4.4. CtKeys Table

Table of control key (CtlKey) definitions.

CtNme

The control key name.

CtVal

An integer value for the control key.

CtDesc

Comments field.

4.5. OwnKeys Table

Table of Owner definitions. Owner names correspond to task numbers in the control system.

OwnNme

The owner name.

OwnVal

The task number of the owner.

OwnDesc

Comments field.

4.6. ScaKeys Table

Database scaling keys.

ScaNme

The scaling key name.

ScaVal

The scaling key value.

Comments

Comments field.

4.7. DevKeys Table

Table of device type definitions.

DevTypeK

Device type name.

DevTypeV

An integer value for the device type.

DevDesc

Comments field.

4.8. DrvKeys Table

Table of driver type definitions. The control system is designed in a way that allows data acquisition from more than one type of data acquisition system at the same time. The driver type specifies which data acquisition system to use.

DrvNme

Driver name.

DrvVal

An integer value for the driver type.

DrvDesc

Comments field.

4.9. CmdKeys Table *

Deprecated (part of button tables).

4.10. QueKeys Table *

Deprecated.

5. Display Page Tables

The display page database is made up of several record types.

PgKeys contains the master records for a display page. There is one record in PgKeys for each page in the system.

The rest of the records define display entities. There is one record for each entity on the screen. An entity can be an alphanumeric field or an icon.

5.1. PgKeys Table

This table associates a display page name with a page number.

PgNme

Page name.

PgVal

Page number.

Dflag

Display flag. The value of this field is either 'Y' or 'N'. If the value is 'Y', all of the records associated with the page are displayed unless their individual Dflags are set to 'N'. If the value is 'N', the entire page is inhibited from being displayed.

PgDesc

Comments field.

5.2. CrtText Table

This table defines static text strings in a display page. These strings can be used for comments and other permanent text.

Together PgNme and RecId form the key for this table.

PgNme

Name of the page.

Validated by PgKeys.PgNme.

RecId

A serial number used to identify the record.

CurX

X coordinate on display page.

CurY

Y coordinate on display page.

Dflag

Display flag. The value of this field is either 'Y' or 'N'. If the value is 'Y', this record is displayed. If the value is changed while the page is displayed, the field is erased.

Width

Width (in characters) of the string.

FontType

Font setting to display the text.

Valid values are: default, big, and user1 through user8.

Text

The string to be displayed.

5.3. CrtFixed Table

This table defines database fields for display.

PgNme

Name of the page.

Validated by PgKeys.PgNme.

DFnme

Type of field to display.

Validated by DFkeys.DFnme.

RecId

A serial number used to identify the record.

CurX

X coordinate on display page.

CurY

Y coordinate on display page.

Dflag

Display flag. The value of this field is either 'Y' or 'N'. If the value is 'Y', this record is displayed. If the value is changed while the page is displayed, the field is erased.

Width

Width (in characters) of the string.

FontType

Font setting to display the text.

Valid values are: default, big, and user1 through user8.

Label, RefName

Name of the parameter to display. If DFnme is set to Label or Name, only the Label must be set. The RefName field may be NULL.

5.4. CrtDCpnt Table

This table defines Display/Control parameter sets for a display page. The first display parameter (DCdisp1_Label, DCdisp1_DrefNme) is the one displayed on the screen at the given coordinates. The DCdisp and DCctl fields work in sets. For example, when a DCpnt is selected on the screen, DCdisp1 will be displayed as the readback parameter and DCctl1 will be displayed as the control parameter. The # in DCdisp# and DCctl# identify the layer number. The first time an item is clicked, the first layer will appear. Subsequent clicks will increment the layer.

PgNme

Name of the page this record is associated with.

Validated by PgKeys.PgNme.

RecId

A serial number used to identify the record.

CurX

X coordinate on display page.

CurY

Y coordinate on display page.

Dflag

Display flag. The value of this field is either 'Y' or 'N'. If the value is 'Y', this record is displayed. If the value is changed while the page is displayed, the field is erased. However, the field may still be selected by the mouse until a new page is loaded or the same page is reloaded.

Width

Width (in characters) of the string.

FontType

Font setting to display the text.

Valid values are: default, big, and user1 through user8.

DCdisp1_Label, DCdisp1_DrefNme

First read back parameter.

DCdisp2_Label, DCdisp2_DrefNme

Second read back parameter.

DCdisp3_Label, DCdisp3_DrefNme

Third read back parameter.

DCdisp4_Label, DCdisp4_DrefNme

Fourth read back parameter.

DCctl1_Label, DCctl1_DrefNme

First control parameter.

DCctl2_Label, DCctl2_DrefNme

Second control parameter.

DCctl3_Label, DCctl3_DrefNme

Third control parameter.

DCctl4_Label, DCctl4_DrefNme

Fourth control parameter.

5.5. CrtBut Table

Deprecated (part of button tables).

5.6. CrtICpnt Table

Icon display definition table. ICdisp and ICctl fields are treated in the same way as in the CrtDCpnt table.

PgNme

Name of the page this record is associated with.

Validated by PgKeys.PgNme.

ICtype

Type of icon to display.

Validated by IconKeys.IconNme.

RecId

A serial number used to identify the record.

GrpNme

Name of the beamline region associated with this record.

Validated by GrpKeys.GrpNme.

CurX

X coordinate on display page.

CurY

Y coordinate on display page.

CurX2

Second X coordinate on display page. This field is used to stretch/modify the geometry of the icon. A value of "0" will result in the default geometry for the given plane.

CurY2

Second Y coordinate on display page. This field is used to stretch/modify the geometry of the icon. A value of "0" will result in the default geometry for the given plane.

ICrot

Amount (in degrees) to rotate the icon from its base orientation (right hand coordinates). A value of "0" will result in the no rotation.

ICscale

Amount to scale the icon size. The default (and most common) size is 1.0.

Dflag

Display flag. If the value is 'Y', this record is displayed. If the value is changed while the page is displayed, the field is erased. However, the field may still be selected by the mouse until a new page is loaded or the same page is reloaded.

ICicon_Label, ICicon_DrefNme

Data point from which to get the icon color.

ICdisp1_Label, ICdisp1_DrefNme

First Display parameter.

ICdisp2_Label, ICdisp2_DrefNme

Second Display parameter.

ICdisp3_Label, ICdisp3_DrefNme

Third Display parameter.

ICdisp4_Label, ICdisp4_DrefNme

Fourth Display parameter.

ICctl1_Label, ICctl1_DrefNme

First Control parameter.

ICctl2_Label, ICctl2_DrefNme

Second Control parameter.

ICctl3_Label, ICctl3_DrefNme

Third Control parameter.

ICctl4_Label, ICctl4_DrefNme

Fourth Control parameter.

Comments

Comments field.

6. Display Page Key Tables

These tables are used to validate fields of other tables in the database. These tables should not be modified by the user. The tables will only change if new functionality is added to AccelNET.

6.1. DFkeys Table

This table is used to validate entries in CrtFixed.DFnme.

DFnme

Display field name.

DFval

An integer value for the display field.

DFdesc

Comments field.

See DFkeys(7) in the AccelNET manual pages for a list of valid DFkeys.

6.2. IconKeys Table

This table is used to validate entries in CrtICpnt.ICtype.

IconNme

Icon name.

IconVal

An integer value for the icon name.

IconDesc

Comments field.

See iconkeys(7) in the AccelNET manual pages for a list of valid IconKeys.

7. Interlock Tables

Interlocks are used to provide conditional actions on data points. They are usually used to provide software equivalents of hardware interlocks. An example might be to prevent a Faraday cup from moving out of the beamline unless the next beamline valve is open. The beamline valve cannot be opened unless there is good pressure on either side of it. Icon colors are also determined by entries in this table.

Interlocks are defined by first choosing a data point to be acted on. The point chosen is entered into a record in the ChkList table.

An interlock chain is created by defining records in the ChkPoint table. The ChkPoint table defines what data points will affect the action. The way in which the data point is evaluated is determined by the CPtype field.

The ChkAct table looks at the word formed by the entries in ChkPoint to determine what will happen to the data point in ChkList. If the word matches the checked criteria, a new value is returned for the ChkList data point.

The ChkAlarm table is processed in a similar way that ChkAct is processed, but returns an error message to the user, instead of a value to the data point.

7.1. ChkList Table

This table defines the data point to be acted on. When a request is made to modify a data point listed in this table, the chain is started. A timer is started lasting the timeout value (in seconds) of TMOvalue. If the interlock does not match an entry in ChkAct by the end of the timer, the default value (Value) is entered into the data point.

RecId

A serial number used to identify the record.

CLdskey_Label, CLdskey_DRefNme

Data point to be acted on.

Value

Value to write into the data point if there is no match in ChkAct table.

TMOvalue

Amount of time to wait before writing the default value.

Comments

Comments field.

7.2. ChkPoint Table

This table defines the data points from which to collect data for interlock evaluation. The records in this table are used to build an evaluation word. An evaluation word is the composite of each record's result specified for the interlock chain. Each record defines an offset (bit) position in the evaluation word to store the result.

MrecId

RecId of the Chklist entry that this record is associated with.

Validated by ChkList.RecId.

RecId

A serial number used to identify the record.

CPdesc_Label, CPdesc_DRefNme

Data point to obtain information from.

CPtype

Type of evaluation to be performed.

Validated by CPTkeys.CPTnme.

Offset

Offset in the evaluation word to write the evaluation into.

LimLo

Set lower limit for evaluation in certain values of CPtype.

LimHi

Set upper limit for evaluation in certain values of CPtype.

Comments

Comments field.

7.3. ChkAct Table

The value of the evaluation word is filtered and compared using Mask and Mask2 in this table. The Mask field defines which bits of the evaluation word to look at. The Mask2 is compared to the bits of the evaluation word defined by Mask. If there is a match, Value is written to the data point described in ChkList.DSkey.

MrecId

RecId of the ChkList entry that this record is associated with.

Validated by ChkList.RecId.

RecId

A serial number used to identify the record.

Mask

Bits in the evaluation word to be checked. A bitwise 'AND' operation is performed on this field and the evalution word to generate a check word.

Mask2

Bit pattern to be matched. This is compared to the previously generated check word.

Value

Value written to the data point described in ChkList.DSkey if Mask2 is identical to the check word.

Comments

Comments field.

7.4. ChkAlarm Table

This table contains information needed to select an alarm message if the interlock evaluation fails. The same method of processing Mask and Mask2 in ChkAct is used to process ChkAlarm. Instead of a value being written into the data point, a message is displayed to the user.

MrecId

RecId of the ChkList entry that this record is associated with.

Validated by ChkList.RecId.

RecId

A serial number used to identify the record.

Mask

Bits in the evaluation word to be checked. A bitwise 'AND' operation is performed on this field and the evalution word to generate a check word.

Mask2

Bit pattern to be matched. This is compared to the previously generated check word.

Message

Error message.

7.5. CPtype Field Usage

See cp_type(7) in the AccelNET manual pages for a list of valid CPtypes.

8. Numeric Processor Tables

The numeric processing system allows simple algebraic manipulation of data points to form a value to be written into a data point. This is used to perform calculations such as total injection voltage.

Just like the interlock tables, the numeric processor works off a chaining system. The data point to be affected is set in the NumList table.

The NumPoint table is used to perform the algebraic operations. The operations are peformed in order based on RecId. NPtype is used to define what algebraic function to perform (e.g. add, subtract, multipy, divide, sin, cos). A chain is started with an initial stored value of 0. The first record usually inserts an initial value using 'load' or 'add' as the NPtype. When a record is processed, the data point specified by NPdskey is multiplied by the Scale field to create the operand. If NPdskey is NULL, the Scale field is used as a constant operand in the calculation. Once the operand is determined, the operation specified by NPtype is evaluated on the stored value and operand. The result is placed in the stored value. This continues until all of the records in the chain have been processed. Once the chain has completed, the resulting stored value is written to the data point specified in NumList.

To facilitate complex algebraic equations, four subtotal values are available. They can be used by appending '_S#' to NPtype, where # is 1 through 4. Once the subtotal has been calculated, it can be evaluated into the main total using 't_add_S#', 't_sub_S#', 't_mul_S#', or 't_div_S#'. When the above evaluations are done with the main total, the subtotal is automatically cleared.

8.1. NumList Table

This table defines the data point to be acted on.

RecId

A serial number used to identify the record.

NLdskey_Label, NLdskey_DRefNme

Name of the data point to write the result into.

Comments

Comments field.

8.2. NumPoint Table

MrecId

RecId of the NumList entry that this record is associated with.

Validated by NumList.RecId.

RecId

A serial number used to identify the record.

NPtype

Type of algebraic operation to perform on this point and the accumulated value.

Validated by NPTkeys.NPTnme.

NPdskey_Label, NPdskey_DRefNme

Data point to obtain information from. If these values are NULL, the value of 1 is assumed.

Scale

Value obtained from the database is multiplied by this before evaluation. A good use of this is to invert the sign of the database value with -1. By using NULL for NPdskey, this field can be used as a constant.

Comments

Comments field.

8.3. NPtype Field Usage

See np_type(7) in the AccelNET manual pages for a list of valid NPtypes.

9. Interlock and Numeric Processor Key Tables

These tables are used to validate fields of other tables in the database. These tables should not be modified by the user. The tables will only change if new functionality is added to AccelNET.

9.1. CPTkeys Table

This table is used to validate entries in ChkPoint.CPtype.

CPTnme

ChkPoint type name.

CPTval

An integer value for the ChkPoint type name.

CPTdesc

Comments field.

9.2. NPTkeys Table

This table is used to validate entries in NumPoint.NPtype.

NPTnme

NumPoint type name.

NPTval

An integer value for the NumPoint type name.

NPTdesc

Comments field.

10. CAMAC Interface Wiring Tables

10.1. JackRec Table

This table contains the jack number and jack types for every connector in the interfaces. It is used to validate connector number entries in the RPrecord, Zrecord, and Trecord tables and to specify connector type on some of the reports.

The two fields, JackTypA and JackTypB, allow specification of both halves of the connector set.

JackNo

Name of the connector.

JackTypA

Connector type.

JackTypB

Connector type.

Comments

Comments field.

10.2. RPrecord Table

This table specifies a connection for one pair in a device connector on the interface.

RPdskey_Label, RPdskey_DRefNme

Parameter associated with this pair.

RPpair

Pair number of the parameter.

RPjack

Jack this connection is located in.

PinA

First pin in the pair.

PinB

Second pin in the pair.

ColorA

Color of the first wire in the pair.

Validated by ColKeys.ColNme.

ColorB

Color of the second wire in the pair.

Validated by ColKeys.ColNme.

SigNameA

Name of the signal associated with the first wire in the pair.

SigNameB

Name of the signal associated with the second wire in the pair.

Buss

Bus to connect to in order to obtain power. If no connection is required, use "none" in this field.

Validated by BusKeys.BusNme.

BussP1

First bus pin.

BussP2

Second bus pin.

Comments1

Comments field.

Comments2

Comments field.

10.3. Zrecord Table

This table is used to define a connection point to a CAMAC module. Connection points to modules are associated with DataRecs.

ZrecId

RecId of the DataRec this record is associated with.

Zpair

Wire pair number for the RecId.

PinA

First pin in the pair.

PinB

Second pin in the pair.

Zjack

Jack this connection is located in.

Comments1

Comments field.

Comments2

Comments field.

10.4. Trecord Table

This table is used to provide connection pairs between any two jacks in the interface without the use of data points.

Typically this is used where connections need to be made between two points in an interface, but there is no entry in the database that corresponds to the signal.

For example:

  1. If there are two interfaces associated with a single CAMAC crate, signals often need to be routed from one interface to the other through the trunk cable. In this case it is used to pass signals on the destination side of the jumper's connection to the device connector.

  2. It is used to make the shield connections for the device cables. In this case the destination connector is a ground block inside the interface and there is only one wire in the pair.

  3. In cases where signals must be passed from connector to another without involving CAMAC. This can happen when hardware interlocks need to be passed between devices.

The fields in the Trecord table are:

TRindex

Index number used to identify the record.

JackA

"Source" jack.

Validated by JackRec.JackNo.

JackB

"Destination" jack.

Validated by JackRec.JackNo.

PinA1

First "source" pin.

PinA2

Second "source" pin.

PinB1

First "destination" pin.

PinB2

Second "destination" pin.

ColorA

First wire color pin.

Validated by ColKeys.ColNme.

ColorB

Second wire color pin.

Validated by ColKeys.ColNme.

SigNameA

First signal name.

SigNameB

Second signal name.

Comments1

"Source" connection first comment field.

Comments2

"Source" connection second comment field.

Comments3

"Destination" connection first comment field.

Comments4

"Destination" connection second comment field.

11. CAMAC Interface Wiring Information Key Tables

These tables are used to validate fields of other tables in the database. These tables should not be modified by the user. The tables will only change if new functionality is added to AccelNET.

11.1. ColKeys Table

Wire Color Key table. This table is used to validate wire colors entered into RPrecord and Trecord color fields. The color value may be used to sort by wire color.

ColNme

Color name.

ColVal

An integer value for color name.

ColDesc

Comments field.

This is list of valid wire colors that may be entered into the color fields in the RPrecords and Trecord. All of the entries listed appear in the ColKeys table.

BK   

Black

BN

Brown

RD

Red

OR

Orange

YL

Yellow

GN

Green

BU

Blue

VI

Violet

GY

Gray

WH

White

n/a

None

SHLD

Shield

11.2. BusKeys Table

The CAMAC interface usually contains one or more power buses. They are used to provide power to drive relays and other such devices. Sometimes the bus is switched to provide interlocking functions. For example, in some machines the tank pressure switch controls power to a bus in the interface. The power from the switched bus is connected to the rotating shaft, gvm power status control, etc. If the tank is under vacuum, power is not applied to the bus. Even if the control system may have told the device to be on, it won't be. The BusKeys table allows the buses to be given names and incorporated in the wire lists.

Note

This table is slated for deprecation/obsolete status and will be replaced by JackRec, but is still in active use.

BusNme

Bus Name.

BusVal

An integer value for the bus name. This field is provided in order to allow an arbitrary sort by bus.

BusDesc

Comments field.

This is a list of common entries for RPrecord.Buss. All of the entries listed should appear in the BusKeys table.

none

No bus connection.

C24

Camac 24v pwr supply.

Nlk1

Interlock Bus 1.

Nlk2

Interlock Bus 2.

11.3. JkKeys Table

This table is used to validate connector types entered into JackRec.JackTypA and JackRec.JackTypB.

JKtype

Name of the jack type.

JKval

An integer value for the jack type. This field is provided in order to allow an arbitrary sort by jack type.

JKdesc

Comments field.

12. Report Usage

12.1. Invoking Reports

dbreport <report_type> <report_arg>

Alarms

List the interlock records.

CM

List the CAMAC modules.

key <arg>

List records of <arg> Key table. (e.g. RefKeys)

msg <arg>

List records of <arg> Message table. (e.g. MsgTbl)

Label

List major database fields, sorted by Label, Desc.

RecId

List records of the DataRec table sorted by RecId.

Module

List records of the DataRec table sorted by Module Address.

mb

List the database scaling coefficients.

lim

List the database spans and limits.

JackRec

List records of the JackRec table.

RPrecord

List records of the RPrecord table.

Zrecord

List records of the Zrecord table.

type

List valid values of <arg> for generating wiring reports. These values are contract dependent.

Example: 'C1I1' means Crate 1, Interface 1.

Buss <arg>

Generate Buss connection list.

Buss2 <arg>

Generate Buss2 connection list.

Rpanel <arg>

Generate rear panel to Z pin wiring list.

Zpanel <arg>

Generate Z pin to rear panel wiring list.

composite <arg>

Generate a composite of Buss, Buss2, Rpanel, and Zpanel wiring lists.

12.2. Printing Reports

Most reports generate a file with a name of the form <report_type>.lst where <report_type> is the argument to dbreport. All reports are stored in $LST, which can be expanded to /AccelNET/pg/$CONF/lst/. For example "Label.lst" is the report file from "dbreport Label". The report may be printed by using the command "lp <arg>" where <arg> is the name of the report file.

13. Report Formats

13.1. Label report

The Label report shows an overview the database. The report is sectioned by LabelRec entries and detailed by RefName.

Label

Device name (LabelRec.Label).

Name

Long device name (LabelRec.Name).

LabelRec Comments

Comments (LabelRec.Lcomm).

Ref

Integer value associated with the RefName (RefKeys.RefVal).

RefName

Parameter name (DescRec.RefName).

AttName

Long parameter name (RefKeys.RefAttNme).

Units

Physical units (DescRec.Units).

DataType

Data conversion key (DescRec.DataType).

CrtKey

Display format key (DescRec.CrtKey).

CtlKey

Device control key (DescRec.CltKey).

Owner

Name of the task that owns the record (DescRec.Owner).

ScaKey

Parameter scaling key (DescRec.ScaKey).

WpermD

Write permissions (DescRec.WpermD).

Message

Name of the Message List if DataType=Ldisp (MsgKeys.MsgNme).

SpanMin

Physical value that corresponds to the minimum binary value of the data point (DescRec.SpanMin).

SpanMax

Physical value that corresponds to the maximum binary value of the data point (DescRec.SpanMax).

PhyMin

Minimum physical value for write limit or read back limit checking (DescRec.PhyMin).

PhyMax

Maximum physical value for write limit or read back limit checking (DescRec.PhyMax).

Sz

Size of the binary data field (DescRec.Size).

Os

Offset into the data word from which to extract the binary data (DescRec.Offset).

DR

DRkey value (DescRec.DRkey).

Id

RecId of DataRec associated with this parameter (DescRec.Addr/DataRec.RecId).

DevType

Device type (DataRec.DevType).

DrvKey

Data acquisition driver name (DataRec.Driver).

C

CAMAC crate number (DataRec.Crate).

N

CAMAC slot number (DataRec.Slot).

ChNo

Module channel number (DataRec.ChanNo).

DT

DTkey value (DataRec.DTkey).

Desc Comments

Comments (DescRec.Comments).

13.2. RecId and Module report

The RecId and Module reports are the same information sorted two different ways. The RecId report is sorted by DataRec.RecId in ascending order. The Module report is sorted by Driver, C, N, DevType, ChNo in ascending order.

Both forms of the report are a cross reference listing showing which parameters (DescRecs) in the database are associated with data acquisition channels.

RecId

RecId (DescRec.Addr/DataRec.RecId).

DT

DTkey value (DataRec.DTkey).

DrvKey

Data acquisition driver name (DataRec.Driver).

C

CAMAC crate number (DataRec.Crate).

N

CAMAC slot number (DataRec.Slot).

ChNo

Module channel number (DataRec.ChanNo).

Sz

Size of the binary data field (DescRec.Size).

Os

Offset into the data word from which to extract the binary data (DescRec.Offset).

DevType

Device type (DataRec.DevType).

Label

Label of the parameter (DescRec.Label).

RefName

RefName of the parameter (DescRec.RefName).

AttName

Long name associated with the RefName (RefKeys.RefAttNme).

13.3. JackRec report

This is a listing of all of the jack numbers in the system.

JackNo

Jack number (JackRec.JackNo).

JackTypA

Jack type for end A (JackRec.JackTypA).

JackTypB

Jack type for end B (JackRec.JackTypB).

13.4. RPrecord report

This is a listing of all of the records in the RPrecord table organized by jack number and pair number.

Jack

Jack number (JackRec.JackNo).

Pr

Pair number in the jack.

Pin

For each record there are two possible pin numbers listed, one above the other. The top one is the first pin in the pair (RPrecord.PinA). The bottom one is the second pin in the pair (RPrecord.PinB).

Color

For each record there are two possible colors listed, one above the other. The top one is the first color in the pair (RPrecord.ColorA). The bottom one is the second color in the pair (RPrecord.ColorB).

SigName

For each record there are two possible signal names listed, one above the other. The top one is the first signal name in the pair (RPrecord.SigNameA). The bottom one is the second signal name in the pair (RPrecord.SigNameB).

BussP1

First side of the buss connection, if needed (RPrecord.BussP1).

Buss

Name of the bus this signal is passed through, if needed (RPrecord.Buss).

BussP2

Second side of the buss connetion, if needed (RPrecord.BussP2).

Label, RefName

Name of the parameter this connection is associated with (DescRec.Label, DescRec.RefName).

Comments

Comments (RPrecord.Comments1/RPrecord.Comments2).

13.5. Zrecord report

This is a listing of all of the records in the Zrecord table organized by RecId and pair number.

RecId

RecId of the DataRec this record is associated with (Zrecord.ZRecId).

DT

DTkey value (DataRec.DTkey).

Driver

Data acquisition driver name (DataRec.Driver).

C

CAMAC crate number (DescRec.Crate).

N

CAMAC slot number (DataRec.Slot).

ChNo

Module channel number (DataRec.ChNo).

DevType

Device Type (DataRec.DevType).

Jack

Jack number (Zrecord.Zjack).

Pr

Pair number of the RecId (Zrecord.Zpair).

Pin

For each record there are two possible pin numbers listed, one above the other. The top one is the first pin in the pair (Zrecord.PinA). The bottom one is the second pin in the pair (Zrecord.PinB).

Comments

Comments (Zrecord.Comments1, Zrecord.Comments2).

13.6. Rpanel report

This is a listing of all of the connections in the interfaces organized from the device connectors to the Z connectors or other device connectors. This report is customized for each contract.

If a connection is made from one rear panel connector to another (one use of the Trecord), the connection will appear twice in the listing. Once from the first connector, again from the second connector.

At the start of each new connector, the page is ejected and the jack number and jack type are printed.

Label, RefName

If the record being listed is a RPrecord, the parameter name from the database is listed on the first line of the signal pair (DescRec.Label, DescRec.RefName).

If the record being listed is a Trecord, the Comments1 and Comments2 fields are listed on the first line and the Comments3 and Comments4 fields are listed on the second line.

SigName

For each record there are two possible signal names listed, one above the other. The top one is the first signal name in the pair based on the type of record (RPrecord.SigNameA or Trecord.SigNameA). The bottom one is the second signal name in the pair based on the type of record (RPrecord.SigNameB or Trecord.SigNameB).

Pin

For each record there are two possible pin numbers listed, one above the other. The top one is the first pin in the pair based on the type of record (RPrecord.PinA, Trecord.PinA1, or Trecord.PinB1). The bottom one is the second pin in the pair based on the type of record (RPrecord.PinB, Trecord.PinA2, or Trecord.PinB2).

Color

For each record there are two possible colors listed, one above the other. The top one is the first color in the pair based on the type of record (RPrecord.ColorA or Trecord.ColorA). The bottom one is the second color in the pair based on the type of record (RPrecord.ColorB or Trecord.ColorB).

Pin

First bus pin, if used (RPrecord.BussP1).

Buss

Bus the pair is routed through, if used (RPrecord.Buss).

Pin

Second bus pin, if used (RPrecord.BussP2).

Z conn

Jack number of the connector this pair is connected to (Zrecord.Zjack).

Pin

For each record there are two possible pin numbers listed, one above the other. The top one is the first pin in the pair based on the type of record (Zrecord.PinA, Trecord.PinA1 or Trecord.PinB1). The bottom one is the second pin in the pair based on the type of record (Zrecord.PinB, Trecord.PinA2, or Trecord.PinB2).

RecId

RecId of the DataRec this entry is associated with (DataRec.RecId).

C

CAMAC crate number (DataRec.Crate).

N

CAMAC slot number (DataRec.Slot).

Ch

Module channel number (DataRec.ChNo).

Os

Offset into the data word from which to extract the binary data (DescRec.Offset).

Comments

For each record there are two comments listed, one above the other. The top one is the first comment field, depending on the type of record (RPrecord.Comments1 or Trecord.Comments3). The bottom one is the second comment field, depending on the type of record (RPrecord.Comments2 or Trecord.Comments4).

13.7. Zpanel report

This listing is similar the Rpanel report except that it is from the Z connector point of view. This report is customized for each contract.

Z conn

Jack number of the Z connector this pair is connected to (Zrecord.Zjack).

Pin

There are two possible pin numbers listed for each record, one above the other. The top one is the first pin in the pair (Zrecord.PinA). The bottom one is the second pin in the pair (Zrecord.PinB).

Color

There are two possible colors listed for each record, one above the other. The top one is the first color in the pair (RPrecord.ColorA). The bottom one is the second color in the pair (RPrecord.ColorB).

Pin

First bus pin, if used (RPrecord.BussP1).

Buss

Bus the pair is routed through, if used (RPrecord.Buss).

Pin

Second bus pin, if used (RPrecord.BussP2).

RP conn

Jack number of the connector this pair is connected to (RPrecord.RPjack).

Pin

There are two possible pin numbers listed for each record, one above the other. The top one is the first pin in the pair (RPrecord.PinA, Trecord.PinA1, or Trecord.PinB1). The bottom one is the second pin in the pair (RPrecord.PinB, Trecord.PinA2, or Trecord.PinB2).

Label, RefName

If the record being listed is a RPrecord, the parameter name from the database is listed on the first line of the signal pair (DescRec.Label, DescRec.RefName).

If the record being listed is a Trecord, the Comments1 and Comments2 fields are listed on the first line and the Comments3 and Comments4 fields are listed on the second line.

SigName

There are two possible signal names listed for each record, one above the other. The top one is the first signal name in the pair based on the type of record (RPrecord.SigNameA or Trecord.SigNameA). The bottom one is the second signal name in the pair based on the type of record (RPrecord.SigNameB or Trecord.SigNameB).

RecId

RecId of the DataRec this entry is associated with if it is a RPrecord (DataRec.RecId).

Pr

Pair number of the Zrecord associated with this entry if it is a RPrecord (Zrecord.Zpair).

C

CAMAC crate number (DataRec.Crate).

N

CAMAC slot number (DataRec.Slot).

Ch

Module channel number (DataRec.ChNo).

Os

Offset into the data word from which to extract the binary data (DescRec.Offset).

Comments

If the record being processed is a RPrecord, then RPrecord.Comments1 and RPrecord.Comments2 are used. Otherwise Zrecord.Comments3 and Zrecord.Comments4 are used.

14. BuildMB Process

After the database is entered, the data conversion coefficients for all of the data points must be calculated. This is done by invoking the BuildMB family of programs.

The buildmb script should be run after the initial creation of a new database, as well as when one of the following has been changed in the DescRec table: SpanMin, SpanMax, DataType, Size, DRkey, MBconvKey, or MBsetIncKey. If MBconvKey is not set to 'Y', buildmb will ignore the record when calculating M and B. If MBsetIncKey is not set to 'Y', buildmb will ignore the record when calculating IncVal.

Invoke a buildmb function by typing the following (as user 'postgres'):

buildmb <arg>

Lin

Build coefficients for records with DataType = 'Lin'.

NLin

Build coefficients for records with DataType = 'NLin'.

Alog

Build coefficients for records with DataType = 'Alog'.

NAlog

Build coefficients for records with DataType = 'NAlog'.

CVG

Build coefficients for records with DataType = 'CVG'.

CVG_275

Build coefficients for records with DataType = 'CVG_275'.

CCVG

Build coefficients for records with DataType = 'CCVG'.

PVG

Build coefficients for records with DataType = 'PVG'.

TCG

Build coefficients for records with DataType = 'TCG'.

IGCgp

Build coefficients for records with DataType = 'IGCgp'.

LinSetInc

Set IncVals for records with DataType = 'Lin'. See rules below.

NLinSetInc

Set IncVals for records with DataType = 'NLin'. See rules below.

all

Invokes all of the arguments.

Here is a list that explains, by DataType, how buildmb treats a record.

Lin

Constructs coefficients for all cases. IncVal is set to the value of M for records where DataType = 'Lin' and Owner = 'CrtTsk'.

NLin

Constructs coefficients for all cases. IncVal is set to the value of M for records where DataType = 'NLin' and Owner = 'CrtTsk'.

Alog

Constructs coefficients for all cases. IncVal is not set.

NAlog

Constructs coefficients for all cases. IncVal is not set.

BCD

Not supported. When used, coefficients should be entered manually, usually with M = 1.0 and B = 0.0.

TCG *

Sets M and B to the correct values to provide a scaler between 0 and 10 for the conversion routine. IncVal is not set.

CVG *

Sets M and B to the correct values to provide a scaler between 0 and 10 for the conversion routine. IncVal is not set.

CVG_275 *

Sets M and B to the correct values to provide a scaler between 0 and 10 for the conversion routine. IncVal is not set.

CCVG *

Sets M and B to the correct values to provide a scaler between 0 and 10 for the conversion routine. IncVal is not set.

PVG *

Sets M and B to the correct values to provide a scaler between 0 and 10 for the conversion routine. IncVal is not set.

Ldisp

Not supported. When used, coefficients should be entered manually, usually with M = 1.0 and B = 0.0.

Raw

Not supported. When used, coefficients should be entered manually, usually with M = 1.0 and B = 0.0.

IGCgp *

Sets M and B to the correct values to provide a scaler between -10 and 0 for the conversion routine. IncVal is not set.

AlinLog

Constructs coefficients for all cases. IncVal is not set.

NAlinLog

Constructs coefficients for all cases. IncVal is not set.

DataTypes marked with an * are handled by the runtime system in the following way: When the data(X) is processed, M and B are applied to scale the value between the desired range (Y = MX + B). The scaled value is then sent to what is called a piece table. A piece table is a predefined set of steps/ranges. Each range contains an internal set of M and B values. The internal set of M and B are applied using the same equation to the scaled value to obtain the final physical value.

15. Table Translation

The database must be converted to the correct format before it can be used by the control system. The format conversion is done by a family of programs that all have roughly the same structure.

The table to be converted is extracted from the Postgres database by a SQL query and placed in a file. When the table is extracted, a filter is applied to substitute integer values for names on certain fields. For example, in the DescRec table, the name in the DataType field is substituted for the integer value known by the runtime system. In the above example, the Dkeys table is considered an immutable table. This means that it cannot/should not be changed. The table is in place to prevent bad entries in database. The actual integer values are defined in the filter/AccelNET source code. The Dkeys table will only be changed when there is a change in AccelNET that affects it. The result of this is an ASCII file where each line contains a number of fields separated by a field separator (usually a vertical bar '|') and terminated by a linefeed.

A program then translates the created file into the record structure used by the control system. This process involves steps such as converting strings of characters into floating point numbers. The program that does the translation is specifically tailored for the table in question, producing a new result file.

It is presently arranged so that the extracted Postgres tables occupy a directory. The SQL scripts share the directory with the extracted files along with a shell script that is used to translate the tables.

The table translation programs, invoked from a shell script, are in a separate directory. They read from the directory containing the extracted files and write into another directory.

16. Using SQL

As you become familiar with the fields of the database and how to manipulate them through the data entry screens you may want to learn to use the tools the Postgres database manager provides for manipulation of the database.

SQL is a programming language that allows records to be added, deleted, and modified to/from the database. It makes adding large quantities of records (for example, if a new beam line is added to the system) very easy to do. Consult the Postgres manuals for more information.

All of the reports described in this manual are generated using SQL, some of the UNIX tools, and a report written in C. Examine the report scripts provided with the system for examples.

For more information on SQL, visit http://www.postgres.org/docs/ as well as other online or printed documentation.

17. Database Construction Tools

To help facilitate construction and maintenance of the database a collection of tools have evolved over time. This collection is not guaranteed to be complete. It is provided as a convenience to the customer.

Using the tools requires a working knowledge of the database design, SQL, and the UNIX shell. There are many existing script files to serve as examples.



[3] http://www.postgres.org/

[4] SQL - Structured Query Language