The SWAIT record is nearly obsolete, because most of its once-unique capabilities are now included in the calcout record. The only thing the calcout record does not (yet?) do is to wait for completion of the processing started by its output link before executing its forward link. The SWAIT record, is derived from the Calc record with the following additional features:
scan parameters
read parameters
expression-related parameters
desired output parameters
write parameters
operator parameters
monitor parameters
run-time and simulation mode parameters
I/O Intr
enables this feature for the record instance as a whole, and the fields INAP - INLP
control the behavior of each input link INPA - INPL, respectively. Thus, if
.SCAN == "I/O Intr" and .INAP == "Yes", then the record will process every time
a new value is posted for the field specified by the input INPA.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor |
---|---|---|---|---|---|---|---|
INAP | Input A ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INBP | Input B ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INCP | Input C ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INDP | Input D ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INEP | Input E ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INFP | Input F ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INGP | Input G ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INHP | Input H ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INIP | Input I ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INJP | Input J ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INKP | Input K ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
INLP | Input L ProcessOnChange | Menu | Yes | No | Yes | Yes | Yes |
Note: Because of the event-driven nature
of this feature, it is quite easy to configure a database that results in
an infinite loop which uses all available CPU time. If the SWAIT record is
set to process as a result of a channel changing and the processing of the
SWAIT record causes the channel to change again, an infinite loop will result.
This is not by itself a bad thing, but if there is no throttle on the rate at
which the SWAIT record causes itself to process, its activity will use all
of the available CPU time. The symptom will be an apparent loss of all channel
access connections (lower priority tasks) even though the shell responds normally.
Using the spy vxWorks utility will confirm the predicament by showing
0% free CPU time. If the condition persists for more than a few tens of seconds,
some system queue is likely to overflow, and a crate reboot may be required to recover.
You can safely use the SWAIT record in such a self-sustaining loop by setting the record's output-delay (.ODLY) field to, say, .02 (seconds). The delay value must be larger than a single system-clock tick (typically, .01667) or it will have no effect. |
The Application Developer's Guide explains how the rest of these fields are used.
These input "links" can be modified at run time. These are ASCII fields which have a special processing routine attached to them. When changed, the routine is called. The record will use the new link the next time the record is processed.
A consequence of reassignable links is that one cannot force the processing of any specified records prior to retrieving the data from them (i.e. there is no .PP flag). This should be considered when designing a database using the SWAIT record.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor |
---|---|---|---|---|---|---|---|
INAN | Input Link A Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INBN | Input Link B Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INCN | Input Link C Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INDN | Input Link D Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INEN | Input Link E Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INFN | Input Link F Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INGN | Input Link G Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INHN | Input Link H Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
ININ | Input Link I Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INJN | Input Link J Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INKN | Input Link K Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
INLN | Input Link L Name | STRING[40] | Yes | 0 | Yes | Yes | Yes |
The CALC field is actually converted to opcode and stored as a postfix expression, in the RPCL field. It is this expression which is actually used to calculate VAL. CALC can be changed at run-time, and the special record routine calls a function to convert it to the postfix expression. The flag field, CLCV, indicates whether or not the expression is a valid one. It will be true (non-zero) if the expression is invalid, in which case an error message is generated.
The postfix expression is evaluated most efficiently during run-time. The range of expressions supported by the calculation record are separated into operands, algebraic operations, trigonometric operations, relational operations, logical operations, parentheses and commas, and the question mark operator.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
CALC | Calculation | DBF_STRING | Yes | 0 | Yes | Yes | Yes | Yes |
RPCL | Reverse Polish | DBF_NOACCESS | No | 0 | No | No | N/A | No |
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor |
---|---|---|---|---|---|---|---|
A | Input Values A | DOUBLE | No | 0 | Yes | Yes/No | Yes |
B | Input Values B | DOUBLE | No | 0 | Yes | Yes/No | Yes |
C | Input Values C | DOUBLE | No | 0 | Yes | Yes/No | Yes |
D | Input Values D | DOUBLE | No | 0 | Yes | Yes/No | Yes |
E | Input Values E | DOUBLE | No | 0 | Yes | Yes/No | Yes |
F | Input Values E | DOUBLE | No | 0 | Yes | Yes/No | Yes |
G | Input Values G | DOUBLE | No | 0 | Yes | Yes/No | Yes |
H | Input Values H | DOUBLE | No | 0 | Yes | Yes/No | Yes |
I | Input Values I | DOUBLE | No | 0 | Yes | Yes/No | Yes |
J | Input Values J | DOUBLE | No | 0 | Yes | Yes/No | Yes |
K | Input Values K | DOUBLE | No | 0 | Yes | Yes/No | Yes |
L | Input Values L | DOUBLE | No | 0 | Yes | Yes/No | Yes |
The comma is supported when used to separate the arguments of a binary function.
(condition)? True result : False result
A + B
(A + B) < (C + D)
(A+B)<(C+D)?E:F
(A+B)<(C+D)?E
A&B
In the desired output location (DOLN) field, the user specifies a link from which the record will retrieve the value that it writes (if the DOPT field specifies DOLD). The value is retrieved and placed in the desired output location data field (DOLD). If DOLN specifies no link, a flag field indicates that the DOLN field is invalid. When the DOLN field is invalid, the value of DOLD can be set via dbPuts at run-time.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
DOLN | Desired Output Location | STRING [40] | Yes | Null | Yes | Yes | No | No |
DOLD | Desired Output Location Data | DOUBLE | Yes | 0 | Yes | Yes | Yes | No |
Use VAL
in the
Data Option (DOPT) field, then the value in VAL will be written. If the user specifies
Use DOL
,
the value retrieved from the DOLN link and contained in the DOLD field will
be written. The DOPT field can be changed during run-time.The Output Link Name (OUTN) specifies where the record is to write the output value.
The SWAIT record does not have to write its output every time the record processes. This allows "downstream" processing of records to be done conditionally. The record has output execution options which can be specified in the OOPT field. These options are as follows:
Every Time
On Change
When Zero
When Non-zero
Transition To Zero
Transition To Non-zero
Never
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
OOPT | Output Option | MENU | Yes | 0 | Yes | Yes | No | No |
OUTN | Output Link Name | STRING [40] | Yes | Null | Yes | Yes | No | No |
DOPT | Data Option | MENU | Yes | 0 | Yes | Yes | No | No |
OEVT | Output Event | USHORT | Yes | 0 | Yes | Yes | No | No |
The HOPR and LOPR fields set the upper and lower display limits for the VAL field. The
get_graphic_double
retrieves these fields.
The PREC field determines the floating point precision with which to display VAL. It is used whenever the
get_precision
record support routine is called.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
HOPR | High Operating Range | FLOAT | Yes | 0 | Yes | Yes | No | No |
LOPR | Low Operating Range | FLOAT | Yes | 0 | Yes | Yes | No | No |
PREC | Display Precision | SHORT | Yes | 0 | Yes | Yes | No | No |
NAME | Record Name | STRING [29] | Yes | 0 | Yes | No | No | No |
DESC | Description | STRING [29] | Yes | Null | Yes | Yes | No | No |
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
ADEL | Archive Deadband | DOUBLE | Yes | 0 | Yes | Yes | No | No |
MDEL | Monitor, i.e. value change, Deadband | DOUBLE | Yes | 0 | Yes | Yes | No | No |
The OVAL field is used to implement monitors on the VAL field. If VAL differs from OVAL (taking into account the deadband) then monitors for VAL are triggered.
The LA-LL fields are used to implement monitors for the A-L field, the fields which hold the values retrieved from the input links. They hold the values retrieved from INPA-INPL the last time the record was processed. For instance, when A, the current value retrieved from INPA, does not equal LA, the last value retrieved, then monitors for A are triggered.
The DOLV and CLCV are flag fields. The DOLV flag is used to indicate if the process variable specified in the Desired Output Location (DOLN) field is a valid name. If it is not, the desired output value is not retrieved from DOLN. The CLCV flag is used to indicate if the SWAIT record's CALC expression is a mathematically valid one.
The CBST field contains a pointer to a record private structure. It is not of concern to the user.
Field | Summary | Type | DCT | Initial | Access | Modify | Rec Proc Monitor | PP |
---|---|---|---|---|---|---|---|---|
CBST | Callback Structure | NOACCESS | No | Null | No | No | No | No |
OVAL | Old Value | DOUBLE | No | 0 | Yes | Yes | No | No |
DOLA | Desired Output Location Address | NOACCESS | No | Null | No | No | No | No |
DOLV | Desired Output Location Valid | LONG | No | 0 | Yes | Yes | Yes | No |
ALST | Archive Last Value | DOUBLE | No | 0 | Yes | No | No | No |
MLST | Monitor Last Value | DOUBLE | No | 0 | Yes | No | No | No |
CLCV | Calculation String Valid | LONG | No | 0 | Yes | Yes | Yes | No |
LA | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LB | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LC | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LD | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LE | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LF | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LG | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LH | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LI | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LJ | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LK | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |
LL | Previous Input | DOUBLE | No | 0 | Yes | Yes | No | No |