b0400df - R-High Level Batch Language (HLBL) User's Guide
b0400df - R-High Level Batch Language (HLBL) User's Guide
b0400df - R-High Level Batch Language (HLBL) User's Guide
*B0400DF*,*R*
B0400DF, Rev R
September 2019
www.schneider-electric.com
Legal Information
The Schneider Electric brand and any trademarks of Schneider Electric SE and its subsidiaries referred to in this guide
are the property of Schneider Electric SE or its subsidiaries. All other brands may be trademarks of their respective
owners.
This guide and its content are protected under applicable copyright laws and furnished for informational use only. No
part of this guide may be reproduced or transmitted in any form or by any means (electronic, mechanical,
photocopying, recording, or otherwise), for any purpose, without the prior written permission of Schneider Electric.
Schneider Electric does not grant any right or license for commercial use of the guide or its content, except for a non-
exclusive and personal license to consult it on an "as is" basis. Schneider Electric products and equipment should be
installed, operated, serviced, and maintained only by qualified personnel.
As standards, specifications, and designs change from time to time, information contained in this guide may be subject
to change without notice.
To the extent permitted by applicable law, no responsibility or liability is assumed by Schneider Electric and its
subsidiaries for any errors or omissions in the informational content of this material or consequences arising out of or
resulting from the use of the information contained herein.
Contents
Figures................................................................................................................................... vii
Tables..................................................................................................................................... ix
Preface.................................................................................................................................... xi
Contents .................................................................................................................................. xi
Audience .................................................................................................................................. xi
Revision Information ............................................................................................................... xi
Reference Documents .............................................................................................................. xi
For More Information ............................................................................................................. xii
2. Sequence Language.......................................................................................................... 19
Algorithm Structure ................................................................................................................ 19
Heading ............................................................................................................................. 19
Subroutines ........................................................................................................................ 20
Standard Block Exception Handlers (SBXs) ....................................................................... 26
Main Statement Section ..................................................................................................... 26
iii
B0400DF – Rev R Contents
4. HLBL Statements............................................................................................................ 57
Sequence Block Statements ..................................................................................................... 57
Statement Syntax .................................................................................................................... 57
iv
Contents B0400DF – Rev R
v
B0400DF – Rev R Contents
vi
Figures
1-1. Processing Order Within a Scheduled BPC ................................................................. 11
vii
B0400DF – Rev R Figures
viii
Tables
1-1. Operational Modes ....................................................................................................... 6
1-2. Sequence States ............................................................................................................. 9
1-3. Compound Sequence State ......................................................................................... 11
2-1. Special Symbols ........................................................................................................... 29
3-1. Preprocessor Commands ............................................................................................. 47
3-2. Include File Examples ................................................................................................. 51
3-3. Sequence Compiler Limits .......................................................................................... 55
ix
B0400DF – Rev R Tables
x
Preface
High Level Batch Language (HLBL) is a PASCAL type language that has been designed to
implement process control strategies. HLBL is used to build sequence control strategies and
structured text items that are needed for sequential process operations.
This document describes the High Level Batch Language used to build sequence blocks and
Structured text (ST) items. It describes the HLBL language, HLBL language preprocessor,
sequence language and compiler, and sequence language error codes. Sequence language is a syn-
onym for HLBL.
Contents
The document is divided into the following chapters:
♦ Chapter 1 “Sequence Logic”
♦ Chapter 2 “Sequence Language”
♦ Chapter 3 “HLBL Preprocessor and Compiler”
♦ Chapter 4 “HLBL Statements”
♦ Appendix A “Sequence Control Error Messages”.
Audience
This document is intended for anyone who needs to use HLBL to build a process control system
to control their process. In particular this document describes the language needed to build
sequence blocks. It is recommended that you be familiar with process control engineering func-
tions and Integrated Control blocks.
Revision Information
For this revision of the document (B0400DF-R), these changes were made:
Chapter 1 “Sequence Logic”
♦ Updated “Operational Error SBXs” on page 12.
Chapter 2 “Sequence Language”
♦ Updated information on the expression of integers in “Data Types” on page 27.
♦ Added item #5 to “Literals” on page 33.
Reference Documents
These documents present additional and related information:
♦ Control Processor 270 (CP270) and Field Control Processor 280 (CP280) Integrated
Control Software Concepts (B0700AG)
♦ Integrated Control Block Descriptions (B0193AX)
xi
B0400DF – Rev R Preface
♦ Integrated Control Block Descriptions for FOUNDATION fieldbus Specific Control Blocks
(B0700EC)
Most of these documents are available on the Foxboro DCS Electronic Documentation media
(K0174MA). The latest revisions of each document are also available through our Global Cus-
tomer Support at https://pasupport.schneider-electric.com.
xii
1. Sequence Logic
This chapter covers sequence logic control: sequential control block types and their various
states, sequence processing, and SBX programming.
Sequence logic control complements continuous and ladder logic control with regulatory feed-
back applications at the equipment control level. For example, the sequential control software can
be used to supervise a sequence of activities such as filling a tank, blending its contents, and drain-
ing the tank.
Whereas most continuous control blocks have fixed algorithms, sequence control blocks have
user-defined algorithms. Sequential control software enables you to:
♦ Define a sequence of events
♦ Monitor process conditions, taking corrective action when needed
♦ Time events
♦ Manipulate any compound or block parameter or any shared variable
♦ Output messages to any logical device or to the Historian.
To introduce sequential control to a control strategy, you have to define sequential control blocks
and add them to compounds.
Sequence logic is created with the Sequence Language, a subset of the High Level Batch Language
(HLBL). The Sequence Language is a high level programming language resembling Pascal, but
specifically geared toward creating process control strategies.
Sequence Block
Three Sequence block types exist:
♦ Independent (IND)
♦ Dependent (DEP)
♦ Exception (EXC).
IND and EXC blocks run independently of other Sequence blocks in the same compound. DEP
blocks pause when an EXC block in the same compound is active.
This relationship between DEP and EXC blocks allows you to separate a sequence algorithm for
handling normal conditions from a sequence algorithm for handling alarm conditions. For exam-
ple, if a Monitor (MON) block detects an alarm condition and activates an EXC block to take
1
B0400DF – Rev R 1. Sequence Logic
corrective action, the DEP block pauses until the corrective action is finished. When the EXC
block is done, the DEP block can finish executing its sequence algorithm.
A Sequence block contains a user-defined sequence algorithm. You can use a Sequence block to:
♦ Manipulate parameters and shared variables
♦ Change the flow of execution based on the state of parameters and shared variables
♦ Activate other Sequence and Monitor blocks
♦ Measure time
♦ Report to the Historian
♦ Send information to logical devices, such as printers
♦ Call a subroutine and pass arguments, if any
♦ Make calculations
♦ Simulate a process for testing purposes.
A Sequence block is composed of:
♦ Standard Parameters
♦ Block Type Identification
♦ Symbolic Constants
♦ Local Block Variables
♦ User-Labels
♦ Include Files
♦ Subroutines (variables and statements)
♦ Standard Block Exception Handlers
♦ Block Statements, grouped into Steps.
Each statement, whether in the block’s main section, in its subroutines, or in its stan-
dard block exception handlers, may optionally have a label.
Standard parameters show block operation details and allow you to control block operation and
connect the block in a control strategy that includes continuous blocks, ladder logic blocks, and
other sequence blocks.
Block Type identification is a small block of information at the start of the sequence language file
where you provide data such as block name, type, creator, revision level and date.
Symbolic constants are identifiers which represent constant values. They are used to indicate or
illustrate the meaning of such values. The constants are an aid in compiling sequence blocks.
Changing the value of a constant in an include file does not affect currently running or already
compiled sequence blocks automatically. After such a change, the blocks containing source code
in which the constants are used have to be recompiled to effect the change.
Block variables are local and are not accessible from outside the block. You define their number
and their size. There are no user-labels for local block variables. Refer to them by their declared
names. You can use them in any HLBL expression and you can assign them to each other, to user
(array) parameters, and to external references.
Local block variables can be any of the following types:
♦ Boolean and Boolean array
2
1. Sequence Logic B0400DF – Rev R
B = Boolean
I = Long Integer
R = Real
S = String of 80 Characters
S6 = String of 6 Characters
S12 = String of 12 Characters
User-labeled parameters can be referenced by the Sequence block’s user-defined algorithm. There
are a fixed number of each of the following types: real, long integer, Boolean, and string. These
types, except string and the data store arrays, can be linked with parameters in other blocks and
compounds and shared variables. The strings and data store arrays are settable but not connect-
able.
The standard parameters, which may be user-labelled, are:
3
B0400DF – Rev R 1. Sequence Logic
Standard and user-labeled parameters are described in the Integrated Control Block Descriptions
(B0193AX) document.
An include file can be any set of HLBL statements. Use include files to define specific constructs
such as sophisticated WAIT loops or complicated expressions of a set of parameters, or to define
objects with a global scope such as symbolic constants, subroutines, or standard block exception
handlers. You cannot compile include files separately.
The subroutine allows you to specify a general piece of control logic just once and apply it as often
as needed in the block algorithm. A subroutine is a sequence of HLBL user-defined statements
that can be called from the sequence block’s main code or from another subroutine. Subroutines
can use any HLBL statement except for standard block exception handlers.
You can use a user-defined number of arguments to parameterize a subroutine. The data types of
these arguments have to be one of the data types supported in HLBL for block parameters and
local variables.
You cannot install a sequence subroutine in a station as an independent entity and you cannot
access it from outside the sequence block in which it is installed.
An Independent, Dependent, or Exception block may have subroutines. However, subroutines are
not supported in the Monitor and Timer blocks.
A Standard Block Exception Handler (SBX) is a user-specified section of HLBL statements that
allows the sequence block to react to an operational error during automatic execution or to an
outside interruption during normal block operation.
There are five events for which SBXs can be specified. Two are error handling SBXs:
♦ User-errors (OP_ERR between 2000 and 3000)
♦ System errors (every other error).
The other three are state change SBXs:
♦ Switch to Inactive
♦ Switch to Manual
♦ Switch to Paused.
Sequence language statements define the sequential control algorithm, as specified by the user.
Monitor Block
A Monitor (MON) block contains up to 16 user-defined Boolean expressions called cases. The
result of the evaluation of a monitor case is stored in the associated Boolean output parameter.
When one of the cases evaluates to true, the MON activates a sequence block (EXC, DEP, IND,
or MON). In this way, up to 16 blocks can be activated from the MON block.
A Monitor block is composed of:
♦ Standard Parameters
♦ Blocktype Identification
4
1. Sequence Logic B0400DF – Rev R
♦ Symbolic Constants
♦ User Labels
♦ Monitor Cases (up to 16).
User-labeled parameters can be referenced by the Monitor block’s user-defined algorithm. There
are a fixed number of each of the following types: real, long integer, and Boolean. Each of the
types can be linked with parameters in other blocks and compounds and shared variables.
Standard and user-labeled parameters are listed and described in the Integrated Control Block
Descriptions (B0193AX) document.
A monitor case consists of a monitor condition and an optional activation request that is per-
formed when the condition is true.
Example:
0001 WHEN level_hi DO :TANK_1:HI_LEVEL_EXC
♦ The case number is 0001.
♦ The condition is “level_hi”, where level_hi is a user-labeled parameter.
♦ The request is “DO :TANK_1:HI_LEVEL_EXC”. “HI_LEVEL_EXC” is the block name
for a sequence block in the compound “TANK_1”. This block will be activated when
the condition “WHEN level_hi” is evaluated true.
♦ You see TRIPPD on the faceplate.
♦ The block activates again if the case is still true upon completion.
♦ BOnnnn output is set to correspond to the active case.
♦ BOnnnn and TRIPPD stay set as long as activated block is active, even if the block
goes to manual.
♦ ACTPAT parameter determines the active patterns.
Timer Block
A Timer (TIM) block keeps track of time while control strategies are executed. It is composed of
standard parameters and four timers. Sequence language statements are not contained in the TIM
blocks.
Standard parameters show block operation details and allow you to control block operation.
A timer is composed of a real and a Boolean parameter. The Boolean parameter value determines
whether the real parameter is updated or not when the block is processed. When the Boolean
value is true, the real parameter is updated. When the Boolean value is false, the real parameter is
not updated.
The TIM block is processed when the compound in which it resides is On and the block is in
Auto. When a TIM block is processed, timers that have been started are updated every scheduled
Basic Processing Cycle (BPC). Timers are started by an external source, such as a statement in a
Sequence block.
5
B0400DF – Rev R 1. Sequence Logic
In addition to the Application states, the sequential control blocks have the following Sequence
states: Active, Inactive, Paused, and Tripped. Tripped applies only to the Monitor block. The set
of operational modes for sequential blocks include:
The Sequence states and the Application states control sequential control block algorithm execu-
tion and the operational state of block outputs.
Application States
The Application states, Auto, Semi-Auto, and Manual, control the operational state of a block’s
outputs. In conjunction with the Sequence states, they also control sequential control block algo-
rithm execution.
The Application state is determined by the value of the block’s MA parameter. When MA is true,
the block is in the Auto state. When MA is false, the block is in the Manual state.
Another block parameter, RSTMA, controls the value of the MA parameter when the compound
changes from Off to On. When RSTMA is 0, MA becomes false; when RSTMA is 1, MA
becomes true; when RSTMA is 2, MA does not change upon the compound switch. You set the
value of RSTMA during block configuration.
Auto State
In the Auto state, a block’s output parameters are secured. This means that the block algorithm is
responsible for updating the output parameters. External sources (other blocks and applications)
cannot write values to block output parameters.
Sequential control block algorithms are processed as follows in the Auto state:
♦ TIM block timers that have been started are updated once every scheduled BPC. A
timer is started with a START_TIMER statement in an IND, DEP, or EXC block.
♦ MON block cases are evaluated each scheduled BPC. If a case trips, it may lead to
activation of an EXC block. If the EXC block activated is remote, tripping and untrip-
ping may need several BPCs to finish.
♦ IND, DEP, and EXC blocks process the number of statements specified by the block’s
BPCSTM parameter each scheduled BPC. When a statement requiring suspension
such as WAIT or WAIT UNTIL executes, fewer statements may be processed than
the number specified by BPCSTM.
Since Sequence block algorithms vary in length, a block may execute completely in one BPC or it
may need several BPCs to execute completely.
6
1. Sequence Logic B0400DF – Rev R
Once the statements have been executed, the Sequence block is no longer processed unless a state-
ment in the user-algorithm causes it to repeat.
If the sequence block contains state change logic, that logic will be executed if the block switches
from the Active/Auto mode to the Inactive, Manual or Paused state. The logic for the state
changes are user-defined in SBXs 3, 4, and 5.
The order of statement execution can be altered while in the Auto state. An operator, at a user-
defined or default display, can redirect statement execution to a new start location by writing the
desired statement number to the STMRQ parameter.
Semi-Auto State
In Semi-Auto (or Step mode), the sequence block executes only the HLBL statements that belong
to a particular step. Statement execution stops when a step boundary is passed. Steps can be
requested in any order, at a user-defined or default display, by writing the desired step number to
the STEPRQ parameter. The block is divided into steps by means of the step labels in HLBL.
If the sequence block contains state change logic, the corresponding logic will be executed if the
block switches from the Active/Step mode to the Inactive, Manual, or Paused state.
The logic for the state changes are user-defined in SBXs 3, 4, and 5.
Manual State
In the Manual state, output parameters are not secured. This means that external sources (other
blocks and applications) can write values to the block’s output parameters. Unlike continuous
control blocks, sequential control blocks may have their own statements write to their own output
parameters while the block is in Manual.
Sequential control block algorithms are processed as follows in the Manual state:
♦ TIM blocks are not processed.
♦ MON block cases are executed one at a time by user-request. You select a case for exe-
cution, from a user-defined or default display, by writing the desired case number to
the CASERQ parameter.
If a requested case trips (i.e., the evaluated condition is true), a block activation request is exe-
cuted. After the case has been processed completely (tripped and untripped), the standard param-
eter CASENO is set to indicate the number of the next case. The next case is not evaluated unless
requested. The TRPCHG parameter is incremented each time a case changes to or from the
tripped state.
The processing of EXC blocks already activated by tripped cases in the MON block are not
affected by other case evaluation requests to the MON block.
♦ IND, DEP, and EXC block statements are executed one at a time by request. You can
select a statement for execution from a user-defined or a default display by:
♦ Writing to the parameter STEPRQ the step number which begins with the
requested statement.
♦ Writing to the parameter STMRQ the number of the requested statement.
♦ Setting NXTSTM to true.
A statement requiring several BPCs to execute, such as a WAIT statement, need only be requested
once to initiate execution.
7
B0400DF – Rev R 1. Sequence Logic
Statement execution can be cancelled by requesting that another statement be executed. The stan-
dard parameter STMNO indicates the number of the statement currently executing. When the
statement finishes execution, STMNO is set to the number of the next statement dictated by exe-
cution flow. That statement is not executed unless requested by:
♦ Writing its number to the parameter STMRQ.
♦ Setting NXTSTM to true.
When the requested statement calls a subroutine, the HLBL statements of that subroutine (and
any nested subroutine) are executed. The parameter SUBRNO indicates in which subroutine, if
any, the currently executed statements reside. The parameter STMNO indicates the statement
number within that subroutine.
The Subr-Trace and SBX-Trace modes enable you to single step through statements of subrou-
tines and SBXs. You can switch the block into one of the Trace modes only when the block is in
the Active/Manual state.
Subr-Trace is a substate of the Manual state that enables you to single-step through a subroutine.
You enter this substate by selecting the “SUBR TRACE” button in the ALL CODE display. This
enters the integer value “1” into the TRACRQ parameter which, in turn, sets the block into the
Subr-Trace mode when the block is in Manual. After granting the request, the block resets
TRACRQ to 0.
Once in the Subr-Trace mode, you “select” a subroutine by requesting a call-subroutine statement
in the block’s main section. The block is then idle before the first statement in the requested sub-
routine. You can then single-step through the subroutine statements by toggling the NXTSTM
parameter. STEPRQ and STMRQ cause the execution of a single statement in the block’s main
section.
When you switch into the SBX-Trace mode, the block environment (i.e., step, subroutine, state-
ment number) is saved. The block returns to this environment when you exit the SBX-Trace
mode.
Once in the SBX-Trace mode, you “select” an SBX by setting the SBXRQ parameter to a value of
1 to 4. SBX5 (a switch to Paused) applies only to the DEP block (the block ignores out of range
values). When you select an SBX, the block idles at the first statement within that SBX. You can
then single-step through the SBX statements by toggling the NXTSTM parameter. The block
ignores step- and statement-requests while it is in the SBX-Trace mode.
In the Manual, Subr-Trace, and SBX-Trace modes, the block does not secure its output parame-
ters. External sources (other blocks and applications) can write values to the block’s outputs.
While the block is in one of these modes, the EXC, DEP, or IND block algorithm can update its
output parameters after a step-, statement-, or next-statement request.
To exit from the Trace mode, select the “TRACE” field in the faceplate.
Auto/Manual Transitions
You can change the block Auto/Manual state from external sources such as user-defined and
default displays, other blocks, and applications.
If a statement is in execution when you request a state change, the statement’s execution is com-
pleted as if it had begun in the requested state. Then any following statements are executed as
appropriate for the requested state.
8
1. Sequence Logic B0400DF – Rev R
NOTE
If one or more cases are making a transition from Active to Tripped (for example,
the blocks to be activated are remote blocks) when you change a MON block from
Automatic to Manual, then the block activation is completed but the cases do not
trip.
Sequence States
The Sequence states, Active, Inactive, Paused, and Tripped, in conjunction with the Application
states, control sequential control block algorithm execution. The Sequence states are determined
by the values of the block’s ACTIVE, PAUSED, and TRIPPD parameters. When ACTIVE is
true, the block is in the Active state. When ACTIVE is false, block is in the Inactive state.
Another block parameter, RSTACT, controls the value of the ACTIVE parameter when the com-
pound in which it resides changes from Off to On, or when the control processor in which it
resides undergoes a restart operation, as follows:
♦ RSTACT = 0: ACTIVE is false.
♦ RSTACT = 1: ACTIVE is true.
♦ RSTACT = 2: ACTIVE retains the value from the checkpoint file when the Control
Processor is restarted, or remains 0 when the compound makes a transition from Off
to On.
When a DEP block is in the ACTIVE state, it may also be in the PAUSED state. A DEP block is
Paused when the PAUSED parameter is true.
When a MON block is in the Active state, it may also be in the Tripped state. A MON block is
tripped when the TRIPPD parameter is true.
State Description
Inactive An IND, DEP, or EXC block is not executing any statements or a MON block
is not evaluating conditions.
Active An IND, DEP, or EXC block is executing statements or a MON block is
evaluating conditions.
Paused A DEP block’s execution is suspended because one or more EXC blocks in
the same compound are Active. The DEP block remains suspended until these
such EXC blocks are done executing.
Tripped A condition evaluated by a MON block causes it to activate other blocks. The
MON block remains tripped until the activated blocks are done executing.
Active State
In the Active state, an IND, DEP, EXC, or MON block is processed. (The TIM block does not
have an Active state. It is processed when the compound is On and the Application state is Auto.)
How statements are executed depends upon the Application states Auto, Step, and Manual.
9
B0400DF – Rev R 1. Sequence Logic
Inactive State
In the Inactive state, an IND, DEP, EXC, or MON block is not processed. (An Inactive state is
not present in TIM blocks. TIM blocks are not processed when the Application state is Manual.)
Active/Inactive Transitions
You can change the block Active/Inactive state from external sources such as user-defined and
default displays, other blocks, and applications.
When a linkage to the ACTIVE parameter exists, it is secured. This means that you cannot access
the parameter directly. To activate or deactivate the block, you can:
♦ Access the ACTIVE parameter through the source of the linkage
♦ Write the number of a non-existing statement to STMRQ.
Writing the number of a non-existing statement to STMRQ directs statement execution to the
end of the algorithm. Although the block is in effect deactivated, the ACTIVE parameter remains
true until it has been released. When released, it is automatically set to false.
Paused State
In the Paused state, DEP block statement execution is suspended due to active EXC blocks in the
same compound. The PAUSED parameter indicates whether a DEP block is in the Paused state.
When PAUSED is true, the block is in the Paused state.
Tripped State
In the Tripped state, a MON block has one or more cases tripped. A case trips when it is evaluated
as true and activates another block. The TRIPPD parameter indicates whether a MON block is in
the Tripped state. As long as at least one case is tripped, the TRIPPD parameter is true; otherwise,
TRIPPD is false.
Transition States
The Transition states, To_Inactive, To_Manual, and To_Paused, are intermediate states that the
Sequence Control block assumes while the block is executing one of the three standard block
exception handlers (SBXs 3, 4, and 5) that are provided for state change handling.
To_Inactive State
The To_Inactive state is an intermediate state that an IND, DEP, or EXC block assumes while
SBX 3 is executing. SBX 3 is the user-defined, user-enabled response to an externally initiated
change of block state from the Active/Auto (or Active/Step) state to the Inactive state.
The MON and TIM blocks do not have a To_Inactive state since they do not contain SBXs.
To_Manual State
The To_Manual state is an intermediate state that an IND, DEP, or EXC block assumes while
SBX 4 is executing. SBX 4 is the user-defined, user-enabled response to an externally initiated
change of block state from the Active/Auto (or Active/Step) state to the Manual state.
The MON and TIM blocks do not have a To_Manual state since they do not contain SBXs.
10
1. Sequence Logic B0400DF – Rev R
To_Paused State
The To_Paused state is an intermediate state that a DEP block assumes while SBX 5 is executing.
SBX 5 is the user-defined, user-enabled response to an externally initiated change of block state
from the Active/Auto (or Active/Step) state to the Paused state.
The IND and EXC blocks do not have a To_Paused state since they do not have a Paused state.
The MON and TIM blocks do not have a To_Paused state since they do not contain SBXs.
When a compound is switched OFF, the sequence blocks in that compound go to the Manual
state, thereby releasing their output parameters.
Sequence Processing
Sequential control blocks are processed every scheduled Basic Processing Cycle (BPC) as defined
for the Control Processor in which they operate. The following figure shows the processing order
within a scheduled BPC.
1 BPC
1 2 3 4 5
11
B0400DF – Rev R 1. Sequence Logic
The scheduled BPC is determined by the block parameters PHASE and PERIOD. The PHASE
parameter specifies when a block is executed relative to the other blocks in that PERIOD. The
PERIOD parameter specifies how frequently a block is executed.
When a sequential control block is activated, it begins executing its block algorithm in the next
scheduled BPC as defined by the block parameters PERIOD and PHASE.
When a MON or TIM block is processed, its entire algorithm is executed each scheduled BPC
until deactivated.
When an IND, DEP, or EXC block is processed, a specified number of statements in the algo-
rithm are executed each BPC. The number of statements processed is determined by the value of
the block’s BPCSTM parameter. When the last statement is executed, the block automatically
deactivates itself.
Sequence language statements are executed in the order programmed by you. Statement execution
continues in a given BPC until:
♦ The number of statements specified by the BPCSTM parameter are executed in Auto,
or in Step mode
♦ The last statement of a step is executed in Step mode
♦ One statement is executed by request in Manual for an IND, DEP, or EXC block.
The number of statements executed in automatic can be less than the number specified by the
BPCSTM parameter if an executed statement needs more than one BPC to finish. For example:
♦ A statement makes a pathname request (specifying the entire pathname) to access a
block parameter in a remote Control Processor.
♦ A SENDCONF is executed.
♦ A WAIT or WAIT UNTIL statement has a wait condition exceeding the BPC.
12
1. Sequence Logic B0400DF – Rev R
A nested SBX execution may cause a memory violation, memory corruption, or unpredictable
control behavior. It is during this event (a nested exception) that the CP could become unavail-
able. Therefore, avoid activating any SBX while one is already ACTIVE.
Try to avoid nested SBX execution by:
♦ NOT activating a state change SBX (TO_INACTIVE, TO_MANUAL or
TO_PAUSED) while an error SBX (TO_SYS_ERROR, TO_USER_ERROR) is
already ACTIVE
♦ NOT activating TO_SYS_ERROR or TO_USR_ERROR SBXs while a state change
SBX is already ACTIVE.
♦ NOT activating a state change SBX while another state change SBX is already active.
Good practices for SBX code should minimize the use of WAIT statements, only use basic logic
calls, no subroutine calls and no external references.
Another alternative approach that can be taken is to DISABLE all other SBXs from within the
active SBX at the start of the exception code and then ENABLE the SBXs again in the last state-
ment before exiting the SBX by using the SET_SBXS command.
For every other error condition, including user-errors (SBX TO_USR_ERROR: 2000 < OP_ER
< 3000), allow retrying the same statement. (If you do this, be careful to avoid infinite loops.) For
most of the cases the “retry” does not clear the error.
Example:
OP_ERR 2314 “string type expected in string expression” does not go away after retry.
Remember that if you decide to continue you may end up with unexpected results.
LOC_VAR, STR1 : S;
STATUS : B;
LOC_VAR := “:CONTROLLER_1.BI0001”;
STATUS := :’LOC_VAR’;
STR1 := “:MAIN_LOOP.BO0001”;
LOC_VAR := STRING :’STR1’;
:’LOC_VAR’ := TRUE;
STR1 is not a FPN (entire path name) for a string type parameter. In this case LOC_VAR
keeps its value unchanged and CONTROLLER_1 BI0001 parameter is set to “TRUE”.
13
B0400DF – Rev R 1. Sequence Logic
must be replaced with IF OP_ERR > 3000 THEN GOTO FINAL ENDIF;
*}
ENDIF
IF BLOCK_STMNO <> SAVED_STMNO THEN
RETRY_CNT := 0;
SAVED_STMNO := BLOCK_STMNO;
ENDIF;
IF RETRY_CNT < LIMIT THEN
RETRY_CNT := RETRY_CNT + 1;
{* In some cases, you may want to add the “WAIT” statement at this
point. For example, OP_ERR ‘-1’ or ‘-45’
*}
RETRY;
ENDIF;
<<FINAL>>
SENDMSG (“ERROR! op_err=”,OP_ERR,” stm=”, BLOCK_STMNO,
“ SBXNO=”,SBXNO) to SN0001; {* or to MSGGRx *}
EXIT;
ENDEXCEPTION
The above SBX design assumes that SAVED_STMNO has to be set to ‘-1’ (initialized):
1. In the first statement of the:
♦ Main code section
♦ Each subroutine
♦ State change SBX (TO_INACTIVE, TO_MANUAL, TO_PAUSED).
2. In the last statement of the state change SBX unless the logic terminates the block.
3. In the first statement after any label which is used as the “GOTO” statement argu-
ment to change execution flow backwards or to jump from any type of SBX to the
block main section.
14
1. Sequence Logic B0400DF – Rev R
ENDSUBROUTINE
NOTE
To continue after unsuccessful retries, you can secure the results by writing the
default value into VAR. Example:
15
B0400DF – Rev R 1. Sequence Logic
Complex Statements
Avoid complex HLBL statements such as the following:
SAVED_STMNO := -1; {* the initialization is not needed for the main
code section. *}
IF :COMP1:BLOCK1.BO0001 <> :COMP2:BLOCK2.BO0002 THEN
...........
ENDIF
This statement can produce OP_ERR “-1” twice and RETRY_CNT is not reset for the second
one. It is preferable to avoid usage of two or more external references in the single statement. Use
extra assignment statements instead:
SAVED_STMNO := -1;
TMP_BOOL := :COMP2:BLOCK2.BO0002;
SAVED_STMNO := -1;
IF :COMP1:BLOCK1.BO0001 <> TMP_BOOL THEN
............
ENDIF
You may also double the number of retries by setting a proper value for LIMIT (the variable
LIMIT was used in the above example for SBX programming).
16
1. Sequence Logic B0400DF – Rev R
17
B0400DF – Rev R 1. Sequence Logic
18
2. Sequence Language
This chapter contains information on Sequence language including block algorithm structure,
sequence language data types, declaration of user-labeled parameters, and sequence language
character set, vocabulary, and expressions. Also included in this chapter is information on data
type checking, reference connection checking, operational errors, the bad status attribute,
preprocessor directives, sequence compiler limits, and the sequence compiler limits table.
The Sequence language is a high level language similar to the Pascal programming language, but
designed to implement process control strategies. Sequence language is a synonym for High Level
Batch Language (HLBL).
The Sequence language is used to write Sequence (IND, DEP, and EXC) and Monitor (MON)
block algorithms. The three Sequence blocks support HLBL statements. Timer (TIM) blocks do
not have Sequence language code.
Algorithm Structure
The block algorithm is composed of:
♦ The heading
♦ The subroutines section
♦ The standard block exceptions section
♦ A main statement section.
Heading
The heading section contains:
♦ Block type identification
♦ Definition of constants
♦ Definition of block local variables
♦ User-labeled parameter declarations.
The “Block Type Identification” is the identifier at the first line (Dependent_sequence,
Independent_sequence, or Exception_sequence).
Constants, variables, and user-labels can take any name normally used for standard block parame-
ters, for example, ACTIVE, PAUSED, BLKSTA, and so forth, except for the following five
names:
♦ OP_ERR
♦ STMNO
♦ SUBRNO
♦ SBXNO
♦ STEPNO.
19
B0400DF – Rev R 2. Sequence Language
The “Definition of Constants” section of the sequence block definition enables you to introduce
names for numerical values. A constant is an identifier which acts as a synonym for a value. The
definition of constants is the introduction of such synonyms.
Constants are known throughout the whole block: in the statements of the subroutines, standard
exception handlers and the block’s statement section.
Constants are an aid in compiling Sequence blocks.
Changing the value of a constant in an include file does not automatically affect a previously com-
piled sequence block. To effect the value change, you have to recompile the block.
The values of the block local variables can be scalars, or arrays, of data type boolean, real, integer,
or string. Strings can be 6, 12, or 80 characters. See Table 3-3 for local variable related limits.
Variables provide local data storage for values, or intermediate results, which are only accessible
from the block in which they are declared. Block local variables are known throughout the whole
block: in the statements of the subroutines, standard exception handlers and the block’s statement
section. It is recommended that the programmer initialize local variables because they are not ini-
tialized by the run-time environment.
The “User-Labeled Parameters” section of the sequence block definition enables you to attach a
specific name to a “usable parameter.” A “usable parameter” is a Sequence control block parameter
that is available to you. See Table 3-3 for the maximum length of a user-parameter label.
The assigning of a user-label to a usable parameter is called a “parameter declaration.” User- labels
are optional, and the labeled parameters can be referenced by either the user-label or the parame-
ter name.
User-labels cannot be used as labels of labeled statements or steps, to which you can jump by
means of a GOTO statement.
Subroutines
Subroutines are supported in Independent, Dependent, and Exception blocks. The Monitor and
Timer blocks do not have subroutines.
A Sequence subroutine is a sequence of user-programmed HLBL statements that can be called
from the Sequence block’s main code section, or from another subroutine. Recursive subroutines,
however, are not supported. Subroutines cannot call themselves, directly or indirectly. See
Table 3-3 for subroutine related limits.
Unlike control blocks, Sequence subroutines:
♦ Are not control objects
♦ Cannot be installed in a station as an independent identity
♦ It is not advised to have parameters that can be linked, connected, or accessed from
the outside in any way.
Each subroutine name uses a number of bytes equal to one plus the number of characters in the
name (for example, SUBROUTINE TIMER uses six bytes).
The compiler numbers the subroutines in the order of their definition within the Sequence block.
The structure of a subroutine consists of:
♦ A heading
♦ The local subroutine variables
♦ A body of HLBL statements.
20
2. Sequence Language B0400DF – Rev R
The heading specifies the subroutine’s name and formal arguments, if any.
A subroutine without arguments can be used for different actions upon the same set of parameters
or block variables.
A subroutine with arguments can be used for repeating the same action on different sets of
parameters.
Subroutine local variables are optional.
The body contains the HLBL statements that define the algorithm.
The subroutine allows you to specify a general piece of coded control logic, only once within a
block, and apply it repeatedly by simply referring to the subroutine name. This reduces program-
ming effort and gains reliability and consistency.
Subroutines can be used in equipment-oriented applications by using string type arguments. The
subroutine can then be called with the name of an object that represents or controls a piece of
equipment. For instance, a subroutine that contains the logic for opening a valve in a particular
way can be called for INLETVALVE1, for INLETVALVE2, and for INLETVALVE3, where these
names refer to I/O blocks that reside in the same compound as the Sequence block that calls the
subroutine label.
You can use subroutines to calculate long integer values for the Monitor block’s ACTPAT using
the new rules for this 32-bit value.
You can save defined objects, including subroutines, as include files, and make them available to
the configured blocks.
21
B0400DF – Rev R 2. Sequence Language
Subroutine arguments can take any name normally used for standard block parameters, for exam-
ple, ACTIVE, PAUSED, BLKSTA, and so forth, except for the following five names:
♦ OP_ERR
♦ STMNO
♦ SUBRNO
♦ SBXNO
♦ STEPNO.
Actual arguments are provided with the CALL statement. Refer to “Calling the Subroutine” on
page 23 for greater detail on actual arguments.
Subroutine Statements
HLBL statements can be used in the subroutine body. Their syntax and semantics are the same as
if they were used within the block code. Control flow statements such as GOTO and EXIT-
LOOP are restricted to the environment of the subroutine, that is, “You cannot jump out of a
subroutine.”
22
2. Sequence Language B0400DF – Rev R
Within a subroutine, you can reference user-input, user-output, and user-array parameters by
their standard names or by their user-labeled names.
A subroutine has a single exit point. Multiple return statements within a subroutine are not possi-
ble. The only way to leave the subroutine code is the ENDSUBROUTINE statement.
HLBL statements are numbered from one for each subroutine, for each SBX, and in the block’s
main code section. You can execute the subroutine statements one at a time when the block is in
the Subr-Trace mode.
Actual Arguments
When called, subroutines are supplied with a list of actual arguments which are substituted for the
corresponding formal arguments. In most cases, the data types of the actual arguments match the
formal ones.
In most cases, the number of elements of an actual argument of type array (parameter or local
variable) match the number of elements of the corresponding formal argument exactly. The corre-
sponding formal argument represents this actual argument during the entire execution of the sub-
routine.
When the CALL statement includes array references for formal arguments of the IN category,
every element of the actual array is physically copied into the subroutine’s data space. If the refer-
ence is for a formal argument of the INOUT category, only the address of the actual array is cop-
ied.
When a subroutine is defined as having a formal INOUT argument, the actual argument
included in the subroutine call has to be an identifier referring to:
♦ A block user-parameter (input, output, string, array)
♦ A local block variable
♦ In the case of nested subroutines, a formal argument
♦ In the case of nested subroutines, a local subroutine variable.
An actual INOUT argument cannot be:
♦ An item of data type string with a subset specification
♦ An external reference
♦ A constant
♦ A literal
♦ An expression.
Upon call, the actual counterpart of an IN argument can be:
♦ A constant
♦ A name of:
23
B0400DF – Rev R 2. Sequence Language
Subroutine Examples
Subroutine with No Arguments
From the subroutine definition part of a Sequence block listing:
SUBROUTINE DATA_IN ()
{***********************************************************
* Purpose: Retrieve data from an identified compound *
* Arguments: - none *
* Global variables used in the Subroutine *
* COMP_ID - String containing the compound name for *
* the data to be retrieved - pre-assigned by the *
* calling program. *
* *
* Global variables modified by the Subroutine *
* CF - Compound Flow *
* Valve-Out - Compound valve output *
* LAI - Low Absolute Flow Alarm *
* Dev_Shut - Deviation Shutdown required *
***********************************************************}
STATEMENTS
CF:= :'COMP_ID':FLOW_BLK.RO01;
Valve_Out:= :'COMP_ID':PID.OUT;
LAI:= :'COMP_ID':INFLOW.LAI;
Dev_Shut:= :'COMP_ID':PID.MEASHI OR :'COMP_ID':PID.MEASLI;
ENDSUBROUTINE
The Main STATEMENTS Section includes the Subroutine Call statement/s
for the DATA_IN subroutine.
.......
COMP_ID:= “BLEND1”;
CALL DATA_IN ();
.......
.......
COMP_ID:= “BLEND2”;
CALL DATA_IN ();
24
2. Sequence Language B0400DF – Rev R
.......
.......
ENDSEQUENCE
NOTE
The argument flow is, by default, an INOUT argument. The arguments Comp_Id
and Valve_No are here designated as IN and INOUT, respectively.
In the first call, the formal argument, Comp_Id, takes the literal string, RINSE_1. In the second
call, Comp_Id takes the literal assigned to the string variable, ProcName. If the actual argument,
ProcName, has the value RINSE_1 when the subroutine is called, the two CALL instructions per-
form identical operations.
25
B0400DF – Rev R 2. Sequence Language
26
2. Sequence Language B0400DF – Rev R
Data Types
The Sequence language uses the following data types: real, long integer, integer, Boolean, string,
and enumerated data type. The data manipulated in the Sequence language has to be of one of
these data types. The data type determines the type of values that an object can be as well as the
operations that can be performed on the value.
Real data can assume values that are approximations of the real numbers. Real values have an
accuracy of seven digits and they are limited to the range -3.40282438...+3.40282438.
Integer data can have values that express whole numbers. Operations that can be performed are
addition, subtraction, multiplication, division, and testing on relational ordering of values.
Integer values are limited to the range (-231)... (+231-1) that is, the range between -2147483648
to 2147483647. Be advised that that -2147483648 is the only number in this range that cannot
be expressed as a literal, as described in “Literals” on page 33.
There is data conversion between real numbers and integers. Real values can be written to long,
short, or integer parameters. Conversely, integer values can be written to real parameters.
Boolean data can assume two values: TRUE and FALSE. These values can be manipulated by the
operators AND, OR, and NOT. They can be compared for equality with other Boolean values.
27
B0400DF – Rev R 2. Sequence Language
String data type variables and parameters can be used in string expressions and assignments. There
are, in addition to the standard 80 character string, the short (6-character) and medium (12-
character) length string data type.
Predefined data is enumerated data associated with a standard parameter. The enumerated data
has a range of symbolic values. Enumerated data can be compared for equality. A standard param-
eter of the predefined data type is assigned symbolic values in the predefined range of integer val-
ues that correspond to the symbolic values in accordance with an ordinal numbering scheme (see
the ORD function in “Transfer Functions” on page 41).
Each predefined type is treated like a data type of its own; it is not considered a variation of the
integer data type.
The compound parameter SSTATE is the only enumerated data type supported in HLBL.
SSTATE has the following three values:
Symbolic Value Ordinal Value
INACTIVE 0
ACTIVE 1
EXCEPTION 2
In a Sequence language statement, you can use either the symbolic or the corresponding ordinal
value. For example, the expression of an IF statement, looking for the condition where the com-
pound SSTATE is active, can be either of the following:
IF (:COMPNAM.SSTATE = ACTIVE)
IF 1 = ORD(:COMPNAM.SSTATE);
The sequence compiler and sequence processor recognize the packed Boolean and packed long
Boolean data types as valid for assignments and subroutine call arguments. Packed Boolean data
types are treated as long integer data types.
user parm =
user_arithm_parm_name |
user_string_parm_name |
user_array_parm_name .
user arithm parm name =
BI00nn (where nn = 01 -- 24) |
II000n (where n = 1 -- 8) |
RI00nn (where nn = 01 -- 15) |
BO00nn (where nn = 01 -- 16) |
IO000n (where n = 1 -- 5) |
RO00nn (where nn = 01 -- 15) .
28
2. Sequence Language B0400DF – Rev R
Character Set
The basic character set of the Sequence language consists of following letters, numbers, and spe-
cial symbols:
♦ Letters A through Z, a through z, and underscore
♦ Numbers 0 through 9
♦ Special Symbols + - * / = { } ( ) < > . , ; : “
Vocabulary
Sequence language statements are composed of the following lexical units:
Special Symbols Keywords
References Literals
Labels Comments
Operator Remarks
Special Symbols
Special symbols serve as operators and delimiters in Sequence language statements (refer to
Table 2-1 below). Some operators and delimiters are created by combining several special sym-
bols.
Table 2-1. Special Symbols
Symbol Description
{... } Encloses comments. Comments are used to document the algorithm.
(* ... *) Encloses operator remarks. Remarks describe the actions performed by
statement execution. Remarks can be seen on the default displays.
“...” Encloses a string data type.
29
B0400DF – Rev R 2. Sequence Language
Symbol Description
--> Means “to.” Assign the results of a Boolean expression to a Boolean output
parameter in a Monitor (MON) block MONITOR CASES statement.
:= Assigns values to parameters.
; Ends a Sequence language statement.
: Begins an external reference to a block, compound or block parameter, or
shared variable. It also separates compound and block names in a block or
block parameter reference.
<<...>> Indicates a statement label. Labels can be referenced from other statements
such as the GOTO statement.
$$...$$ Step label.
(...) Establishes precedence when evaluating arithmetic and Boolean expressions. It
delimits messages sent with the SENDMSG statement. It delimits activation
requests in an ACTCASES statement. It delimits TIMER statements.
* The arithmetic operator for multiplication.
/ The arithmetic operator for real division.
+ The arithmetic operator for addition; it is also a unary operator for identity.
- The arithmetic operator for subtraction; it is also a unary operator for sign
inversion.
= The relational operator meaning equality.
<> The relational operator meaning inequality.
< The relational operator meaning less than.
> The relational operator meaning greater than.
<= The relational operator meaning less than or equal to.
>= The relational operator meaning greater than or equal to.
. Separates a compound from a parameter in a path or a block from a parameter
in a parameter reference.
, Separates a block reference from case activation requests in the ACTCASES
statement. Also, it separates lexical units that make up a message in the
SENDMSG statement – string concatenation operator.
/*...*/ Comments in preprocessor directives
Keywords
Keywords are reserved to specify actions carried out by statements when the block is processed.
Keywords are expressed in uppercase characters. Other lexical units, such as literals and identifiers,
cannot be given the same name as a keyword. The keywords are:
ABORT DO INDEPENDENT NOT THEN
_SEQUENCE
ACTCASES DOWNTO ENDWHILE ON TIMER
ACTIVATE E EXIT OR TO
AFTER ELSE EXITLOOP REPEAT TRUE
30
2. Sequence Language B0400DF – Rev R
References
A Sequence language algorithm can access data by specifying a path to the data in a Sequence lan-
guage statement. This data is called a reference. Any of the following types of data can serve as a
reference in a Sequence language statement:
♦ Blocks
♦ Parameter status attributes (ON SECURED BAD)
♦ Compound parameters
♦ Block parameters (standard and user-labeled)
♦ Shared variables
♦ Timers.
Before referencing user-labeled parameters in the statement section, you have to declare the
parameters in the heading section. It is not necessary to declare in the heading section the stan-
dard Compound:Block parameters (SSTATE, MA, and so forth).
Internal References
An internal reference is a reference to a standard block parameter, a user-labeled parameter, or one
of the status attributes (ON, SECURED, or BAD) associated with a user-labeled parameter, that
belongs to the block. In an internal reference, a user-labeled parameter has to be referred to by the
user-label assigned to the parameter in the heading section.
Examples:
A user-labeled parameter declaration in the heading of block1:
ERR_FLG : BI0001;
A reference to the user-labeled parameter in the statement section of block1:
31
B0400DF – Rev R 2. Sequence Language
ERR_FLG := TRUE;
A reference to a standard block parameter in the statement section of block1:
BI0001 := TRUE;
Internal reference formats are described in “Reference Format” on page 32.
External References
An external reference is a reference to a standard parameter, shared variable, timer, or user-labeled
parameter that is specified by pathname. (It may or may not belong to the block.)
When you make an external reference to a user-labeled parameter, use the path to the parameter
and the parameter name (not the user-label assigned in the heading).
When you use a string type external reference in an expression, precede it with the keyword
STRING. HLBL assumes the external references without the keyword STRING are arithmetic
data types (real, integer, or Boolean).
You can use relative specification in external references. You can omit the compound name when
referring to blocks (and/or their parameters) within the compound. The compound name is pre-
pended to the path name.
Examples:
A reference to a Boolean input parameter in BLOCK1 from the statement section in
another block in the same compound:
::BLOCK1.BI0001 := TRUE;
A reference to a Boolean input parameter in COMPOUND1, BLOCK1 from the state-
ment section in the same compound or in another compound:
:COMPOUND1:BLOCK1.BI0001 := TRUE;
External reference formats are described in the next section.
NOTE
The HLBL External Reference Table (ERT) maximum size is 40 entries.
Reference Format
The path specified in a reference may contain spaces or comments, such as in the following
example: (::COMP:BLOCK.PARM:=1;).
External references are case sensitive. Compound names, block names, and parameters have to be
entered in uppercase.
Internal Reference Formats:
PARAM
PARAM.STATF
where:
. = Separates parameter and status field names
PARAM = User-labeled parameter name (one to ten characters).
STATF = ON, SECURED, BAD parameter status field.
These status extensions have to be used only on the right side of the :=assignment. If used
on the left, a syntax error results.
32
2. Sequence Language B0400DF – Rev R
Examples:
FILLFLAG
HEAT_F
LEVEL_F.SECURED
External Reference Formats:
:CNAM.CPARAM
:CNAM:BNAM
:CNAM:BNAM.BPARAM
:CNAM:BNAM.TIM
::BNAM
::BNAM.BPARAM
::BNAM.TIM
:SVAR
where:
: = Precedes external references; separates compound and block names.
. = Separates compound and block names from parameter and timer names.
CNAM = Compound name (one to 12 characters) – not needed if referenced block is in
same compound
CPARAM = Compound parameter name (one to six characters).
BNAM = Block name (one to 12 characters).
BPARAM = Block parameter name (one to six characters).
TIM = Timer name (TIMR1, TIMR2, TIMR3, TIMR4).
SVAR = Shared variable name (one to 12 characters).
NOTE
::.BPARAM and ::.TIM are invalid. In both cases, BNAM has to be specified.
There are only two cases where BNAM may be excluded, namely
:CNAM.CPARAM (a compound parameter reference)
:SVAR (a shared variable reference)
Examples:
:REACT_FILL.ON
:REACT_FILL:LEVER
:REACT_FILL:DRAIN.MA
:REACT_FILL:DRAIN.BI0001
:REACT_FILL:FILL_TIME.TIMR4
::CLEAN.MA
::CLEAN.RI0004
::CLEAN_TIME.TIMR2
:TANK_LEVEL
:.ON
Literals
Literals are values that are interpreted as they appear literally in a statement. A literal can be a real,
integer, Boolean, string, or enumerated value.
33
B0400DF – Rev R 2. Sequence Language
Examples:
unsigned integer literal: 325
unsigned real literal: 200, 233.2, 5E4, 23E-12, .5E+6
Boolean literal: TRUE, FALSE
enumerated literal: Active, Inactive, Exception
string literal: “Heat Phase is beginning”
Labels
A label identifies a statement or a step. A labeled statement, or step, can be executed by request
from another statement, such as a GOTO statement in the same coded programming entity
(block, subroutine or SBX).
Labels are only recognized in the block in which they are defined. At run time, they cannot be
referred to from sources outside the block.
NOTE
It is not recommended for a label to be the last line in a subroutine or program. Add
a semicolon “;” following the label if this positioning is necessary in the routine.
You can refer to a statement label, or step label, within the block’s main code section, only from a
statement within that same main code section, or, from a statement in one of the block’s SBXs;
that is, you can use a label reference to jump out from an SBX into the main code section.
The HLBL compiler generates an error message if the program tries to use a label reference to:
♦ Jump into a subroutine
♦ Jump out from a subroutine
♦ Jump into a standard block exception handler.
34
2. Sequence Language B0400DF – Rev R
Format:
<<x>>
where:
<< >> = special symbol that encloses the label.
x = one to 12 characters (letters, digits, or underscores).
Examples:
<<fill_vat2>>
ACTIVATE :REACT_LOGIC:FILL;
.
.
.
GOTO fill_vat2;
The fill_vat2 label is not enclosed in << >> symbols when referred to in a statement.
Only the actual label has to be so enclosed.
<<repeat>>
ACTIVATE :COMP_REACT:DRAIN;
This is accepted by the HLBL compiler. If the label uses uppercase lettering, the compiler
rejects the label because REPEAT in uppercase characters is a keyword.
Comments
Comments, enclosed by the special symbols { and }, describe algorithm actions; they do not
affect the algorithm’s flow of control or any data operations. Use comments to document your
algorithm.
Comments can appear anywhere in the algorithm between identifiers, numbers, and special sym-
bols. A comment can occupy more than one line.
Format:
{x}
where:
{ } = Special characters that enclose the comment
x = One or more characters (letters, digits, or underscores); there is no limit to the num-
ber of characters.
Example:
{Set alarm block used to activate annunciator light.}
NOTE
The backslash character (“\”) must not be added in comments sections of HLBL
code, or IACC will throw an error during validation.
Operator Remarks
An operator remark tells the operator what the program is doing while executing. It is not used to
tell the operator to perform an action.
35
B0400DF – Rev R 2. Sequence Language
NOTE
If the next line is a label, you have to end the operator remark line with a semicolon.
Expressions
Expressions combine operands and operators according to rules of computation to obtain new
values.
There are two kinds of expressions in HLBL: string expressions and arithmetic expressions.
String Expressions
A string expression constructs a string from any mixture of:
♦ String literals
♦ Results of arithmetic expressions (including non-string external references)
♦ Internal references to a string item, optional with a subset specification
♦ External references of data type string.
The comma (,) is the concatenation operator.
The conversion of arithmetic values to ASCII character string expressions are automatically per-
formed as follows:
1. A Boolean value is converted into one of the strings TRUE or FALSE.
2. An integer value is converted into a string of digits, if positive, or into a minus sign
followed by a string of digits, if negative.
3. A real value converts into a string of fixed length. The string contains:
For the mantissa: a sign character (+ or -), one digit, the decimal point, six digits, and
the character e. For the exponent: a sign character (+ or -), and two digits.
Examples: +8.800497e+01, -7.423075e-13
36
2. Sequence Language B0400DF – Rev R
A string expression can occupy up to 80 characters. Characters in excess of 80 are ignored without
notification; that is, no operational error is raised.
Trailing blanks of the elements that make up the expression are not removed. Trailing blanks of
the string expression are also not removed.
An external reference is interpreted as data type string if, and only if, it is preceded by the keyword
STRING. Without that keyword, arithmetic values retrieved from the external reference are con-
verted to ASCII as described above.
Examples of string expressions include:
1. 7 * 10 + 6
2. “7”, “6”
3. IO0003
If IO0003 = 76, then Examples 1, 2, and 3 each yield: 76.
4. STRING :.NAME , “biphenyl_temp =” , RO0002
If the compound name = COMP_64 and RO0002 = 27.4, then Example 4 yields:
COMP_64 biphenyl_temp = +2.740000e+01
5. “string” , SN0010 , 3 * i , :COMP:BLK.IO0003
The result of Example 5 consists of the characters “string”, contents of SN0010 (with-
out trailing blanks), the ASCII representation of the value of 3*i, and the ASCII rep-
resentation of the value stored in COMP:BLK.IO0003.
Arithmetic Expressions
Arithmetic expressions include integer, real, and Boolean expressions.
Integer arithmetic expressions are those in which the operators operate on integer operands only,
and the results are integers.
In real arithmetic expressions, the operators operate on only real operands or a combination of
integer and real operands. In the latter case the integer value is changed to real before the operator
is applied. The results are real.
In Boolean arithmetic expressions, the Boolean result is derived by applying the logical operator
not to a Boolean value, or by applying the relational operators (=, <>, <=, >=, <, or >) to compati-
ble operands, either arithmetic or string.
Examples of Boolean expressions include:
BI0001 := NOT BI0002;
BI0003 := cycle_no = 6;
This assigns a value of TRUE (=1) to the parameter, BI0003, when the integer
variable, cycle_no, has a value of 6; any other value of cycle_no sets BI0003 to FALSE
(=0).
BI0004 := cycle_no <> last_cyc;
This assigns a value of TRUE (=1) to the parameter, BI0004, when the integer vari-
able, cycle_no, is not equal to the integer variable, last_cyc; if the two variables are
equal, BI0004 is set to FALSE (=0).
Boolean expressions (and IF conditional clauses) can also use string comparisons to determine
Boolean values.
The following string items can be compared:
37
B0400DF – Rev R 2. Sequence Language
♦ String constants
♦ Local string scalars (block or subroutine variables, or subroutine arguments)
♦ Subsets of local string scalars
♦ Elements of local string arrays (block or subroutine variables, or subroutine
arguments).
Any external string parameter to be used in a comparison has to appear on the left hand side of
the (in)equality sign and has to be preceded by the keyword STRING.
String expressions cannot be compared with each other because the concatenation operator (,)
cannot be used.
When entire strings are being compared, trailing blanks of the strings (on either the left or right
hand side of the comparison) are stripped away. As a result, the following Boolean expressions
each yield the same result:
IF STRING :A:B.SN0001 = “COOL ” THEN ...
IF STRING :A:B.SN0001 = “COOL” THEN ...
IF SN0001 = “COOL ” THEN ...
IF “COOL” = SN0001 THEN ...
When the expression is comparing string subsets, the trailing blanks are not stripped. For
instance, the following two statements do not yield the same result.
BI0001 := SN0002 ( 1 .. 5 ) = “COOL ”;
This assigns a value of TRUE (=1) to the parameter, BI0001, when the first
five characters of the string variable are C, O, O, L, and space. If any of the first char-
acters differ, BI0001 is set to FALSE (=0).
BI0001 := SN0002 ( 1 .. 4 ) = “COOL ”;
In this example, BI0001 cannot be true since the subset does not specify enough char-
acters, and since it is a subset that is being compared, the trailing space in COOL is
not stripped away.
Other examples of valid string comparisons include:
1. BO0001 := LoopNamesArr[14] = SN0005 ;
2. IF SN0003 ( 61 .. 72 ) = “TempLoop1988” THEN ...
3. BI0001 := STRING :COMP4711:BLK0011.SN0010 = “COMP002” ;
4. SUBROUTINE PQR ( IN arg1 : S80; INOUT arg2 : S12[2] )
VARIABLES
STATEMENTS
II0001 := 5 ;
BI0001 := (arg1[ II0001 .. 9 ] = arg2[1] );
ENDSUBROUTINE
.
.
.
strarr[1] := “FC101”
CALL PQR ( “ FC101”, strarr ); {this sets BI0001 True}
Operands
An operand is an internal or external reference that is evaluated according to the operators in an
expression. The following references can be used as operands: a compound parameter, block
parameter, block status attribute (ON, SECURED, or BAD), shared variable, or literal. Refer-
38
2. Sequence Language B0400DF – Rev R
ences are described in more detail in “References” on page 31. Reference formats are described in
“Reference Format” on page 32.
When evaluating an expression, if the results of addition (adding operators: + and -) or multiplica-
tion (multiplying operators: *, /, MOD, and DIV) cause an overflow, underflow or divide-by-zero
condition, the appropriate minimum or maximum value is substituted for the result. During
translation the HLBL compiler detects division by zero in constant expressions.
Operators
Operators combine operands to obtain a single value. The data type of operands and operators
have to be consistent. The table below lists each operator and its appropriate operand data types.
Operator Operation Type of Operand Type of Result
Unary
+ Identity Integer or real Same as operand
- Sign inversion Integer or real Same as operand
NOT
Logical negation Boolean Boolean
Arithmetic Dyadic
+ Addition Integer or real Integer/Real
- Subtraction Integer or real Integer/Real
*
Multiplication Integer or real Integer/Real
/
DIV Real division Integer or real Real
MOD Integer division Integer Integer
Modulus Integer Integer
Relational
= Equality Both boolean or both compatible Boolean
<> Inequality Both boolean or both compatible Boolean
<=
Less than or equal Compatible Boolean
>=
< Greater than or equal Compatible Boolean
> Less than Compatible Boolean
Greater than Compatible Boolean
Logical Dyadic
AND Logical and Boolean Boolean
OR Logical or Boolean Boolean
String Dyadic
, Concatenation B, I, R, S, S12, S6 String
39
B0400DF – Rev R 2. Sequence Language
Functions
The Sequence language provides a set of functions that include transfer functions, arithmetic
functions, and array functions shown in this table.
Transfer functions convert values of one data type into another data type. They have one parame-
ter and deliver one result. A transfer function can be a simple expression by itself or an operand in
a more complex expression. HLBL transfer functions include TRUNC, ROUND, and ORD.
Arithmetic functions perform an algebraic operation on an integer or real value. An arithmetic
function can be a simple expression by itself or an operand in a more complex expression. HLBL
arithmetic functions include ABS and SQRT.
Array functions allow you to manipulate each of the elements of an array with a single statement.
An array function can only appear in the right hand side of an assignment statement. HLBL array
functions include SET_ARRAY, SUM_ARRAY, and MULT_ARRAY.
40
2. Sequence Language B0400DF – Rev R
Transfer Functions
Transfer functions convert values of one data type into another data type. They have one parame-
ter and deliver one result. A transfer function can be a simple expression by itself or an operand in
a more complex expression. HLBL transfer functions include TRUNC, ROUND, and ORD.
TRUNC
The TRUNC(r) function changes a real value into an integer value by truncating any places to the
right of the decimal point.
Examples:
TRUNC(1.83 + 1.56) = 3
TRUNC(-3.7) = -3
The value r has to be an integer or a real value. If r is an integer, TRUNC(r) yields r.
If r is not within the range -3.1E10 to 3.1E10 (floating-point notation), TRUNC(r) assumes the
minimum value 80000001 hexadecimal (-231) or the maximum value 7FFFFFFF hexadecimal
(+231-1).
ROUND
The ROUND(r) function changes a real data value to an integer data value by rounding to the
nearest integer. Specifically, if r Š 0 then ROUND(r) = TRUNC(r + 0.5), or if r < 0 then
ROUND(r) = TRUNC(r - 0.5), where TRUNC truncates any places to the right of the decimal
point.
Examples:
ROUND(3.2 + 1.3) = 5
ROUND(-4.5) = -5
The value r has to be an integer or real. If r is an integer, then ROUND(r) yields r.
If r is not within the range -3.1E10 to 3.1E10 (floating-point notation), ROUND(r) assumes the
minimum value 80000001 hexadecimal (-231) or the maximum value 7FFFFFFF hexadecimal
(+231 - 1).
ORD
The ORD(v) function converts any enumerated type value into an integer value. The integer
value reflects the ordinal number in a list of symbolic values that defines the enumerated type.
The value v has to yield a Boolean, integer, or enumerated type value.
If v is boolean, then ORD(false) = 0 and ORD(true) = 1.
If v is an integer, then ORD(v) yields the value of v.
If v is enumerated, then ORD(v) yields the integer ordinal number in the range of values
for that enumerated type. See “Data Types” on page 27, for the enumerated data types
supported in HLBL.
In a Sequence language statement, either the symbolic value or the corresponding ordinal value
can be used. For example, the expression of an IF statement looking for the condition where the
compound SSTATE is active can be either of the following:
IF (:COMPNAM.SSTATE = ACTIVE) THEN ...
IF (1 = ORD (:COMPNAM.SSTATE)) THEN ...
41
B0400DF – Rev R 2. Sequence Language
The restrictions to the data types of the values r and v are enforced during compilation when the
data type is known. If r and v contain external references, data type checking is done at run time
and a violation yields an operational error.
The Bad Status attribute associated with the operand of a transfer function is propagated to the
result.
Arithmetic Functions
Arithmetic functions perform an algebraic operation on an integer or real value. An arithmetic
function can be a simple expression by itself or an operand in a more complex expression. HLBL
arithmetic functions include ABS and SQRT.
ABS
The ABS(v) function yields the absolute value of the real or integer value v. The data type of the
result is that of v.
Example:
ABS(-26.37) = +26.37
SQRT
The SQRT(v) computes the real, square root of the integer or real value v. The data type of the
result is real.
Example:
SQRT(4) = 2.0
The HLBL compiler generates an error message when the operand, v, of the SQRT function
assumes a value that, during compilation, is known to be negative. If v assumes a negative value at
run time, the function yields the square root of the absolute value without any detected error mes-
sage.
The Bad Status attribute associated with the operand of an arithmetic function is propagated to
the result.
Array Functions
Array functions allow you to manipulate the elements of an array with a single statement. HLBL
array functions include SET_ARRAY, SUM_ARRAY, and MULT_ARRAY.
An array function can only appear in the right-hand side of an assignment statement. Only one
array function can appear in a statement, that is, an array function cannot be a factor within a
more complicated expression.
The left-hand side of the statement is an internal reference to:
♦ An array item
♦ A user-array parameter
♦ A local-array variable
♦ An array IN argument
♦ An array INOUT argument.
An array function cannot manipulate the elements of an external array.
42
2. Sequence Language B0400DF – Rev R
SET_ARRAY
The SET_ARRAY(expr) function assigns the value of the expression to the elements of an array.
The data type of the expression, and of the destination array, can be either string or arithmetic.
Examples:
RA0001 := SET_ARRAY (0) ;
BA0001 := SET_ARRAY (II0008 < 3 OR BI0024) ;
STR_A2 := SET_ARRAY (“Initialized String ”) ;
SUM_ARRAY
The SUM_ARRAY(expr) function adds the value of the expression to the elements of an array. The
data type of the expression, and of the destination array, has to be arithmetic. The HLBL com-
piler generates an error if the destination array is data type string.
Example:
RA0002 := SUM_ARRAY ( -130.5 * Min_Level ) ;
MULT_ARRAY
The MULT_ARRAY(expr) function multiplies the elements of an array by the value of the
expression. The data type of the expression, and of the destination array, has to be arithmetic. The
HLBL compiler generates an error if the destination array is data type string.
Example:
IA0002 := MULT_ARRAY ( 1 / AcidTempsArr [5] )
TRANSFERRING ARRAYS
The following external reference will transfer the contents of the local array “xarray” to another
block’s RA0001 array:
:CMPD:BLK.RA0001 := xarray;
43
B0400DF – Rev R 2. Sequence Language
Operational Errors
An operational error occurs at run time when a sequential control block encounters an error that
it cannot recover from by itself. Operational error codes are stored in the block’s OP_ERR param-
44
2. Sequence Language B0400DF – Rev R
eter and can be displayed during operation. Here are some conditions that can cause operational
errors:
♦ Data type inconsistencies in an external reference are discovered.
♦ A statement tries to set the value of a secured parameter. For example, an
ACTCASES statement cannot address a MON block if the block’s ACTPAT parame-
ter is secured.
♦ An external reference is defined to a compound, block, or parameter that is not
defined in uppercase.
♦ A statement references a parameter or block that does not exist. For example, a
START_TIMER statement cannot address a TIM block that does not exist.
♦ A statement cannot address a parameter or block due to communication errors. For
example, the ABORT statement does not deactivate a block.
SBX1, for errors (OP_ERR = 2000 ... 3000), enables sequence blocks to suppress error messages
and execute error handling logic. This logic can either re-execute the erroneous statement, or
move to the statement following the erroneous statement. You can also define SBX1 to count
errors and/or to output a user-specific message. SBX2 provides the same capability for system
errors (errors outside the 2000 to 3000 range).
45
B0400DF – Rev R 2. Sequence Language
46
3. HLBL Preprocessor and Compiler
The HLBL preprocessor is a macro processor that transforms the source text before checking and
also before compilation.
Preprocessor Commands
Preprocessor commands are lines of source code which start with “#”.
The “#” is followed by an identifier which is the command name. For example, “#define” is the
command which defines a macro.
Space characters are allowed before and after the “#”.
There is a fixed set of valid preprocessor command names (see Table 3-1). You cannot define new
preprocessor commands.
Some of the command names need arguments. These make up the rest of the command line and
have to be separated from the command name by space character.
For example, “#define” has to be followed by a macro name and the intended expansion of the
macro.
A preprocessor command cannot be more than one line but may be split with the backslash “\”
character to force a new line for the sake of readability without changing the semantics of the
command.
Table 3-1 lists the commands that the preprocessor supports.
Command Description
#define Define a preprocessor macro.
#undef Remove or cancel a preprocessor macro definition.
#include Insert text from another source file.
#if Conditionally include some text, based on the value of a constant expression.
#ifdef Conditionally include some text, based on whether a macro name is defined.
#ifndef Conditionally include some text, with the sense of the test opposite that of #ifdef.
#else Alternatively include some text, if the previous #if, #ifdef, or #ifndef, test did not
pass.
#endif Terminate conditional text.
The /* and */ comment markers can also be used. Note that this comment is stripped by the pre-
processor and, therefore, it does not appear in the error and listing file nor in the operator repre-
sentation module.
47
B0400DF – Rev R 3. HLBL Preprocessor and Compiler
NOTE
The { and } are invalid to enclose comments for preprocessor commands. The /*
and */ must be used for preprocessor commands.
The preprocessor commands are processed before the actual compilation. As a result those direc-
tives do not appear in the error and listing file nor in the operator representation module.
Macros
Macros are a sort of abbreviation used for the substitution of code parts. They are definable with
or without arguments.
Any macro definition has to be a single line; however it can be split up to more than one line by
the backslash “\” character as described in “Preprocessor Commands” on page 47.
You can place (even multiple line) comments within a macro without any impact on the macro.
The syntax of the “#define” does not need an assignment operator or any special delimiter token
like the “;”. You need not balance parentheses, but a quoted (delimited by “'”) string is extended
to include the matching quote character.
Although the body need not resemble valid code, it provides valid code for the source code con-
text it is used in. If not, further compilation results in errors.
The macro body can contain calls to other macros.
Example:
#define BUFSIZE 1000
#define TABLESIZE BUFSIZE
The name “TABLESIZE” then when used in source code would go through two stages of expan-
sion, at last resulting in “1000”.
48
3. HLBL Preprocessor and Compiler B0400DF – Rev R
Also the preprocessor does not recognize macros which are defined within another macro like
intended in the following example:
#define DO_MY_DEFINITION #define FLAG 2
:
:
DO_MY_DEFINITION; (* error *)
Definition Rules
1. A macro with arguments is defined with the “#define” command followed by a list of
argument names in parentheses.
2. The arguments can be any valid identifiers, separated by commas and optional space
characters.
3. The open-parenthesis “(” has to immediately follow the macro name, with no space in
between as shown in the example to calculate the distance between two points.
Example:
#define DIST(X1, Y1, X2, Y2) (SQRT ((X1–X2)*(X1-X2)+ \
(Y1-Y2)*(Y1-Y2)))
4. To use the macro that expects arguments, the name of the macro is written followed
by a list of actual arguments in parentheses, separated by commas. The number of
actual arguments has to match the number of arguments the macro expects.
Example:
dist := DIST (10.1, 12.5, 5.3, 3.4);
or
dist := DIST (x + 10.0, y + 3.0, 40.0, 10.0);
5. The expansion text of the macro depends on the used arguments. Each of the argu-
ment names of the macro is replaced, throughout the macro definition, with the cor-
responding actual argument.
Example:
dist := DIST (10.1, 12.5, 5.3, 3.4);
expands to
SQRT ((10.1–5.3)*(10.1-5.3)+(12.5-3.4)*(12.5-3.4)))
and
49
B0400DF – Rev R 3. HLBL Preprocessor and Compiler
Argument Rules
1. Parentheses in the actual arguments have to balance.
2. A comma within parentheses does not end an argument.
3. Brackets as used in arrays need not be balanced and thus do not keep a comma from
separating arguments.
Example:
macro (array[x := y, x + 1])
The arguments separated by the comma passed to the macro are:
“array[x := y” and “x + 1]”.
To supply an appropriate argument the following syntax with parentheses has to be
used:
macro (array[(x := y, x + 1)])
4. The actual arguments of a macro can contain calls to other macros, either with or
without arguments, or even to the same macro. The macro body can also contain calls
to other macros.
To supply an empty argument to macro “MAC(arg1)” it has to be called with at least
one space character between the parentheses, like this: “MAC( )”.
Calling “MAC()” is providing no arguments, which is an error as MAC expects an
argument.
But if a macro is defined like 'MAC0()' the correct way to call this macro to take zero
arguments is 'MAC0()'.
5. Using the macro name followed by something other than an open-parenthesis (after
ignoring any spaces, tabs and comments that follow), causes the preprocessor to leave
the source code as is.
Undefining Macros
To undefine a macro means to cancel its definition. This is done with the “#undef ” command.
“#undef ” is followed by the macro name to be undefined.
Example:
#define MAC 4
x := MAC;
#undef MAC
x := MAC;
expands into
50
3. HLBL Preprocessor and Compiler B0400DF – Rev R
x := 4;
The same form of “#undef ” command will cancel definitions with arguments or definitions that
do not expect arguments.
The “#undef ” command has no effect when used on a name not currently defined as a macro.
Redefining Macros
Redefining a macro means defining (with “#define”) a name that is already defined as a macro.
A redefinition is trivial if the new definition is transparently identical to the old one.
That can happen automatically when a source file containing macro definitions is included more
than once (see “Include Files” on page 51).
Nonidentical redefinition provokes a “warning” system message from the preprocessor. As it is
sometimes useful to change the definition of a macro in mid-compilation, a system message can
be inhibited by undefining the macro with “#undef ” before the second definition.
For a redefinition to be identical, the new definition has to exactly match the one already in effect,
with two possible exceptions:
♦ Space character can be added or deleted at the beginning or the end.
♦ Space character can be changed in the middle (but not inside strings). However, it can
not be eliminated entirely, and it can not be added where there was no space character.
Comments do not have any impact on redefinition.
Include Files
An include file is a file containing declarations, macro definitions (see “Macros” on page 48) or
common source code to be shared between several source files.
The file inclusion statement is a directive to the HLBL compiler to include the characters of the
named file into the source file of the block that is being translated. To request the use of an
include file the preprocessor command “#include” is used together with a sequence of printable
characters.
The include statement can appear anywhere in an HLBL source. The characters in the include file
need not be a correct compilation unit. The source file, resulting from the combination of the
include file(s) and the source file, is checked by the HLBL compiler for syntax and semantic
errors.
The requested filename is identified through the configurator’s database.
Syntax:
“#include” ['"']{<any printable character>}['"']
Examples:
Table 3-2. Include File Examples
51
B0400DF – Rev R 3. HLBL Preprocessor and Compiler
#include Command
The “#include” command has two variants:
♦ “#include” “filename”
The requested filename is identified within the configurator’s database. If it does not
represent an identifiable filename, the preprocessor generates a system message.
♦ “#include” macro_text
macro_text is checked for being a valid macro call and expanded to the above version
of “#include” command. This allows you to define a macro that controls the file name
to be used at a later point in the program.
The following directory is used to search for the file:
♦ /usr/fox/ciocfg/sequeninclude (for ICC - VENIX)
♦ /opt/fox/ciocfg/sequeninclude (for ICC - Solaris)
♦ IACC puts them in the library for text objects.
The “#include” command works by directing the preprocessor to scan the specified file as input
before continuing with the rest of the current file. The output from the preprocessor contains the
output already generated, followed by the output resulting from the included file, followed by the
output that generates from the text after the “#include” command.
Included files are not limited to declarations and macro definitions; those are merely the typical
uses. You can include any fragment of a code program. The include file could even contain the
beginning of a statement that is concluded in the containing file, or the end of a statement that
was started in the containing file.
However, a comment or a string may not start in the included file and finish in the including file.
An unterminated comment or string constant in an included file is considered to end (with an
error message) at the end of the file.
The line following the “#include” command is treated as a separate line by the preprocessor even
if the included file lacks a final new line.
Example of a sequence source file using preprocessor directives:
INDEPENDENT_SEQUENCE
52
3. HLBL Preprocessor and Compiler B0400DF – Rev R
#define TESTPHASE 2
#define ON TRUE
#define OFF FALSE
#define Switch_Motor2(s) :COMP_12:MTR_101.MA:=s
CONSTANTS
#include “constant.defs.2”
VARIABLES
#include “vars_2.decl.org”
USER LABELS
Nylon_Temp : RI0001 ;
#include “nylon2.subrs”
#if TESTPHASE == 2
#include “dral.sbxs.tst” { test version }
#else
#include “dral.sbxs.fin { final version }
#endif
STATEMENTS
#include “polym.main” {main polymerization logic }
#ifdef TESTPHASE { not in final version }
SENDMSG (“Executing Motor switch logic”) TO MSGGR2 ;
#endif
Switch_Motor2 ( ON ); { <- parameterized macro }
WAIT 30;
Switch_Motor2 ( OFF );
ENDSEQUENCE
The macro __MY_INC_FILE__ indicates that the file has been included once already.
It is recommended that its name begin with “__” to avoid any conflicts with other names used
and includes the name of the file with additional text.
Conditional Commands
Conditional commands allow parts of the source code to be included or ignored during compila-
tion. The condition can be tested based on the value of a constant expression or on whether a
macro name is defined.
53
B0400DF – Rev R 3. HLBL Preprocessor and Compiler
#if Command
The “#if ” command in its simplest form consists of:
#if “expression”
controlled text
#endif
#else Command
The “#else” command can be added to a conditional command to provide alternative text to be
used if the condition is false.
Example:
#if expression
text-if-true
#else
text-if-false
#endif
If expression is nonzero, and thus the text-if-true is active, then “#else” acts like a non-succeeding
conditional and the text-if-false is ignored and vice versa.
54
3. HLBL Preprocessor and Compiler B0400DF – Rev R
Limit Description
32000 Maximum size (in bytes) of a sequence block including header,
parameters, and interpretive code
30000 Maximum size (in bytes) of a sequence block in the CP30, CP40, or
CP60 including, parameters, and interpretive code
31200 Maximum size (in bytes) of a sequence block in a CP270 or FCP280
including, parameters, and interpretive code
161 Maximum length of a constant identifier
161 Maximum length of a variable name
161 Maximum length of an argument name
161 Maximum length of a user-parameter label
10 Maximum length of a subroutine name
16 (12) 16 character maximum length of a step label (including the enclosing
$$ and $$ ) (for example, $$step$$)
12 character maximum length for the text between the enclosing $$
and $$
16 (12) 16 character maximum length of a statement label (including the
enclosing << and >>) (for example, <<stmt>>)
12 character maximum length for the text between the enclosing <<
and >>
128 Maximum number of block local variables in the main code
128 Maximum length of a line of source code
50 Maximum combined number of subroutine local variables and
subroutine arguments in each subroutine
20 Maximum number of comma separated arguments before a data type
specification
256 Maximum number of dimensions in an array-type block local variable
or subroutine local variable
8 Maximum levels of nested array index expressions (for example,
a[1,b[6,c[8,2]]] has three levels)
55
B0400DF – Rev R 3. HLBL Preprocessor and Compiler
Limit Description
10 Maximum number of nested subroutine CALLs
(Note that a subroutine cannot call itself, directly or indirectly.)
255 Maximum number of subroutines in each dependent, independent, or
exception block
255 Maximum number of external references
a) in each subroutine or
b) in the main code and all SBXs (standard block exception handlers)
255 Maximum number of message strings
a) in each subroutine or
b) in the main code and all SBXs
255 Maximum number of steps in the main code including INIT_STEP
and END_STEP
255 Maximum combined number of statement labels and step labels
a) in each subroutine or
b) in the main code and all SBXs
(Note that only the main code can have step labels and INIT_STEP
and END_STEP are counted as two.)
20 Maximum levels of nested control constructs
(for example if, for, repeat, while, . . .)
4096 Maximum buffer size for all subroutine names in each dependent,
independent, or exception block
4096 Maximum buffer size for all external references
a) in each subroutine or
b) in the main code and all SBKs
4096 Maximum buffer size for all message strings
a) in each subroutine or
b) in the main code and all SBKs
1025 Maximum buffer size for each operator remark
1. These strings may exceed 16 characters. However, their first 16 characters HAVE
TO be unique, as only these 16 characters are used (valid).
56
4. HLBL Statements
This chapter contains information on HLBL statements including statement syntax and the
statements ABORT, ACTCASES, ACTIVATE, ASSIGNMENT, SCALAR, ASSIGNMENT,
ARRAY, BIT_PATTERN, EXIT, EXITLOOP, FOR, GOTO, IF, MONITOR CASE,
REPEAT, RETRY, SENDCONF, SENDMSG, SET_SBXS, START_TIMER,
STOP_TIMER, WAIT, and WHILE.
Statement Syntax
The executable HLBL algorithm code in the IND, DEP, EXC, and MON blocks consists of state-
ments and statement_sequences defined below. The code enclosed by square brackets [ ] is
optional.
57
B0400DF – Rev R 4. HLBL Statements
Statement syntax:
assignment_statement
or
logic_flow_control_statement
or
procedural_statement
or
subr_call_statement
or
empty
Algorithm_terminator syntax:
ENDSEQUENCE
or
ENDSUBROUTINE
or
ENDEXCEPTION
A statement can also be empty.
The Monitor (MON) block has only one type of statement, the Monitor Cases statement. It is
used to define up to 16 cases that can be monitored by the block.
Following the information on statement syntax and format conventions, statements are listed in
alphabetical order.
The semicolon separates statements in an algorithm. Additional algorithm terminators are:
ENDFOR, ENDWHILE, ENDIF, ENDSEQUENCE, ELSE, ELSEIF, and UNTIL.
When constructing a statement, adjacent lexical units have to be separated by spaces, tabs, or
lines.
Except for comments, operator remarks, and string literals, spaces or tabs are not to be contained
within lexical units.
Lexical units, except for comments and operator remarks, have to fit on a single line. Otherwise,
spacing is optional and used to make statements legible.
58
4. HLBL Statements B0400DF – Rev R
Abort
Format
ABORT :compoundname:blockname
Description
The ABORT statement deactivates an active Sequence (IND, DEP, or EXC) or Monitor
(MON) block by writing a false value to the ACTIVE parameter of the addressed block. If
another request is pending, the ABORT statement is retried once every scheduled basic
processing cycle (BPC) until no other request is pending.
An attempt to deactivate a block that is already deactivated is treated as a successful
attempt.
An unsuccessful attempt to deactivate the block is treated as an operational error.
Example:
ABORT :REACT_LEVEL:FILL
Actcases
Format
ACTCASES (compoundname:blockname,“activate pattern”)
Description
The ACTCASES statement can set the activity status of individual cases in the Monitor
Case statement of the specified Monitor (MON) block.
The activation pattern represents the new activity states of the cases belonging to the
MON block specified in the statement.
Each character in the activation pattern corresponds to a case in that block. The characters
allowed in the pattern are A, I, and -. The character A stands for Active, I for Inactive, and
- indicates no change in activity state.
The first character stands for the first case in the Monitor Case statement, the second
character for the second case, and so on. Any cases not specified in the pattern are left as
they are.
59
B0400DF – Rev R 4. HLBL Statements
Examples:
ACTCASES (:REACT_LEVEL:FILL,“AAAAAIAIAIAIAAAA”)
ACTCASES (:REACT_LEVEL:DRAIN,“A-AIIIA-I---A”)
Activate
Format
ACTIVATE :compoundname:blockname [WHEN ALREADY GOTO label]
Description
The activation statement activates a Sequence (IND, DEP, or EXC) or Monitor (MON)
block by writing a true value to the ACTIVE parameter of the addressed block. If another
request is pending, the ACTIVATE statement is retried once every scheduled BPC until
no other request is pending.
An attempt to activate a block that is already active is treated as a successful attempt. An
optional WHEN ALREADY GOTO clause allows you to branch to a statement specified
by a label when the block is already active. The label can be either a statement label or a
step label.
An unsuccessful attempt to activate the block is treated as an operational error.
Examples:
ACTIVATE :REACT_LOGIC:FILL;
ACTIVATE :REACT_LOGIC:LEVEL WHEN ALREADY GOTO drain;
.
.
.
<<drain>>
ACTIVATE :REACT_LOGIC:DRAIN
Assignment, Scalar
Format 1
internal reference := expression
Format 2
external reference := expression
Description
The assignment statement replaces the current value of an internal or external reference
(on the left hand side) with the value that results from evaluating an expression (on the
right hand side). The value of the expression’s Bad status bit is transferred to the reference
(refer to “Bad Status Attribute” on page 45).
The two categories of scalar assignments are the arithmetic assignment statement and the
string assignment statement. The data type of the left hand side of the assignment state-
ment determines the category of any given statement.
60
4. HLBL Statements B0400DF – Rev R
If the left hand side is a reference to a string type internal reference, the assignment is a
string assignment. In all other cases involving internal references the assignment is arith-
metic.
If the left hand side is an external reference, the right hand side, if it is an internal refer-
ence, determines the assignment category.
If both left and right sides are external references, the assignment is arithmetic unless the
keyword STRING precedes the external reference in the right hand side. See the following
table.
External Reference
External References
Non-String Internal Reference AE CE AE CE are specified by a
FPN_construct.
String-Type Internal Reference SE SE SE SE
FPN = Full Pathname
External Reference AE SE AE SE
61
B0400DF – Rev R 4. HLBL Statements
♦ Standard parameters of the Sequence block cannot be the left value when addressed
using an internal reference.
♦ Connection status fields (SECURED, ON, and BAD) can only be read in HLBL
statements, that is, they can only appear on the right hand side of an assignment.
They cannot be set to some value by means of an assignment statement.
The data types of the reference and the value yielded by evaluating the expression has to be com-
patible as follows:
♦ If the right value is integer, the left value has to be either real or integer and the right
value is coerced appropriately.
♦ If the right value is real, the left value has to be real. The expression can be pro-
grammed to deliver an integer using the TRUNC or the ROUND function.
♦ If the right value is Boolean, the left value has to be Boolean.
When the data type is not known at compilation time, a check is performed at run time. At that
time, if the right value appears to be a real and the left value is an integer, the right value is coerced
automatically as if the ROUND function were specified. Any other data-type mismatch at run
time raises an operational error.
Any non-success, not described above, that occurs during execution of the assignment statement,
is treated as an operational error.
If the conversion of a real value causes overflow, because the converted value does not fit into a
long integer, an appropriate minimum or maximum value is substituted for the result.
Examples:
:REACT_LOGIC:HEAT.BI0001 := TRUE
opr_res := -1
Assignment, Array
Format
array reference := array reference
where an array reference can be: an external reference, a user array parameter, or a
local variable array name.
Description
While scalar assignment statements can manipulate the individual elements of arrays,
array assignment statements can assign whole arrays, arithmetic or string, to each other
with one statement.
It is recommended that the right hand side of the statement be an internal or an external
reference; that is, the right side cannot be an expression of more than one operand or
operator.
Elements of external arrays cannot be accessed individually; that is, you cannot index
within an external array.
If the right hand side is an external array parameter, an operational error occurs at run
time because a whole array cannot be pushed onto the internally used evaluation stack. As
62
4. HLBL Statements B0400DF – Rev R
a result, elements of two external arrays cannot be moved from one to the other with a sin-
gle array assignment statement.
If the right hand side is a scalar and the left hand side is an array, no operational error
occurs, but only the first element of that array is assigned a new value.
The data types of the left and right hand side have the same compatibility requirements as
Scalar Assignment statements.
If the source and destination internal references do not have the same number of ele-
ments, the compiler issues an error message. If the number of elements are equal and the
dimensioning is different, the compiler publishes a “warning” system message. For
instance, two arrays dimensioned [3, 2, 4] and [12, 2] can be assigned to each other.
Arrays are stored in memory with the last index moving fastest.
If either side is an external reference, the compiler cannot check its size. If the number of
elements differ, then:
♦ If the destination array contains fewer elements than the source array, an operational
error is raised and the elements in the destination array remain unchanged.
or
♦ If the destination array contains more elements than source array, only destination ele-
ments in excess remain unchanged.
As with the scalar assignment, the array assignment is in one of two categories: arithmetic
and string.
An external reference cannot be a string array. Therefore, the compiler does not allow a
string-type array assignment to have external references. If both sides of an array assign-
ment are external references, the compiler translates the assignment as an arithmetic array
assignment.
Examples:
BA0003 := BOOL_VALUES
:COMP:BLK.RA0002 := IA0001
The number of array dimensions can be up to 256. There is no limit on the number of elements
you can define for an array.
The following are examples for assignments to sequence logic array:
BA0001[3] := FALSE;
USER_BA := SET_ARRAY(0);
USER_BA[2, 2, 2] := BA0001[3];
USER_BA[2, 3, 4] := TRUE;
IA0001[16] := 100;
Bit_pattern
Format
destination := BIT_PATTERN ( source )
Description
The BIT_PATTERN statement enables:
♦ The packing of a set of Boolean values into a bit pattern
63
B0400DF – Rev R 4. HLBL Statements
Examples:
IO0004 := BIT_PATTERN ( BA0003 )
{Each of the 16 elements of BA0003 are packed as a bit pattern into IO0004}
IO0008 := BIT_PATTERN ( BO0001 )
{Each of the 16 boolean output parameters are packed as a bit pattern into IO0008}
II0001 := BIT_PATTERN ( Loc_Bool_Arr )
{Up to 32 elements of Loc_Bool_Arr are packed as a bit pattern into II0001}
BI0001 := BIT_PATTERN ( II0002 )
{24 bits of II0002 are unpacked to give the boolean input parameters a boolean
value}
BO0001 := BIT_PATTERN ( Loc_Int_Var )
{16 bits of the Loc_Int_Var are unpacked to give the boolean output parameters a
boolean value}
Exit
Format
EXIT
Description
When executed, the EXIT statement terminates the block algorithm. Any statements fol-
lowing EXIT are not executed. You can use the EXIT statement in subroutines, in SBXs,
and/or the main code section.
Example:
STATEMENTS
<<fill>>
64
4. HLBL Statements B0400DF – Rev R
NOTE
In this example, the statements after EXIT are not executed when conditions are
normal. However, if conditions specified in the AFTER clause of the WAIT
UNTIL statement are met, statement execution skips the EXIT statement and goes
to the statement labeled fill_fail. Then statement execution terminates at
ENDSEQUENCE.
Exitloop
Format
EXITLOOP
Description
The EXITLOOP statement directs control flow to the point right after the nearest enclos-
ing loop. It can only occur within a loop.
Example:
FOR batchno := 1 TO 5 DO
SENDMSG (“Beginning batch number,” batchno) TO status_stg;
IF a = 1 THEN
GOTO startcycle;
ELSE
EXITLOOP;
ENDIF;
ENDFOR
NOTE
The EXITLOOP statement terminates the FOR loop, not the ELSE clause.
65
B0400DF – Rev R 4. HLBL Statements
For
Format
FOR control variable := expression TO expression DO
statement...
statement...
statement...
ENDFOR;
FOR control variable := expression DOWNTO expression DO
statement...
statement...
ENDFOR
Description
The FOR statement executes a group of statements a specified number of times. The con-
trol variable determines the number of repetitions.
The control variable is an integer. It can be a user output parameter (labeled or not) or a
local variable (either block or subroutine) known by the sequence block, or an arithmetic
user parameter name (II000n or IO000n).
The first expression in the statement is the initial value of the control variable, the second
expression is the final value of the control variable for which the DO statement is per-
formed. In most cases, both expressions yield an integer value. If they do not, a compiler
error is generated in case of internal references or a run-time error is generated in case of
external references.
Statements in the FOR loop are executed until the control variable reaches its final value.
After each repetition, the control variable is incremented or decremented by one until the
final value is reached. The keyword TO increments the value. The keyword DOWNTO
decrements the value.
The control variable value is tested before statements in the loop are executed. If the initial
value of the control variable is equal to (or greater than) the final value, when the key-
word, TO, is used, the statements are not executed. Likewise, when the keyword,
DOWNTO, is used, the statements are not executed if the initial value is equal to (or less
than) the final value.
For a positive increment, the FOR statement terminates when the control variable exceeds
the second expression. Likewise, for a negative increment, the FOR statement terminates
when the control variable is less than the second expression. These conditions are tested
before executing the DO statements. Therefore, if either of these conditions exist initially,
the DO statements are not executed. The value of the control variable, after leaving the
FOR statement, is undefined.
If evaluating one of the expressions sets the Bad Status Attribute, the Bad Status is ignored
and the statement uses the value as if it were not marked Bad. This can occur if:
♦ One of the operands of the expression is an input parameter that belongs to the block
and is currently serving as a data sink of a linkage.
♦ One of the operands of the expression is an external reference to an input, or output,
parameter that has its Bad status attribute set.
66
4. HLBL Statements B0400DF – Rev R
♦ If an operand is an external reference and its value cannot be retrieved at run time, an
operational error is raised.
Examples:
FOR batchno := :REACT_COMP:DRAIN.IO0001 TO end_cntr DO
SENDMSG (“Beginning batch number,” batchno) TO MSGGR2;
ENDFOR
The following FOR statement,
FOR i := 42 TO 50 DO
asciinr := i;
:'dcomp':V0'asciinr'.AUTOPN := FALSE;
ENDFOR
can replace the following nine commands:
:'dcomp':V042.AUTOPN:=FALSE;
:'dcomp':V043.AUTOPN:=FALSE;
:'dcomp':V044.AUTOPN:=FALSE;
:'dcomp':V045.AUTOPN:=FALSE;
:'dcomp':V046.AUTOPN:=FALSE;
:'dcomp':V047.AUTOPN:=FALSE;
:'dcomp':V048.AUTOPN:=FALSE;
:'dcomp':V049.AUTOPN:=FALSE;
:'dcomp':V050.AUTOPN:=FALSE
Goto
Format
GOTO label
Description
The GOTO statement provides transfer of the flow of control to any labeled statement
within the same coded programming entity (block main section, subroutine, or SBX).
Flow of control cannot be transferred to a statement inside another block.
You can refer to a statement label, or a step label, within the block’s main code section
only from a statement within that same main code section or from a statement in one of
the block’s SBXs; that is, you can use the GOTO statement to jump out from an SBX into
the main code section.
The HLBL compiler generates an error message if the program tries to use the GOTO
statement to:
♦ Jump into a subroutine
♦ Jump out from a subroutine
♦ Jump into a standard block exception handler.
Example:
IF amount < REACT_COMP2:MIXER.RI0001
THEN GOTO drain_fail;
ENDIF;
<<drain_fail>>
67
B0400DF – Rev R 4. HLBL Statements
If
Format
IF expression THEN statement;
[ELSEIF expression THEN statement...;]
[ELSE statement;]
ENDIF
Description
The IF statement provides conditional statement execution. Statements are executed
according to the evaluation of a conditional expression. The ELSEIF and ELSE clauses are
optional. When an expression in the IF clause or an optional ELSEIF clause in the state-
ment is true, the THEN statement following the expression is executed. In an IF state-
ment that contains an optional ELSE clause, or if the IF clause expression and the
optional ELSEIF clauses are false, the statement following the ELSE clause is executed.
An IF statement can have multiple ELSEIF clauses and/or one ELSE clause.
If evaluating the expression sets the Bad status attribute, the block ignores it and interprets
the value as if it were not marked Bad. The Bad status attribute can be set when:
♦ One of the operands of the expression is an input parameter that belongs to the block
itself and the parameter serves as a data sink of a linkage.
♦ One of the operands of the expression is an external reference to an input or output
parameter that has its Bad status attribute set.
An operational error is raised if one of the operands is an external reference and its value
cannot be retrieved at run time.
Examples:
IF a <1 OR a >3 THEN
GOTO error_msg;
ENDIF;
IF a = 1 THEN
GOTO startcycle;
ELSEIF a = 2 THEN
GOTO stopcycle;
ELSE
GOTO error_msg;
ENDIF;
IF a = 1 THEN
GOTO startcycle;
ELSE
GOTO error_msg;
ENDIF
When a CALL subroutine statement is the last statement of an IF/THEN clause, and is
executed, the STEPNO parameter indicates the step number of the CALL subroutine
statement. The parameter, STMNO, indicates the statement being executed, or to be exe-
cuted next, within the current subroutine.
68
4. HLBL Statements B0400DF – Rev R
Monitor Case
Format
MONITOR
mb_heading;
casenumber boolean expression --> output parameter label;
casenumber WHEN boolean expression [ --> output parameter label] DO
:compoundname:blockname;
ENDMONITOR
Description
The Monitor Case statement only applies to the Monitor (MON) block. Each MON
block contains one Monitor Case statement which can be assigned up to 16 cases for eval-
uation. Expressions in the Monitor Case statement have to yield a Boolean value when
evaluated. The data type is checked at compilation time. No external references are
allowed in monitor expressions.
Each time a Monitor Case is evaluated the Boolean result is stored in the corresponding
Boolean output parameter. When a compound:block name is specified it can activate any
sequence block (EXC, DEP, IND, or MON).
The user-labeled Boolean output parameter is not declared in the heading section. It is
named in the case where it is used to save a Boolean value. That user-label is only intro-
duced to convey the Boolean result of a particular Monitor Case onto another one. See
Table 3-3 for the maximum length of a user parameter.
The Monitor block heading has two forms:
♦ Only user-label declarations without any keywords
♦ Constants definition and the user-label declaration preceded by keywords.
Before you have added any cases, the HLBL source of a monitor looks like this:
MONITOR
CONSTANTS
USER_LABELS
CASES
0001 ;
0002 ;
0003 ;
0004 ;
0005 ;
0006 ;
0007 ;
0008 ;
0009 ;
0010 ;
0011 ;
0012 ;
0013 ;
0014 ;
0015 ;
0016 ;
ENDMONITOR
69
B0400DF – Rev R 4. HLBL Statements
Example:
MONITOR
CONSTANTS
USER_LABELS
level_hi : BI0001;
level_lo : BI0002;
CASES
0001 level_lo --> level_rec1;
0002 WHEN level_hi DO :REACT_LOGIC:HI_LVL_EXC;
0003 WHEN level_rec1 DO :REACT_LOGIC:LO_LVL_EXC;
.
.
.
0016;
ENDMONITOR
NOTE
1. Cases can be added after each of the case numbers listed.
2. Case numbers need not have a case assigned to them, but the case numbers have
to be listed.
3. A case statement can be preceded by an operator remark that is following a case
number.
4. If the Bad status attribute is set as a result of evaluating the expression, the expres-
sion is interpreted as being false. The value of Bad status attribute is sent to the asso-
ciated Boolean output parameter.
5. Only active cases, as determined by the parameter ACTPAT, are evaluated.
Repeat
Format
REPEAT statement... UNTIL expression
Description
The REPEAT statement executes a series of statements repeatedly until the value of a con-
ditional expression is true. Statements in the REPEAT statement are executed at least
once.
Example:
time: = 0;
REPEAT
IF opr_res < 1 OR opr__res > 3 THEN
GOTO drain_fail;
ENDIF;
time = time + 1;
WAIT 1;
UNTIL time = 50;
If evaluating the expression sets the bad status attribute, the block ignores it and interprets
the value as if it were not marked Bad. The Bad status attribute can be set when:
70
4. HLBL Statements B0400DF – Rev R
♦ One of the operands of the expression is an input parameter that belongs to the block
itself and the parameter serves as a data sink of a linkage.
♦ One of the operands of the expression is an external reference to an input or output
parameter that has its Bad status attribute set.
An operational error is raised if one of the operands is an external reference and its value
cannot be retrieved at run time.
Retry
Format
RETRY
Description
The RETRY statement is an alternate exit point from the two error handling SBXs. You
can use RETRY only with the two error handling SBXs. Any other use produces a com-
piler error.
When an error handling SBX is terminated with ENDEXCEPTION, statement execu-
tion resumes with the statement following the one that caused the SBX to be executed.
The RETRY statement directs the logic to re-execute the erroneous statement that caused
the SBX to be executed.
NOTE
Use the RETRY statement with care. The execution of an error handling SBX sup-
presses the generation of an alarm, and the switching of the block state to Manual.
The RETRY statement permits the repeated execution of the erroneous statement,
with no check, or indicator, of the number of retries. It is advised that you build a
counting mechanism (see Example) and/or a security check into the SBX.
Example:
BLOCK_EXCEPTION TO_SYS_ERROR
#if PHASE == FINAL APPLICATION
{ use this retry counting after all tests have passed }
IF Retry_Cnt < 3 THEN
Retry_Cnt := Retry_Cnt + 1;
RETRY ;
ELSE
SENDCONF (“Should”, COMPOUND103,”;”,BLOCK14,” do another 3
retries?”)
TO MSGGR1 AFTER 60 GOTO no_answer;
Retry_Cnt := 0;
RETRY ;
ENDIF
<<no_answer>>
SENDMSG (“No confirmation on retry, “, BLOCK14, “ de-activated”) TO
MSGGR1;
EXIT
71
B0400DF – Rev R 4. HLBL Statements
Sendconf
Format
SENDCONF ([literal, literal..], [expression, expression..]) TO
parameter AFTER expression GOTO label
Description
The SENDCONF statement sends messages interactively to logical devices or objects that
act like logical devices (such as historians and printers).
Upon executing the SENDCONF statement, the standard block parameter SUSPND
(suspended on message) is set true and statement execution is suspended until SUSPND
is set to false again from outside the block, or until an optional time-out value expires.
The message has to be less than 80 characters.
The message is a string composed of any combination of string literals and expressions.
Commas separate individual strings and expressions in the message.
The label can be either a statement label or a step label.
Examples:
SENDCONF ( “Operational Error is”, OP_ERR ) TO MSGGR3;
SENDCONF ( “Suspension lasts for”, II0001, “sec.” ) TO MSGGR2
AFTER II0001 GOTO DRAINING
Sendmsg
Format
SENDMSG ([string literal, string literal...], [expression, expres-
sion...]) TO parameter
Description
The SENDMSG statement sends messages to logical devices or objects that act like logical
devices (such as historians and printers) and user-labeled string parameters.
♦ The message is a string composed of any combination of string literals and
expressions.
♦ Commas separate individual strings and expressions in the message.
♦ The message has to be less than 80 characters.
♦ When an expression that is part of a message, is evaluated, the results are converted
into strings as follows:
♦ A real value is converted into a string of fixed length. The string format is:
sx.xxxxxxesyy
where:
72
4. HLBL Statements B0400DF – Rev R
DV1 <logical_name>
DV3 <logical_name>
DV9 <logical_name>
73
B0400DF – Rev R 4. HLBL Statements
DV15 <logical_name>
and
GR5 0xA082
where:
You can also send a message to a user-labeled string parameter that belongs to the
block. The Operator Message Interface can then retrieve the message for operator dis-
play. The standard parameter MSGNO belonging to the block is incremented by one
each time a new message is assigned to any of the user-labeled string parameters.
NOTE
1. Using an out-of-range value for x in the MSGGRx entry clamps the value at 1
or 8, whichever is nearest.
2. When sent to a message group parameter, the message is appended to a list of
fixed message fields and sent to the logical devices associated with the message
group.
3. To send messages to the Historian, assign the message to a MSGGRx parameter
that has the Historian in its group of associated devices.
4. The compiler raises an error if the parameter name in the TO clause is not one of
MSGGRx parameters or a user-string parameter.
Examples:
status_flg : SN0001 ;
.
.
.
SENDMSG (“Beginning New Batch”) TO status_flg;
SENDMSG (“Beginning Batch Number = ”, batchno) TO MSGGR2
Set_sbxs
Format
SET_SBXS (availability pattern)
Description
The SET_SBXS statement uses its availability pattern to manipulate the five block param-
eters DISBX1, DISBX2, DISBX3, DISBX4, DISBX5. When an SBX is “Enabled”
74
4. HLBL Statements B0400DF – Rev R
(DISBXx = False) the SBX is available, and the block executes the statements specified in
the SBX when the corresponding event occurs.
The availability pattern is a string literal whose only three valid characters are:
As long as an SBX is set “Disabled” (DISBXx = True) the SBX is unavailable and its logic
is not executed.
Two standard block exception handlers (SBXs) are supported for error handling and three
are supported for state change handling.
Example:
SET_SBXS (“E-EDD”)
This statement:
♦ Enables the “TO_SYS_ERROR” SBX (DISBX1 = False)
♦ Leaves the “TO_USR_ERROR” SBX as it was (DISBX2 is not changed)
♦ Enables the “TO_INACTIVE” SBX (DISBX3 = False)
♦ Disables the “TO_MANUAL” SBX (DISBX4 = True)
♦ Disables the “TO_PAUSED” SBX (DISBX5 = True).
Start_timer
Format
START_TIMER (:compoundname:blockname.timername [, expression])
75
B0400DF – Rev R 4. HLBL Statements
Description
The START_TIMER statement turns on a specified timer in a Timer (TIM) block.
START_TIMER optionally initializes a timer to the number of seconds specified in the
expression. The timer is then incremented by the value of the block’s period each time the
block is scheduled to be executed. Timers are updated as long as the TIMER block is in
Auto and the compound is on.
Specify the timer name as TIMR1, TIMR2, TIMR3, or TIMR4.
If the addressed Timer block does not exist, an operational error is raised at run time.
NOTE
After starting a timer, suspend (for example, use a WAIT statement) before testing
the timer. Otherwise, the timer block does run and you receive an invalid timer sta-
tus.
Examples:
START_TIMER (:REACT_LOGIC:FILL_TIME.TIMR1)
WAIT 0.5 ;
{or}
START_TIMER (:REACT_LOGIC:FILL_TIME.TIMR1, 0.0)
WAIT 0.5 ;
Stop_timer
Format
STOP_TIMER (:compoundname:blockname.timername)
Description
The STOP_TIMER statement turns off a specified timer in a Timer (TIM) block.
Specify the timer names as: TIMR1, TIMR2, TIMR3, or TIMR4.
If the addressed Timer block does not exist, an operational error is raised at run time.
Example:
STOP_TIMER (:REACT_LOGIC:FILL_TIME.TIMR1)
Wait/Wait Until
Format 1
WAIT time_period
Format 2
WAIT UNTIL controlling_expression AFTER time_period GOTO label
Description
Statement execution can be delayed with a WAIT or WAIT UNTIL statement.
76
4. HLBL Statements B0400DF – Rev R
Examples:
WAIT 1.0;
WAIT UNTIL fill_actv = FALSE AFTER 600 GOTO fill_fail;
.
.
<<fill_fail>>
SENDMSG (“Filling too slowly 1:Retry 2:Abort 3:Continue”) TO
status_stg
While
Format
WHILE expression DO statement... ENDWHILE
Description
The WHILE statement executes a series of statements repeatedly while a given condi-
tional expression is true. Statements in the WHILE loop are not executed if the specified
condition is not true initially.
Example:
WHILE count <= 5 DO
value := value * count;
count := count + 1;
ENDWHILE
If evaluating the expression sets the Bad status attribute, the block ignores it and interprets
the value as if it were not marked Bad. The Bad status attribute can be set when:
♦ One of the operands of the expression is an input parameter that belongs to the block
itself and the parameter serves as a data sink of a linkage.
♦ One of the operands of the expression is an external reference to an input or output
parameter that has its Bad status attribute set.
77
B0400DF – Rev R 4. HLBL Statements
An operational error is raised if one of the operands is an external reference and its value
cannot be retrieved at run time.
When a CALL subroutine statement is the last statement of a WHILE loop, and is exe-
cuted, the STEPNO parameter indicates the step number of the CALL subroutine state-
ment. The parameter, STMNO, indicates the statement being executed, or to be executed
next, within the current subroutine.
78
Appendix A. Sequence Control
Error Messages
Operational Errors occur at runtime when a sequential control block encounters an error that it
cannot recover from by itself. Operational error codes are stored in the block’s OP_ERR parame-
ter and can be displayed during operation. Some conditions that can cause operational errors are
as follows:
♦ Data type inconsistencies in an external reference are discovered.
♦ A statement tries to set the value of a secured parameter. For example, an
ACTCASES statement cannot address a MON block if the block’s ACTPAT parame-
ter is secured.
♦ An external reference is defined to a compound, block, or parameter that is not
defined in upper case.
♦ A statement references a parameter or block that does not exist. For example, a
START_TIMER statement cannot address a TIM block that does not exist.
♦ A statement cannot address a parameter or block due to communication errors. For
example, the ABORT statement does not deactivate a block.
Operational Errors (OP_ERR) messages listed in the following sections are those which can be
raised in a Monitor or a Sequence block. When this occurs, the OP_ERR parameter assumes an
integer that indicates the type of condition that occurred.
The 2000 and 3000 series OP_ERR messages are detected by the sequence control blocks. The
values of OP_ERR less than 2000 are simply conveyed by the sequence control blocks.
These error messages are classified as either priority one (High) or priority two (Low) messages.
Priority one messages, requiring immediate attention, are those sent to the workstation processors
and/or personal computers designated to report system alarms. This type is also sent to the histo-
rian and to a high-priority message printer. Priority two messages, those usually not requiring
your immediate attention, are sent to the historian and to a low-priority message printer.
The following string text represents a typical message line that is printed via a logging device to a
priority printer. The standard message line contains the following constants:
(mm-dd-yy) month-day-year
(HH:MM:SS) hour:minute:second
(PRI <subsystem>) the primary subsystem (for example, PRI SYSMON=SYSMN1)
(IPC) the subsystem text string file
(-01071) the file code
“Invalid station address the Message
and/or letterbug”
79
B0400DF – Rev R Appendix A. Sequence Control Error Messages
Code Description
2101 attempt to assign a Boolean value to a user parameter or variable with a data type of
integer or real
2102 attempt to assign a non-Boolean value to a Boolean user parameter or variable
2103 attempt to write to an array value(s) which cannot be converted to integer or real
2116 more external array elements read than can be assigned to destination array
Code Description
2301 in an arithmetic expression, the data type is unequal to BOOL, LONG, or FLOAT
encountered,
OR
in a string expression, the data type is unequal to STRING encountered.
(NOTE: External string parameters have to be preceded by the keyword STRING in
string expressions. For example, SN0005: = STRING : CMP1: BLK1.SN0001)
2302 only a Boolean data type is permitted in a logical expression
2303 a Boolean data type is not permitted in an arithmetic expression
2304 only an integer data type is permitted in a DIV or MOD function
2305 in most cases, operands are compatible for (in)equality
2306 in most cases, operands are integer or real for equality operator
2307 a Boolean data type is not permitted in a TRUNC, ROUND, ABS, or SQRT function
2308 a real data type is not permitted in an ORD function
2309 timer value is not treated as a real value
2310 array index out of bounds
2311 array index expression not of data type long
2312 first subset position out of bounds
2313 second subset position out of bounds
2314 string type expected (in string expressions)
2315 first subset position expression not of data type long
2316 second subset position expression not of data type long
2317 input parameter is not writable: an attempt was made to write to a linked input
parameter; check reason for linkage and reconfigure, if necessary.
23181 tried to divide a floating point number by zero
23191 tried to divide a 32-bit integer by zero
80
Appendix A. Sequence Control Error Messages B0400DF – Rev R
Code Description
23201 tried to perform a modulus zero operation on a 32-bit integer
1. Returned only if “enhanced math checking” (Bit 9) is enabled in the CFGOPT parameter in the
Station block.
Code Description
2401 Indicates an attempt to set the ACTIVE parameter to a value it presently assumes
2402 Monitor case cannot activate block because the ACTIVE parameter of the target block
is the sink of the linkage or connection
Code Description
3001 bad SRC parameter detected by Monitor block
3002 deleted SRC block detected by Monitor block
3003 no input parameter located by Monitor block
3004 evaluation stack empty
3005 evaluation stack full
3006 invalid bit number
3007 invalid category number
3008 invalid constant type
3009 invalid function
3010 invalid message group index
3011 invalid message number
81
B0400DF – Rev R Appendix A. Sequence Control Error Messages
Code Description
3012 invalid operator code
This indicates a statement has been made that executes an ILLEGAL OPERATOR such
as ADD, MUL, DIV, and so forth, with an ILLEGAL OPERATION such as a WAIT,
JUMP, SEND MESSAGE, and so forth. This statement has to be located and corrected.
The Standard Block Exception Handler (SBX) can locate this statement, and is dis-
cussed in section “Useful Hints on SBX Programming” in Control Processor 270
(CP270) and Field Control Processor 280 (CP280) Integrated Control Software Concepts
(B0700AG).
3013 invalid operator
3014 invalid parameter number
3015 invalid path
3016 invalid return from IC (interpretive code) processor
3017 statement request and IC-PTR null
3018 invalid data type on stack (stack may be corrupted)
3019 statement not implemented
3020 string corrupted
3021 (not being used)
3022 message not queued
3023 no message packet allocated
3024 error return from string pool function stripped
3025 invalid vector type
3026 invalid scalar type
3027 invalid argument type
3028 invalid return from SUBR processor
3029 invalid path indication
3030 no FPN (full path name) construct
3031 invalid return from SBX (standard block exception) processor
3032 HLBL statement not found
3033 FPN construct too long
3034 invalid array operation
3035 invalid array category
3036 invalid data type
3037 invalid length for CPGET
3038 invalid length for GETVAL
3039 statement not found
3040 STMNO out of bounds
3041 real value too big (real to ASCII conversion – conversion to ASCII unsuccessful)
3042 real value too small (real to ASCII conversion – conversion to ASCII unsuccessful)
3101 invalid parameter type
82
Appendix A. Sequence Control Error Messages B0400DF – Rev R
Code Description
3102 data type of loop variable not integer
3103 no conversion to string
3201 ERH entry for ACTIVATION is not serviced
3202 invalid index of ERH-entry
3203 (not being used)
3204 not an ACTIVATION ERH-entry
3205 request type mismatch
3206 invalid data type CPSET
3207 invalid data type setconfirm
3208 invalid length CPSET
3209 invalid length setconfirm
3210 import table is full, import not possible, data returned
3211 too many external references exist, no free entries in table
3301 data type of monitor expression is not boolean
Code Description
2 INACTIVE – the parameter ACTIVE already has the value you are trying to write
(this is a warning, not an error)
3 SECURED – attempt to set a parameter that is secured
4 NOT_SECURABLE – the point is not securable
5 NOT_SECURED – the point is not secured
6 NOT_RELEASABLE – the point is secured and cannot be released
7 (not being used)
8 (not being used)
9 TO_BOOL_CONV_ERROR – value cannot be converted into boolean
10 TO_STRING_CONV_ERROR – value cannot be converted into string
11 TO_INTEGER_CONV_ERROR – value cannot be converted into integer
12 TO_REAL_CONV_ERROR – value cannot be converted into real
13 TOO_BIG – attempt to write a real value greater than an integer parameter can hold
14 NOT_CONNECTABLE – the point is not connectable
15 NOT_SETTABLE – attempt to set a parameter that is not settable
83
B0400DF – Rev R Appendix A. Sequence Control Error Messages
Code Description
16 TOO_MUCH – attempt to write too much data to parameter, or not enough room
available to read value from parameter.
17 OUT_OF_ENG_RANGE – the point was set beyond the engineering range
18 LOCKED_ACCESS – locked access to the parameter
19 TO_CHAR_CONV_ERROR – to character conversion error
20 GETPTRP_ERROR – the string could not be retrieved from the string pool
21 PUTSTR_ERROR – the string could not be stored in the string pool
22 ONLY_LONG_FOR_ACTPAT – The ACTPAT parameter of the Sequence Monitor
block needs a data type of long integer; no other data type is acceptable
23 TO_PACKED_CONV_ERROR – to packed Boolean conversion error
24 OUTPUTS_DISABLED – outputs are disabled
25 TOO_LITTLE – too little (for example, an attempt to write a large INTEGER value
into SHORT INT, or an attempt to write a negative value into a parameter with the
“non_negative” rule [refer to SPRATE of PIDA])
26 INVALID_REAL – Floating point representation of REAL data type is an invalid
IEEE754 floating point value (i.e., a NaN).
Code Description
0 OM_SUCCESS – no error
-1 ENOTFOUND – top level name not found or internal time-out expired
-2 EBADTYPE – invalid data type argument
-3 ESECURE – attempt to write to a secured variable
-4 ENOTOPENED – invalid om_descriptor
-5 EREADERROR – inaccessible change-driven variable
-6 EREAD – om_descriptor has write-only access
-7 EWRITE – om_descriptor has read-only access
-8 EWRITEERROR – change-driven variable write
-9 ENOSPACE – memory allocation error or shared memory attach not successful
-10 EDUPLICATE – entry is already in table
-11 ELOCAL – name is local; cannot import
-12 EBADNAME – invalid full pathname
-13 EBADLEN – data not returned (receive buffer too small)
for example, SN0001 := ; SN0001 can accommodate 80 characters, but a shared
variable of the String type is good for 255 characters
-14 ESTRLEN – string length is invalid
-15 EOPENED – omopen list is already opened
84
Appendix A. Sequence Control Error Messages B0400DF – Rev R
Code Description
-16 EBADLIST – bad variable list pointer
-17 EBADATBL – bad address table pointer
-18 ECONNBAD – omopen non-success; no connections
-19 EQNOTEMPTY – change queue is not empty
-20 ENOVALUE – object type has no value record
-21 EBADVREC – bad value record
-22 EIMPORT – not enough space for import table
-23 EOBJDIR – not enough space for object directory
-24 EADDRTBL – not enough space for address table
-25 ESCANDB – not enough space for scanner database
-26 EIMPFULL – import list is full
-27 EBADQTBL – not enough space for dqchg queue table
-28 EBADQUE – error creating a queue
-29 EOMWSIZE – invalid omwrite list size
-30 EQEMPTY – dqchg queue is empty
-31 ENOADDTBL – optimized omopen without address table
-32 ENOQUE – unable to get a queue for omopen
-33 ENOSEND – unable to send omopen requests
-34 ENOADRSP – caller’s address table is full
-35 ENOTACTIVE – caller not activated with IPC
-36 EBCONTBL – error creating connection table
-37 ENODISQ – error creating disconnect queue
-38 ENOOPNTBL – error creating open ID table
-39 EMAXOPNS – the omopen ID table is full
-40 ESCANFUL – the scanner database is full
-41 EIPCRET – error detected in IPC system
-42 EWAIT – remote scanner has not responded
-43 ESTATION – communications cannot be established with remote station (remote sta-
tion has not responded)
-44 EOBJPND – object with same name pending creation
-45 ENOCONFIRM – no setval confirmation
-46 ENOVENQ – unable to get omvenix queue
-47 ENOSCANTSK – unable to create scanner task
-48 ENOVENTSK – unable to create omvenix task
-49 ENOSRVTSK – unable to create server task
-50 EFABORT – a fabort was received from VENIX
-51 ESIZELST – invalid list size
-52 ENORECQ – error creating reconnect queue
85
B0400DF – Rev R Appendix A. Sequence Control Error Messages
Code Description
-53 EBADRSZ – invalid users address table size
-54 ENORECTSK – error creating OM reconnect task
-55 OM_ECBSY – open condition; each of the connections busy
-56 EOMOSIZE – invalid open variables list size
-57 EBADINDEX – invalid open variables list index
-58 EBADMSK – bad status write mask
-59 EBADWKSTA – Workstation name length
-60 EBADPARM – parameter does not exist;
for example, this error is generated when a full pathname refers to a block that exists in
the control database, but the parameter with given name does not exists in the block
86
Appendix A. Sequence Control Error Messages B0400DF – Rev R
87
Schneider Electric Systems USA, Inc.
38 Neponset Avenue
Foxboro, Massachusetts 02035–2037
United States of America