Você está na página 1de 270

SIMATIC PCS 7 OSx

Batch Programming Manual

Order Number: 6ES7 6550XX048BC4


Manual Assembly Number: 2806854--0001
Original Edition
! DANGER
DANGER indicates an imminently hazardous situation that, if not avoided, will
result in death or serious injury.
DANGER is limited to the most extreme situations.

! WARNING
WARNING indicates a potentially hazardous situation that, if not avoided, could
result in death or serious injury, and/or property damage.

! CAUTION
CAUTION used with a safety alert symbol indicates a potentially hazardous situ-
ation that, if not avoided, could result in minor or moderate injury.

CAUTION
CAUTION used without the safety alert symbol indicates a potentially
hazardous situation that, if not avoided, could result in property damage.

NOTICE
NOTICE indicates a potential situation that, if not avoided, could result in an
undesirable result or state.

Copyright 2001 by Siemens Energy & Automation, Inc.


All Rights Reserved — Printed in USA

Reproduction, transmission, or use of this document or contents is not permitted without express consent of Siemens Energy &
Automation, Inc. All rights, including rights created by patent grant or registration of a utility model or design, are reserved.

Since Siemens Energy & Automation, Inc., does not possess full access to data concerning all of the uses and applications of
customer’s products, we do not assume responsibility either for customer product design or for any infringements of patents or rights
of others which may result from our assistance.
MANUAL PUBLICATION HISTORY
SIMATIC PCS 7 OSX 4.1.1 Batch Programming Manual
Order Manual Number: 6ES7 6550XX048BC4

Refer to this history in all correspondence and/or discussion about this manual.

Event Date Description

Original Issue 1/01 Original Issue (2806854--0001)


LIST OF EFFECTIVE PAGES

Pages Description Pages Description

Cover/Copyright Original
History/Effective Pages Original
Trademarks Original
iii — xvii Original
1-1 — 1-11 Original
2-1 — 2-7 Original
3-1 — 3-36 Original
4-1 — 4-22 Original
5-1 — 5-6 Original
6-1 — 6-4 Original
7-1 — 7-26 Original
A-1 — A-10 Original
B-1 — B-1 Original
C-1 — C-63 Original
D-1 — D-12 Original
E-1 — E-3 Original
F-1 — F-5 Original
G-1 — G-28 Original
Index-1 — Index-5 Original
Registration Original
Trademarks

SIMATICr, SINECr, and STEPr are registered trademarks, and S5t and S7t are trademarks, of Siemens AG.
PCSt, APTt, Series 505t, and TISOFTt are trademarks of Siemens Energy & Automation, Inc.
Adober and Acrobatr are registered trademarks of Adobe Systems, Inc.
@aGlancet and Net OLEt are trademarks of eMation, Inc.
Epsonr is a registered trademark of Seiko Epson Kabushiki Kaisha.
Excelt is a trademark, and Windowsr and MS-DOSr are registered trademarks, of Microsoft Corporation.
HPr, DeskJetr, LaserJetr, and PaintJetr are registered trademarks of Hewlett--Packard Company.
IBMr is a registered trademark of International Business Machines Corporation.

Intelr is a registered trademark of Intel Corporation.


Internetr is a registered trademark of Internet, Inc.
Lantronixr is a registered trademark of Lantronix.
Linuxr is a registered trademark of Linus Torvalds.
Lotusr and 1--2--3r are registered trademarks of Lotus Development Corporation.
Network Computing Devicesr is a registered trademark of Network Computing Devices, Inc.
Oracler is a registered trademark of Oracle Corporation.
PostScriptr is a registered trademark of Adobe Systems, Inc.
Red Hatr is a registered trademark of Red Hat, Inc.
TIt is a trademark of Texas Instruments, Inc.
Tektronixr is a registered trademark of Tektronix, Inc.
UNIXr is a registered trademark of X/Open Company, Ltd.
VMSr is a registered trademark of Compaq.
X Window Systemt is a trademark, and Motifr is a registered trademark, of the Open Group.
XESSr is a licensed, registered trademark, and AISr is a registered trademark of Applied Information Systems, Inc.
Other trademarks are the acknowledged property of their respective holders.
Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Chapter 1 Overview of Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 What Is OSx Batch Processing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Components of Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Interaction of Batch Processing Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6

1.2 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8


Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

1.3 Working with Screen Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10


Using Navigational Tools to Enter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10

Chapter 2 Configuring OSx for Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1


2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Does OSx Configuration Change? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

2.2 Configuring Security Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

2.3 Configuring the Batch Log Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Printer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5

2.4 Configuring Unit Tags and Establishing Links to Other Tags . . . . . . . . . . . . . . . . . . . . . . . 2-6
Defining Units and Their Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Configuring Tag Capacities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

Chapter 3 Controlling Batch Operation Using BCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1


3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
What Is the Batch Control Language? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Components of a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3

3.2 Planning a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4


Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
BCL Handling of Network Writes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Considerations for Multiple-Station Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7

Contents iii
3.3 Creating a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Steps to Create a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Referencing Tag Names in BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
3.4 Using Keywords to Write a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Reserved Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
3.5 Using #include Statements in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Translating BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
3.6 Using Variable Definitions in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Variable Definition Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
3.7 Using Unit Mapping in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Unit Mapping Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Parameter Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
3.8 Using Event Blocks in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Event Block Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Event Block Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Special Event Block Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Database Event Trigger Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Referencing Controller-Resident Data in WHERE Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Event Block trigger_spec Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Event Block Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Retrieve Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Replace Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Delete Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Event Block Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
BCL Program Bit Conversion Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
Invalid Bit Type Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
3.9 Controlling Batch Operation with Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
3.10 Controlling the Operation of BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
BCL Program Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
3.11 Creating BCL Code to Handle Error Conditions in Event Blocks . . . . . . . . . . . . . . . . . . . . 3-35
BCL Error Handling Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-35

Chapter 4 BCL Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1


4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Managing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
BCL and Station Role Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Primary Role Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

iv Contents
4.2 Compiling a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4

4.3 Modifying a Program Description and Options Interactively . . . . . . . . . . . . . . . . . . . . . . . . 4-6

4.4 Installing a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8

4.5 Starting and Halting a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9


BCL Program Cannot Be Halted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
4.6 Removing a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11

4.7 Deleting a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12

4.8 Updating the BCL Program List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

4.9 Compiling a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14


BCL Debug Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
4.10 Installing a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16

4.11 Controlling BCL Programs from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17


Executing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
Halting and Starting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
4.12 Removing and Deleting a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . 4-22
Removing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
Deleting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22

Chapter 5 Batch Operations and the Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1


5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
The Controller Program and OSx Batch Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
How Does the Controller Program Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Batch Request Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
5.2 Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
List of Batch Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

Chapter 6 Batch Logs and Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1


6.1 Understanding Batch Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
What Is a Batch Log? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Batch Internal ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
6.2 Guidelines for Generating Batch Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Report Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Batch Report Format Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

Contents v
Chapter 7 Running and Supervising a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3

7.2 Configuring a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4


Using Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4

7.3 Displaying a List of Active Batches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

7.4 Displaying the Active Batch Tag Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

7.5 Viewing the Operation of an Active Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10


Viewing Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
Viewing Batch-Related Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
Viewing Batch-Related Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

7.6 Assigning Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12

7.7 Releasing Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13

7.8 Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14


Changing the State of a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Starting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14

7.9 Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16

7.10 Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17

7.11 Ending a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18


Completing or Aborting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
Removing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19

7.12 Viewing Batch-Related Tag Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20

7.13 Viewing the Unit Tag Detail and Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22


Viewing Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22
Changing the State of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
Changing the Mode of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
Viewing the Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26

Appendix A Attributes and Status Bits for New Tags . . . . . . . . . . . . . . . . . . . . . . . . . . A-1


A.1 Batch (BCH) Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2

A.2 Unit (UNIT) Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7

Appendix B Configuration Planning Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1

vi Contents
Appendix C Batch Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
C.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4
Custom and Internal Batch IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4
C.2 bc_activate_autolog( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-6

C.3 bc_add_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-7

C.4 bc_allocate_batch( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8

C.5 bc_assign( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-9

C.6 bc_assign_graphic( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-10

C.7 bc_assign_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-11

C.8 bc_batch_list_entry_exists( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-12

C.9 bc_clear_unit_elements( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-13

C.10 bc_copy( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-14

C.11 bc_create_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-15

C.12 bc_deactivate_autolog( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-16

C.13 bc_destroy_all_batch_lists( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-17

C.14 bc_destroy_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-18

C.15 bc_exit( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-19

C.16 bc_get_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-20

C.17 bc_get_batch_id_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-21

C.18 bc_get_batch_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-22

C.19 bc_get_batch_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-23

C.20 bc_get_custom_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-24

C.21 bc_get_printer_mask( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-25

C.22 bc_get_system_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-26

C.23 bc_get_unit_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-27

C.24 bc_get_unit_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-28

C.25 bc_load( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-29

Contents vii
C.26 bc_lock_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-30

C.27 bc_log_comment( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-31

C.28 bc_log_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-32

C.29 bc_log_value( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-33

C.30 bc_print_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-34

C.31 bc_release( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-35

C.32 bc_release_all( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-36

C.33 bc_release_graphic( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-37

C.34 bc_remove_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-38

C.35 bc_request_batch_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-40

C.36 bc_request_batch_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-42

C.37 bc_request_unit_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-44

C.38 bc_request_unit_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-46

C.39 bc_scale_recipe( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-48

C.40 bc_select( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-49

C.41 bc_set_batch_end( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-50

C.42 bc_set_batch_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-51

C.43 bc_set_batch_product( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-52

C.44 bc_set_batch_start( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-53

C.45 bc_set_first_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-54

C.46 bc_set_log_destination( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-55

C.47 bc_set_next_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-56

C.48 bc_set_unit_end( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-58

C.49 bc_set_unit_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-59

C.50 bc_set_unit_start( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-60

C.51 bc_split_batch( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-61

C.52 bc_trigger_request( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-62

C.53 bc_unlock_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-63

viii Contents
Appendix D BCL Program Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-1
D.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-2

D.2 bcl_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-3

D.3 bcl_disable_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-4

D.4 bcl_disable_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-5

D.5 bcl_disable_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-6

D.6 bcl_enable_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-7

D.7 bcl_enable_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-8

D.8 bcl_enable_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-9

D.9 bcl_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-10

D.10 bcl_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-11

D.11 print_trace_message( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-12


Appendix E Security Privileges for Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-1
E.1 Security Privileges for Batch Commands and Batch Mode Commands . . . . . . . . . . . . . E-2

E.2 Security Privileges for Unit Commands and Batch Mode Commands . . . . . . . . . . . . . . . E-3
Appendix F Advanced BCL Programming Techniques . . . . . . . . . . . . . . . . . . . . . . . . F-1
F.1 BCL Access to Custom Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2
Who Should Read This Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2
Custom Database Table Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2
Privilege Masks of Standard Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-3
F.2 USER_MSG Event Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4
Using the USER_MSG Event Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4
Appendix G BCL Application Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . G-1
G.1 BCL Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Simple Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Sample Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Configuration Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-4
Program Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5
Program Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5
Event Block #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-9
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index-1

Contents ix
List of Figures

1-1 Responsibilities of SIMATIC PCS 7 OSx During Batch Processing . . . . . . . . . . . . . . . . . . . . . . 1-2


1-2 Hierarchy of OSx Batch Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
1-3 Batch Processing Components and Their Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
1-4 Tasks for Configuring OSx Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

2-1 Tasks for Configuring Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3


2-2 Example Unit Tag Configuration Using a Spreadsheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6

3-1 BCL Program Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3


3-2 Tasks for Developing and Installing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
3-3 Sample BCL Program with #include Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
3-4 Sample BCL Program with Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36

4-1 Displaying the BCL Program Administration Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3


4-2 Compile BCL Program Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4-3 Modifying a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
4-4 Installing a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
4-5 Halting a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
4-6 Removing a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
4-7 Deleting a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4-8 Updating the BCL Program List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

6-1 Example of Batch ID Fields in the Batch Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2


6-2 Log File Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3

7-1 Recommended Order of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3


7-2 Accessing Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7-3 Committing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7-4 Active Batch Directory Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7-5 Displaying Active Batch Tag Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
7-6 Sample Batch Tag Detail Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
7-7 Assigning Units to a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
7-8 Releasing Units from a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
7-9 Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15
7-10 Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16
7-11 Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
7-12 Ending a Batch Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
7-13 Displaying Assigned Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21
7-14 Displaying Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23
7-15 Changing Unit Tag State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
7-16 Changing the Unit Operational Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
7-17 Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26

x Contents
A-1 Bit Locations for Batch Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
A-2 Bit Locations for UNIT Status Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-8

B-1 Example Planning Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1

G-1 Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-3

Contents xi
List of Tables

1-1 Interactions between Batch Processing Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7

2-1 Unit Tag Types and Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

3-1 BCL Keywords (Outside Event Blocks) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10


3-2 BCL Keywords (Inside Event Blocks) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
3-3 Batch Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
3-4 BCL Program Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34

4-1 Modify BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7


4-2 BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20

5-1 Batch Controller Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

A-1 BCH Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2


A-2 Bit Locations for Batch Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
A-3 Status Bit Settings for Batch States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
A-4 Status Bit Settings for Batch Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
A-5 Values for the Batch Command Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-6
A-6 Values for the Batch MODE_CMD Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-6
A-7 UNIT Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7
A-8 Bit Locations for Unit Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-8
A-9 Status Bit Settings for Unit States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9
A-10 Status Bit Settings for Batch Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9
A-11 Values for the Unit Command Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-10
A-12 Values for the Unit MODE_CMD Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-10

E-1 Security Privileges for Batch Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-2


E-2 Security Privileges for Batch Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-2
E-3 Security Privileges for Unit Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-3
E-4 Security Privileges for Unit Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-3

G-1 Example Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-4


G-2 Example Action Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5
G-3 Source Code Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5

xii Contents
Preface
New Features of SIMATIC PCS 7 OSx Release 4.1.1 supports the following new features:
PCS 7 OSx
 S7 417H support — Support for the S7 417H redundant controller has
been incorporated into OSx 4.1.1. OSx supports this controller in either
stand-alone or redundant mode. When a single CPU417H is configured
as an independent controller, it operates in stand-alone mode. When
two CPU417H and two CP443-1 modules are configured in separate
subsystems (racks), one controller acts as the Master while the other
serves as an emergency Standby.

 OSx Library for S7-400 controller enhancements — Additions


were made to the OSx Library for S7-400 controllers to support the S7
417H controller. Additionally, modifications were made to encompass
the new restart OB structures for the latest controller revisions.

 Modern Reports Editor — A third-party package, Xess, has been


added to OSx 4.1.1. This package is used for the functionality of the
report editor, report preview, report execution, and report output
viewing currently in OSx. The standard OSx report functions are
incorporated into the Xess environment (except where noted), so that
users retain the capabilities of the former Report Editor, while adding
the benefits of a modern editing interface and modern spreadsheet
functionality, such as graphical data representation. The “classic”
Report Editor remains in the system as do the “classic” standard
reports that are shipped with the system.

 Login confirmation for password configuration — When a new


user ID/password account is added to OSx, the administrator must
confirm the password entered in a second field prior to saving the
configuration. This avoids the problem of typing the password
incorrectly, saving it, and not being able to modify or delete the account
in the future because you do not know what was typed.

 Superuser ability to change user accounts — Any OSx user with


System Configuration or Database Administration privileges is now
able to maintain OSx user accounts without knowing their passwords.
This avoids having to keep a hard copy of all user passwords, which is
generally not desirable.

 Move to Linux Operating System — OSx 4.1.1 has been moved from
the SCO UNIX operating system to the Red Hat Linux Operating
System. This should allow for more efficient support of any underlying
operating system problems that might arise in the future, in addition to
a quicker response time to supporting any future hardware platform
modifications or peripheral additions.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Preface xiii


Conventions Used The procedures in the various manuals give you step-by-step instructions
in the Manual Set about how to carry out tasks. Typically, the last step of any procedure
requires that you select the OK or Save button, press Enter, etc. To save space
and reduce redundancy, this last step does not appear in the procedure.
However, you need to finish each procedure with one of these actions.

OK Saves information that you have entered and closes the window.

Save Saves information that you have entered and does not close the
window.

Cancel Closes the window without saving any information that you
entered and terminates any action that you initiated.

Dismiss Closes the window. If you have already pressed Enter, your work
is not lost; if you have not pressed Enter, your work is discarded.

The different fonts used in the manual set have the following meanings.

 Entries that you enter from the keyboard are indicated with the
courier font.

 Items that you select on the screen, or keys that you press on the
keyboard are indicated with this bolded font.

Items that you select on a cascaded menu are linked in the manual text
with arrows. The first term indicates where to click the main menu bar. For
example, Controls->Change System State tells you to click Controls on the
main menu bar, then select Change System State from the pull-down menu.

Controls Startup Change System State


Change System State Operate
Logoff Offline
Logon Shutdown OSx
OSx Terminal
Shutdown OSx and Linux

OK Cancel

xiv Preface SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Purpose of This The SIMATIC PCS 7 OSx Batch Programming Manual describes how to
Manual configure and control the batch process along with programming in BCL,
the Batch Control Language.

 Chapter 1 defines batch processing, explains batch configuration


prerequisites, and describes how to get around on the screen and do
some basic tasks, such as logging on, powering up the system, where to
get started in configuration, etc.

 Chapter 2 is an overview of how to configure security privileges, log


destinations, and associate unit tags with tag links for batch processing.

 Chapter 3 describes creating, compiling, and running BCL (Batch


Control Language) programs for controlling batch operations.

 Chapter 4 describes how to manage BCL programs interactively from


the BCL Program Administration dialog box and from the operating
system command line.

 Chapter 5 describes batch request commands for the controller.

 Chapter 6 describes batch logging events for batch execution, how to


retrieve log reports, and how to create batch reports using Report Editor
functions.

 Chapter 7 explains how to create, run, and supervise a batch.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Preface xv


Other Manuals The SIMATIC PCS 7 OSx manual set consists of several manuals. If you
cannot find the information that you need in the SIMATIC PCS 7 OSx
Batch Programming Manual, refer to these other books:

 SIMATIC PCS 7 OSx System Administration Manual This manual


describes configuring network nodes, and procedures that explain how
to configure printers, how to archive data, and how to back up files.
Other functions normally carried out by the systems administrator are
also described here.

 SIMATIC PCS 7 OSx Process Configuration Manual This manual


describes the primary tasks required to configure your OSx system for
controlling your process.

 SIMATIC PCS 7 OSx Graphical Editor This manual describes how to


create the graphical displays used with OSx.

 SIMATIC PCS 7 OSx Hardware Manual This manual describes the


various hardware components of the system and how to install them.

 SIMATIC PCS 7 OSx Reports Manual This manual describes how to


create reports on your process and your OSx configuration.

 SIMATIC PCS 7 OSx Recipe Manual This manual describes more


advanced configuration tasks involving the creation and use of recipes.

 SIMATIC PCS 7 OSx Operator Manual This manual is written for the
configuration engineer, but it describes how to carry out the various
tasks that the process operator must do when the system is in the
Operate state. You can photocopy all or portions of this manual as a
reference for your operators. You may prefer to rewrite sections and
perhaps incorporate additional information where necessary.

 SIMATIC PCS 7 OSx Interface to S5 Controllers Manual This manual


describes the OSx interface with SIMATIC S5 controllers.

 SIMATIC PCS 7 OSx Interface to S7 Controllers Manual This manual


describes the OSx interface with SIMATIC S7 controllers.

 SIMATIC PCS 7 OSx Library Manual This manual describes the


function blocks used to program the S7-400 controllers to interface with
OSx.

xvi Preface SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Be sure to check the Readme File for information that did not become
available until after the publication deadlines for the OSx manuals. The
Readme File also points to important copyright, licensing, and warranty
information. Select Help ->About OSx from the main menu bar, and then click
the Show Readme button at the bottom of the About OSx dialog box.

The following manuals are available for optional OSx features.

 SIMATIC PCS 7 OSx Remote Data Transfer Manual This manual


describes the remote data transfer feature, which allows you to
transmit data collected from the process by an OSx station to an Oracle
database on the remote computer for historical records and other
purposes.

 SIMATIC PCS 7 OSx X Terminal User Manual This manual describes


how to connect and operate an X terminal as an extension of an OSx
station.

 SIMATIC PCS 7 OSx @aGlance User Manual This manual describes


how to import OSx data into a Windows application, such as Excel or
Lotus=1-2-3 or into another UNIX or VMS application.

If You Need Help If you have difficulty with your system, contact the Siemens Energy &
Automation, Inc., Technical Services Group in the U.S.A. at 423--461--2522.
Outside the U.S.A., call 49--911--895--7000.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Preface xvii


xviii Preface SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 1
Overview of Batch Processing
1.1 What Is OSx Batch Processing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Components of Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Interaction of Batch Processing Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
1.2 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
1.3 Working with Screen Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Using Navigational Tools to Enter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-1
1.1 What Is OSx Batch Processing?

Overview OSx enables you to supervise and record information related to the
operation of a batch process. Figure 1-1 illustrates where OSx fits in a
typical batch control system and lists those aspects of batch processing that
are controlled and supervised by OSx.

In the factory process, a batch is the material that is being produced by a


single execution of a batch process. In the SIMATIC PCS 7 OSx
environment, a batch is a collection of related data that is gathered from the
factory process and stored in the system. To supervise the operation of a
batch with OSx, you must create a set of data that represents an internal
(software) model of the factory process.

Supervises batch, gathers data,


and generates batch logs and
reports. SIMATIC PCS 7 OSx

Operator Supervisory
Station Station
Offers several batch control
utilities to help integrate OSx
with the batch.

Control
Station
Displays batch-related graphics
and tag details.

I/O modules
local and
Offers configurable action remote
requests that announce when a
batch changes state and that
prompt operators for a response.

Offers limited control of a batch.


Primary responsibility for
controlling the batch is handled
by the controller.

Offers manual entry of


batch-related data.
Batch process

Figure 1-1 Responsibilities of SIMATIC PCS 7 OSx During Batch Processing

1-2 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
With SIMATIC PCS 7 OSx, batch processing typically involves one or more
units. In a factory environment, a unit corresponds to a specific collection of
machinery or equipment (for example: an evaporator or boiler). In the OSx
environment, a unit corresponds to a collection of one or more I/O tags that
are configured and associated with factory equipment.

In the sample process shown in Figure 1-2, the data model for the factory
process consists of one batch, three units, and eight I/O tags. OSx uses the
information gathered by these tags to create an internal model of the
process and to supervise the batch.

Batch

Unit Unit Unit

Tag Tag Tag Tag Tag Tag Tag Tag

Unit 1 Unit 2 Unit 3

Figure 1-2 Hierarchy of OSx Batch Data

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-3
What is Batch Processing? (continued)

Components of To enable OSx to supervise and manipulate batch-related data, batch


Batch Processing processing offers the following features. These features are described in
subsequent chapters.

 Batch Control Language (BCL) Batch processing provides several


Microsoft C language-based utilities. You use these utilities to create a
program that supervises the progress of a batch, generates reports, and
manipulates data in the database.

Refer to Chapter 3 for more information about using BCL.

Refer to Chapter 4 for information about administering BCL programs.

 Controller-requested batch commands The programmable


controller can initiate any batch or unit commands.

Refer to Chapter 5 for more information about requesting batch


commands.

1-4 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
 Batch log and reports The batch log contains all log messages that
are generated during batch processing. This log records the
step-by-step progress of a batch and lists any errors that might occur
during processing. The batch reports are similar to other reports, but
they primarily consist of batch-related data from the batch log and the
database.

Refer to Chapter 6 for more information about creating batch logs and
reports.

 Batch displays Several of the OSx configuration and operation


screens contain fields specifically related to batch processing.

Refer to Chapter 7 for information about using the batch displays.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-5
What is Batch Processing? (continued)

Interaction of Batch Figure 1-3 illustrates the interactions between the OSx components that
Processing can be associated with batch processing. Table 1-1 describes the interactions
Components that are labeled A--L in Figure 1-3.

Supervisory Operator Action


Station Station AA Requests B Batch Log
(Primary) Display

C D

Batch Batch
E Control F
F
6 Reports
Language
G

H I J

Tag Database Historical


Configuration K L Trends

Control Node

Figure 1-3 Batch Processing Components and Their Interactions

1-6 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table 1-1 Interactions between Batch Processing Components

Interaction Description
This interaction enables you to configure OSx to generate action requests when specific
batch-related events occur. If an action request is triggered, a flashing icon appears on the
A
Operator Station Display. If a batch requires operator interaction, an action request can
prompt the operator for a response.
This interaction logs an action request to the batch log if a tag in the action request is part of
B
a batch.
This interaction enables you to develop a program of batch control instructions that pull
C specific data from the OSx database, manipulate the data (if required), and place the data in
the batch log associated with the currently running batch.
This interaction enables you to create report formats that pull data from a batch log and
D create customized reports. Each report contains data related to a single batch. You can also
use a report function to write data to the batch log.
This interaction enables you to create action requests that constantly monitor the appropriate
E attributes in the OSx database for any changes. If any changes occur in the monitored
attributes, OSx triggers the corresponding action requests.
This interaction uses changes to tags from the OSx database to generate a batch log for the
F
batch associated with the changing tags.
This interaction causes data changes in the OSx database to be reflected in the corresponding
G graphics. While OSx is in the Operate state, any change that you enter through the Operator
Station Display updates the database.
This interaction enables you to develop a program of batch control instructions that pull
H specific data from the OSx database, manipulate the data (if required), and place the data
back in the database.
This interaction enables you to create report formats that pull data from the OSx database
I and create customized reports. You can also write data to the database with the #writetag
function.
This interaction enables you to create report formats that pull historical trend data from the
J
OSx database and create customized reports.
This interaction enables you to configure tags for a batch and store that configuration data in
the OSx database. Batch processing offers two additional tag types: batch and unit. You are
K not required to create batch tags because the system creates them automatically. Batches are
identified by a batch ID, not the batch tag name. You must, however, configure a unit tag for
each collection of I/O tags that you want to associate with a portion of the batch process.
This interaction causes data changes in the OSx database to be reflected in the corresponding
L
historical trends.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-7
1.2 Prerequisites

Ensure the following prerequisites are true before you configure OSx to
monitor and/or control a batch.

 You have a thorough knowledge of real-world batch processing. This


knowledge is crucial to designing an effective solution to your batch
control requirements.

 You have a thorough knowledge of controller programming with either


SIMATIC APT or RLL programming tools.

 You have a thorough understanding of OSx and its components (tags,


action requests, general configuration, etc.).

 You have a working knowledge of C Language programming if BCL


programs are to be used.

1-8 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Sequence of Tasks Figure 1-4 lists the recommended order for setting up OSx to run a batch
process. After you set up OSx, you can adapt the order to the needs of the
process.

Configure Batch
State OSx Configure OSx for a batch.
Recipe
Repeat

var1:=A*B Develop a program that supervises


mv var1 C and/or controls a batch.
z:=C/D^^2

Develop custom reports for


recording batch data.

Run the batch.

Figure 1-4 Tasks for Configuring OSx Batch Processing

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-9
1.3 Working with Screen Elements

Using Navigational Use the navigational tools to display menus and lists, choose options, and
Tools to Enter Data enter data into the system.

Pushbuttons Place the cursor on a pushbutton and select it to display a


menu or another window. When the button text is bold, the pushbutton is
active. When the button text is gray, you cannot select the button.

Some buttons have no text or the text is adjacent to the button. Clicking on
the button causes no action when the button is inactive.

Radio Buttons These are specially linked buttons. When a second button
in the group is selected, the first automatically turns off. As a safeguard,
you are always required to confirm your selection, by clicking on an OK
button.

Toggle Buttons These buttons are not linked. Each one must be clicked
off and on independently; changing the status of one has no effect on the
other.

Text Browsers These tools allow you to see information not visible in a
window. Place the cursor on the bar and slide the bar back and forth while
holding down the left mouse button. You can also click on the pointers at
each end of the bar groove to display single lines or columns.

Sliders These tools allow you to see an increase or decrease in an array of


values. That is, as you move the slider the values go up or down. Place the
cursor on the bar and slide the bar back and forth while holding down the
left mouse button.

Data Entry Field Click on a field in which you want to enter


information. Some windows require an entry in one field before you can
enter information in another field. Therefore, if one field does not appear to
be active, move the cursor to another field that precedes it in the window.

1-10 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Cascaded Menus When menus appear, you choose a given item by
clicking on it. Some menu items have cascaded menus that appear when
you slide the cursor to follow the triangle indicator. When you cannot select
an item because of the current operation or display, the text of the item is
gray.

The following five pushbuttons appear in most of the dialog windows used
in OSx. Their action does not change from window to window.

OK Saves information that you have entered and closes the window.

Save Saves information that you have entered and does not close the
window.

Cancel Closes the window without saving any information that you
entered and terminates any action that you initiated.

Dismiss Closes the window without undoing any changes that you have
entered. If you press Dismiss before you press Enter, the changes that you
make are discarded.

Help Displays a context-sensitive help window.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Overview of Batch Processing 1-11
1-12 Overview of Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 2
Configuring OSx for Batch Processing
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Does OSx Configuration Change? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2.2 Configuring Security Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

2.3 Configuring the Batch Log Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Printer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
2.4 Configuring Unit Tags and Establishing Links to Other Tags . . . . . . . . . . . . . . . . . . . . . . . 2-6
Defining Units and Their Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Configuring Tag Capacities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Configuring OSx for Batch Processing 2-1
2.1 Overview

Does OSx The configuration of your system remains essentially unchanged in batch
Configuration processing. You still configure forms, symbols, graphics, and animation
Change? tables in the same way as is described in the SIMATIC PCS 7 OSx Process
Configuration Manual. However, additional features for configuring OSx to
run in a batch environment are described in this document.

Prerequisites Before you try to configure batch processing, ensure that the following
prerequisites and those listed in Section 1.2 are true.

 You are thoroughly familiar with configuring the process as described


in the SIMATIC PCS 7 OSx Process Configuration Manual.

 You know the batch security privileges required for your operator.

 You know the printer and file destinations that you want to define for
the batch log.

 You know which tags and units you want to define and which tags you
want to link to a unit.

2-2 Configuring OSx for Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Sequence of Tasks Figure 2-1 lists the recommended order for performing the topics covered in
this chapter.

OSx Configure batch security privileges


for operators.

Log
Configure batch log destinations.

Configure unit tags.

Unit 1 Unit 2
Establish unit/child tag linkages.

Figure 2-1 Tasks for Configuring Batch Processing

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Configuring OSx for Batch Processing 2-3
2.2 Configuring Security Privileges

All batch and unit operations require the security privilege of either
Primary Control or Batch Control. For example, the batch Hold command
requires the Batch Control security privilege; the unit Jog command
requires the Primary Control security privilege.

A list of all batch and unit operations and their required security privileges
can be found in Appendix E.

Instructions for configuring security privileges for user IDs can be found in
the SIMATIC PCS 7 OSx Process Configuration Manual.

2-4 Configuring OSx for Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
2.3 Configuring the Batch Log Destination

Overview The batch log contains all messages pertaining to batches. Batch log
messages can appear in other logs as well. For example, an operator change
log message appears in both the Operator Change Log and the Batch Log if
the message also has a batch identification (batch ID).

Printer Refer to the SIMATIC PCS 7 OSx System Administration Manual for
Configuration information on how to configure printers.

Batch Identification Batch identification allows you to enter data to start a new batch and allows
you to modify data items associated with an existing batch. The default
batch log destination is configured using the Log Destination utility,
described in the SIMATIC PCS 7 OSx System Administration Manual. This
is the default destination for all batch log messages. To modify the default
destination for a particular batch, use the Batch Identification utility
(Section 7.2, Configuring a Batch).

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Configuring OSx for Batch Processing 2-5
2.4 Configuring Unit Tags and Establishing Links to Other Tags

Unit tags are configured in the same way that all other tag types are
configured. Figure 2-2 shows an example of a unit tag configuration.

Record Control Tag Type Tag Description Process Manual Parent Attribute Memory Locations Upload Twenty % Autolog Init
Node Group Set Value
T PC1 UNIT UNIT1 Bake_Unit_2 0xffffffff
A STATUS V100 1 N N N
A COMMAND V101 1 N N N
A MODE_CMD V102 1 N N N
A BCH_REQ V103 1 N N N
BCH_REQ_ 8
A V104 N N N
INFO
BCH_REQ_
A V112 1 N N N
RESP
E

Figure 2-2 Example Unit Tag Configuration Using a Spreadsheet

Defining Units and In preparing to define a unit to the OSx system, follow these guidelines.
Their Links
 Look over the P&ID for the batch process and determine whether some
of the process equipment can be logically grouped together into
functional units. Avoid making a unit a single device, such as a pump.

 After you determine which units you want to define, create a unit tag
using the procedures described in the SIMATIC PCS 7 OSx Process
Configuration Manual. Before you can assign tags to a unit, you must
first create a unit tag.

NOTE: Do not delete a tag from the system if it is currently used in a BCL
program. Remove the tag from the program first, and then recompile and
reinstall the program. Then delete the tag from the system.

2-6 Configuring OSx for Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
After you create one or more unit tags, you are ready to assign the process
I/O tags to the unit tags.

 Select a tag type other than the unit or batch tag types and enter the
appropriate unit tag name in the Parent field. As with the
configuration of any tag type, you do this in APT, a spreadsheet, or the
ASCII text file containing your tag data.

 When you link a regular tag to a unit tag, OSx adds the process groups
of the unit tag to its child tag. Similarly, if the linkage is removed by
blanking out the name of the unit tag in the Parent field for a tag, then
the process groups of the unit tag are deleted from the child tag’s
process groups. Refer to the SIMATIC PCS 7 OSx Process
Configuration Manual for more information on process groups.

You can translate APT unit extensions to OSx by marking the unit in the
APT Program Content Directory. Table 2-1 lists the unit tag type and its
corresponding APT extensions. Refer to the SIMATIC APT User Manual for
information about how to mark tags for OSx.

Table 2-1 Unit Tag Types and Extensions

OSx Type APT Extension OSx Attributes Descriptor

Unit name (no extension) Unit tag on OSx


Unit name.STATUS Status Current status
Unit name.COMMAND Command Command request
Unit name.MODE_CMD Mode_cmd Mode request

UNIT No extension available Operation Current operation


No extension available Type Type
Unit name.BCH_REQ Bch_req Batch request
No extension available Bch_req_info Batch information
Unit name.BCH_REQ_RESP Bch_req_resp Response to batch request

Configuring Tag To reconfigure tag capacities, refer to the SIMATIC PCS 7 OSx Process
Capacities Configuration Manual.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Configuring OSx for Batch Processing 2-7
2-8 Configuring OSx for Batch Processing SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 3
Controlling Batch Operation Using BCL
3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
What Is the Batch Control Language? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Components of a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
3.2 Planning a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
3.3 Creating a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Steps to Create a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Referencing Tag Names in BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
3.4 Using Keywords to Write a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
3.5 Using #include Statements in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Translating BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
3.6 Using Variable Definitions in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Variable Definition Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
3.7 Using Unit Mapping in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Unit Mapping Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Parameter Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
3.8 Using Event Blocks in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Event Block Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Event Block Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
Special Event Block Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Database Event Trigger Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Referencing Controller-Resident Data in WHERE Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Event Block trigger_spec Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Event Block Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
Retrieve Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
Replace Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Delete Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Event Block Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
BCL Program Bit Conversion Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
Invalid Bit Type Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-31
3.9 Controlling Batch Operation with Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32

3.10 Controlling the Operation of BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34

3.11 Creating BCL Code to Handle Error Conditions in Event Blocks . . . . . . . . . . . . . . . . . . . . 3-35

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-1
3.1 Overview

What Is the Batch The Batch Control Language (BCL) consists of several programming tools
Control Language? that allow you to supervise and, to a lesser degree, control the operation of a
batch. These C-language-based tools enable you to write the OSx station
portion of a batch control program. Program the control node to assume the
major role in controlling the batch; allow the OSx station to oversee the
process.

Using the Batch Control Language, you can do these functions:

 Define events and the corresponding processing that takes place when
the events occur. Events consist of bit set/reset, simple changes, system
state changes, or BCL program startup/shutdown.

 Access the database to retrieve, replace, delete, or transfer data.

 Perform bit operations within the database.

 Execute the OSx standard library functions and custom C-language


functions from within a BCL program file.

 Support global variables for each batch.

 Support the definition of element names for specific tag:attribute


combinations in units.

 Support multiple BCL programs.

OSx uses a batch manager process to control the execution of the BCL
programs. When OSx transitions from the Offline state to the Operate state,
the batch manager starts any BCL programs that are installed. The
procedures for installing BCL programs are outlined in Section 4.4.

! WARNING
The standard OSx database tables contain configuration and operating
information maintained by the SIMATIC PCS 7 system processes and are
identified by the presence of the Database Admin privilege flag.
Attempting to delete records from the standard OSx database tables using a
BCL program, or attempting to replace attributes in any tables other than those
keyed by tag name, can cause unpredictable operation by the controller which
could cause death or serious injury and/or damage to equipment.
Do not attempt to delete records from standard OSx database tables or replace
attributes in any tables other than those keyed by tag name. This warning
applies to the standard OSx database tables. You can define custom tables and
add them to the database in such a way that BCL programs can freely append
records to them and delete records from them. See Appendix F for details.

3-2 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Components of a A typical BCL program consists of two major types of statements: definition
BCL Program statements and action statements. Figure 3-1 illustrates and describes the
components that comprise these two types of statements. A BCL program
does not require all the components in Figure 3-1 to operate correctly, but if
the program contains one or more of the components, they must appear in
the order shown in the diagram.

The remainder of this chapter describes each of the BCL program


components in greater detail and shows you how to use each component
within a BCL program. Section 4.2 and Section 4.4 outline the procedures
for compiling and installing a BCL program.

Program components

Include statements enable the BCL


program to access other OSx header files
and custom header files.

Variable definitions enable the BCL BCL program*


Definition statements program to set up a block (structure) of
variables that can be used throughout the #include statements
program.
Variable definitions

Unit maps
Unit maps enable the BCL program to
establish unit element names that are used Event blocks
to pass process information from one unit to
another.
* The program
components
must appear in
Event blocks enable the BCL program to the order shown
perform activities when specific events here.
Action statements
occur. Any bit transition or value change can
trigger an event.

Figure 3-1 BCL Program Components

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-3
3.2 Planning a BCL Program

Prerequisites Ensure the following prerequisites are true before you begin to develop your
own BCL programs.

 You must be familiar with C-language programming, especially in the


OSx environment.

 You must be familiar with accessing and reading the OSx database.

 You must be thoroughly familiar with your batch process and its units.

 You must identify all of the tags, including unit tags, that will be
referenced by the BCL program. Before you can execute the program,
you must also configure these same tags in the database.

3-4 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Sequence of Tasks Figure 3-2 lists the recommended order of tasks for developing and
installing BCL programs.

var1:=A*B Use any of the editors to compose


mv var1 C
z:=C/D^^2 a BCL program source file.

01001110
01110010 Translate and compile the program.
00001011
11000001 Correct any errors that might occur.
01010000

01001110
01110010 Validate the program. Correct any
00001011
11000001
✓ errors that might occur.
01010000

01001110
01110010 Translate, compile, and install the BCL
00001011 program.
11000001
01010000

Figure 3-2 Tasks for Developing and Installing BCL Programs

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-5
Planning a BCL Program (continued)

BCL Handling of If your BCL program writes networked tag:attributes to a given control
Network Writes node, keep these points in mind when you design the BCL program.

 If the control node is in communication with OSx (that is, its tag:status
is active), and subsequently loses communication (for instance, due to a
network problem), any write of the tag:attributes returns an error
while the control node is off the network. Furthermore, this error is not
reported if the Ignore Network Response runtime option has been
selected for the BCL program through the BCL Program
Administration utility.

 If the control node never comes on the network (that is, its tag:status
always remains inactive), all writes of the tag:attributes occur only on
the memory values held in the OSx database. The writes do not go to
the network, and no error is returned.

 If the operator selects the Scan_Off command for the controller in


Network Setup, or if the operator manually sets a tag inactive from a
tag detail, then BCL writes occur only on the memory values in the
OSx database. The BCL writes do not go to the control node.

If necessary, you can code your BCL program to take into account the
active/inactive status of the control node (that is, to assess the
DATA_NODE:STATUS settings for the control node tag). There are two
ways to do this.

 You can retrieve the status of the control node and check it before
writing the tag: attribute value to the control node.

 You can write an event block that is triggered when the appropriate
DATA_NODE:STATUS bit changes, and set a global variable to be
checked prior to each write.

In either case, you can design your code so that the write is only performed
when the control node is in an active state, and in all other cases, an error is
generated.

3-6 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Considerations for Keep these points in mind when you write a BCL program for a system with
Multiple-Station more than one supervisory station.
Systems
 BCL programs execute simultaneously on all supervisory stations.
Therefore, station role changes do not adversely affect automated batch
processing for a system with more than one supervisory station if you
follow the rules below.

 Database changes occur only on the primary, which must be a


supervisory station for BCL program execution to occur.

 Since BCL programs are event driven, corresponding BCL programs on


each station execute approximately the same code at all times.

Consider these effects of a role change when you design BCL event blocks.

 If a failover occurs, then BCL programs have approximately ten


seconds to complete the event block that they are executing. After this,
the role change occurs and any database changes in the event block
could be lost. Therefore, if failover has been implemented for the
system, you need to design all event blocks to take less than ten
seconds to execute.

 If a manual role change takes place, then BCL programs have


approximately one minute to complete the event block that they are
executing. After this, the role change will fail if any event blocks are
still executing. Therefore, to anticipate manual role changes, you need
to design all event blocks to take less than one minute to execute.

 Do not use global variables to maintain program state information


between event blocks. Use the database for this purpose. Otherwise,
the values of the variables could be different on each OSx station
because the system processes events at slightly different times on each
station.

If you attempt to start a BCL program while a role change is in progress,


the program does not begin execution until after the role change is
complete.

You may observe some delay in the execution of a BCL program in the
Operate state when another OSx station is synchronizing. To see if this is
the cause of the delay, check Network Status, which shows when stations
are synchronizing. After synchronization has finished, program execution
will be complete shortly thereafter.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-7
Planning a BCL Program (continued)

If BCL programs use tag values other than the status attribute to trigger
events, and the value in the controller changes faster than the event scan
period, then it is possible that different OSx stations in the system will get
different values for the same tag. In addition, if such a tag value has a
deadband, it is very likely that a BCL program running on one station will
not get the same events as the same BCL program that is running on
another station. If this happens, then a role change could lead to unexpected
behavior by the BCL program.

! WARNING
If a BCL program uses tag values other than status to trigger events, it is
possible that different OSx stations in the system will get different values for
the same tag.
This can cause a BCL program running on one station not to get the same
events as the same BCL program that is running on another station. In this
situation, a role change could lead to unexpected behavior by the BCL program,
which could cause serious injury or death to personnel and/or damage to
equipment.
To avoid this situation, use a tag’s status attribute as the event trigger. When
the status attribute changes, the change will be seen on all OSx stations.

If you choose not to use the tag’s status attribute as the event trigger, then
these precautions can help minimize the possibility of a BCL program
running on one station not getting the same events as the same BCL
program that is running on another station.

 Set the event scan period to be less than the change rate for all tag
values used for events.

 Set the deadband for all tag values used for events to the lowest
possible value.

3-8 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
3.3 Creating a BCL Program

Steps to Create a To create a BCL program, follow these steps.


BCL Program
1. Select OSx Terminal from Controls on the Main Menu.

2. Enter your login and password.

3. Enter the following command.

cd /usr/tistar/hist/batch/source

NOTE: The file system /usr/tistar/hist has more available disk space than
others. Storing BCL program files in smaller file systems may cause
interference with other OSx functions.

4. Use any text editor, such as vi or SCOedit, to create your BCL program
source file.

For a BCL source program, the filename must have the suffix .bcl, and
the non-suffix portion of the filename must be no more than ten
characters. For example, the filename packaging1.bcl consists of a
ten-character filename and the .bcl suffix.

NOTE: When you create a BCL program, make sure that you do not include
any infinite loops in your code.

Referencing Tags used in BCL programs must have standard valid tag names as
Tag Names in described in the SIMATIC PCS 7 OSx Process Configuration Manual.
BCL Programs

NOTE: Do not delete a tag from the system if it is currently used in a BCL
program. Remove the tag from the program first, and then recompile and
reinstall the program. Then delete the tag from the system.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-9
3.4 Using Keywords to Write a BCL Program

Reserved The Batch Control Language consists of several reserved keywords that
Keywords define the operation of BCL programs. Avoid using these keywords as
names for variables, structure members, and program statement labels. You
can embed keywords in comments because the BCL translator ignores all
comments.

The keywords listed in Table 3-1 are reserved for BCL statements that are
outside event blocks. Refer to Section 3.8 for information about event blocks.

Table 3-1 BCL Keywords (Outside Event Blocks)

Keyword Keyword Keyword


ALL OFLN_TO_STBY STBY_TO_OFLN
AND ON STBY_TO_OPER
AS OPER_TO_STBY UNIT
CHANGES OR USER_MSG
DEFINE RECIPE VAR
EVENT RESET WHERE
FOR SHUTDOWN
MAP STARTUP

3-10 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
The keywords listed in Table 3-2 are reserved for BCL statements that are
inside event blocks.

Table 3-2 BCL Keywords (Inside Event Blocks)

Keyword Keyword Keyword


AND EXEC OFF
DELETE INIT_VAR REMOVE_VARS
DROP_VAR LATCH WHERE

NOTE: Due to constraints within the BCL translator, if any of the keywords
listed in Table 3-2 appear within quoted strings in event blocks, the BCL
program generates a syntax error.

Before you start creating code for a BCL program, read the guidelines,
examples, and suggestions described in Section 3.5 through Section 3.11.
When you finish creating a BCL program, save the program, exit the editor,
and refer to Chapter 4 for instructions about compiling and installing the
program.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-11
3.5 Using #include Statements in a BCL Program

Translating BCL When you compile a BCL program (Section 4.2), OSx automatically inserts
Programs the following #include statements into the translated file.

#include <pcsstdinc.h>
#include <pcsinc.h>
#include <db_types.h>
#include <bclpgm.h>
#include <bc_fdecl.h>
#include <bc_lfdecl.h>
#include <vb.h>

If your program requires header files other than those automatically


inserted by the translator, you can add the appropriate #include statements
to the BCL program. The additional statements enable the program to
access OSx header files or custom header files.

NOTE: Do not specify any of the automatically inserted #include


statements in your BCL source program. The compiler cannot read the same
statements twice.

If you insert additional #include statements in your program, ensure that


they appear on the first lines of the program. Figure 3-3 illustrates how OSx
translates a BCL program containing a #include statement and
automatically inserts the required #include statements.

BCL program Output file (C-language)

#include<enum_types/b_i_d.t> #include <pcsstdinc.h>


. #include <pcsinc.h>
. #include <db_types.h>
. Translator: #include <bclpgm.h>
Converts BCL to C #include <bc_fdecl.h>
code and inserts #include <bc_lfdecl.h>
#include statements #include <vb.h>

.
.
.

Figure 3-3 Sample BCL Program with #include Statements

3-12 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
3.6 Using Variable Definitions in a BCL Program

This section describes the BCL statement that enables you to define a block
of variables and group them under a single name. Variable definitions
enable you to define a set of global variables that can be used to store
intermediate values during batch processing. These variables are available
to all event blocks within the BCL program in which they are defined. They
are visible only within the program in which they are defined and cannot be
accessed by other BCL programs.

When a BCL program defines the variables, it does not initialize them.
Therefore, you must initialize the variables in the event block section of the
BCL program (see Section 3.8).

The variable data types can be any of the standard C-language types, any of
the types defined in the OSx header file pcstyp.h, or any of the types that
you define in custom header files.

Variable Definition DEFINE var_block_name FOR ALL


Syntax

Parameter var_block_name
Description Name corresponding to a block of variable definitions. Event blocks can use
this name to access any of the associated variables.

FOR ALL
These are required keywords which terminate the opening definition line.

Example The following example defines a block of variables. The variable block name
cook_var1 enables an event block that appears later in the BCL program to
access all of the variables between the braces.

DEFINE cook_var1 FOR ALL


{
FLOAT32 v1;
SINT16 v2;
CHAR v3;
CHAR batch_id [T_B_I_D_LENGTH];
FLOAT32 sugar;
FLOAT32 flour;
FLOAT32 soda;
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-13
3.7 Using Unit Mapping in a BCL Program

This section describes the BCL statements that enable you to map elements
within a unit.

Unit maps enable you to generate meaningful element names for specific
tag attribute instances within a unit. OSx uses these element names to pass
information from one unit to another during the operation of a batch. For
example, you can assign the unit element name MIX_TEMPERATURE to
the tag attribute instance tmp101:pv. OSx then uses the element
MIX_TEMPERATURE to pass temperature data from one unit to another
unit containing the same element name. The BCL program typically uses
the bc_copy( ) function (described in Appendix C) to move element data from
unit to unit.

Unit Mapping UNIT MAP unit_name


Syntax {
tag:attr AS element_name;
}

Parameter unit_name
Descriptions Name of the unit for which the element mapping applies.

tag:attr
Tag attribute instance that is associated with a specific element name. OSx
passes the value of this instance to the next unit that contains the same
element name.

element_name
Name of the element for which a tag attribute instance is associated. The
element name enables OSx to pass data associated with the name to other
units. For each unit, the element name is usually associated with a different
tag attribute instance.

3-14 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example defines an element mapping for the units mix_tank_1
and mix_tank_2. After the map is defined, the values associated with unit
elements MIX_WEIGHT, MIX_TEMP, and MIX_PH can be passed from unit to
unit if the subsequent unit contains the same elements.

UNIT MAP mix_tank_1


{
lc101:pv AS MIX_WEIGHT;
tmp101:pv AS MIX_TEMP;
ph101:value AS MIX_PH;
}

UNIT MAP mix_tank_2


{
lc102:pv AS MIX_WEIGHT;
tmp102:pv AS MIX_TEMP;
ph102:value AS MIX_PH;
}

ON EVENT mix_tank_1:status:OOS
{
bc_copy (“mix_tank_1”, “mix_tank_2”);
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-15
3.8 Using Event Blocks in a BCL Program

Event Block This section describes the BCL statements that enable you to create event
Definition blocks. Event blocks enable a BCL program to perform data manipulation
activities when a specific event occurs. Each event block consists of an event
trigger and one or more lines of database operations and/or C-language
code.

The event trigger defines the type of change in a tag attribute instance that
executes the activities listed within the event block. Events can be triggered
by a change in the system or program state, a change in an analog value, a
bit transition from one to zero, or a bit transition from zero to one.

When you have multiple event blocks within a BCL program, be aware of
how the event blocks interact. All event blocks within the same program
operate synchronously. This means that each event block, once triggered,
runs to completion before the program looks for another trigger event and
runs another block. An event block that takes a long time to execute will
delay the triggering of other event blocks in the same program. If event
blocks do not access the same OSx database tables, or write to the same tag
locations, you can place the event blocks in separate programs to avoid the
delay.

When you run multiple BCL programs at the same time, event blocks that
are located in different programs operate asynchronously and may interact
unpredictably if they access the same OSx database tables or write to the
same tag locations. To avoid these interactions, place event blocks that
access the same tables or control points in the same BCL program.

When the batch triggers an event, OSx executes the database or C-language
statements in the event block. Database operations enable the program to
access the controller data via the database. C-language code enables the
program to perform math and data manipulation functions. Database
operations and C-language code cannot be mixed within the same statement
but can exist in separate statements within an event block.

The example event block contains references to library functions that


increase the flexibility of BCL programs in controlling/supervising a
process. For a complete list of these batch control functions, refer to
Table 3-3 on page 3-32. For more detailed examples of event blocks, refer to
Appendix G.

3-16 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
In the event block code, a variable reference refers to a C-language variable.
These variable references must translate to an address. Failure to properly
encode and/or initialize a variable reference can cause the BCL program to
dump core or operate on invalid data. In addition, the data type of the
variable must match the corresponding database type. Failure to match
data types can result in overwrites, memory faults, and/or corrupt data.

Parentheses around the variable references are optional, but use them for
clarity.

Event Block Syntax ON EVENT trigger_spec_0


OR trigger_spec_1
OR trigger_spec_2
.
.
.
OR trigger_spec_n
{
event block instruction(s)
}

Parameter trigger_spec_0 -- trigger_spec_n


Description Specifies the event or events that trigger an event block. If you want more
than one event to trigger the event block, place the OR keyword between
each of the trigger_spec options.

Within the event block code, you can determine which trigger activated the
block by reading the global variables BCL_block_event_id and
BCL_special_event_id, which are declared in one of the default header files.
The BCL_block_event_id variable consists of a zero-based index that
indicates which event of the ON EVENT trigger specifications triggered the
event block. A value of zero indicates the first trigger_spec.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-17
Using Event Blocks in a BCL Program (continued)

Special Event The BCL_special_event_id variable consists of an identifier that indicates


Block Identifiers whether a special event (such as Startup, Shutdown, or User_Msg)
occurred.

The bm_user.h header file defines the special event identifiers. This file is
not one of the default header files; therefore, if you intend to use the special
event labels, you must explicitly specify bm_user.h with a #include
statement.

The following special event identifiers are available.

SE_NO_EVENT — trigger is not a special event


SE_STARTUP — BCL program startup
SE_OFLN_TO_STBY — offline to standby system state transition
SE_STBY_TO_OPER — standby to operate system state transition
SE_OPER_TO_STBY — operate to standby system state transition
SE_STBY_TO_OFLN — standby to offline system state transition
SE_SHUTDOWN — BCL program termination
SE_USER_MSG — user-defined or unrecognized message received

Only one of the two global event variables can be set when an event triggers
the action block. When one variable is set by an event, the other is assigned
the value --1. You can mix database and special event triggers within the
same ON EVENT instruction. OSx indexes database event triggers
independently of special event entries. When OSx counts the index numbers
for database events, it does not include special event entries in the count
because these events are indicated by the special event identifiers.

3-18 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Database Event When a database event triggers an action block, the data value causing the
Trigger Values event is made available to the BCL program by means of the following
global variable:

extern DB_VALUE_UNION BCL_event_trigger;

This declaration is made in one of the automatically included header files.


You do not need to code it into your BCL program. DB_VALUE_UNION is a
C-language union data type defined in the header file db_types.h which is
automatically included when the BCL program is compiled. Since
BCL_event_trigger is a union type, you must take into account the data type
of the trigger value. The program must use the member of DB_VALUE_UNION
corresponding to the data type of the database event trigger that just
activated the action block to access the trigger value. The value in
BCL_event_trigger is valid upon entry into the action block and remains so
until the block returns and another event occurs.

Referencing Queries that reference controller-resident data as part of the key for
Controller-Resident selecting tuples from the database usually take longer than queries where
Data in WHERE all components of the key are resident in the OSx station. The extra time is
Clauses required to allow updates from the controller to refresh the referenced data.
The increase in access time is proportional to the number of
controller-resident items in the WHERE clause and to the number of tuples
that must be examined to satisfy the query. A single controller-resident
datum (that is, a single attribute in a single tuple) may require up to 0.25
seconds for the refresh update.

Note that controller-resident data that is configured for RBE or armed for
event notification does not require extra time since those data are
maintained fresh by the controller communications subsystem.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-19
Using Event Blocks in a BCL Program (continued)

Event Block The following trigger_spec options are available for the ON EVENT statement:
trigger_spec
Options  STARTUP

Executes an event block when OSx starts the BCL program.

 OFLN_TO_STBY

Executes an event block when OSx transitions from the Offline state to
the Standby state.

 STBY_TO_OPER

Executes an event block when OSx transitions from the Standby state
to the Operate state.

NOTE: When the OSx system state transitions directly from Offline to
Operate, BCL programs might miss the OFLN_TO_STBY and STBY_TO_OPER
transition messages. System loading causes some delay in the startup of
BCL programs; therefore, the programs might not be fully operational in
time to receive these messages. However, BCL programs usually receive the
OPER_TO_STBY and STBY_TO_OFLN messages. Although the Standby state
is not user selectable, the system still uses this state internally.

 OPER_TO_STBY

Executes an event block when OSx transitions from the Operate state
to the Standby state.

 STBY_TO_OFLN

Executes an event block when OSx transitions from the Standby state
to the Offline state.

 SHUTDOWN

Executes an event block when OSx terminates the BCL program.

3-20 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
 tag:attr CHANGES

Executes an event block when the value of the specified tag attribute
instance changes (for example: from 100 to 113).

 tag:attr:bit

Executes an event block when the specified bit in the tag attribute
instance transitions from zero to one. Define the bit name in the
BIT_DEFS table in the database. Unless the bit name is a standard
name, you are responsible for defining it. You can use a numeric
constant to specify a bit position; decimal and hexadecimal (0X0001)
formats are acceptable. Avoid a bit pattern of all zeros (0x0000), as this
pattern does not allow an event to be detected. You must set one, and
only one, bit in the pattern in order for events to occur. If a bit name
contains spaces, you must place double quotes around it (‘‘HH ALM”).

 tag:attr:bit RESET

Executes an event block when the specified bit in the tag attribute
instance transitions from one to zero. Define the bit name in the
BIT_DEFS table in the database. Unless the bit name is a standard
name, you are responsible for defining it. You can use a numeric
constant to specify a bit position; decimal and hexadecimal (0X0001)
formats are acceptable. Avoid a bit pattern of all zeros (0x0000), as this
pattern does not allow an event to be detected. You must set one, and
only one, bit in the pattern in order for events to occur. If a bit name
contains spaces, you must place double quotes around it (‘‘HH ALM”).

 table:attr WHERE
(
table:attr1 = (var_spec1) AND
table:attr2 = (var_spec2) AND
...
table:attrN = (var_specN)
) CHANGES

Executes an event block when the specified table attribute changes


where table:attr1 = var_spec1 and table:attr2 = var_spec2 . . . and table:attrN =
var_specN. Var_spec1 through var_specN are numeric or string constants.
Numeric constants may be expressed in decimal or hexadecimal integer
format or in floating point format. String constants must be delimited
by double quotes. Be sure to insert a space on both sides of the = sign in
a WHERE clause. These stipulations apply to all WHERE clauses in this
trigger_spec section.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-21
Using Event Blocks in a BCL Program (continued)

Event Block The following trigger_spec options are available for the ON EVENT statement:
trigger_spec
Options  table:attr:bit WHERE (table:attr1 = (var_spec1))
(continued)
Executes an event block when the specified table-attribute bit
transitions from zero to one where table:attr1 = var_spec1. Define the bit
name in the BIT_DEFS table in the database. Unless the bit name is a
standard name, you are responsible for defining it. You can use a
numeric constant to specify a bit position; decimal and hexadecimal
(0X0001) formats are acceptable. Avoid a bit pattern of all zeros
(0x0000), as this pattern does not allow an event to be detected. You
must set one, and only one, bit in the pattern in order for events to
occur. If a bit name contains spaces, you must place double quotes
around it (‘‘HH ALM”).

 table:attr:bit WHERE
(
table:attr1 = (var_spec1) AND
table:attr2 = (var_spec2) AND
...
table:attrN = (var_specN)
)

Executes an event block when the specified table-attribute bit


transitions from zero to one where table:attr1 = var_spec1 and table:attr2 =
var_spec2 . . . and table:attrN = var_specN. The bit name must be defined in
the BIT_DEFS table in the database. Unless the bit name is a standard
name, you are responsible for defining it. You can use a numeric
constant to specify a bit position; decimal and hexadecimal (0X0001)
formats are acceptable. Avoid a bit pattern of all zeros (0x0000), as this
pattern does not allow an event to be detected. You must set one, and
only one, bit in the pattern in order for events to occur. If a bit name
contains spaces, you must place double quotes around it (‘‘HH ALM”).

 table:attr:bit WHERE (table:attr1 = (var_spec1)) RESET

Executes an event block when the specified table-attribute bit


transitions from one to zero where table:attr1 = var_spec1. The bit name
must be defined in the BIT_DEFS table in the database. Unless the bit
name is a standard name, you are responsible for defining it. You can
use a numeric constant to specify a bit position; decimal and
hexadecimal (0X0001) formats are acceptable. Avoid a bit pattern of all
zeros (0x0000), as this pattern does not allow an event to be detected.
You must set one, and only one, bit in the pattern in order for events to
occur. If a bit name contains spaces, you must place double quotes
around it (‘‘HH ALM”).

3-22 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
 table:attr:bit WHERE
(
table:attr1 = (var_spec1) AND
table:attr = (var_spec2) AND
...
table:attrN = (var_specN)
) RESET

Executes an event block when the specified table attribute transitions


from one to zero where table:attr1 = var_spec1 and table:attr2 = var_spec2 . . .
and table:attrN = var_specN. The bit name must be defined in the
BIT_DEFS table in the database. Unless the bit name is a standard
name, you are responsible for defining it. You can use a numeric
constant to specify a bit position; decimal and hexadecimal (0X0001)
formats are acceptable. Avoid a bit pattern of all zeros (0x0000), as this
pattern does not allow an event to be detected. You must set one, and
only one, bit in the pattern in order for events to occur. If a bit name
contains spaces, you must place double quotes around it (‘‘HH ALM”).

 USER_MSG

Executes an event block when the BCL program receives an input-


queue message that is neither generated by a database change event
nor generated by the batch manager program. For example, a response
message from the network is one type of user message.

This event type is provided to accommodate the needs of system


integrators who are experienced with highly advanced OSx system
programming techniques. In order for a BCL program to receive the
type of messages that would be handled by a USER_MSG event block,
the programmer must take specific steps to cause such messages to be
sent to the program.

Advanced OSx system programmers who need to use USER_MSG event


blocks can refer to Section F.2 of this manual for further details.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-23
Using Event Blocks in a BCL Program (continued)

Event Block The following instructions are available for the event block controlled by the
Instructions ON EVENT statement:

 c_instructions;

Contains one or more C-language instructions.

 INIT_VAR var_type, block_id;

Allocates an instance of var_type (a variable block name from a DEFINE


statement) and assigns it to the identifier block_id, which is a string
variable. The var_type must be defined by a DEFINE statement earlier in
the program. The block_id must be a variable of type pointer to character
string. The block_id identifies the specific instance of var_type and allows
multiple instances to exist. However, only one instance of a particular
type can be accessed at a given time.

If the specified instance does not exist when INIT_VAR is invoked, the
program allocates a new instance and initializes a pointer named
var_type to point to the new instance. If the specified instance is already
allocated, the program sets the pointer var_type to the existing instance.
After it is initialized, var_type functions the same as a C-language
POINTER TO STRUCT. The variables defined within the block are
accessible as structure members.

 DROP_VAR var_type, block_id;

Deallocates the instance of var_type (a variable block name from a


DEFINE statement) that is assigned to the identifier block_id, which is a
string variable. Following this instruction, data that is stored in the
instance cannot be accessed.

 REMOVE_VARS block_id;

Deallocates all instances of variable blocks that are identified by the


string variable block_id. Following this instruction, data that is stored in
the instances cannot be accessed. This instruction can help you dispose
of all variable blocks that are associated with a particular batch.

3-24 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
 LATCH tag:attribute:bit_name_or_pattern;

Transitions the specified bit_name_or_pattern from zero to one. If you use


a bit name, it must appear in the BIT_DEFS table. Otherwise, you can
use a decimal or hexadecimal constant to represent the bit pattern.
Examples of correctly formed LATCH statements follow:

LATCH rm2mt1cmd:command: ackadd;

LATCH rm2mt1cmd:command: “on”;

LATCH rm2mt1cmd:command: 0x8000;

Bit names that contain spaces must be delimited by double quote


marks.

 OFF tag:attribute:bit_name_or_pattern;

Transitions the specified bit_name_or_pattern from one to zero. If you use


a bit name, it must appear in the BIT_DEFS table. Otherwise, you can
use a decimal or hexadecimal constant to represent the bit pattern.
Examples of correctly formed OFF statements follow:

OFF rm2mt1cmd:command: ackstop;

OFF rm2mt1cmd:command: “on”;

OFF rm2mt1cmd:command: 0x1000;

Bit names that contain spaces must be delimited by double quote


marks.

 EXEC target_location <- source_location;

Retrieves data from the source_location and places a copy of the data in
the target_location. The following combinations of source_location and
target_location items are acceptable:

variable reference <-- tag:attribute

tag:attribute <-- variable reference

tag:attribute <--tag:attribute

boolean variable reference <--tag:attribute:bit_name_or_pattern

The EXEC parameter is optional. Thus it would be equally valid simply


to say: target_location <- source_location; .

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-25
Using Event Blocks in a BCL Program (continued)

Event Block The following instructions are available for the event block controlled by the
Instructions ON EVENT statement:
(continued)
 WHERE_clause;

Enables the BCL program to use a key other than a tag name to
address a database record. BCL supports WHERE clauses in retrieve,
replace, and delete operations.

The following syntax examples for the retrieve, replace, and delete
operations represent suggested layouts for WHERE clauses. Because
BCL statements are free format, you can, however, insert new lines and
extra spaces at your discretion. Be sure to insert a space on both sides
of the = sign in a WHERE clause.

In the examples, the variables var_spec, var_spec1, var_spec2, and


var_specN are address references to variables that you define. The
table_name is the name of a database table. The variables attr, attr1, attr2,
and attrN are names of attributes that belong to the specified table_name.

These stipulations apply to all WHERE clauses in retrieve, replace, and


delete operations.

3-26 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Retrieve Operation For a retrieve operation with a WHERE clause that specifies a single
component key, use the following format:

EXEC (var_spec) <-- table_name:attr WHERE (table_name:attr1 = (var_spec1)) ;

For a retrieve operation with a WHERE clause that specifies a


multi-component key, use the following format:

EXEC (var_spec) <-- table_name:attr WHERE


(
table_name:attr1 = (var_spec1) AND
table_name:attr2 = (var_spec2) AND
.
.
table_name:attrN = (var_specN)) ;

The following only applies for an attribute that has an address in the
controller. When true, the global variable db_communicate indicates that the
system reads a value from the network. When false, the system reads the
value from the database. For BCL, the default is to read from the network.
You can set/unset this global variable anywhere in a BCL program.

When an attribute has a controller address, reading a value from the


network may take longer depending on how frequently the value changes in
the controller.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-27
Using Event Blocks in a BCL Program (continued)

Replace Operation For a replace operation with a WHERE clause that specifies a single
component key, use the following format:

EXEC table_name:attr WHERE (table_name:attr1 = (var_spec1)) <-- (var_spec) ;


or
EXEC table_name:attr <-- (var_spec) WHERE (table_name:attr1 = (var_spec1));

For a replace operation with a WHERE clause that specifies a


multi-component key, use the following format:

EXEC table_name:attr WHERE


(
table_name:attr1 = (var_spec1) AND
table_name:attr2 = (var_spec2) AND
.
.
.
table_name:attrN = (var_specN)
) <-- (var_spec) ;
or
EXEC table_name:attr <-- (var_spec) WHERE
(
table_name:attr1 = (var_spec1) AND
table_name:attr2 = (var_spec2) AND
.
.
.
table_name:attrN = (var_specN)
);

To replace multiple attributes in a single tuple with one operation, use the
following format:

EXEC table_name:replace_attr1 <-- (replace_var_spec1),


table_name:replace_attr2 <-- (replace_var_spec2),
.
.
.
table_name:replace_attrN <-- (replace_var_specN)
WHERE (where_clause);

The WHERE clause may contain one or more terms as presented in preceding
sections.

3-28 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Delete Operation The delete operation removes a single tuple from a database table according
to the key or keys that you specify.

! WARNING
The standard OSx database tables contain configuration and operating
information maintained by the SIMATIC PCS 7 OSx system processes and are
identified by the presence of the Database Admin privilege flag. Attempting to
delete records from the standard OSx database tables using a BCL program, or
attempting to replace attributes in any tables other than those keyed by tag
name, can cause unpredictable operation by the controller.
Unpredictable controller operation can cause death or serious injury to
personnel and/or damage to equipment.
Do not attempt to delete records from standard OSx database tables or replace
attributes in any tables other than those keyed by tag name. This warning
applies to the standard OSx database tables. You can define custom tables and
add them to the database in such a way that BCL programs can freely append
records to them and delete records from them. See Appendix F for further
details.

For a delete operation with a WHERE clause that specifies a single


component key, use the following format:

DELETE table_name WHERE (table_name:attr = (var_spec)) ;

For a delete operation with a WHERE clause that specifies a


multi-component key, use the following format:

DELETE table_name WHERE


(
table_name:attr1 = (var_spec1) AND
table_name:attr2 = (var_spec2) AND
.
.
.
table_name:attrN = (var_specN)
);

Error reporting for delete operations is the same as it is for other BCL
database operations except when a statement tries to delete a record that
does not exist. Unless you specifically request that errors of this type be
reported, BCL normally does not report them. For information about
reporting errors when you try to delete a non-existent record, refer to
Section 3.10.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-29
Using Event Blocks in a BCL Program (continued)

Event Block The following example defines an event block that executes when the
Example addition bit in rm2mt1:status transitions from zero to one. Refer to Appendix G
for a more detailed example. The event block then performs the following
activities in the order shown:

1. Defines two local variables: batch_id and addition.

2. Retrieves the batch ID for the tag rm2mt1 and initializes an instance of
the variable block cook_var1 using the batch_id as the block identifier.

3. Executes the bc_log_value function to write the value of rm2mt1:value to


the batch log. The batch control functions increase the flexibility of the
BCL programs. For a complete list of these functions, refer to Table 3-3.

4. Retrieves data from the rm2mt1:value instance and places the data into
addition.

5. Adds the value currently in the variable v1 (in variable block cook_var1)
to the value in the variable addition and places the resulting value back
in v1.

6. Replaces the data in the tag attribute rm2mt1total:value with the data
from v1.

7. Transitions (latches) the ackadd bit in rm2mt1cmd:command from zero to


one.

ON EVENT rm2mt1:status:addition
{
char batch_id [BATCH_ID_LENGTH];
float addition;

bc_get_batch_id (”rm2mt1”, batch_id);


INIT_VAR cook_var1, batch_id;

bc_log_value (batch_id, ”rm2mt1”, ”value”);


EXEC (&addition) <-- rm2mt1:value;
cook_var1-->v1 += addition;
EXEC rm2mt1total:value <-- (&cook_var1-->v1);
LATCH rm2mt1cmd:command:ackadd;
}

For clarity, the example listed above does not contain error handling code.
Refer to Section 3.11 for information about detecting and handling errors
within event blocks.

3-30 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
BCL Program Bit BCL runtime routines must convert the contents of the bit position field in a
Conversion Error BCL database reference statement into a bit position value. When a BCL
statement references an invalid bit name the following occurs.

 A system alarm is generated with the associated alarm text:

Batch Manager System degraded.

 Error message 7949 appears in the log.out file.

 The following error message appears in the log.out file:

date: time BCL pgm.exe error exited

 Your BCL program terminates.

Invalid Bit Type The BCL database reference statements with bit position fields include:
Examples trigger specifications, LATCH and OFF statements, and retrieve statements
that return a boolean value. Examples of each follow where the bit position
field is the third colon-separated field (such as 0x800). If the contents of this
field cannot be converted to a bit position value, Error 7949 occurs.

 Event trigger specification: ON EVENT do_34: command: 0x800

 LATCH statement: LATCH do_35: command: 32768;

 OFF statement: OFF do_36: command: ”my flag”;

 Boolean statement: (&boolean_var) <-- di_99: status: data val;

! WARNING
Termination of a BCL program caused by using an invalid bit name can result in
the BCL program’s failure to execute instructions that control a controller.
If the BCL program controls equipment, the program termination could cause
death or serious injury to personnel, and/or damage to equipment.
Ensure that correct bit position string names are recorded in the BIT_DEFS
table, and that no illegal characters exist in the decimal or hexadecimal
constants that the standard string-to-number conversion routines use in the
C library. Make sure the BCL runtime routines can convert the contents of the
bit position field in a BCL database reference statement into a bit position
value.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-31
3.9 Controlling Batch Operation with Library Functions

OSx contains several library functions that allow you to control and/or
supervise the operation of a batch more easily. The batch control functions,
which can be called from event blocks, enable a BCL program to perform
high-level functions when a trigger event occurs.
You can use the usrbcl utility to add your own object files to the BCL user
library archive libUBCL.a. This library is scanned when you compile and link
the BCL programs. The syntax for the command line is
usrbcl object_file.o [object_file.o], where the object_file.o
parameter specifies the name of an object file generated by the C compiler.
Table 3-3 lists the library functions that pertain specifically to batch
processing. For complete descriptions of these functions, see Appendix C.

Table 3-3 Batch Control Functions

Function name Purpose


bc_activate_autolog Activate automatic logging for a tag:attr instance
bc_add_batch_list_entry Add a new batch ID to a specified list
bc_allocate_batch Allocate a batch tag
bc_assign Assign a unit to a batch
bc_assign_graphic Associate a graphic with a batch
bc_assign_id Assign a custom ID to an existing batch
bc_batch_list_entry_exists Test the validity of an entry at the current position
bc_clear_unit_elements Clear a unit’s elements
bc_copy Copy a unit’s batch information
bc_create_batch_list Add a new batch ID list
bc_deactivate_autolog Deactivate automatic logging for tag:attr instance
bc_destroy_all_batch_lists Remove all existing batch ID lists
bc_destroy_batch_list Remove specified batch ID list(s)
bc_exit Request batch control subprogram to exit
bc_get_batch_id Retrieve the custom batch ID for the specified tag
bc_get_batch_id_entry Retrieve the batch ID from the current entry
bc_get_batch_mode Retrieve the current operating mode of the batch
bc_get_batch_state Retrieve the current status of the batch
bc_get_custom_id Retrieve the custom batch ID for the specified system ID
bc_get_printer_mask Retrieve the printer bit mask for a printer name and station.
bc_get_system_id Retrieve the system batch ID for the specified custom ID
Table continues on next page.

3-32 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table 3-3 Batch Control Functions (continued)

Function name Purpose


bc_get_unit_mode Retrieve the current operating mode of the unit
bc_get_unit_state Retrieve the current status of the unit
bc_load Download a recipe to the controller
bc_lock_batch_id Protect a batch ID from further changes
bc_log_comment Write a comment to the log file
bc_log_operation Log the operation of a unit
bc_log_value Write a tag:attribute message to the log file
bc_print_batch_list Print contents of all batch ID lists
bc_release Release the specified unit
bc_release_all Release all units that are associated with a batch
bc_release_graphic Disassociate the current graphic from a batch
bc_remove_batch_list_entry Remove batch ID entry from a given list
bc_request_batch_mode Issue a mode command to a batch
bc_request_batch_state Issue a command to a batch
bc_request_unit_mode Issue a mode command to a unit
bc_request_unit_state Issue a command to a unit
bc_scale_recipe Scale an OSx recipe
bc_select Select the unit to be used in a recipe download
bc_set_batch_end Record the current time as the batch end time
bc_set_batch_operation Fill in a batch’s operation attribute
bc_set_batch_product Set the product name in a batch
bc_set_batch_start Record the current time as the batch start time
bc_set_first_batch_list_entry Set list position to first entry
bc_set_log_destination Set the destination printer for the batch log
bc_set_next_batch_list_entry Set list position to next entry
bc_set_unit_end Record the current time as the unit end time
bc_set_unit_operation Fill in a unit’s operation attribute
bc_set_unit_start Record the current time as the unit start time
bc_split_batch Split a batch into multiple batches
bc_trigger_request Trigger an action request
bc_unlock_batch_id Enable batch ID for changes

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-33
3.10 Controlling the Operation of BCL Programs

BCL Program In addition to the batch control functions described in Table 3-3, BCL offers
Control Functions several built-in functions that enable you to control the operation of BCL
programs. While the batch control functions work within event blocks to
manipulate batch-related data, the BCL program control functions
determine how the programs execute. The BCL program control functions
described in Table 3-4 are currently available.

For detailed descriptions of these functions and their parameters, refer to


Appendix D.

Table 3-4 BCL Program Control Functions

Function name Purpose


bcl_auto_append Report state of auto append switch
bcl_disable_auto_append Disable auto append feature for failed replace operations
bcl_disable_error_on_empty_delete Disable error reporting for delete operations on non-existent records
bc_enable_auto_append Enable auto append feature for failed replace operations
bcl_enable_error_on_empty_delete Enable error reporting for delete operations on non-existent records
bcl_error_on_empty_delete Report state of error on empty delete switch
print_trace_message Send a textual message to the trace output file
bcl_disable_error_on_not_found Disable error reporting for failed retrieve operations
bcl_enable_error_on_not_found Enable error reporting for failed retrieve operations
bcl_error_on_not_found Indicates whether failed retrieve operations generate an error or not

3-34 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
3.11 Creating BCL Code to Handle Error Conditions in Event Blocks

BCL Error Handling OSx provides a built-in method for detecting error conditions. Your BCL
Code program must read the result and use it to respond to the error condition.
Always encode some means for handling the errors that might occur within
BCL event blocks.

All software errors reported by BCL programs, as well as similar errors


reported by any other OSx process, are sent to the following file:
/usr/tistar/data/log.out.

When you compile a BCL program (Section 4.2), the translator


automatically inserts the following declaration in each translated event
block.

INT BCL_error = NO_ERROR;

All BCL-generated database operations use BCL_error to report their


completion status. The translator also sets the global variable errno, which
contains an error number that identifies the type of error.

If an error occurs during a database operation, OSx sets BCL_error to


ERROR and automatically generates an error message. After these actions
take place, the BCL program is responsible for checking BCL_error and
implementing an appropriate response to the error condition. The constants
NO_ERROR and ERROR are defined in pcsdef.h, and the global variable
errno is defined in errno.h. The files pcsdef.h and errno.h are default header
files.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Controlling Batch Operation Using BCL 3-35
Creating BCL Code to Handle Error Conditions in Event Blocks (continued)

The following options are suggested responses to an error condition.

 Return ERROR when the program exits from the error-producing event
block. This option generates another error message but does not
terminate the execution of the BCL program. This option simply
records the occurrence of an error; it does not perform any other action.

 Generate a custom error message. You can use the standard macro
XMT_ERR within event blocks to generate a message to the system
error log. You can also use the error message to trigger an alarm if you
configure the message for alarming in the ERR_MSGS table. Refer to
header file pcsmacro.h for the syntax of the XMT_ERR macro.

 Terminate the BCL program by executing the bc_exit( ) function. Use


this option only when critical errors occur and only when the process is
able to run without the BCL program.

 Create your own custom error handling within event blocks. You can
include code that executes application-specific operations that are
appropriate for the process.

Figure 3-4 demonstrates a typical example of error handling code within a


BCL program.

ON EVENT oven1:status:run
{
SINT16 tmp;

(&tmp) <-- ivar_0:value;


if (BCL_error == ERROR)
{
if (errno == DBELIST) /* Cannot find database item */
{
XMT_ERR (”For temp. event block”, errno, ”Key value fetch failed”);
return (NO_ERROR);
}
else /* Critical error */
{
XMT_ERR (”For temp. event block”, ALRM, ”Critical error occurred”);
bc_exit( ); /*Terminate program after exiting this event block */
return (ERROR);
}

}
return (NO_ERROR);
}

Figure 3-4 Sample BCL Program with Error Handling

3-36 Controlling Batch Operation Using BCL SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 4
BCL Administration
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Managing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
BCL and Station Role Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Primary Role Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
4.2 Compiling a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4

4.3 Modifying a Program Description and Options Interactively . . . . . . . . . . . . . . . . . . . . . . . . 4-6

4.4 Installing a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8

4.5 Starting and Halting a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9


BCL Program Cannot Be Halted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
4.6 Removing a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11

4.7 Deleting a Program Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12

4.8 Updating the BCL Program List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

4.9 Compiling a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14


BCL Debug Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
4.10 Installing a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16

4.11 Controlling BCL Programs from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17


Executing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
Halting and Starting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
4.12 Removing and Deleting a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . 4-22
Removing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
Deleting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-1


4.1 Overview

Managing BCL After you write a BCL program, you can manage it interactively from the
Programs BCL Program Administration dialog box. You can also administer BCL
programs from the operating system command line. Use the command line
method when you want to manage multiple programs as a group, using a
shell script. You can do many of the same tasks that are supported by the
BCL Program Administration dialog box. These tasks are listed below.

 Compile the program (interactively: Section 4.2;


from the operating system: Section 4.9)

 Modify the program description and execution options


(interactively only: Section 4.3)

 Install the program (interactively: Section 4.4;


from the operating system: Section 4.10)

 Start and halt the program in the Operate state


(interactively: Section 4.5; from the operating system: Section 4.11)

 Remove (de-install) the program (interactively: Section 4.6;


from the operating system: Section 4.12)

 Delete the program (interactively: Section 4.7;


from the operating system: Section 4.12)

 Update the list of programs in the dialog box


(interactively only: Section 4.8)

You can display the BCL Program Administration dialog box and/or run the
the operating system commands on one or more supervisory stations
simultaneously, but you cannot administer a particular program from more
than one station at a time.

If you select a BCL program from the BCL Program Administration dialog
box after another user has already selected the same program on another
station, the system does not allow you to modify any program information.
The program remains selected and you can view any of the Compile- or
Modify-related information for the program. When the user on the other
station finishes with the program, you still cannot modify the program until
you deselect the program and then reselect it.

To display the BCL Program Administration dialog box, select the BCL
Program Administration option under Data on the menu bar. The BCL
Program Administration dialog box appears (Figure 4-1). The system
displays all BCL programs that you have created. All programs that you
store in the /usr/tistar/hist/batch/source directory, or in directories under this
directory, appear in the dialog box.

4-2 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


NOTE: In order to select a BCL program in the Batch Program
Administration dialog, the program must have the operating system write
permission. If it has only read permission, the following message appears:

Program being modified by another user. Modification not allowed.

Make sure all programs have both read and write permissions.

Data Tags Editors

Action Request
Alarm Group
Alarm Tag
Batch Identification
BCL Program Administration
Process Group
RDT Program Administration
Recipe
Recipe Area & Component
Report
Tag Group
Trend
Window Group

Figure 4-1 Displaying the BCL Program Administration Dialog Box

BCL and Station If a BCL Program Administration dialog box remains on the screen during
Role Changes multiple role changes involving the primary, and you reselect the original
primary to become the new primary, the system can fail to mount the
primary’s history file system. The system indicates this by displaying the
message Node can’t switch to primary. At this point, access to trend and report
outputs is no longer supported on the station displaying the BCL Program
Administration dialog box.

You can prevent this situation by exiting the BCL Program Administration
dialog box before you select the original primary as the new primary. If the
situation does occur, exit the BCL Program Administration dialog box, and
resynchronize the station.

Primary Role Do not use BCL Program Administration during a role change to a new
Change primary. Normally, the OSx system prevents you from doing this; however,
under heavily loaded conditions, you may be able to start BCL Program
Administration before the system has propagated the start of the role
change to all stations.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-3


4.2 Compiling a Program Interactively

After you write a BCL program, you must compile the program before
installing it. When the program is successfully compiled, the system copies
the executable file to all supervisory stations. The path for the file is
/usr/tistar/hist/batch/work/<pgm> .exe, where <pgm> is the BCL program name
without the .bcl extension. When the compile is unsuccessful, the system
displays the file containing the compiler errors and the “Compiled On”
column shown in Figure 4-2 displays a string of asterisks (*****). It is
possible to recompile a BCL program while it is running.

The system stores information about programs in the BCL_PROGRAM_DIR


database table. You can compile up to 32 BCL programs for execution.

To compile a BCL program, highlight the name of a program on the BCL


Program Administration dialog box, and select the Compile button. The
Compile BCL Program dialog box appears (Figure 4-2).

Figure 4-2 Compile BCL Program Dialog Box

4-4 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Debug If you select Yes for the Debug option, or if any errors occur, the
system saves all .o (object) files, and .h and .c (source code) files created
during the compile. These are located in the directory called
/usr/tistar/hist/batch/work/<pgm>, where <pgm> is the BCL program name
without the .bcl extension. You can examine these files to troubleshoot your
program for syntax and other kinds of errors. If you select No (the default)
and the program compiles without error, the system saves none of these
files, thereby conserving disk space.

If you compile the same BCL program later from the command line, the
system deletes the debug subdirectory and files unless you use the -C
compilation option. The original BCL source files, which are located in the
/usr/tistar/hist/batch/source subdirectory, are not affected. Refer to Section 4.9
for additional information.

You can rebuild the BCL program by accessing the BCL Program
Administration dialog box and recompiling with the Debug option.

Options Table 4-2 on page 4-20 lists the options that you can enter in this
field. The most common options can also be changed from the Modify BCL
Program Information dialog box (Section 4.3), which is the recommended
method for changing these options.

BCL programs are not compatible with all compiler options and can fail to
compile successfully if you specify an incompatible option. Do not use the
--ansi and --compat compiler options when compiling BCL programs. Use the
man cc command for online help about the compiler.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-5


4.3 Modifying a Program Description and Options Interactively

After you compile a BCL program, you can add or change its description and
specify various runtime options. To modify a BCL program, click on the
program name, and select the Modify button on the BCL Program
Administration dialog box. The system displays the Modify BCL Program
Information dialog box (Figure 4-3). Enter an appropriate description and
select one or more options from Table 4-1.

Because some of the options in Table 4-1 place their output files in the
/usr/tistar/hist/batch/output directory, the /usr/tistar/hist file system may
become full. To reduce the possibility of running out of disk space, either
delete or move the files when you are finished with them. The output
directory must exist on all superviory stations prior to the execution of the
BCL program or the system does not write the output. The BCL program
does not create the directory.

If you have already installed a program, you can still use the Modify feature
to change the description or program options. If the program is running
when you modify it, you must halt the program and restart it for your
changes to take effect.

Figure 4-3 Modifying a BCL Program

4-6 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Table 4-1 Modify BCL Program Options

Command
Option Description
Line Syntax
Inhibits the BCL program from automatically appending a new tuple
to the database when a replace operation fails. If a BCL replace
Inhibit operation fails because the target tuple does not exist, the BCL
Automatic --a program normally appends a new tuple and places the data in the new
Append location. The --a option disables this feature, prevents the creation of a
new tuple, and generates an error message if the replace operation
fails.
Ignores network responses to database replace operations that alter
controller-resident data. Normally, the DBMS routines that execute
the replace operation wait for a response from the network before they
return to the calling program. This procedure ensures the integrity of
Run Ignore the transaction but reduces the rate at which the program updates the
Time Network --r database. The --r option causes the DBMS routines to return to the
Options Response calling program immediately after they issue a request to network.
With this option active, the calling program is not informed if errors
occur when the network attempts to handle the request; therefore, use
the --r option only when the failure to write data to controller memory
can be ignored.
Reports errors when the BCL program attempts to delete a
non-existent record from the database. Normally, a BCL program does
Report
not report this type of error. If, however, you need to know whether a
Delete --d
record that the program tries to delete is missing, the --d option
Errors
enables you to report the error so that the BCL program can detect the
error condition.
Enables user trace output. This option causes the BCL program to
write output from the print_trace_message( ) function to a file that is
associated with the BCL program. The output filename is bcltrN.out,
Enable
where N is the program ID of the installed program. Program ID must
Trace --t
be unique for all installed and/or executing BCL programs. IDs of
Output
installed programs are recorded in the BCL_PROGRAM_DIR database
table. The default directory for the trace output is
/usr/tistar/hist/batch/output.
Enables internal debug output. This option causes the BCL program to
generate a file containing information intended for debugging internal
Output functions. This option is for internal debugging, not for debugging user
Enable
Options --d applications: the print_trace_message( ) function and --t option are
Debug
Output intended for this purpose. Refrain from using this option unless
instructed to do so by a Siemens Energy & Automation, Inc., customer
support representative.
Places the trace and verbose output files in the directory specified by
the parameter output_dir. BCL normally places these output files in
Output /usr/tistar/hist/batch/output. The output directory must exist on all
--o output_dir
Directory superviory stations prior to the execution of the BCL program or the
system does not write the output. The BCL program does not create
the directory.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-7


4.4 Installing a Program Interactively

In order for a compiled program to execute automatically when the system


transtions to the Operate state, you must install it. To install a BCL
program, click on the program name, and select the Install button on the
BCL Program Administration dialog box (Figure 4-4). The system prompts
you to confirm your choice and then installs your program. OSx stores the
BCL executable files in the /usr/tistar/hist/batch/bin directory.

It is not necessary to install a program before executing it.

If you need to reinstall a program and it is already running, you must halt
the program first.

NOTE: The system does not display an entry in the Description field until
you use the Modify option (Section 4.3) to add the description for a program.

Figure 4-4 Installing a BCL Program

4-8 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


4.5 Starting and Halting a Program Interactively

After the BCL program is compiled and installed, it is available for


execution. When OSx transitions from the Offline state to the Operate state,
the system executes installed BCL programs using the program options that
you have chosen. The programs continue running until OSx transitions to
the Offline state. A transition back to the Operate state restarts the
programs.

Refer to Chapter 7 for more information about supervising a batch process.

To halt a BCL program, click on the program name, and select the Halt
button on the BCL Program Administration dialog box (Figure 4-5). The
system prompts you to confirm your choice. After halting a program, the
system enables the Start button and the Halted column displays Yes. You can
select this button to restart the program; and the Halted column then
displays No.

If you halt a program, it does not start again until you restart it by selecting
the Start button. When OSx transitions from Offline to Operate, no program
that you halt manually resumes execution until you restart it manually.

Figure 4-5 Halting a BCL Program

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-9


Starting and Halting a Program Interactively (continued)

BCL Program If a BCL program executes an infinite loop, it can never return to an idle
Cannot Be Halted state where it is looking for program events. A program in such a condition
cannot process a Halt command. If you select the Halt button in the BCL
Program Administration dialog box, the system displays Yes for halted, even
though you cannot actually halt the program.

If you suspect that a program is running when the system shows that it is
halted, you can kill it using operating system commands. Follow the steps
below.

1. Open an Xterm window and log in as tistar.

2. Enter the following command: ps -ef | grep <program name>

3. Note the first number that appears on the line containing your
program executable (not the grep command), if it exists. This is the
process ID (pid) for the program. If it does not appear, your program is
already halted. If the process ID does appear, go to step 4.

4. Kill the program by entering the following command:


kill <pid>
where <pid> is the process ID.

Correct the code within the program that caused the runaway processing.

4-10 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


4.6 Removing a Program Interactively

Use the Remove feature to de-install a BCL program. A program that has
been removed no longer begins executing automatically when the system
transitions to the Operate state. To remove a BCL program, click on the
program name, and select the Remove button on the BCL Program
Administration dialog box (Figure 4-6). The system prompts you to confirm
your choice and then removes your program.

If the program is running, you must halt the program before removing it.

Figure 4-6 Removing a BCL Program

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-11


4.7 Deleting a Program Interactively

Use the Delete feature to delete a compiled BCL program. The source code
for that program is unaffected by the Delete feature. Use the rm command
to delete the file containing the source code.

To delete a BCL program, click on the program name, and select the Delete
button on the BCL Program Administration dialog box (Figure 4-7). The
system prompts you to confirm your choice and then deletes your program.

If the program is running, you must halt the program before deleting it.

Figure 4-7 Deleting a BCL Program

4-12 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


4.8 Updating the BCL Program List

Use the Update List feature to update the list of BCL programs in the BCL
Program Administration dialog box. This feature causes the program to
rebuild its list to reflect changes to BCL programs made on other
supervisory stations. You know the list needs updating if you select a
program and the buttons are not enabled or disabled correctly for the list
entry. For example, the Remove button is enabled but the Installed On
column for the selected program is empty.

To update the list, select the Update List button on the BCL Program
Administration dialog box (Figure 4-8).

Figure 4-8 Updating the BCL Program List

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-13


4.9 Compiling a Program from the Command Line

You can compile a BCL program from the operating system command line.
Use this method when you want to compile multiple programs as a group,
using a shell script. Do not recompile a program if it is running. Halt the
program before compiling it again. Follow these steps.

The system stores information about programs in the BCL_PROGRAM_DIR


database table. You can compile up to 32 BCL programs for execution.

1. Select Controls ->OSx Terminal on the menu bar.

2. Enter your login and password.

3. Enter bcl_admin -c <pgm> at the prompt.


The system translates, compiles, and links the BCL program.

At the command line, use -c to compile without the Debug option, and
-C to compile with Debug.

The <pgm> corresponds to the name of a BCL program file. The


program name must have the extension .bcl, and the non-extension
portion can have up to ten characters.

4. Correct any problems that might arise and exit the OSx terminal
window. Errors are written to a file. The system displays the error file
name when the compile finishes.

You can do multiple operations by combining command line switches. For


example, enter bcl_admin -ci <pgm> to install a program after compiling
it. Installing is described in Section 4.10. For online information about
combining command line switches, enter bcl_admin at the prompt.

BCL programs are not compatible with all compiler options and can fail to
compile successfully if you specify an incompatible option. Do not use the
--ansi and --compat compiler options when compiling BCL programs.

NOTE: For BCL compile time syntax errors from within action blocks, the
erroneous BCL statement is displayed. For BCL statements outside of
action blocks, the numeric Block ID that is closest to or contains the
erroneous BCL statement is displayed. The Block ID for the first action
block is 0, with the following blocks consecutively numbered.

4-14 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


BCL Debug Files When you use the BCL Program Administration dialog box to compile a
BCL program and select the Debug option, the system creates several object
and source files in a subdirectory underneath the /usr/tistar/hist/batch/work
directory. The name of the debug subdirectory matches that of the BCL
program.

If you compile the same BCL program later from the operating system
command line, the system deletes the debug subdirectory and files unless
you use the -C compilation option. The original BCL source files, which are
located in the /usr/tistar/hist/batch/source subdirectory, are not affected.

You can rebuild the BCL program by accessing the BCL Program
Administration dialog box and recompiling with the Debug option.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-15


4.10 Installing a Program from the Command Line

You can install a BCL program from the operating system command line.

If the program is running, you must halt the program before re-installing it.

To install a program, follow these steps.

1. Select Controls ->OSx Terminal on the menu bar.

2. Enter your login and password.

3. Enter bcl_admin -i <pgm>.bcl at the prompt.


The system installs the BCL program.

The <pgm> corresponds to the name of a BCL program file. The


program name must have the extension .bcl, and the non-extension
portion can have up to ten characters.

OSx stores the BCL executable files in the /usr/tistar/hist/batch/bin directory.


It is not necessary to install a program before executing it from the
operating system command line.

4-16 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


4.11 Controlling BCL Programs from the Command Line

Executing a You can execute a BCL program from the operating system command line.
Program from the Typically, you do this operation from the command line when you are testing
Operating System the program. Make sure that the system is offline first. It is not necessary to
install a program before executing it from the command line; however, you
must install it before you can execute it from the BCL Program
Administration dialog box.

! WARNING
Testing BCL programs online (including installing, starting, and halting) can
affect I/O devices or controller operation.
Unpredictable operation by the controller and I/O could cause death or serious
injury to personnel, and/or damage to equipment.
Test a BCL program offline prior to installing it on the target system to ensure
that the program does not adversely affect I/O devices or the operation of the
controller.

To execute a compiled BCL program, follow these steps.

1. Select Controls ->OSx Terminal on the menu bar.

2. Enter your login and password.

3. Enter cd /usr/tistar/hist/batch/work
The system changes the default directory.

4. Enter <pgm>.exe <options> <pgm_id> at the prompt.


The system executes the BCL program.

The pgm corresponds to the program name. The .exe extension must be
present to execute the program.

The options parameter corresponds to zero or more of the options


described in Table 4-2 on page 4-20. Refer to the example that follows.

The pgm_id parameter at the end of the command line is the program
ID, which can be any number greater than 32 and less than 32,767.
This parameter is required. Use unique program IDs if you run more
than one standalone (--x option) program or if any installed programs
are currently running. Otherwise, the trace and debug files may
overlap.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-17


Controlling BCL Programs from the Command Line (continued)

For example, to run the program called line_1 and check for errors, produce
trace and verbose (debug) output, enter the following: line_1.exe
-tvex 99

The --e option is the best method for validating the program’s database
references. This mode of execution does not change the database.

! WARNING
After it is activated, a BCL program that was started with the stand-alone mode
(-x option) does not communicate with the batch manager; therefore, the batch
manager cannot shut down the BCL program when the system transitions to
the Offline state.
When you execute a BCL program in the stand-alone mode, the program has
full access to the OSx database and can make unexpected changes to I/O
devices and controller outputs. Such changes can cause unpredictable
operation by the controller that could cause death or serious injury to
personnel, and/or damage to equipment.
Do not attempt to run a BCL program in stand-alone mode (-x option) when OSx
is connected to the controller or is in the Operate state. Ensure that the OSx
system is in the Offline state or is disconnected from the controller before you
run a BCL program in stand-alone mode.

If you run a BCL program in the stand-alone mode (-x option), you cannot
halt it with the usual commands. Moreover, the program does not stop when
the system transitions to the Offline state. Use the kill command to stop the
program.

4-18 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Halting and You can halt and start a BCL program from the operating system command
Starting a Program line. To halt a program that has been started, enter the following command
from the Operating at the command line: bcl_admin -h <pgm>.bcl
System
To start a program that has been halted, enter the following command at
the command line: bcl_admin -s <pgm>.bcl

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-19


Controlling BCL Programs from the Command Line (continued)

BCL Program Table 4-2 lists the BCL program options that you can specify when you
Options execute a BCL program from the operating system command line. See step 4
on page 4-17 for the syntax. The options listed in Table 4-2 can also be
entered in the Options field of the Compile dialog box. The most common
options can be changed in the Modify BCL Program Information dialog box
(Section 4.3), which is the recommended method for changing these options.

Table 4-2 BCL Program Options

Option Description
Inhibits the BCL program from automatically appending a new tuple to the database when a
replace operation fails. If a BCL replace operation fails because the target tuple does not
--a exist, the BCL program normally appends a new tuple and places the data in the new
location. The --a option disables this feature, prevents the creation of a new tuple, and
generates an error message if the replace operation fails.
Reports errors when the BCL program attempts to delete a non-existent record from the
database. Normally, a BCL program does not report this type of error. If, however, you need
--d
to know whether a record that the program tries to delete is missing, the --d option enables
you to report the error so that the BCL program can detect the error condition.
Checks the BCL program for errors. When it is executed with this option, the BCL program
starts and executes all initialization steps that resolve references to the OSx database. The
references include tag, table, attribute, and bit names. The option also checks for data type
--e compatibility between similarly-named unit elements and then exits without performing any
further processing. The program reports any problems on the standard output. No output
indicates that the program validated properly. Refer to Section 4.5 for information about
running a BCL program manually.
Places the trace and verbose output files in the directory specified by the parameter output_dir.
--o output_dir
BCL normally places these output files in /usr/tistar/hist/batch/output.
Accesses the database in the directory specified by the parameter db_path. This option is
--p db_path necessary only if the TQL_DB environment variable is not set. The standard OSx login
normally sets the TQL_DB variable; therefore, the --p option is seldom required.
Ignores network responses to database replace operations that alter controller-resident data.
Normally, the DBMS routines that execute the replace operation wait for a response from the
network before they return to the calling program. This procedure ensures the integrity of
the transaction but reduces the rate at which the program updates the database. The --r
--r
option causes the DBMS routines to return to the calling program immediately after they
issue a request to network. With this option active, the calling program is not informed if
errors occur when the network attempts to handle the request; therefore, use the --r option
only when the failure to write data to controller memory can be ignored.
Table continues on next page.

4-20 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Table 4-2 BCL Program Options (continued)

Option Description
Enables user trace output. This option causes the BCL program to write output from the
print_trace_message( ) function to a file that is associated with the BCL program. The output
filename is bcltrN.out, where N is the program ID of the installed program. Program ID must
be unique for all installed and/or executing BCL programs. IDs of installed programs are
recorded in the BCL_PROGRAM_DIR database table. The default directory for the trace
--t output is /usr/tistar/hist/batch/output.
When you run a BCL program from the operating system command line, state change event
notification is not available, since the BCL program is not communicating with the batch
manager program in this mode. Therefore, the trace output does not show events such as
OFLN_TO_STBY, STBY_TO_OPER, OPER_TO_STBY, and STBY_TO_OFLN. All other
event messages (including STARTUP and SHUTDOWN) are received by the program.
Enables internal debug output. This option causes the BCL program to generate a file
containing information intended for debugging internal functions. This option is for internal
--v debugging, not for debugging user applications: the print_trace_message( ) function and --t
option are intended for this purpose. Refrain from using this option unless instructed to do so
by a Siemens Energy & Automation, Inc., customer support representative.
Runs the BCL program in stand-alone mode. This option allows offline testing of your BCL
programs. However, if the BCL program contains networked tags, you cannot run it with the
--x option in the Offline state. To use the --x option in the Offline state, you can temporarily
substitute non-networked tags for the networked tags. When executed with the --x option, a
--x
BCL program arms all events and executes event block code in response to events, regardless
of the OSx system state. Code within the event blocks might alter the database; therefore,
avoid using this option if the BCL program can interfere with the data that affects a live
process.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Administration 4-21


4.12 Removing and Deleting a Program from the Command Line

Removing a You can remove a BCL program from the operating system command line.
Program from the Use the Remove feature to de-install a BCL program. A program that has
Operating System been removed no longer begins executing automatically when the system
transitions to the Operate state.

If the program is running, you must halt the program before removing it.

To remove a program, follow these steps.

1. Select Controls ->OSx Terminal on the menu bar.

2. Enter your login and password.

3. Enter bcl_admin -r <pgm>.bcl at the prompt.


The system de-installs the BCL program.

Deleting a Program You can delete a compiled BCL program from the operating system
from the Operating command line. The Delete feature deletes only a compiled program; the
System source code for that program is unaffected by the Delete feature. Use the rm
command to delete the file containing the source code.

If the program is running, you must halt the program before deleting it.

To delete a BCL program, follow these steps.

1. Select Controls ->OSx Terminal on the menu bar.

2. Enter your login and password.

3. Enter bcl_admin -d <pgm>.bcl at the prompt.


The system deletes the BCL program.

4-22 BCL Administration SIMATIC PCS 7 OSx 4.1.1 Batch Programming


Chapter 5
Batch Operations and the Controller
5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
The Controller Program and OSx Batch Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
How Does the Controller Program Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Batch Request Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
5.2 Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
List of Batch Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Operations and the Controller 5-1
5.1 Overview

The Controller A mechanism has been devised to permit the controller program to contain
Program and OSx the batch control, but still allow OSx to assist in batch tracking/reports. The
Batch Tracking mechanism is to use the following three attributes, available in the unit tag
relation:

bch_req number (--32768 to +32767. Triggers on change in


value)
bch_req_info 16 character string
bch_req_resp SUCCESSFUL (0¢8000) (set by OSx ) or
FAILED (0¢4000) (set by OSx ) or
NO_COMMAND (0¢0000) (set by controller)

How Does the The controller program can set these attributes as needed to perform the
Controller Program appropriate connections between the control node and the OSx station. OSx
Work? uses its database to log batch changes and to create batch reports. Making
batch requests in the controller by way of the bch_req attribute allows OSx
to notify its database of the actions taking place in the controller and keep
appropriate records of what is happening during the batch. The bch_req _info
attribute is a variable used to provide more information that may be
required to perform the batch request being made. Typically, the controller
sets bch_req_resp to NO_COMMAND before a batch request.

Batch Request The bch_req can be set to valid batch and unit commands. Refer to Table 5-1
Commands for batch request commands and be aware of the following:

 A unit can command itself by setting its own COMMAND attribute,


and does not need to use bch_req.

 The bch_req can be used to send commands to another unit by way of


the bch_req_info attribute.

Refer to Table 2-1, on page 2-7, for information about how APT makes use of
these attributes for unit tags.

NOTE: Some batch and unit commands share the same name; therefore a
prefix of B_ (BATCH) and U_ (UNIT) is used to distinguish between the two
types of commands.

Batch Request Each time the bch_req is set to a batch or unit command, the OSx batch
Response manager processes the command and then writes successful (0x8000) or
failed (0x4000) to the bch_req_resp attribute of the unit that made the
request. Note that a value of successful does not mean that the requested
command was actually successfully executed; it merely means that the
batch manager successfully read the request and has passed it along to the
batch and/or unit.

5-2 Batch Operations and the Controller SIMATIC PCS 7 OSx 4.1.1 Batch Programming
5.2 Batch Request Commands

List of Batch Table 5-1 lists controller batch requests.


Requests
Table 5-1 Batch Controller Request Commands
bch_req value Contents of
bch_req name Comments
Hex Dec bch_req_info
A new batch is created by the unit that sets this
bch_req. The new batch is created with the batch ID in
BCH_REQ_B_COMMIT 0xcf00 --12544 new batch ID bch_req_info and the unit who made this request is
sent the U_CMD_ASSIGN command to indicate it has
been assigned to the new batch.
The batch to which this unit is assigned sends the
BCH_REQ_B_REMOVE 0xc000 --16384 U_CMD_RELEASE command to all units assigned to it
and then the batch is removed permanently.
The batch to which this unit is assigned is given the
product name indicated in bch_req_info. Then all units
BCH_REQ_B_START 0x9a00 --26112 product name
assigned to this batch are sent the U_CMD_START
command.
A new sub-batch is created and committed with the
batch ID found in bch_req_info. This sub-batch is
BCH_REQ_B_SPLIT 0xcB00 --13568 batch ID automatically assigned the same product name as the
batch of the unit making the request. In addition, the
new sub-batch does not have any units assigned to it.
The tag name found in bch_req_info is assigned to the
first encountered sub-batch with no units assigned that
BCH_REQ_B_SPLIT_ASN 0xca00 --13824 tag name was split from the batch ID of the unit making the split
assign request, then the tag is sent the
U_CMD_ASSIGN command.
The batch command B_CMD_ABORT is processed for
the batch ID of the unit making this request. The unit
command U_CMD_ABORT is sent to all units
currently assigned to the batch being aborted.
BCH REQ B ABORT
BCH_REQ_B_ABORT 0xaf00 --20736
20736
The batch command B_CMD_ABORT is processed for
the batch ID of the unit identified by tag name. The
tag name
unit command U_CMD_ABORT is sent to all units
currently assigned to the batch being aborted.
The batch command B_CMD_COMPLETE is processed
for the batch ID of the unit making this request. The
unit command U_CMD_DONE is sent to all units
currently assigned to the batch.
BCH REQ B COMPLETE
BCH_REQ_B_COMPLETE 0xab00 --21760
21760
The batch command B_CMD_COMPLETE is processed
for the batch ID of the unit identified by tag name. The
tag name
unit command U_CMD_DONE is sent to all units
currently assigned to the batch being completed.
Table continues on next page.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Operations and the Controller 5-3
Batch Request Commands (continued)

Table 5-1 Batch Controller Request Commands (continued)


bch_req value Contents of
bch_req name Comments
Hex Dec bch_req_info
The batch command B_CMD_HOLD is processed for
the batch ID of the unit making this request. The unit
command U_CMD_HOLD is sent to all units currently
assigned to the batch being held.
BCH REQ B HOLD
BCH_REQ_B_HOLD 0x9d00 --25344
25344
The batch command B_CMD_HOLD is processed for
the batch ID of the unit identified by tag name. The
tag name
unit command U_CMD_HOLD is sent to all units
currently assigned to the batch being held.
The batch command B_CMD_RESUME is processed
for the batch ID of the unit making this request. The
unit command U_CMD_RESUME is sent to all units
currently assigned to the batch being resumed.
BCH REQ B RESUME
BCH_REQ_B_RESUME 0x8d00 --29440
29440
The batch command B_CMD_RESUME is processed
for the batch ID of the unit identified by tag name. The
tag name
unit command U_CMD_RESUME is sent to all units
currently assigned to the batch being resumed.
The batch command B_CMD_SET_ALARM is
processed for the batch ID of the unit making this
request. The unit command U_CMD_SET_ALARM is
sent to all units currently assigned to the batch being
alarmed.
BCH REQ B SET ALARM
BCH_REQ_B_SET_ALARM 0x9e00 --25088
25088
The batch command B_CMD_SET_ALARM is
processed for the batch ID of the unit identified by tag
tag name name. The unit command U_CMD_SET_ALARM is
sent to all units currently assigned to the batch being
alarmed.
The batch command B_CMD_CLR_ALARM is
processed for the batch ID of the unit making this
request. The unit command U_CMD_CLR_ALARM is
sent to all units currently assigned to the batch being
cleared.
BCH REQ B CLR ALARM
BCH_REQ_B_CLR_ALARM 0x8e00 --29184
29184
The batch command B_CMD_CLR_ALARM is
processed for the batch ID of the unit identified by tag
tag name name. The unit command U_CMD_CLR_ALARM is
sent to all units currently assigned to the batch being
cleared.
Tag name will represent the tag name of another unit
in the system. The unit making the request is assigned
BCH_REQ_U_ASSIGN 0x1700 5888 tag name
to the same batch ID as the unit identified by tag
name and is sent the U_CMD_ASSIGN command.
Table continues on next page.

5-4 Batch Operations and the Controller SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table 5-1 Batch Controller Request Commands (continued)
bch_req value Contents of
bch_req name Comments
Hex Dec bch_req_info
The unit making the request is released from the
BCH_REQ_U_RELEASE 0x0700 1792 batch in which it is currently assigned and is sent the
U_CMD_RELEASE command.*
The unit making the request is sent the
U_CMD_START command.*
BCH REQ U START
BCH_REQ_U_START 0x1a00 6656
The unit identified by tag name is sent the
tag name
U_CMD_START command.
The unit making the request is sent the
U_CMD_DONE command.*
BCH REQ U DONE
BCH_REQ_U_DONE 0x0a00 2560
The unit identified by tag name is sent the
tag name
U_CMD_DONE command.
The unit making the request is sent the
U_CMD_HOLD command.*
BCH REQ U HOLD
BCH_REQ_U_HOLD 0x1d00 7424
The unit identified by tag name is sent the
tag name
U_CMD_HOLD command.
The unit making the request is sent the
U_CMD_RESUME command.*
BCH REQ U RESUME
BCH_REQ_U_RESUME 0x0d00 3328
The unit identified by tag name is sent the
tag name
U_CMD_RESUME command.
The unit making the request is sent the
U_CMD_WAIT command.*
BCH REQ U WAIT
BCH_REQ_U_WAIT 0x1b00 6912
The unit identified by tag name is sent the
tag name
U_CMD_WAIT command.
The unit making the request is sent the U_CMD_JOG
command.*
BCH REQ U JOG
BCH_REQ_U_JOG 0x0b00 2816
The unit identified by tag name is sent the
tag name
U_CMD_JOG command.
The unit making the request is sent the
U_CMD_ABORT command.*
BCH REQ U ABORT
BCH_REQ_U_ABORT 0x1f00 7936
The unit identified by tag name is sent the
tag name
U_CMD_ABORT command.
The unit making the request is sent the
U_CMD_CLR_ABORT command.*
BCH REQ U CLR ABORT
BCH_REQ_U_CLR_ABORT 0x0f00 3840
The unit identified by tag name is sent the
tag name
U_CMD_CLR_ABORT command.
* Instead of using the bch_req attribute to issue a request, it is possible to bypass the batch manager by having the
unit write the command to its own command attribute.
Table continues on next page.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Operations and the Controller 5-5
Batch Request Commands (continued)

Table 5-1 Batch Controller Request Commands (continued)


bch_req value Contents of
bch_req name Comments
Hex Dec bch_req_info
The unit making the request is sent the
U_CMD_SET_ALARM command.*
BCH REQ U SET ALARM
BCH_REQ_U_SET_ALARM 0x1e00 7680
The unit identified by tag name is sent the
tag name
U_CMD_SET_ALARM command.
The unit making the request is sent the
U_CMD_CLR_ALARM command.*
BCH REQ U CLR ALARM
BCH_REQ_U_CLR_ALARM 0x0e00 3584
The unit identified by tag name is sent the
tag name
U_CMD_CLR_ALARM command.
The unit making the request is sent the
U_CMD_IN_SERVE command.*
BCH REQ U IN SERVE
BCH_REQ_U_IN_SERVE 0x0600 1536
The unit identified by tag name is sent the
tag name
U_CMD_IN_SERVE command.
The unit making the request is sent the
U_CMD_OUT_SERVE command.*
BCH REQ U OUT SERVE
BCH_REQ_U_OUT_SERVE 0x1600 5632
The unit identified by tag name is sent the
tag name
U_CMD_OUT_SERVE command.
* Instead of using the bch_req attribute to issue a request, it is possible to bypass the batch manager by having the
unit write the command to its own command attribute.

5-6 Batch Operations and the Controller SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 6
Batch Logs and Reports
6.1 Understanding Batch Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
What Is a Batch Log? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Batch Internal ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
6.2 Guidelines for Generating Batch Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Report Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Batch Report Format Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Logs and Reports 6-1
6.1 Understanding Batch Logs

What Is a Batch The batch log consists of all messages that OSx generates during batch
Log? processing. Like the other logs that OSx generates, the batch log is not a
separate group of messages. Instead, the batch log characterizes those
messages within the system log that are related either to a specific batch ID
or to all batch IDs. If a system-generated message does not relate to a
batch ID, then the message is not part of the batch log (Figure 6-1).

Batch Internal ID The batch ID field contains the internal ID of the batch, not the
user-defined custom batch ID, in the daily system log file. However, reports
reading the log file translate this internal ID to the customer-defined
batch ID.

325.0 WARN Temperature of Oven #1 BID920729--0002 Internal Batch ID


associated with the log
LL_ALARM WARN Temperature of Oven #1 BID920729--0002 message.

START GINGER_SNAP_1 BID920729--0003

Asterisk denotes a log


DATE: 10--DEC--91 TIME: 10:27:17 * message that applies to all
325.0 WARN Temperature of Oven #1 BID920729--0002 batches.

Earl Login OPERATE Log message does not


apply to any batch if this
ASSIGNED MIXER_1 Start of Mixer #1 BID920729--0003 field is blank. System
messages often do not
0x0003 WARN SPOOLER SYSTEM ALARM * have corresponding batch
IDs.

Figure 6-1 Example of Batch ID Fields in the Batch Log

6-2 Batch Logs and Reports SIMATIC PCS 7 OSx 4.1.1 Batch Programming
OSx creates a new log file every day and stores each file for the number of
days that is specified in the File Duration field of the Printer Configuration
Destination display. This log file is stored in the /usr/tistar/hist/rpt/output
directory and is named RPLOG.<date>--<sequence number>, for example,
RPLOG.06APR--1 for the first file of April 6th.

Figure 6-2 illustrates how OSx generates log messages and log files during
batch processing. To view or print data related to a specific batch, you must
develop a report format that extracts the required data from the log and
places it in a file. For more information about creating batch reports, refer
to Section 6.2.

Generates
OSx system
changes

Batch process Generates


messages

Spooler:
Queues messages and
sends them to the correct Printer
destination depending on configuration
the items selected during
printer configuration

Hard copy of log


file data
Log files Report editor: Custom reports
Enables you to pull
current data from log files
1 day old

2 days old

Figure 6-2 Log File Generation

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Logs and Reports 6-3
6.2 Guidelines for Generating Batch Reports

Batch reports use customer-defined batch IDs to retrieve information from


the OSx database and the system log file. All commands and functions
described in the SIMATIC PCS 7 OSx Reports Manual may also be used
within batch reports.

Prerequisites Before you try to generate batch reports, ensure that you are aware of the
following prerequisites.

 You know which tags are linked to units that are associated with a
batch.

 You know which batch IDs you want to use to create the batch reports.

 You are thoroughly familiar with the information in the SIMATIC


PCS 7 OSx Reports Manual.

 You are thoroughly familiar with the message types and fields in the
log files. See the SIMATIC PCS 7 OSx Reports Manual for more
information about the message types.

Report Editor The procedures for creating batch reports with the Report Editor are exactly
the same as they are for creating typical reports. For information about
using the Report Editor, refer to the SIMATIC PCS 7 OSx Reports Manual.

Batch Report Several report functions exist that are especially useful for batch reports:
Format Functions @blog, @setbid, #readlog, and #field. For a description of these functions and
their syntax, usage, and output, refer to the SIMATIC PCS 7 OSx Reports
Manual.

6-4 Batch Logs and Reports SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Chapter 7
Running and Supervising a Batch
7.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
7.2 Configuring a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Using Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7.3 Displaying a List of Active Batches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

7.4 Displaying the Active Batch Tag Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

7.5 Viewing the Operation of an Active Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10


Viewing Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
Viewing Batch-Related Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
Viewing Batch-Related Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7.6 Assigning Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12

7.7 Releasing Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13

7.8 Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14


Changing the State of a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Starting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
7.9 Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16

7.10 Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17

7.11 Ending a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18


Completing or Aborting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
Removing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
7.12 Viewing Batch-Related Tag Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20

7.13 Viewing the Unit Tag Detail and Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22


Viewing Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-22
Changing the State of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
Changing the Mode of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
Viewing the Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-1
7.1 Prerequisites

Ensure that you have done the following before you initiate and supervise a
batch.

 You have configured one or more unit tags and their associated process
tags.

 You have configured one or more recipes for specific products.

 You have programmed the controller to control the execution of the


batch.

 You have written a BCL program that links OSx with your process
(optional).

 You are in the Offline or Operate state to configure batches; or you are
in the Operate state to start and monitor batches.

7-2 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Sequence of Tasks Figure 7-1 lists the recommended order of tasks for executing and
supervising a batch. The security privileges that are required to perform
these batch and unit commands are found in Appendix E.

ID 1
Associate a batch ID with a
ID 2 product.

Start the batch.

Observe the operation of the


batch.

Change the state or mode of a


batch, if required.
ON OFF

Figure 7-1 Recommended Order of Tasks

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-3
7.2 Configuring a Batch

Using Batch OSx enables you to associate a unique batch ID with every product. If, for
Identification example, you run six batches of the same product in one day, use a unique
batch ID for each batch. The unique batch IDs make it easy to track data
related to the batches.

To enter a new batch or change an existing batch, select Data ->Batch


Identification from the menu bar (Figure 7-2). Batch Identification enables
you to associate a batch with a product, commit a batch for execution,
rename the batch, and configure the destination of the batch log. You must
have Primary or Batch Control Security privileges to perform these
functions. The Batch Identification function is not available on a station
with the sysadmin role.

Data Tags Editors


Action Request
Alarm Group
Alarm Tag
Batch Identification
BCL Program Administration
Process Group
RDT Program Administration
Recipe
Recipe Area & Component
Report
Tag Group
Trend
Window Group

Figure 7-2 Accessing Batch Identification

7-4 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Batch ID Enter a unique batch ID or select a batch ID from the list. A
batch ID can have up to 16 characters. The space, the character
combinations --> and <-- and the characters ; , \ ” are invalid for
batch IDs. You can change a batch ID at any time while entering data for a
new batch. You can rename a batch by selecting an existing batch ID and
typing over the ID with the new batch ID.

Enter the batch ID description in the field to the right of the Batch ID field.
The characters ; \ ” are invalid for batch ID descriptions. If you select
an existing batch ID, the description appears in this field. You may change
the description by editing the field. The new description is saved when
Commit or OK is selected.

Typically, when you commit a new batch using the Batch Identification option,
the batch state changes from New to either Commit or Ready to indicate that
the system has successfully created the batch. However, if you modify an
existing batch, and the modification does not cause a batch state change,
then there is no visual feedback to indicate that the batch change
succeeded. To be sure that the change has actually succeeded, select Clear
and then enter the batch ID again in the Batch ID field. The system
displays the current information for the batch.

Product Enter or select the name of an existing recipe to be associated


with the batch ID. The product list contains all OSx recipes. The None
product allows the operator to reserve a batch ID for a product that is not
yet defined. The None product appears in the product list, and you can also
type None in the product field. When you decide on the recipe, you can
reassign a product to the batch with the None product. OSx links the
Product (Recipe) to the batch ID when Commit or OK is selected.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-5
Configuring a Batch (continued)

Batch State Displays the current state of a batch. You cannot edit this
field. This field displays New during the entry of new batch information.
This field dynamically updates as the state of the batch changes. Assigning
None as the product places the batch in the Commit state. Assigning any
other product to the batch causes the batch to bypass the Commit state and
go directly to the Ready state (Figure 7-3).

Destination Enables you to change the default destination of the batch


log file for the duration of the selected batch. When you select this option,
the screen displays the available printer destinations that you can choose.

Initial batch messages print to the default batch log printer as configured in
the Log Destination dialog box (select Startup ->Printer ->Log Destination) until
you select a new destination. To minimize the number of messages printed
to the default printer, follow these guidelines.

When you select Data ->Batch Identification on the menu bar to create a new
batch, select Commit before making any changes in the printer destination.
Initial commit messages print at the default destination. After committing
the batch, make any changes that you want in the printer destination, and
all subsequent messages print at the new destination.

Before you modify an existing batch, make any changes in the printer
destination and select Commit. Then make any other changes that you want
for the batch, and select Commit or OK. All batch messages that are
generated after the destination change are then logged using the new
printer destination.

7-6 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Commit Saves the batch information that you enter and associates the
batch ID with a product (recipe). Commit does not start a batch recipe
(Figure 7-3). When you select the Commit option, the batch is considered
active, the batch start time is set to reflect the time at which the Commit
command was executed, and OSx places the batch ID with its description in
the Active Batch Directory. You cannot commit a batch unless it is
associated either with a product or with the special None product. Until a
batch has started and passed the Ready state, you can change the product
associated with a batch.

When you commit a new batch with a product other than the special None
product when OSx is in the Operate state, the system may log a batch
tracking message indicating that the batch has made a state change to
COMMIT transition. You can ignore this message. The COMMIT state is a
temporary, transitory state for batches committed with a product other than
the None product. A second batch tracking message follows, indicating a
state change to READY.

Figure 7-3 Committing a Batch

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-7
7.3 Displaying a List of Active Batches

In the Operate state, OSx enables you to display a directory of all active
batches. A batch becomes active by associating a batch with a product and
committing the batch (Section 7.2). To display the Active Batch Directory,
select Batch from the Directory pushbutton in the navigation area
(Figure 7-4).

When you select a batch ID, OSx displays the graphic that your BCL
program associated with that batch. If a batch ID does not have an
associated graphic, OSx displays the corresponding batch tag detail.

Figure 7-4 Active Batch Directory Example

7-8 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
7.4 Displaying the Active Batch Tag Group

To display the Active Batch Tag Group, select Active Batches from the
Navigation Area (Figure 7-5). A tag group containing one faceplate for each
currently active batch is displayed in alphabetical order by batch ID. Only
eight faceplates fit on one display page; if there are more than eight
currently active batches, then the Right button in the navigation area is
sensitized. Selecting Right displays the next set of active batches. Selecting
Left at any time after selecting Right returns you to the previous page of
active batches.

As with faceplates for other tag types, selecting Detail on the faceplate
displays the tag detail for the batch.

The Active Batches button is grayed out when there are no batches currently
active.

Left Button

Right Button

Active Batches

Detail

Figure 7-5 Displaying Active Batch Tag Group

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-9
7.5 Viewing the Operation of an Active Batch

You can view the graphic associated with an active batch if a BCL program
has associated the graphic with the batch ID. If a batch ID is not associated
with a graphic, OSx displays the detail screen corresponding to the batch.

Viewing Program If your station is in Operate state, you may observe some delay in the
Execution execution of a BCL program when another station is synchronizing. To see if
this is the cause of the delay, check Network Status, which shows when
stations are synchronizing. Program execution will be complete shortly after
synchronization finishes.

Viewing To view the graphic associated with a batch, access the Active Batch
Batch-Related Directory and select a batch ID. OSx displays the currently associated
Graphics graphic (or the tag detail if an associated graphic does not exist). Your BCL
program can automatically change the graphic associated with a batch as
the batch progresses. For information on how to associate a graphic with a
batch, refer to the bc_assign_graphic function in Appendix C.

Viewing To view the tag detail associated with a batch graphic, select Tag Detail from
Batch-Related the navigation area Directory pushbutton while the batch graphic is
Detail displayed, or while the Active Batch Tag Group is displayed, select the Detail
button on the faceplate of your batch ID (Figure 7-6). The tag detail is then
displayed.

7-10 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-6 Sample Batch Tag Detail Screen

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-11
7.6 Assigning Batch Units

To assign one or more units to a batch from the batch tag detail, follow these
steps:

1. Select Assign Unit. A list of unassigned units displays in the navigation


area (Figure 7-7). Use the scroll bar to view multiple pages of units.

2. Select the unit(s) you want to assign to the batch. Use the scroll bar to
view multiple pages of units.

3. Select OK to assign the units or select Cancel to not assign any units.

See Appendix E for an explanation of security privileges required to assign


units to batches.

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-7 Assigning Units to a Batch

7-12 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
7.7 Releasing Batch Units

To release one or more units from a batch using the batch tag detail, follow
these steps:

1. Select Release Unit. A list of all units currently assigned to the batch
displays in the navigation area (Figure 7-8). Use the scroll bar to view
multiple pages of units.

2. Select the unit(s) you want to release from the batches, or choose Select
All & OK to release all assigned units from the batch.

3. Select OK to release individually selected units or select Cancel to not


release any units.

See Appendix E for an explanation of security privileges required to release


units from batches.

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-8 Releasing Units from a Batch

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-13
7.8 Changing Batch State

The batch tag detail enables you to monitor the status of a batch and to
access a dynamically built tag group consisting of the units currently
assigned to the batch. From these screens, an operator may issue commands
to a batch or unit if he or she has the correct security privilege. See
Table E-1 and Table E-3 in Appendix E for the valid security privileges for
batch and unit commands.

Changing the State To change the operational state of a batch and its assigned units, select the
of a Batch State field. OSx displays a command form that lists the batch state options
(Figure 7-9). The selected command is also propagated to the units assigned
to the batch.

Starting a Batch After creating an active batch, follow these steps to start the batch.

1. Access the batch tag detail (Section 7.5).

2. Select the Start option from the State field on the Batch Tag Detail. The
system sends the Start command to the batch and propagates it to the
units assigned to the batch.

The Start option sends the Start command to all units currently assigned to
the batch. The logic that you build into the batch program determines any
other actions that occur when you select the Start option. See Table A-5 on
page A-6 for the values of the batch command attribute and Table A-11 on
page A-10 for the values of the unit command attribute.

NOTE: At least one unit must be assigned to the batch before starting it.
Refer to Section 7.6 for instructions on assigning units to a batch.

7-14 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-9 Changing Batch State

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-15
7.9 Changing Batch Mode

To change the operational mode of a batch and its assigned units, select the
Mode field (Figure 7-10). OSx displays a command form that lists these
batch mode options.

 Automatic — Logic in the programmable controller controls the batch


processing.

 Manual — The operator controls the batch processing manually.

 Semi-Automatic — The operator controls some functions of the batch


processing, depending on the logic of the batch program. The
programmable controller controls the other functions.

The selected mode command is also sent to the units assigned to the batch.
See Table E-2 and Table E-4 in Appendix E for the valid security privileges
for mode commands, Table A-6 on page A-6 for the values for the batch
MODE_CMD attribute, and Table A-12 on page A-10 for values for the unit
MODE_CMD attribute.

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-10 Changing Batch Mode

7-16 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
7.10 Splitting a Batch

A batch may be split into multiple batches from the batch tag detail by
selecting Split Batch and entering a new, unique batch ID at the Sub-Batch ID
prompt, followed by selecting OK (Figure 7-11). This creates a new batch
with the same product as the parent batch. The new child batch is placed in
the ready state and its start time is set to reflect the time at which the split
command was performed. See Table E-1 in Appendix E for an explanation of
security privileges required to split batches.

Parent batches are automatically removed when all of their child batches
are removed. Of course, you may choose to remove the parent batch yourself
before all the children have been removed. See Section 7.11 for more
information on removing batches.

Reports may be created that include log messages for parents or children of
a particular batch. See Chapter 6 for more information.

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-11 Splitting a Batch

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-17
7.11 Ending a Batch

Completing or To end a batch, perform the steps below.


Aborting a Batch
1. Select State from the batch tag detail.

2. Select Complete or Abort option for the batch State field (Figure 7-12).
The end time is set to reflect the time at which the Complete or Abort
command was executed.

The Complete option sets the end time for the batch and sends the Done
command to all units currently assigned to the batch. The logic that you
build into the batch program determines any other actions that occur when
you select the Complete option. The Abort option also sets the end time for
the batch and sends the Abort command to all units currently assigned to
the batch. The logic that you build into the batch program determines any
other actions that occur when you select the Abort option.

See Table A-5 for the values of the batch command attribute and Table A-11
for the values of the unit command attributes.

NOTE: The batch uses OSx resources until Remove is selected for the batch
State. After selecting Remove, the batch tag is released to the system and is
available for use by another batch. After the Remove is executed, the
batch ID is removed from the Active Batch Directory.

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-12 Ending a Batch Example

7-18 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Removing a Batch After the system completes or aborts a batch, you can remove a batch from
the system. Batch removal does not have to immediately follow the ending
of a batch. To remove a batch, select the Remove option from the batch
State. The batch is removed if all units assigned to it have been released.

NOTE: The Remove command does not remove the batch unless all units
associated with the batch have been released.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-19
7.12 Viewing Batch-Related Tag Groups

To display a dynamically created tag group of all units currently assigned to


the batch, select Display Units on the batch tag detail (Figure 7-13). Up to
eight unit faceplates appear on the screen at a time. If a batch has more
than eight associated units, the screen displays a message indicating that
only eight of the units are displayed. Section 7.13 describes the unit
faceplate.

7-20 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-13 Displaying Assigned Units

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-21
7.13 Viewing the Unit Tag Detail and Faceplate

Viewing Unit Tag The unit tag detail enables an operator to monitor the status of a unit and
Detail to issue commands to the unit. See Table E-3 in Appendix E for the valid
security privileges for unit commands.

To view a unit tag detail, follow the steps below. See Figure 7-14.

1. Select the Directory icon in the navigation area.

2. Select Tag Detail from the navigation area directory.

3. Select the name of a unit tag you have configured.

4. Select OK to display the tag detail.

7-22 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Selection List

Incremental

Single Selection
_ACTREQ SYS ACTION REQUEST SYSTEM ALARM
_ALARMING SYS ALARMING SYSTEM ALARM
_ARCHIVING SYS ARCHIVING SYSTEM ALARM
_BATCH SYS BATCH SYSTEM ALARM
_CHANGE_LOG SYS OPERATOR CHANGE LOG SYSTEM
_CONFIG SYS CONFIGURATION SYSTEM ALARM
_DATA_BASE SYS DATABASE SYSTEM ALARM
_DATA_XFER SYS REMOTE DATA TRANSFER ALARM
_DIAGNOSTIC SYS DIAGNOSTICS SYSTEM ALARM
_FO_CIRCUIT SYS FAILOVER CIRCUIT ALARM
_GENERAL SYS GENERAL SYSTEM ALARM
_H1_COMM SYS H1 COMM. SYSTEM ALARM
_HT_COLLECT SYS HT COLLECTION SYSTEM ALARM
_HT_DISPLAY SYS HT DISPLAY SYSTEM ALARM
_HT_UPDATE SYS HTU SYSTEM ALARM
_LIBRARIAN SYS LIBRARIAN SYSTEM ALARM

OK Filter... Next

Top Cancel Help

Figure 7-14 Displaying Unit Tag Detail

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-23
Viewing the Unit Tag Detail and Faceplate (continued)

Changing the State To change the operational state of a unit, select the State option on the Unit
of a Unit Tag Detail. OSx displays the unit state options (Figure 7-15).

The logic that you build into the batch program determines the actions that
take place when you select one of the unit commands. See Table A-11 for the
values of the unit command attribute.

Tag: UNIT_1
Tag Type: UNIT
Scan Status: Active
Batch ID: Dutch Cookies
P/C: C1

Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-15 Changing Unit Tag State

7-24 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Changing the Mode To change the operational mode of a unit, select the Mode option on the Unit
of a Unit Tag Detail. OSx displays the following unit mode options (Figure 7-16).

 Automatic — Logic in the programmable controller controls the batch


processing.

 Manual — The operator controls the batch processing manually.

 Semi-Automatic — The operator controls some functions of the batch


processing, depending on the logic of the batch program. The
programmable controller controls the other functions.

See Table A-12 for the values of the unit MODE_CMD attribute.

Tag: UNIT_1
Tag Type: UNIT
Scan Status: Active
Batch ID: Dutch Cookies
P/C: C1
Alarm Group:
Alarm State Sequencing:
Alarming:
State:

Figure 7-16 Changing the Unit Operational Mode

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Running and Supervising a Batch 7-25
Viewing the Unit Tag Detail and Faceplate (continued)

Viewing the Unit You can view the unit faceplate by selecting the Display Units option from the
Faceplate batch tag detail (Figure 7-13 on page 7-21), or by creating and displaying a
tag group with one or more unit tags in it. The same state and mode
commands available from the unit tag detail are also available from the
faceplate (Figure 7-17).

Figure 7-17 Unit Faceplate

7-26 Running and Supervising a Batch SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix A
Attributes and Status Bits for New Tags
A.1 Batch (BCH) Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2

A.2 Unit (UNIT) Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Attributes and Status Bits for New Tags A-1
A.1 Batch (BCH) Tag

Table A-1 through Table A-6 and Figure A-1 describe the attributes for
Batch tags.

Table A-1 BCH Attributes

Attribute Domain Definition


tag CISTRING[12] Tag name
pseudo_tag SINT16 Tag reference ID
{Active, Alrm UnAck, Manual Set, Mode
2, Mode 1, Spare 4, Commit, Spare 3,
status Current status
Spare 2, Ready; Run, Complete, Spare 1,
Hold, Alarm, Abort}
Name and color code for current highest
alt_stat UINT32
priority alarm
{Commit, Start, Hold, Resume,
Complete, Remove, Abort, Set Alarm, Batch state commands; see the description for
Clear Alarm, Set Spare 1, Clear Spare 1, the bc_request_batch_state( ) function in
command
Set Spare 2, Clear Spare 2, Set Spare 3, Appendix C for information on issuing state
Clear Spare 3, Set Spare 4, Clear Spare commands to a batch
4, Split, Split Assign, Reset}
Custom batch ID associated with batch;
batch_id CISTRING[16] defaults to internal_id if a custom ID is not
specified
internal_id CISTRING[13] System-generated batch ID
parent_id CISTRING[13] Internal_id of parent batch
User-defined string for indicating the
operation CISTRING[10]
operational state of the batch
Operating system time stamp indicating when
u_start LONG
the batch started
start_time CISTRING[8] Time-of-day portion of u_start
start_date CISTRING[9] Date portion of u_start
Operating system time stamp indicating when
u_end LONG
the batch ended
end_time CISTRING[8] Time-of-day portion of u_end
end_date CISTRING[9] Date portion of u_end
control_recipe CISTRING[8] Not currently used
product_name CISTRING[12] Recipe name
graphic CISTRING[7] Graphic name currently associated with batch
log_file CISTRING[8] Not currently used
id_locked BOOLEAN Batch ID locked indicator
in_use BOOLEAN Batch tag in use indicator

A-2 Attributes and Status Bits for New Tags SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table A-2 Bit Locations for Batch Status Attribute

Status bit Description Bit location (hex)


Abort Batch aborted 0x8000
Alarm Batch in general alarm 0x4000
Hold Batch holding 0x2000
Spare_1 Spare bit 1 0x1000
Complete Batch completed 0x0800
Run Batch running 0x0400
Ready Batch ready 0x0200
Spare_2 Spare bit 2 0x0100
Spare_3 Spare bit 3 0x0080
Commit Batch committed 0x0040
Spare_4 Spare bit 4 0x0020
Mode bits: 00 = manual
01 = undefined
Mode 0x0018
10 = auto
11 = semi-automatic)
Man_Set Manually set 0x0004
Alrm_UnAck Alarm Acknowledge 0x0002
Active Tag is being scanned 0x0001

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Attributes and Status Bits for New Tags A-3
Batch (BCH) Tag (continued)

Set by Batch Manager Set by OSx

MSB LSB

MODE
SPARE_2SPARE_3

READY COMMIT
ACTIVE
RUN SPARE_4 ALRM_UNACK
COMPLETE MAN_SET
SPARE_1
HOLD
ALARM
ABORT

Figure A-1 Bit Locations for Batch Status Attribute

Table A-3 Status Bit Settings for Batch States

Batch Status Bits


Batch
Abort Alarm Hold Spl Complete Run Ready Sp2 Sp3 Commit Sp4 Md1 Md2
States
Abort 1 X X X X X X X X X X X X
Alarm X 1 X X X X X X X X X X X
Hold X X 1 X X X X X X X X X X
Spare_1 X X X 1 X X X X X X X X X
Complete X X X X 1 X X X X X X X X
Run X X X X X 1 X X X X X X X
Ready X X X X X X 1 X X X X X X
Spare_2 X X X X X X X 1 X X X X X
Spare_3 X X X X X X X X 1 X X X X
Commit X X X X X X X X X 1 X X X
Spare_4 X X X X X X X X X X 1 X X
BLANK X X X X X X X X X X X X X
NOTE: An “X” indicates a don’t care status for the bit.

A-4 Attributes and Status Bits for New Tags SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table A-4 Status Bit Settings for Batch Modes

Batch Status Bits


Batch
Abort Alarm Hold Spl Complete Run Ready Sp2 Sp3 Commit Sp4 Md1 Md2
Mode
Manual X X X X X X X X X X X 0 0
Auto X X X X X X X X X X X 1 0
Semi-
X X X X X X X X X X X 1 1
Auto
NOTE: An “X” indicates a don’t care status for the bit.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Attributes and Status Bits for New Tags A-5
Batch (BCH) Tag (continued)

Table A-5 Values for the Batch Command Attribute

Command Hexadecimal Value Decimal Value Unit Command * Comment


Commit 0xCF00 --12544 —
Start 0x9A00 --26112 Start Also sets start time.
Hold 0x9D00 --25344 Hold
Resume 0x8D00 --29440 Resume
Complete 0x0AB00 --21760 Done Also sets end time.
Remove 0xC000 --16384 —
Abort 0xAF00 --20736 Abort Also sets end time.
Set Alarm 0x9E00 --25088 Set Alarm
Clear Alarm 0x8E00 --29184 Clear Alarm
Set Spare1 0x9C00 --25600 Set Spare1
Clear Spare1 0x8C00 --29696 Clear Spare1
Set Spare2 0x9800 --26624 Set Spare2
Clear Spare2 0x8800 --30720 Clear Spare2
Set Spare3 0x9700 --26880 Set Spare3
Clear Spare3 0x8700 --30976 Clear Spare3
Set Spare4 0x9500 --27392 Set Spare4
Clear Spare4 0x8500 --31488 Clear Spare4
Split 0xCB00 --13568 —
Split Assign 0xCA00 --13824 —
Reset 0xC100 --16128 —
* When you select a batch command, the system also sends the corresponding unit command to all units
currently assigned to the batch. See Table A-11 for the values of the unit command attribute.

Table A-6 Values for the Batch MODE_CMD Attribute

Command Hexadecimal Value Decimal Value Unit Command *


Auto 0x4000 16384 Auto
Manual 0x8000 --32768 Manual
Semi-Auto 0xC000 --16384 Semi-Auto
* When you select a batch command, the system also sends the corresponding unit command to all units
currently assigned to the batch. See Table A-12 for the values of the unit MODE_CMD attribute.

A-6 Attributes and Status Bits for New Tags SIMATIC PCS 7 OSx 4.1.1 Batch Programming
A.2 Unit (UNIT) Tag

Table A-7 through Table A-12 describe the attributes for Unit tags.
Figure A-2 shows the bit locations for the Unit status word.

Table A-7 UNIT Attributes

Attribute Domain Definition


tag CISTRING[12] Tag name
pseudo_tag SINT16 Tag reference ID
{Active, Alrm_UnAck, Man_Set, Mode 2, Mode
status 1, Spare_4, OOS, In_Use, Spar_ 3, Spare_2, Current status
Run, Wait, Spare_1, Hold, Alarm, Abort}
Name and color code for current highest
alt_stat UINT32
priority alarm
{Assign, Start, Hold, Done, Jog, Resume,
Release, Abort, Wait, In Serve, Clear Abort, Unit state commands; see the description for
Set Alarm, Clear Alarm, Out Serve, Set Spare the bc_request_unit_state( ) function in
command
1, Clear Spare 1, Set Spare 2, Clear Spare 2, Appendix C for information on issuing state
Set Spare 3, Clear Spare 3, Set Spare 4, Clear commands to a unit
Spare 4, Reset}
Unit mode commands; see the description
for the bc_request_unit_mode( ) function in
mode_cmd {Auto, Manual, Semi}
Appendix C for information on issuing unit
mode commands
batch_id CISTRING[16] Batch ID associated with unit
User-defined string for indicating the
operation CISTRING[10]
operational state of the unit
Operating system time stamp indicating
u_start LONG
when the associated batch started
start_time CISTRING[8] Time-of-day portion of u_start
start_date CISTRING[9] Date portion of u_start
Operating system time stamp indicating
u_end LONG
when the associated batch ended
end_time CISTRING[8] Time-of-day portion of u_end
end_date CISTRING[9] Date portion of u_end
product_name CISTRING[12] Recipe name
type CISTRING[10]
{Start, Hold, Resume, Abort, Set Alarm, Clear
Alarm, Set Spare 1, Clear Spare 1, Set Spare
2, Clear Spare 2, Set Spare 3, Clear Spare 3, Controller requested batch and unit
bch_req Set Spare 4, Clear Spare 4, Commit, Complete, commands; for information on using this
Remove, Reset, Split, Split Assign, Assign, attribute, see Chapter 5
Done, Jog, Release, Wait, In Serve, Clear
Abort, Out Serve}
bch_req_info CISTRING[16] Extra information for bch_req
bch_req_resp {Successful, Failed, No Command} Response to bch_req

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Attributes and Status Bits for New Tags A-7
Unit (UNIT) Tag (continued)

Table A-8 Bit Locations for Unit Status Attribute

Status bit Description Bit location (hex)


Abort Unit aborted 0x8000
Alarm Unit in general alarm 0x4000
Hold Unit holding 0x2000
Spare_1 Spare bit 1 0x1000
Wait Unit waiting 0x0800
Run Unit running 0x0400
Spare_2 Spare bit 2 0x0200
Spare_3 Spare bit 3 0x0100
In_Use Unit in use 0x0080
OOS Unit out of service 0x0040
Spare_4 Spare bit 4 0x0020
Mode bits: 00 = manual
01 = undefined
Mode 0x0018
10 = auto
11 = semi-automatic)
Man_Set Manually set 0x0004
Alrm_UnAck Alarm Acknowledge 0x0002
Active Tag is being scanned 0x0001

Set in controller Set in OSx

MSB LSB

IN_USE
MODE
SPARE_3 OOS
SPARE_2 SPARE_4 ACTIVE
RUN ALRM_UNACK
WAIT MAN_SET
SPARE_1
HOLD
ALARM
ABORT

Figure A-2 Bit Locations for UNIT Status Word

A-8 Attributes and Status Bits for New Tags SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Table A-9 Status Bit Settings for Unit States

Unit Status Bits


Unit
Abort Alarm Hold Sp1 Wait Run Sp2 Sp3 In_Use OOS Sp4 Md1 Md2
States
Abort 1 X X X X X X X X X X X X
Alarm X 1 X X X X X X X X X X X
Hold X X 1 X X X X X X X X X X
Spare_1 X X X 1 X X X X X X X X X
Wait X X X X 1 X X X X X X X X
Run X X X X X 1 X X X X X X X
Spare_2 X X X X X X 1 X X X X X X
Spare_3 X X X X X X X 1 X X X X X
In_Use X X X X X X X X 1 X X X X
OOS X X X X X X X X X 1 X X X
Spare_4 X X X X X X X X X X 1 X X
Available X X X X X X X X X X X X X
NOTE: An “X” indicates a don’t care status for the bit.

Table A-10 Status Bit Settings for Batch Modes

Unit Status Bits


Unit
Abort Alarm Hold Spl Wait Run Sp2 Sp3 Sp3 OOS Sp4 Md1 Md2
Mode
Manual X X X X X X X X X X X 0 0
Auto X X X X X X X X X X X 1 0
Semi-Auto X X X X X X X X X X X 1 1
NOTE: An “X” indicates a don’t care status for the bit.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Attributes and Status Bits for New Tags A-9
Unit (UNIT) Tag (continued)

Table A-11 Values for the Unit Command Attribute

Command Hexadecimal Value Decimal Value


Assign 0x1700 5888
Start 0x1A00 6656
Hold 0x1D00 7424
Done 0x0A00 2560
Jog 0x0B00 2816
Resume 0x0D00 3328
Release 0x0700 1792
Abort 0x1F00 7936
Wait 0x1B00 6912
In Service 0x0600 1536
Clear Abort 0x0F00 3840
Set Alarm 0x1E00 7680
Clear Alarm 0x0E00 3584
Out of Service 0x1600 5632
Set Spare1 0x1C00 7168
Clear Spare1 0x0C00 3072
Set Spare2 0x1900 6400
Clear Spare2 0x0900 2304
Set Spare3 0x1800 6144
Clear Spare3 0x0800 2048
Set Spare4 0x1500 5376
Clear Spare4 0x0500 1280
Reset 0x4100 16640

Table A-12 Values for the Unit MODE_CMD Attribute

Command Hexadecimal Value Decimal Value


Auto 0x4000 16384
Manual 0x8000 --32768
Semi-Auto 0xC000 --16384

A-10 Attributes and Status Bits for New Tags SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix B
Configuration Planning Sheet
SIMATIC PCS 7 OSx is designed to simplify the process of configuring a
system. The software provides easy-to-use menus and screens. Planning
sheets, found in the SIMATIC PCS 7 OSx Process Configuration Manual,
provide a means of organizing the configuration and recording system
information, thereby saving you a significant amount of time in the
data-entry process. Figure B-1 shows an example planning sheet that you
can use for Unit type tags.

NOTE: No planning sheet is included for batch tag type. You do not need to
configure batch tags, since the system creates them automatically.

Sheet ___ of ___


CONTROL NODE:

TAG NAME:

DESCRIPTION:

PROCESS GROUP:
PARENT:

MEMORY NUMBER OF
ATTRIBUTES TYPE/ADDRESS LOCATIONS UPLOAD AUTOLOG INITIAL VALUE

STATUS YES NO YES NO

COMMAND YES NO YES NO

MODE_CMD YES NO YES NO

BCH_REQ YES NO YES NO

BCH_REQ_INFO YES NO YES NO

BCH_REQ_RESP YES NO YES NO

Figure B-1 Example Planning Sheet

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Configuration Planning Sheet B-1
B-2 Configuration Planning Sheet SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix C
Batch Control Functions
C.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4

C.2 bc_activate_autolog( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-6

C.3 bc_add_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-7

C.4 bc_allocate_batch( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8

C.5 bc_assign( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-9

C.6 bc_assign_graphic( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-10

C.7 bc_assign_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-11

C.8 bc_batch_list_entry_exists( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-12

C.9 bc_clear_unit_elements( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-13

C.10 bc_copy( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-14

C.11 bc_create_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-15

C.12 bc_deactivate_autolog( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-16

C.13 bc_destroy_all_batch_lists( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-17

C.14 bc_destroy_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-18

C.15 bc_exit( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-19

C.16 bc_get_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-20

C.17 bc_get_batch_id_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-21

C.18 bc_get_batch_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-22

C.19 bc_get_batch_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-23

C.20 bc_get_custom_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-24

C.21 bc_get_printer_mask( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-25

C.22 bc_get_system_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-26

C.23 bc_get_unit_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-27

C.24 bc_get_unit_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-28

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-1
C.25 bc_load( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-29

C.26 bc_lock_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-30

C.27 bc_log_comment( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-31

C.28 bc_log_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-32

C.29 bc_log_value( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-33

C.30 bc_print_batch_list( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-34

C.31 bc_release( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-35

C.32 bc_release_all( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-36

C.33 bc_release_graphic( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-37

C.34 bc_remove_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-38

C.35 bc_request_batch_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-40

C.36 bc_request_batch_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-42

C.37 bc_request_unit_mode( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-44

C.38 bc_request_unit_state( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-46

C.39 bc_scale_recipe( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-48

C.40 bc_select( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-49

C.41 bc_set_batch_end( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-50

C.42 bc_set_batch_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-51

C.43 bc_set_batch_product( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-52

C.44 bc_set_batch_start( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-53

C.45 bc_set_first_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-54

C.46 bc_set_log_destination( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-55

C.47 bc_set_next_batch_list_entry( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-56

C.48 bc_set_unit_end( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-58

C.49 bc_set_unit_operation( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-59

C.50 bc_set_unit_start( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-60

C-2 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.51 bc_split_batch( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-61

C.52 bc_trigger_request( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-62

C.53 bc_unlock_batch_id( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-63

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-3
C.1 Overview

This appendix describes the batch control functions that you can use within
your BCL programs to manipulate batch-related data. Each function
description consists of the following components.

 Synopsis — shows the syntax and data types for the parameters used
by the function
 Parameters — describes the parameters required by the function
 Description — describes the operation of the function
 Return values — lists the possible return codes that the function may
produce
 Usage example — gives a brief example of the usage of the function
 See also — refers to related functions

Custom and In order to understand and apply the batch control functions described in
Internal Batch IDs this appendix, it is important to understand some of the details concerning
the way OSx manages batch identifiers.

Internally, the system maintains two identifiers for each batch. One of these
can be modified by system users and BCL programs and is commonly
referred to as the “batch ID.” This is the ID that appears on displays and in
printed reports. Unless otherwise specified, references to batch ID
throughout this document refer to this customizable ID, which is why it is
often also referred to as the “custom batch ID” or just the “custom ID.”
Generally, this identifier is the one that is visible to operators and system
users other than system integrators and providers of custom-programmed
application software.

C-4 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
The other batch ID is internally generated. References to it are usually
qualified by the phrase “internally generated” or by the keywords “internal”
or “system.” When a batch is newly allocated, both the custom and internal
IDs are set to the same, internally-generated string and remain that way
unless the custom ID is altered by the user. The internal ID is not available
for modification. Its value remains fixed to provide the system with a means
of identifying the batch that is guaranteed to remain unique over time. The
internal ID is constructed in such a way that it will not repeat unless more
than 1000 batches are run in a single day. The format of the internal ID is
as follows:

BIDyymmdd-nnn
BID is the prefix for the internal ID
yy is the last two digits of the current year
mm is the number of the month, where January is 01
dd is the day of the month
nnn is a decimal sequence number

This convention of two batch identifiers allows you to reuse custom batch
IDs, provided that no two active batches are assigned the same custom ID.
If an attempt is made to assign a duplicate ID, the system refuses to accept
it and issues an error message.

Functions described on the following pages use both custom and internal
batch IDs as parameters. The distinction between the two must be closely
observed for proper operation of the batch control functions.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-5
C.2 bc_activate_autolog( )

Synopsis The bc_activate_autolog( ) function is defined with the following


parameter definitions.

INT bc_activate_autolog(tag_name, attribute_name)


CHAR *tag_name;
CHAR *attribute_name;

Parameters tag_name (in) Name of a tag


attribute_name (in) Name of an attribute within the specified tag

Description This function enables OSx to log changes to the specified tag:attribute while
the system remains in the Standby or Operate state. If OSx transitions to
the Offline state, the auto logging feature stops. When OSx transitions to
the Standby or Operate state, the auto logging feature resets to its original
value. This value is defined when tags are configured. Refer to the SIMATIC
PCS 7 OSx Process Configuration Manual for additional information.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example enables the auto logging feature for rm1mt1:status
when the BCL program starts execution.

ON EVENT STARTUP
{
INT bc_status;
bc_status = bc_activate_autolog(”rm1mt1”, ”status”);
}

See Also bc_deactivate_autolog

C-6 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.3 bc_add_batch_list_entry( )

Synopsis The bc_add_batch_list_entry( ) function is defined with the following


parameter definitions.

INT bc_add_batch_list_entry(l_name, batch_id)


CHAR *l_name;
CHAR *batch_id;

Parameters l_name (in) Name of the list


batch_id (in) Batch ID string to be added to the list

Description This function adds the batch ID identified by batch_id to the list identified by
l_name. Before you execute this function, you must execute
bc_create_batch_list( ) to create the list.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates a new batch ID, creates an empty batch ID
list named BID_LIST, and then adds the new ID (specifically, the
internally-generated system ID) to the list. This is done when the BCL
program starts execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
bc_create_batch_list(”BID_LIST”);
bc_add_batch_list_entry(”BID_LIST”, sys_bid);
}

See Also bc_batch_list_entry_exists


bc_create_batch_list
bc_get_batch_id_entry
bc_remove_batch_list_entry
bc_set_first_batch_list_entry
bc_set_next_batch_list_entry

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-7
C.4 bc_allocate_batch( )

Synopsis The bc_allocate_batch( ) function is defined with the following parameter


definitions.

INT bc_allocate_batch(system_batch_id, system_descriptor)


CHAR *system_batch_id;
CHAR *system_descriptor;

Parameters system_batch_id (out) System-generated batch ID string


system_descriptor (out) System-generated batch descriptor

Description This function finds an available batch tag and reserves it for the calling
program. The default NONE product is assigned to the batch and the batch
is placed in the COMMIT state. The function returns the system-generated
batch ID and descriptor to the calling program. The allocated batch then
becomes available to various BCL operations through its system or custom
batch ID.

The calling program is responsible for allocating the space that is required
for the batch ID and descriptor strings.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates an available batch ID and its descriptor to
to sys_bid and sys_desc, respectively, when the BCL program starts
execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
}

See Also bc_set_batch_start


bc_set_batch_product

C-8 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.5 bc_assign( )

Synopsis The bc_assign( ) function is defined with the following parameter


definitions.

INT bc_assign(unit_name, system_batch_id)


CHAR *unit_name;
CHAR *system_batch_id;

Parameters unit_name (in) Name of the unit tag to be assigned to a batch


system_batch_id (in) System-generated batch ID string

Description This function assigns the unit identified by unit_name to the batch identified
by system_batch_id. The unit must not be out of service or assigned to
another batch. If the unit is available for assignment, the assign command
will be written to the unit’s command attribute.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates a new batch ID and assigns the unit oven_1
to the batch when the BCL program starts execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
bc_assign(“oven_1”,sys_bid);
}

See Also bc_release

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-9
C.6 bc_assign_graphic( )

Synopsis The bc_assign_graphic( ) function is defined with the following parameter


definitions.

INT bc_assign_graphic(graphic_name, system_batch_id)


CHAR *graphic_name;
CHAR *system_batch_id;

Parameters graphic_name (in) Name of the graphic to be associated with the batch
system_batch_id (in) System-generated batch ID string

Description This function assigns the graphic display identified by graphic_name to the
batch identified by system_batch_id. For a list of possible graphic names,
display the Graphic Directory while OSx is in the Operate state.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates a new batch ID and assigns the graphic
display bake_area to the batch when the BCL program starts execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
bc_assign_graphic(“bake_area”, sys_bid);
}

See Also bc_release_graphic

C-10 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.7 bc_assign_id( )

Synopsis The bc_assign_id( ) function is defined with the following parameter


definitions.

INT bc_assign_id(user_batch_id, system_batch_id)


CHAR *user_batch_id;
CHAR *system_batch_id;

Parameters user_batch_id (in) Custom batch ID string


system_batch_id (in) System-generated batch ID string

Description This function assigns a custom ID to an existing batch. You can create a
custom batch ID only if the system-generated batch ID is unlocked and the
user_batch_id is unique.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates a new batch and assigns the custom
batch ID CHOC_CHIP to it when the BCL program starts execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
bc_assign_id(”CHOC_CHIP”, sys_bid);
}

See Also bc_lock_batch_id


bc_unlock_batch_id

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-11
C.8 bc_batch_list_entry_exists( )

Synopsis The bc_batch_list_entry_exists( ) function is defined with the following


parameter definitions.

BOOLEAN bc_batch_list_entry_exists(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function verifies the existence of an entry at the current pointer
location in the list identified by l_name.

Before you execute this function, you must call one or more of the following
functions:

 bc_set_first_batch_list_entry( )

 bc_set_next_batch_list_entry( )

Return Value FALSE Current entry is not active.


TRUE Current entry is active.

Example The following example traverses the list named BID_LIST, allowing
operations of your choice to be performed using each batch ID stored in the
list. These operations are performed when the BCL program starts
execution.

ON EVENT STARTUP
{
CHAR *current_bid_ptr;

bc_set_first_batch_list_entry (”BID_LIST”);
while (bc_batch_list_entry_exists (”BID_LIST”))
{
current_bid_ptr =
bc_get_batch_id_entry (”BID_LIST”);
/*
** Do something with the current batch ID,
** then go on to the next one.
*/
bc_set_next_batch_list_entry (”BID_LIST”);
}
}

See Also bc_add_batch_list_entry


bc_get_batch_id_entry
bc_remove_batch_list_entry
bc_set_first_batch_list_entry
bc_set_next_batch_list_entry

C-12 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.9 bc_clear_unit_elements( )

Synopsis The bc_clear_unit_elements( ) function is defined with the following


parameter definitions.

INT bc_clear_unit_elements(unit_name)
CHAR *unit_name;

Parameters unit_name (in) Name of the unit tag containing elements

Description This function clears each element within the specified unit by changing the
element value to either the defined null value or the low-range value (as
defined in the OSx database). If a unit element (or tag) relation contains
both low-range and high-range attributes, OSx assigns the low-range value
to the element. If a unit element does not use these attributes, OSx assigns
the null value to the element.

Use this function in conjunction with the bc_copy( ) function to move a


batch between units. The bc_copy( ) function enables you to copy the unit
element data from one unit and move it to the next unit in the batch. After
the data is copied, the bc_clear_unit_elements( ) function enables you to
clear the unit element data from the previous unit.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example copies unit elements from mix1 unit to oven1 unit and
clears the elements in mix1 when the OOS (out-of-service) bit goes high in
the status word.

ON EVENT mix1:status:OOS
{
bc_copy(”mix1”, ”oven1”);
bc_clear_unit_elements(”mix1”);
}

See Also bc_copy

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-13
C.10 bc_copy( )

Synopsis The bc_copy( ) function is defined with the following parameter definitions.

INT bc_copy(src_unit_name, dest_unit_name)


CHAR *src_unit_name;
CHAR *dest_unit_name;

Parameters src_unit_name (in) Name of the source unit with elements to be copied
dest_unit_name (in) Name of the destination unit receiving element data

Description This function copies all mapped element data from the source unit to the
destination unit. The destination unit must be assigned to the same batch
as the source unit.

To move a batch from one unit to another, use bc_copy( ) in conjunction


with the bc_clear_unit_elements( ) function. The bc_copy( ) function
enables you to copy the unit element data from one unit and move it to the
next unit in the batch. After the data is copied, the
bc_clear_unit_elements( ) function enables you to clear the unit element
data from the previous unit.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example copies unit elements from mix1 unit to oven1 unit
when the OOS (out-of-service) bit goes high in the status word.

ON EVENT mix1:status:OOS
{
bc_copy(”mix1”, ”oven1”);
}

See Also bc_clear_unit_elements

C-14 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.11 bc_create_batch_list( )

Synopsis The bc_create_batch_list( ) function is defined with the following


parameter definitions.

INT bc_create_batch_list(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function creates an empty batch ID list identified by l_name. You can
access this list by using one or more of the batch control functions created
specifically for manipulating lists.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example creates the batch ID list BID_LIST when the BCL
program starts execution.

ON EVENT STARTUP
{
bc_create_batch_list(”BID_LIST”);
}

See Also bc_add_batch_list_entry


bc_batch_list_entry_exists
bc_destroy_all_batch_lists
bc_destroy_batch_list
bc_get_batch_id_entry
bc_print_batch_list
bc_remove_batch_list_entry
bc_set_first_batch_list_entry
bc_set_next_batch_list_entry

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-15
C.12 bc_deactivate_autolog( )

Synopsis The bc_deactivate_autolog( ) function is defined with the following


parameter definitions.

INT bc_deactivate_autolog(tag_name, attribute_name)


CHAR *tag_name;
CHAR *attribute_name;

Parameters tag_name (in) Name of a tag


attribute_name (in) Name of an attribute within the specified tag

Description This function disables the auto logging feature for the specified tag:attribute
instance. When OSx transitions from Offline to the Standby or Operate
state, the auto logging feature resets to its configuration value. This value is
defined when tags are configured. Refer to the SIMATIC PCS 7 OSx Process
Configuration Manual for additional information.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example disables the auto logging feature for rm1mt1:status
when the BCL program transitions from Operate to Standby system state.
ON EVENT SE_OPER_TO_STBY
{
bc_deactivate_autolog(”rm1mt1”, ”status”);
}

See Also bc_activate_autolog

C-16 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.13 bc_destroy_all_batch_lists( )

Synopsis The bc_destroy_all_batch_lists( ) function is defined with the following


parameter definitions.

VOID bc_destroy_all_batch_lists( )

Parameters None

Description This function removes all batch ID lists that exist within the calling
program.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value None

Example The following example removes all batch ID lists from the calling program
when the BCL program finishes execution.

ON EVENT SHUTDOWN
{
bc_destroy_all_batch_lists( );
}

See Also bc_create_batch_list


bc_destroy_batch_list
bc_print_batch_list

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-17
C.14 bc_destroy_batch_list( )

Synopsis The bc_destroy_batch_list( ) function is defined with the following


parameter definitions.

INT bc_destroy_batch_list(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function removes the batch ID list identified by l_name.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example removes the batch ID list BID_LIST when the BCL
program finishes execution.

ON EVENT SHUTDOWN
{
bc_destroy_batch_list(”BID_LIST”);
}

See Also bc_create_batch_list


bc_destroy_all_batch_lists
bc_print_batch_list

C-18 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.15 bc_exit( )

Synopsis The bc_exit( ) function is defined with the following parameter definitions.

VOID bc_exit( )

Parameters None

Description Executing this function causes the BCL program to terminate execution
after it finishes executing the action block in which it is called.

Return Value None

Example The following example stops program execution when the abort bit goes high
for the unit status word.

ON EVENT oven1:status:abort
{
bc_exit( );
}

See Also None

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-19
C.16 bc_get_batch_id( )

Synopsis The bc_get_batch_id( ) function is defined with the following parameter


definitions.

INT bc_get_batch_id(tag_name, custom_batch_id)


CHAR *tag_name;
CHAR *custom_batch_id;

Parameters tag_name (in) Name of the tag associated with the custom batch ID
custom_batch_id (out) Custom batch ID string

Description This function retrieves the custom batch ID for the tag identified by
tag_name. The tag name parameter may specify a tag of any type.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the custom batch ID associated with the
oven temperature tag tmp1 when the temperature changes.

#include <enum_types/b_i_d.t>
ON EVENT tmp1:pv CHANGES
{
CHAR custom_bid[T_B_I_D_LENGTH];

bc_get_batch_id(”tmp1”, custom_bid);
}

See Also bc_get_custom_id


bc_get_system_id

C-20 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.17 bc_get_batch_id_entry( )

Synopsis The bc_get_batch_id_entry( ) function is defined with the following


parameter definitions.

CHAR *bc_get_batch_id_entry(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function obtains the current batch ID from the current entry of l_name.

Before you use this function, ensure that the current entry ID has been set
with either the bc_set_first_batch_list_entry( ) function or the
bc_set_next_batch_list_entry( ) function.

Return Value This function returns a pointer to the batch ID string stored at the current
location of the specified list. If a current entry does not exist or the list is
empty, the function returns a NULL value.

Example The following example traverses the list named BID_LIST allowing
operations of your choice to be performed using each batch ID stored in the
list. These operations are performed when the BCL program starts
execution.

ON EVENT STARTUP
{
CHAR *current_bid_ptr;

bc_set_first_batch_list_entry (”BID_LIST”);
while (bc_batch_list_entry_exists (”BID_LIST”))
{
current_bid_ptr =
bc_get_batch_id_entry (”BID_LIST”);
/*
** Do something with the current batch ID,
** then go on to the next one.
*/
bc_set_next_batch_list_entry (”BID_LIST”);
}
}

See Also bc_add_batch_list_entry


bc_batch_list_entry_exists
bc_remove_batch_list_entry
bc_set_first_batch_list_entry
bc_set_next_batch_list_entry

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-21
C.18 bc_get_batch_mode( )

Synopsis The bc_get_batch_mode( ) function is defined with the following parameter


definitions.

INT bc_get_batch_mode(system_batch_id, mode)


CHAR *system_batch_id;
T_B_QUAL *mode;

Parameters system_batch_id (in) System-generated batch ID string


mode (out) Bit pattern that defines the mode status of the batch.
See Appendix A for more information.

Description This function retrieves the mode bits from the batch tag identified by
system_batch_id. The two mode bits are found in the batch tag status word.
For more information about the batch status attribute, refer to Appendix A.

This function returns the value of the two mode bits. All other bits in the
status attribute are masked and return a value of zero. The calling routine
must decode the bit settings.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the mode bits for the batch running in the
unit oven1 when the run bit goes high for that unit. In order to obtain the
batch’s system ID, which is required for the call to bc_get_batch_mode( ), the
custom ID for the unit tag oven1 is first retrieved and is then translated to
the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>
#include <enum_types/b_qual.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_B_QUAL batch_mode;

bc_get_batch_id(“oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_get_batch_mode(system_id, &batch_mode);
}

See Also bc_request_batch_mode

C-22 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.19 bc_get_batch_state( )

Synopsis The bc_get_batch_state( ) function is defined with the following parameter


definitions.

INT bc_get_batch_state(system_batch_id, state)


CHAR *system_batch_id;
T_B_QUAL *state;

Parameters system_batch_id (in) System-generated batch ID string


state (out) Bit pattern that defines the status of the batch.
See Appendix A for more information.

Description This function retrieves the status attribute from the batch tag identified by
system_batch_id. For more information about the batch status attribute, refer
to Appendix A.

The state value does not include the mode bits that also appear in the status
attribute. The mode bits are masked and return a value of zero. The calling
routine must decode the bit settings.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the batch state for the batch running in the
unit oven1 when the run bit goes high for that unit. In order to obtain the
batch’s system ID, which is required for the call to bc_get_batch_state( ), the
custom ID for the unit tag oven1 is first retrieved and is then translated to
the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_B_QUAL batch_state

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_get_batch_state(system_id, &batch_state);
}

See Also bc_request_batch_state

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-23
C.20 bc_get_custom_id( )

Synopsis The bc_get_custom_id( ) function is defined with the following parameter


definitions.

INT bc_get_custom_id(system_batch_id, custom_batch_id)


CHAR *system_batch_id;
CHAR *custom_batch_id;

Parameters system_batch_id (in) System-generated batch ID string


custom_batch_id (out) Custom batch ID string

Description This function retrieves the custom batch ID for the batch tag identified by
the system-generated batch ID system_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves a character string from the TEXT tag job
and stores it in the local variable current_batch. This character string is
assumed to be a system-generated batch ID. It then uses this ID to get the
associated custom batch ID by calling bc_get_custom_id( ). These actions will
occur as the BCL program terminates execution.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT SHUTDOWN
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR current_batch[T_BATCH_INTERNAL_ID_LENGTH];

EXEC (current_batch) <-- job:text_1;


bc_get_custom_id(current_batch, custom_bid);
}

See Also bc_get_batch_id


bc_get_system_id

C-24 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.21 bc_get_printer_mask( )

Synopsis The bc_get_printer_mask( ) function is defined with the following


parameter definitions.

INT bc_get_printer_mask(const char *name, T_DEV_SET *mask);

Parameters name (in) printer name


mask (out) printer bit mask

Description This function retrieves the bit mask of a printer name and returns it in mask
form.

Return Value ERROR Error occurred.


NO_ERROR Normal return.

Example The following example sets the log destination to multiple printers, i.e.,
three printers, for the batch being processed in unit oven1 when the unit
in_use bit goes high. In order to obtain the batch’s system ID, which is
required for the call to bc_set_log_destination( ), the custom ID for the unit
tag oven1 is first retrieved and is then translated to the system ID.

#include <spool_user.h>
#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_DEV_SET one_printer,all_printers;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_get_printer_mask(”p1”,&one_printer);
all_printers = one_printer;
bc_get_printer_mask(”p2”,&one_printer);
all_printers |= one_printer;
bc_get_printer_mask(”p3”,&one_printer);
all_printers |= one_printer;

bc_set_log_destination(system_id, all_printers);
}

See Also bc_set_log_destination

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-25
C.22 bc_get_system_id( )

Synopsis The bc_get_system_id( ) function is defined with the following parameter


definitions.

INT bc_get_system_id(custom_batch_id, system_batch_id)


CHAR *custom_batch_id;
CHAR *system_batch_id;

Parameters custom_batch_id (in) Custom batch ID string


system_batch_id (out) System-generated batch ID string

Description This function retrieves the system batch ID for the batch tag identified by
the custom batch ID custom_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the system-generated batch ID associated


with the tag tmp1 when the value of its pv attribute changes.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT tmp1:pv CHANGES


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”tmp1”, custom_bid);
bc_get_system_id(custom_bid, sys_bid);
}

See Also bc_get_batch_id


bc_get_custom_id

C-26 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.23 bc_get_unit_mode( )

Synopsis The bc_get_unit_mode( ) function is defined with the following parameter


definitions.

INT bc_get_unit_mode(unit_name, mode)


CHAR *unit_name;
T_U_QUAL *mode;

Parameters unit_name (in) Unit tag name


mode (out) Bit pattern that defines the mode status of the unit.
See Appendix A for more information.

Description This function retrieves the mode bits from the unit identified by unit_name.
The two mode bits are found in the unit tag status word. For more
information about the unit status attribute, refer to Appendix A.

This function returns the value of the two mode bits. All other bits in the
status attribute are masked and return a value of zero. The calling routine
must decode the bit settings.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the mode bits from the unit identified by
oven1 when the BCL program starts execution.

#include <enum_types/u_qual.t>

ON EVENT STARTUP
{
T_U_QUAL unit_mode;

bc_get_unit_mode(”oven1”, &unit_mode);
}

See Also bc_request_unit_mode

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-27
C.24 bc_get_unit_state( )

Synopsis The bc_get_unit_state( ) function is defined with the following parameter


definitions.

INT bc_get_unit_state(unit_name, state)


CHAR *unit_name;
T_U_QUAL *state;

Parameters unit_name (in) Unit tag name


state (out) Bit pattern that defines the status of the unit.
See Appendix A for more information.

Description This function retrieves the status attribute from the unit tag identified by
unit_name. For more information about the unit status attribute, refer to
Appendix A.

The state value does not include the mode bits that also appear in the status
attribute. The mode bits are masked and return a value of zero. The calling
routine must decode the bit setting.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example retrieves the unit state from the unit tag identified
by oven1 when the BCL program starts execution.

#include <enum_types/u_qual.t>

ON EVENT STARTUP
{
T_U_QUAL unit_state;

bc_get_unit_state(”oven1”, &unit_state);
}

See Also bc_request_unit_state

C-28 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.25 bc_load( )

Synopsis The bc_load( ) function is defined with the following parameter definitions.

INT bc_load(unit_name)
CHAR *unit_name;

Parameters unit_name (in) Unit tag name

Description This function downloads a recipe to the controller for the unit identified by
unit_name. OSx downloads the recipe to the controller as if the controller
requested the download.

Before this function can operate successfully, the BCL program must
execute the bc_select( ) function to select a valid recipe.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example loads the recipe for the unit oven1 when the run bit
goes high for that unit. In order to obtain the batch’s system ID, which is
required for the call to bc_select( ), the custom ID for the unit tag oven1 is
first retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_select(system_id, ”oven1”);
bc_load(”oven1”);
}

See Also bc_scale_recipe


bc_select
bc_set_batch_product

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-29
C.26 bc_lock_batch_id( )

Synopsis The bc_lock_batch_id( ) function is defined with the following parameter


definitions.

INT bc_lock_batch_id(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function locks the batch identified by system_batch_id by setting the
id_locked attribute to LOCKED (or TRUE). The batch ID of a locked batch
cannot be changed.

To change a batch ID during batch processing, run the


bc_unlock_batch_id( ) function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example allocates a new batch, assigns the custom ID
CHOC_CHIP to it, and then locks the ID against further changes. This all
takes place when the BCL program starts execution.

#include <enum_types/batch.r>
#include <enum_types/t_desc.t>

ON EVENT STARTUP
{
CHAR sys_bid[T_BATCH_INTERNAL_ID_LENGTH];
CHAR sys_desc[T_T_DESC_LENGTH];

bc_allocate_batch(sys_bid, sys_desc);
bc_assign_id(”CHOC_CHIP”, sys_bid);
bc_lock_batch_id(sys_bid);
}

See Also bc_unlock_batch_id

C-30 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.27 bc_log_comment( )

Synopsis The bc_log_comment( ) function is defined with the following parameter


definitions.

INT bc_log_comment(batch_id, keyword, comment)


CHAR *batch_id;
CHAR *keyword;
CHAR *comment;

Parameters batch_id (in) Custom batch ID string


keyword (in) Value for keyword field in message
comment (in) Value for comment field in message

Description This function sends the comment message to the log for the batch identified
by batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sends a message that contains the comment “Oven
unit 1 is running” and the keyword STATUS to the log for the batch that
oven1 is currently processing. This takes place when the run bit goes high for
the oven1 unit.

#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_log_comment(custom_bid, ”STATUS”, ”Oven unit 1 is running.”);
}

See Also bc_log_operation


bc_log_value

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-31
C.28 bc_log_operation( )

Synopsis The bc_log_operation( ) function is defined with the following parameter


definitions.

INT bc_log_operation(unit_name, unit_event)


CHAR *unit_name;
INT unit_event;

Parameters unit_name (in) Unit tag name


unit_event (in) Unit phase; EVENT_START and EVENT_FINISH are
the only valid events; suitable constants are defined in
header file ba_user.h

Description This function generates a log message for the specified unit and its
corresponding event (either EVENT_START or EVENT_FINISH). The log
message contains the unit operation in the specified event.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example logs the EVENT_START event when the run bit goes
high for the oven1 unit.

#include <ba_user.h>
ON EVENT oven1:status:run
{
bc_log_operation(”oven1”, EVENT_START);
}

See Also bc_log_comment


bc_log_value

C-32 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.29 bc_log_value( )

Synopsis The bc_log_value( ) function is defined with the following parameter


definitions.

INT bc_log_value(batch_id, tag_name, attr_name)


CHAR *batch_id;
CHAR *tag_name;
CHAR *attr_name;

Parameters batch_id (in) Custom batch ID string


tag_name (in) Name of tag where log value is found
attr_name (in) Name of attribute where log value is found

Description This function sends a tag:attribute message to the log associated with the
batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example logs the current oven temperature (from tag
oven1temp:pv) for the unit oven1 in the log for the batch that oven1 is
currently processing. This happens when the run bit goes high for the oven1
unit.

#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_log_value(custom_bid, ”oven1temp”, ”pv”);
}

See Also bc_log_comment


bc_log_operation

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-33
C.30 bc_print_batch_list( )

Synopsis The bc_print_batch_list( ) function is defined with the following parameter


definitions.

VOID bc_print_batch_list()

Parameters None

Description This function dumps the current contents of a batch ID list to a verbose
(debug) output file. This statement produces a dump only when the BCL
program is run with the --v option.

Return Value None

Example The following example prints batch ID lists when the BCL program finishes
execution.

ON EVENT SHUTDOWN
{
bc_print_batch_list();
}

See Also bc_create_batch_list,


bc_destroy_all_batch_lists,
bc_destroy_batch_list

C-34 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.31 bc_release( )

Synopsis The bc_release( ) function is defined with the following parameter


definitions.

INT bc_release(unit_name, system_batch_id)


CHAR *unit_name;
CHAR *system_batch_id;

Parameters unit_name (in) Name of the unit tag to be released from a batch
system_batch_id (in) System-generated batch ID string

Description This function releases the unit identified by unit_name from the batch
identified by system_batch_id. The unit must be already assigned to the batch
specified by system_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example releases the unit oven1 from the batch with which it
is currently associated when the unit status bit oos (out-of-service) goes
high. In order to obtain the batch’s system ID, which is required for the call
to bc_release( ), the custom ID for the unit tag oven1 is first retrieved and is
then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:oos
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_release(”oven1”, system_id);
}

See Also bc_assign


bc_release_all

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-35
C.32 bc_release_all( )

Synopsis The bc_release_all( ) function is defined with the following parameter


definitions.

INT bc_release_all(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function releases all units that are assigned to the batch identified by
system_batch_id. The units must be already assigned to the batch specified by
system_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example releases all units from the batch with which the unit
oven1 is associated when the in_use bit for oven1 goes low. In order to obtain
the batch’s system ID, which is required for the call to bc_release_all( ), the
custom ID for the unit tag oven1 is first retrieved and is then translated to
the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_release_all(system_id);
}

See Also bc_assign


bc_release

C-36 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.33 bc_release_graphic( )

Synopsis The bc_release_graphic( ) function is defined with the following parameter


definitions.

INT bc_release_graphic(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function releases the graphic that is assigned to the batch identified by
system_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example releases the graphic that is assigned to the batch
currently being processed in the unit oven1 when the in_use bit for oven1 goes
low. In order to obtain the batch’s system ID, which is required for the call
to bc_release_graphic( ), the custom ID for the unit tag oven1 is first
retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_release_graphic(system_id);
}

See Also bc_assign_graphic

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-37
C.34 bc_remove_batch_list_entry( )

Synopsis The bc_remove_batch_list_entry( ) function is defined with the following


parameter definitions.

INT bc_remove_batch_list_entry(l_name, batch_id)


CHAR *l_name;
CHAR *batch_id;

Parameters l_name (in) Name of the list


batch_id (in) Batch ID string to be removed from the list

Description This function removes the batch ID identified by batch_id from the list
identified by l_name.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-38 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example removes the ID for the batch which the unit oven1 is
currently processing from the list named BID_LIST when the in_use bit for
oven1 goes low.

#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_remove_batch_list_entry(”BID_LIST”, custom_bid);
}

See Also bc_add_batch_list_entry


bc_batch_list_entry_exists
bc_get_batch_id_entry
bc_set_first_batch_list_entry
bc_set_next_batch_list_entry

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-39
C.35 bc_request_batch_mode( )

Synopsis The bc_request_batch_mode( ) function is defined with the following


parameter definitions.

INT bc_request_batch_mode(system_batch_id, mode_command)


CHAR *system_batch_id;
T_B_MD_CMD mode_command;

Parameters system_batch_id (in) System-generated batch ID string


mode_command (in) Bit pattern representing one of three commands:
AUTO, MANUAL, or SEMI

The following constants represent the legal values for the mode_command
parameter; they are defined in /usr/tistar/include/enum_types/b_md_cmd.t:

B_MD_CMD_AUTO Set batch to automatic mode


B_MD_CMD_MANUAL Set batch to manual mode
B_MD_CMD_SEMI Set batch to semi-automatic mode

Description This function writes the specified mode command to the batch tag identified
by system_batch_id. The bit pattern representing the mode command is
defined in the header file enum_types/b_md_cmd.t. Appendix A also describes
the bit pattern for the batch mode command.

If this function completes successfully, the status attribute of the batch tag
reflects the specified mode command. The calling program, then, must query
the status attribute to determine the completion status of the request.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-40 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example writes the mode command B_MD_CMD_AUTO and
retrieves the mode bits for the batch currently being processed in unit oven1
when the unit in_use bit goes high. In order to obtain the batch’s system ID,
which is required for the call to bc_request_batch_mode( ), the custom ID for
the unit tag oven1 is first retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>
#include <enum_types/b_md_cmd.t>
#include <enum_types/b_qual.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_B_QUAL batch_mode;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_request_batch_mode(system_id, B_MD_CMD_AUTO);

/* Pause while command is sent to controller. */


sleep (3);

bc_get_batch_mode(system_id, &batch_mode);
}

See Also bc_get_batch_mode

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-41
C.36 bc_request_batch_state( )

Synopsis The bc_request_batch_state( ) function is defined with the following


parameter definitions.

INT bc_request_batch_state(system_batch_id, command)


CHAR *system_batch_id;
T_B_CMD command;

Parameters system_batch_id (in) System-generated batch ID string


command (in) Numeric value representing the batch command

The following constants represent the legal values for the command
parameter; they are defined in usr/tistar/include/enum_types/b_cmd.t:

B_CMD_ABORT Abort batch


B_CMD_CLR_ALARM Clear batch alarm flag
B_CMD_COMMIT Commit batch setup
B_CMD_COMPLETE Mark batch as completed
B_CMD_HOLD Place batch in hold state
B_CMD_REMOVE Remove batch from active state
B_CMD_RESUME Resume batch
B_CMD_SET_ALARM Set batch alarm flag
B_CMD_START Start batch

Description This function writes the specified command to the command attribute of the
batch tag identified by system_batch_id. If this function completes
successfully, the status attribute of the batch tag reflects the specified
command. The calling program, then, must query the status attribute to
determine the completion status of the request.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-42 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example writes the command B_CMD_RESUME and
retrieves the state bits for the batch currently being processed in unit oven1
when the unit oos (out-of-service) bit goes low. In order to obtain the batch’s
system ID, which is required for the call to bc_request_batch_state( ), the
custom ID for the unit tag oven1 is first retrieved and is then translated to
the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>
#include <enum_types/b_cmd.t>
#include <enum_types/b_qual.t>

ON EVENT oven1:status:oos RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_B_QUAL batch_state;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_request_batch_state(system_id, B_CMD_RESUME);

/* Pause while command is sent to controller. */


sleep (3);

bc_get_batch_state(system_id, &batch_state);
}

See Also bc_get_batch_state

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-43
C.37 bc_request_unit_mode( )

Synopsis The bc_request_unit_mode( ) function is defined with the following


parameter definitions.

INT bc_request_unit_mode(system_batch_id, unit_name, mode_command)


CHAR *system_batch_id;
CHAR *unit_name;
T_U_QUAL mode_command;

Parameters system_batch_id (in) System-generated batch ID string


unit_name (in) Unit tag name
mode_command (in) Bit pattern representing one of three commands:
AUTO, MANUAL, or SEMI

The following constants represent the legal values for the mode_command
parameter; they are defined in /usr/tistar/include/enum_types/b_md_cmd.t:

B_MD_CMD_AUTO Set unit to automatic mode


B_MD_CMD_MANUAL Set unit to manual mode
B_MD_CMD_SEMI Set unit to semi-automatic mode

Description This function writes the specified mode command to the unit tag identified
by unit_name that is used in the batch identified by system_batch_id. If this
function completes successfully, the status attribute of the unit tag reflects
the specified mode command. The calling program, then, must query the
status attribute to determine the completion status of the request.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-44 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example writes the mode command B_MD_CMD_MANUAL
and retrieves the mode bits for the unit oven1 when the unit in_use bit goes
high. In order to obtain the batch’s system ID, which is required for the call
to bc_request_unit_mode( ), the custom ID for the unit tag oven1 is first
retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>
#include <enum_types/b_md_cmd.t>
#include <enum_types/u_qual.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_U_QUAL unit_mode;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_request_unit_mode(system_id, B_MD_CMD_MANUAL);

/* Pause while command is sent to controller. */


sleep (3);

bc_get_unit_mode(system_id, &unit_mode);
}

See Also bc_get_unit_mode

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-45
C.38 bc_request_unit_state( )

Synopsis The bc_request_unit_state( ) function is defined with the following


parameter definitions.

INT bc_request_unit_state(system_batch_id, unit_name, command)


CHAR *system_batch_id;
CHAR *unit_name;
T_U_CMD command;

Parameters system_batch_id (in) System-generated batch ID string


unit_name (in) Unit tag name
command (in) Numeric value representing the unit command

The following constants represent the legal values for the command
parameter; they are defined in /usr/tistar/include/enum_types/u_cmd.t:

U_CMD_ABORT Abort unit processing


U_CMD_CLR_ABORT Clear unit abort field
U_CMD_CLR_ALARM Clear unit alarm flag
U_CMD_DONE Mark unit as done with processing
U_CMD_HOLD Place unit in hold state
U_CMD_IN_SERVE Place unit in service
U_CMD_JOG Jog unit to next processing state
U_CMD_OUT_SERVE Place unit out of service
U_CMD_RELEASE Release unit from batch
U_CMD_RESUME Resume unit processing
U_CMD_SET_ALARM Set unit alarm flag
U_CMD_START Start unit processing
U_CMD_WAIT Place unit in wait state

Description This function writes the specified command to the command attribute of the
unit tag identified by unit_name. The unit must be assigned to the batch
identified by system_batch_id. If this function completes successfully, the
status attribute of the unit tag reflects the specified command. The calling
program, then, must query the status attribute to determine the completion
status of the request.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-46 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example writes the command U_CMD_JOG and retrieves the
state bits for the unit oven1 when the unit in_use bit goes high. In order to
obtain the batch’s system ID, which is required for the call to
bc_request_unit_state( ), the custom ID for the unit tag oven1 is first retrieved
and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>
#include <enum_types/u_cmd.t>
#include <enum_types/u_qual.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_U_QUAL unit_state;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_request_unit_state(system_id, U_CMD_JOG);

/* Pause while command is sent to controller. */


sleep (3);

bc_get_unit_state(system_id, &unit_state);
}

See Also bc_get_unit_state

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-47
C.39 bc_scale_recipe( )

Synopsis The bc_scale_recipe( ) function is defined with the following parameter


definitions.

INT bc_scale_recipe(unit_name, scale_factor)


CHAR *unit_name;
FLOAT32 scale_factor;

Parameters unit_name (in) Unit tag name


scale_factor (in) Numerical amount to scale a recipe

Description This function provides the scaling factor that the recipe package uses when
creating a production recipe. The function writes the scale_factor to every
area tag that is assigned to the unit_name.

Before this function can operate successfully, the BCL program must
execute the bc_select( ) function to select a valid recipe. The recipe scale
factor must be set before the recipe is downloaded.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example selects, scales (by 2.5), and loads the current recipe
for the unit oven1 when the run bit goes high for that unit. In order to obtain
the batch’s system ID, which is required for the call to bc_scale_recipe( ), the
custom ID for the unit tag oven1 is first retrieved and is then translated to
the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_select(system_id, ”oven1”);
bc_scale_recipe(”oven1”, 2.5);
bc_load(”oven1”);
}

See Also bc_load


bc_select
bc_set_batch_product

C-48 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.40 bc_select( )

Synopsis The bc_select( ) function is defined with the following parameter


definitions.

INT bc_select(system_batch_id, unit_name)


CHAR *system_batch_id;
CHAR *unit_name;

Parameters system_batch_id (in) System-generated batch ID string


unit_name (in) Unit tag name

Description This function selects the current recipe for the unit identified by unit_name in
the batch identified by system_batch_id. The selected recipe corresponds to
the unit product name. The recipe is selected for all recipe areas associated
with the unit. After the recipe is selected, it can be downloaded to the
controller with the bc_load( ) function.

To alter the unit product name, execute the bc_set_batch_product( )


function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example selects and loads the current recipe for the unit oven1
when the run bit goes high for that unit. In order to obtain the batch’s
system ID, which is required for the call to bc_select( ), the custom ID for
the unit tag oven1 is first retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_select(system_id, ”oven1”);
bc_load(”oven1”);
}

See Also bc_load


bc_scale_recipe
bc_set_batch_product

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-49
C.41 bc_set_batch_end( )

Synopsis The bc_set_batch_end( ) function is defined with the following parameter


definitions.

INT bc_set_batch_end(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function sets the ending time stamp, time string, and date string for
the batch identified by system_batch_id to the current time and date. When
the batch is commanded to complete or abort, these times are set
automatically if they have not been already set with a call to
bc_set_batch_end( ); however, they may be overwritten with a call to this
function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sets the ending time stamp, time string, and date for
the batch being processed in unit oven1 when the unit in_use bit goes low. In
order to obtain the batch’s system ID, which is required for the call to
bc_set_batch_end( ), the custom ID for the unit tag oven1 is first retrieved
and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_set_batch_end(system_id);
}

See Also bc_set_batch_start

C-50 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.42 bc_set_batch_operation( )

Synopsis The bc_set_batch_operation( ) function is defined with the following


parameter definitions.

INT bc_set_batch_operation(system_batch_id, operation_name)


CHAR *system_batch_id;
CHAR *operation_name;

Parameters system_batch_id (in) System-generated batch ID string


operation_name (in) Batch operation string

Description This function defines the operation string for the batch identified by
system_batch_id. The operation_name corresponds to the operation attribute of
the batch tag and can be any valid character string. If the string is too long,
the function truncates the string to a length of 10 characters before
continuing execution. The operation string appears in the batch tag detail
screen.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example installs the operation string “cooking” for the batch
currently being processed in unit oven1 when the unit run bit goes high. In
order to obtain the batch’s system ID, which is required for the call to
bc_set_batch_operation( ), the custom ID for the unit tag oven1 is first
retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_set_batch_operation(system_id, ”cooking”);
}

See Also bc_set_batch_end


bc_set_batch_product
bc_set_batch_start

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-51
C.43 bc_set_batch_product( )

Synopsis The bc_set_batch_product( ) function is defined with the following


parameter definitions.

INT bc_set_batch_product(system_batch_id, product)


CHAR *system_batch_id;
CHAR *product;

Parameters system_batch_id (in) System-generated batch ID string


product (in) Any character string representing a batch product

Description This function defines the product for the batch tag identified by
system_batch_id. The product parameter corresponds to the product name of a
recipe and can be any valid character string. If recipe downloads are to be
performed, the product name must also be a valid recipe name. If the string
is too long, the function truncates the string to a length of 12 characters
before continuing execution.

Successful execution of this function will cause the batch to enter the
READY state, unless the special NONE product is requested. In that case,
the COMMIT state will be entered. The function returns an error and will
not change the product if the batch is currently running.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example defines the product CHOC_CHIP for the batch
currently being processed in unit oven1 when the unit in_use bit goes high.
In order to obtain the batch’s system ID, which is required for the call to
bc_set_batch_product( ), the custom ID for the unit tag oven1 is first retrieved
and is then translated to the system ID

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_set_batch_product(system_id, ”CHOC_CHIP”);
}

See Also bc_set_batch_end


bc_set_batch_operation
bc_set_batch_start

C-52 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.44 bc_set_batch_start( )

Synopsis The bc_set_batch_start( ) function is defined with the following parameter


definitions.

INT bc_set_batch_start(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function sets the starting time stamp, time string, and date string for
the batch identified by system_batch_id to the current time and date. When
the batch is committed, these times are set automatically; however, they
may be overwritten with a call to this function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sets the starting time stamp, time string, and date
for the batch being processed in unit oven1 when the unit in_use bit goes
high. In order to obtain the batch’s system ID, which is required for the call
to bc_set_batch_start( ), the custom ID for the unit tag oven1 is first retrieved
and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_set_batch_start(system_id);
}

See Also bc_set_batch_end


bc_set_batch_operation
bc_set_batch_product

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-53
C.45 bc_set_first_batch_list_entry( )

Synopsis The bc_set_first_batch_list_entry( ) function is defined with the following


parameter definitions.

INT bc_set_first_batch_list_entry(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function sets the current pointer to the first batch ID in the list
identified by l_name.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example traverses the list named BID_LIST allowing
operations of your choice to be performed using each batch ID stored in the
list. These operations are performed when the BCL program starts
execution.

ON EVENT STARTUP
{
CHAR *current_bid_ptr;

bc_set_first_batch_list_entry (”BID_LIST”);
while (bc_batch_list_entry_exists (”BID_LIST”))
{
current_bid_ptr =
bc_get_batch_id_entry (”BID_LIST”);
/*
** Do something with the current batch ID,
** then go on to the next one.
*/
bc_set_next_batch_list_entry (”BID_LIST”);
}
}

See Also bc_add_batch_list_entry


bc_batch_list_entry_exists
bc_create_batch_list
bc_get_batch_id_entry
bc_remove_batch_list_entry
bc_set_next_batch_list_entry

C-54 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.46 bc_set_log_destination( )

Synopsis The bc_set_log_destination( ) function is defined with the following


parameter definitions.

INT bc_set_log_destination (system_batch_id, destinations)


CHAR *system_batch_id;
T_DEV_SET destinations;

Parameters system_batch_id (in) System-generated batch ID string


destinations (in) Set of printer devices

Description This function sets the destination printer device(s) to those printer(s)
indicated with the bit pattern defined in destinations. The printer bit pattern
is retrieved using the bc_get_printer_mask function that identifies one or more
printer devices. You can logically OR the results of several
bc_get_printer_mask( ) calls to specify multiple printers. These printers can
receive log messages for the specified batch.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sets the log destination, printer p1 on station mynode,
for the batch being processed in unit oven1 when the unit in_use bit goes
high. In order to obtain the batch’s system ID, which is required for the call
to bc_set_log_destination( ), the custom ID for the unit tag oven1 is first
retrieved and is then translated to the system ID.

#include <spool_user.h>
#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use
{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];
T_DEV_SET printer;

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);
bc_get_printer_mask(”p1”,”mynode”,&printer);

bc_set_log_destination(system_id, printer);
}

See Also bc_get_printer_mask

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-55
C.47 bc_set_next_batch_list_entry( )

Synopsis The bc_set_next_batch_list_entry( ) function is defined with the following


parameter definitions.

INT bc_set_next_batch_list_entry(l_name)
CHAR *l_name;

Parameters l_name (in) Name of the list

Description This function sets the current pointer to the next batch ID (relative to the
current position) in the list identified by l_name. Before this function can be
executed, the BCL program must call the bc_set_first_batch_list_entry ( )
function.

A batch list is a means for maintaining a collection of named lists of


character strings. In BCL programs, an obvious use for such a construct is
to maintain lists of batch IDs, hence the name “batch list.” These can be
either user-defined custom IDs or the internally-generated system IDs.
These lists are only available within the BCL program that creates them.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

C-56 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Example The following example traverses the list named BID_LIST allowing
operations of your choice to be performed using each batch ID stored in the
list. These operations are performed when the BCL program starts
execution.

ON EVENT STARTUP
{
CHAR *current_bid_ptr;

bc_set_first_batch_list_entry (”BID_LIST”);
while (bc_batch_list_entry_exists (”BID_LIST”))
{
current_bid_ptr =
bc_get_batch_id_entry (”BID_LIST”);
/*
** Do something with the current batch ID,
** then go on to the next one.
*/
bc_set_next_batch_list_entry (”BID_LIST”);
}
}

See Also bc_add_batch_list_entry


bc_batch_list_entry_exists
bc_create_batch_list
bc_get_batch_id_entry
bc_remove_batch_list_entry
bc_set_first_batch_list_entry

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-57
C.48 bc_set_unit_end( )

Synopsis The bc_set_unit_end( ) function is defined with the following parameter


definitions.

INT bc_set_unit_end(unit_name)
CHAR *unit_name;

Parameters unit_name (in) Unit tag name

Description This function sets the ending time stamp, time string, and date string for
the unit identified by unit_name to the current time and date.

When the in_use bit of the unit status word goes off, these times will be set
automatically if they have not been set already by a call to
bc_set_unit_end( ); however, they may be overwritten with a call to this
function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sets the ending time stamp, time string, and date
string to the current date when the status bit oos goes high for oven1.

ON EVENT oven1:status:oos
{
bc_set_unit_end(”oven1”);
}

See Also bc_set_unit_operation


bc_set_unit_start

C-58 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.49 bc_set_unit_operation( )

Synopsis The bc_set_unit_operation( ) function is defined with the following


parameter definitions.

INT bc_set_unit_operation(unit_name, operation_name)


CHAR *unit_name;
CHAR *operation_name;

Parameters unit_name (in) Unit tag name


operation_name (in) Batch operation string

Description This function defines the operation for the unit identified by unit_name. The
operation_name corresponds to the operation attribute of the unit tag and can
be any valid character string. If the string is too long, the function truncates
the string to a length of 10 characters before continuing execution. The
operation string appears in the unit tag detail screen.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example prints the operation string cooking in the unit tag
detail screen for the unit oven1 when the status bit run goes high for that
unit.

ON EVENT oven1:status:run
{
bc_set_unit_operation(”oven1”, ”cooking”);
}

See Also bc_set_unit_end


bc_set_unit_start

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-59
C.50 bc_set_unit_start( )

Synopsis The bc_set_unit_start( ) function is defined with the following parameter


definitions.

INT bc_set_unit_start(unit_name)
CHAR *unit_name;

Parameters unit_name (in) Unit tag name

Description This function sets the starting time stamp, time string, and date string for
the unit identified by unit_name to the current time and date.

When the in_use bit of the unit status word goes on, these times will be set
automatically. Additionally, the end times are cleared for the unit. However,
the start times may be overwritten with a call to this function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example sets the starting time stamp, time string, and date
string to the current date when the status bit run goes high for oven1.

ON EVENT oven1:status:run
{
bc_set_unit_start(”oven1”);
}

See Also bc_set_unit_end


bc_set_unit_operation

C-60 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.51 bc_split_batch( )

Synopsis The bc_split_batch function( ) is defined with the following parameter


definitions.

INT bc_split_batch(system_batch_id, new_batch_id)


CHAR *system_batch_id;
CHAR *new_batch_id;

Parameters system_batch_id (in) System-generated batch ID string


new_batch_id; (in) Name desired for new split batch

Description This function splits the batch referenced by system_batch_id. The new
split-off batch is named new_batch_id.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example splits off a new batch with custom ID set to
CHOC_CHIP_2 for the batch being processed in unit oven1 when the unit
run bit goes low. In order to obtain the batch’s system ID, which is required
for the call to bc_split_batch( ), the custom ID for the unit tag oven1 is first
retrieved and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:run RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_split_batch(system_id, ”CHOC_CHIP_2”);
}

See Also None

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-61
C.52 bc_trigger_request( )

Synopsis The bc_trigger_request( ) function is defined with the following parameter


definitions.

INT bc_trigger_request(request_name)
CHAR *request_name;

Parameters request_name (in) Name of an action request

Description This function triggers the action request identified by request_name. The
function sets the trigger bit that was defined during the configuration of the
action request.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example triggers the action request OVEN_ON when the status
bit run goes high for oven1.

ON EVENT oven1:status:run
{
bc_trigger_request(”OVEN_ON”);
}

See Also None

C-62 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
C.53 bc_unlock_batch_id( )

Synopsis The bc_unlock_batch_id( ) function is defined with the following parameter


definitions.

INT bc_unlock_batch_id(system_batch_id)
CHAR *system_batch_id;

Parameters system_batch_id (in) System-generated batch ID string

Description This function unlocks the batch identified by system_batch_id by setting the
id_locked attribute to UNLOCKED (or FALSE). After a batch ID is
unlocked, it can be changed.

To prevent a change to a batch ID during batch processing, run the


bc_lock_batch_id( ) function.

Return Value ERROR Error occurred. The variable errno indicates the specific error.
NO_ERROR Normal return.

Example The following example unlocks the custom batch ID for the batch with
which the unit oven1 is associated when the in_use bit for oven1 goes low. In
order to obtain the batch’s system ID, which is required for the call to
bc_unlock_batch_id( ), the custom ID for the unit tag oven1 is first retrieved
and is then translated to the system ID.

#include <enum_types/batch.r>
#include <enum_types/b_i_d.t>

ON EVENT oven1:status:in_use RESET


{
CHAR custom_bid[T_B_I_D_LENGTH];
CHAR system_id[T_BATCH_INTERNAL_ID_LENGTH];

bc_get_batch_id(”oven1”, custom_bid);
bc_get_system_id(custom_bid, system_id);

bc_unlock_batch_id(system_id);
}

See Also bc_lock_batch_id

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Batch Control Functions C-63
C-64 Batch Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix D
BCL Program Control Functions
D.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-2

D.2 bcl_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-3

D.3 bcl_disable_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-4

D.4 bcl_disable_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-5

D.5 bcl_disable_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-6

D.6 bcl_enable_auto_append( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-7

D.7 bcl_enable_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-8

D.8 bcl_enable_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-9

D.9 bcl_error_on_empty_delete( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-10

D.10 bcl_error_on_not_found( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-11

D.11 print_trace_message( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-12

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-1
D.1 Overview

This appendix describes the built-in functions that enable you to control the
operation of a BCL program while it is running. Each function description
consists of the following components.

 Synopsis shows the syntax and data types for the parameters used by
the function.

 Parameters describes the parameters required by the function.

 Description describes the operation of the function.

 Return value lists the possible return codes that the function may
produce.

D-2 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
D.2 bcl_auto_append( )

Synopsis The bcl_auto_append( ) function is defined with the following parameter


definitions.

BOOLEAN bcl_auto_append( )

Parameters None

Description This function enables a BCL program to determine the setting of the
automatic append switch. The bcl_auto_append( ) function is useful when
you must set the switch to a particular setting and then return it to its
original setting at a later time.

Return Value TRUE Automatic append for a failed replace operation is enabled.
FALSE Automatic append for a failed replace operation is disabled.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-3
D.3 bcl_disable_auto_append( )

Synopsis The bcl_disable_auto_append( ) function is defined with the following


parameter definitions.

VOID bcl_disable_auto_append( )

Parameters None

Description This function disables the auto append feature that attempts to append a
record to the database if a replace operation fails. The auto append feature
remains disabled until the bcl_enable_auto_append( ) function executes.

Return Value The return value of this function is undefined.

D-4 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
D.4 bcl_disable_error_on_empty_delete( )

Synopsis The bcl_disable_error_on_empty_delete( ) function is defined with the


following parameter definitions.

VOID bcl_disable_error_on_empty_delete( )

Parameters None

Description This function disables error reporting for delete operations that refer to
records that cannot be found when the operations are executed. This
function represents the default behavior of BCL programs under these
circumstances. The error reporting feature remains disabled until the
bcl_enable_error_on_empty_delete( ) function executes.

Return Value The return value of this function is undefined.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-5
D.5 bcl_disable_error_on_not_found( )

Synopsis The bcl_disable_error_on_not_found( ) function is defined with the


following parameter definitions.

VOID bcl_disable_error_on_not_found( )

Parameters None

Description This function disables the generation of a system error message when a
BCL retrieve operation fails to find its intended target record in the
database. BCL programs normally issue an error message in such cases. In
order to suppress these error messages, this function must be called. This
error reporting feature will remain disabled until the
bcl_enable_error_on_not_found( ) function executes.

Return Value The return value of this function is undefined.

D-6 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
D.6 bcl_enable_auto_append( )

Synopsis The bcl_enable_auto_append( ) function is defined with the following


parameter definitions.

VOID bcl_enable_auto_append( )

Parameters None

Description This function enables the auto append feature that attempts to append a
record to the database if a replace operation fails. This function represents
the default behavior of BCL programs under these circumstances. This
feature applies only to replace operations that incorporate a WHERE clause.
The appended data record consists of the key data from the WHERE clause
and the data originally intended to be replaced. The auto append feature
remains enabled until the bcl_disable_auto_append( ) function executes.

Return Value The return value of this function is undefined.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-7
D.7 bcl_enable_error_on_empty_delete( )

Synopsis The bcl_enable_error_on_empty_delete( ) function is defined with the


following parameter definitions.

VOID bcl_enable_error_on_empty_delete( )

Parameters None

Description This function enables error reporting for delete operations that refer to
records that cannot be found when the operations are executed. BCL
programs do not normally report errors of this type. The error reporting
feature remains enabled until the bcl_disable_error_on_empty_delete( )
function executes.

Return Value The return value of this function is undefined.

D-8 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
D.8 bcl_enable_error_on_not_found( )

Synopsis The bcl_enable_error_on_not_found( ) function is defined with the


following parameter definitions.

VOID bcl_enable_error_on_not_found( )

Parameters None

Description This function enables the generation of a system error message when a BCL
retrieve operation fails to find its intended target record in the database.
This function represents the default behavior of BCL programs under these
circumstances. This error reporting feature remains enabled until the
bcl_disable_error_on_not_found( ) function executes.

Return Value The return value of this function is undefined.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-9
D.9 bcl_error_on_empty_delete( )

Synopsis The bcl_error_on_empty_delete( ) function is defined with the following


parameter definitions.

BOOLEAN bcl_error_on_empty_delete( )

Parameters None

Description This function enables a BCL program to determine the state of the empty
delete error switch. The bcl_error_on_empty_delete( ) function is useful when
you must set the switch to a particular state and then return it to its
original state at a later time.

Return Value TRUE Error messages are generated if an attempt is made to


delete a nonexistent record.
FALSE Error messages are not generated if an attempt is made to
delete a nonexistent record.

D-10 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
D.10 bcl_error_on_not_found( )

Synopsis The bcl_error_on_not_found( ) function is defined with the following


parameter definitions.

BOOLEAN bcl_error_on_not_found( )

Parameters None

Description This function allows the BCL program to determine the state of the switch
that controls whether a system error message is generated when a BCL
retrieve operation fails to find its intended target record in the database.
This function is useful when you must set the switch to a particular state
and then return it to its original state at a later time.

Return Value TRUE Retrieve operations resulting in ‘‘not found” produce an


error message.
FALSE Retrieve operations resulting in ‘‘not found” do not produce an
error message.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Program Control Functions D-11
D.11 print_trace_message( )

Synopsis The print_trace_message( ) function is defined with the following


parameter definitions.

VOID print_trace_message(message)
CHAR *message

Parameters message (in) Pointer to the character array containing the string
that the function sends to the trace file

Description This function appends the string in the message buffer to the trace output
file. The BCL program creates a trace file only if the --t option is specified
when the program is activated through the batch manager or the operating
system command line.

Return Value The return value of this function is undefined.

D-12 BCL Program Control Functions SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix E
Security Privileges for Commands
E.1 Security Privileges for Batch Commands and Batch Mode Commands . . . . . . . . . . . . . E-2

E.2 Security Privileges for Unit Commands and Batch Mode Commands . . . . . . . . . . . . . . . E-3

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Security Privileges for Commands E-1
E.1 Security Privileges for Batch Commands and Batch Mode Commands

NOTE: For user configuration security privileges, see the SIMATIC PCS 7
OSx Process Configuration Manual.

Table E-1 Security Privileges for Batch Commands

Command Required Privilege Available from


Abort Batch Control std displays, BCL program, controller request
Change Batch Descriptor Primary Control Batch identification
Change Batch ID Batch Control Batch identification, BCL
Change Batch Log Destination Primary Control Batch identification, BCL
Clear Alarm Primary Control std displays, BCL program, controller request
Batch identification, BCL program, controller
Commit Primary Control
request
Complete Primary Control std displays, BCL program, controller request
Hold Batch Control std displays, BCL program, controller request
Remove Primary Control std displays, BCL program, controller request
Resume Batch Control std displays, BCL program, controller request
Set Alarm Primary Control std displays, BCL program, controller request
Primary Control or
Split std displays, BCL program, controller request
Batch Control
Primary Control or
Split/Assign controller request
Batch Control
Start Primary Control std displays,* BCL program, controller request
* Batch tag detail and faceplate

Table E-2 Security Privileges for Batch Mode Commands

Command Required Privilege Available from


Auto Batch Control std displays, BCL program, controller request
Manual Batch Control std displays, BCL program, controller request
Semi-Auto Batch Control std displays, BCL program, controller request

E-2 Security Privileges for Commands SIMATIC PCS 7 OSx 4.1.1 Batch Programming
E.2 Security Privileges for Unit Commands and Batch Mode Commands

Table E-3 Security Privileges for Unit Commands

Command Required Privilege Available from


Abort Batch Control std displays, BCL program, controller request
Assign Primary Control std displays*, BCL program, controller request
Clear Abort Batch Control std displays, BCL program, controller request
Clear Alarm Primary Control std displays, BCL program, controller request
Done Primary Control std displays, BCL program, controller request
Hold Batch Control std displays, BCL program, controller request
In Service Batch Control std displays, BCL program, controller request
Jog Primary Control std displays, BCL program, controller request
Out of Service Batch Control std displays, BCL program, controller request
Release Primary Control std displays, BCL program, controller request
Resume Batch Control std displays, BCL program, controller request
Set Alarm Primary Control std displays, BCL program, controller request
Start Primary Control std displays, BCL program, controller request
Wait Primary Control std displays, BCL program, controller request
* Batch tag detail and faceplate

Table E-4 Security Privileges for Unit Mode Commands

Command Required Privilege Available from


Auto Batch Control std displays, BCL program, controller request
Manual Batch Control std displays, BCL program, controller request
Semi-Auto Batch Control std displays, BCL program, controller request

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Security Privileges for Commands E-3
E-4 Security Privileges for Commands SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix F
Advanced BCL Programming Techniques

F.1 BCL Access to Custom Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2


Who Should Read This Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2
Custom Database Table Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-2
Privilege Masks of Standard Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-3
F.2 USER_MSG Event Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4
Using the USER_MSG Event Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Advanced BCL Programming Techniques F-1
F.1 BCL Access to Custom Database Tables

This appendix explains the appropriate privilege settings for custom


database tables that are to be manipulated by BCL programs.

Who Should Read The information in this section is intended for SIMATIC PCS 7 OSx
This Appendix integrators and other advanced OSx users. It is assumed that the
reader/user is well-acquainted with the structure of the OSx database and
knows how to use ddl, the database utility program used to build the
database. If you are not experienced in these areas and have no need to add
custom tables to your OSx program, then this material is not important to
your application and can be ignored. If you think that you do need to
customize your database by adding tables specific to your application, please
consult a qualified SIMATIC PCS 7 OSx integrator.

Custom Database Each OSx database table has a privilege mask. This privilege mask is
Table Privileges defined by using the Privilege statement in the database table’s associated
.ddl file. In order for a BCL program to be able to modify a database table,
the Database Admin privilege must not be set. By not specifying any
privilege restrictions on the table, the table’s privilege mask has no
privileges set and BCL programs are able to freely manipulate the tables.
Or if any privilege flags are set as part of the table’s ddl definition, simply
refrain from specifying the Database Admin privilege for any of the table’s
attributes. This allows BCL programs to freely alter the table.

Definitions for the standard privilege flags in the database may be found in
database source file catalog.ddl in the /usr/tistar/data/db/tables directory.

F-2 Advanced BCL Programming Techniques SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Privilege Masks of The following warning must be adhered to in regard to privilege masks in
Standard Database standard database tables.
Tables

! WARNING
The standard tables contain configuration and operating information
maintained by the SIMATIC PCS 7 OSx system processes and may be identified
by the presence of the Database Admin privilege flag. Alteration of the
information in these tables by any custom program, including BCL programs,
may cause improper operation.
Alteration of the privilege masks of the standard OSx database tables to allow
BCL programs to alter their contents can cause unpredictable operations that
can result in death or serious injury to personnel and/or damage to the
equipment.
Do not attempt to delete records from standard OSx database tables or attempt
to replace attributes in any tables.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Advanced BCL Programming Techniques F-3
F.2 USER_MSG Event Blocks

Introduction The USER_MSG event block exists to allow BCL programs to interact with
OSx subsystems that issue response messages to the calling process’s input
queue. Writing BCL programs that interface in this manner requires
extensive experience with OSx system programming techniques and a high
degree of familiarity with OSx subsystems and their programming
interfaces. The information presented here is intended to provide only the
necessary details specific to the USER_MSG event block implementation to
allow the advanced system programmer to use this feature in conjunction
with the OSx subsystem interface libraries. BCL programmers wishing to
know more about these interfaces should consult a qualified SIMATIC
PCS 7 OSx system integrator.

Using the A USER_MSG event block executes when the BCL program receives an
USER_MSG Event input queue message that is not generated by a database change event nor
Block generated by the batch manager program. For example, a response message
from the network is one type of user message.

The block becomes active when it receives a message that the BCL program
kernel does not recognize. If your code does not recognize the message type,
use the USER_MSG block to generate an error message. If your BCL
program does not contain a block triggered on USER_MSG, the BCL
program kernel generates an error message and continues running.

F-4 Advanced BCL Programming Techniques SIMATIC PCS 7 OSx 4.1.1 Batch Programming
The code for this type of event block, whether it is written into the block or
in a function called by the block, must be able to distinguish between
expected and unexpected resource IDs. The following resource IDs are
handled internally and are already defined for all BCL programs.

#define BM_DB_EVENT_ID 1
#define BM_MGR_RSRC_ID 3
#define BM_BCPGM_RSRC_ID 4

The BCL program kernel initializes its interface to the network by calling
cs_init( ) with the following resource ID.

#define BM_UPDATE_REPLY_ID 2

Although it automatically initializes BM_UPDATE_REPLY_ID, the BCL


program kernel does not handle messages generated by this resource ID. If
the kernel receives a message from this resource ID, it either triggers a
USER_MSG event block or generates an error message. Although
BM_UPDATE_REPLY_ID is automatically initialized for the network, you can
reinitialize it with your own ID because cs_init( ) can be called multiple
times. The IDs that you specify must not duplicate any of the ID numbers
mentioned above (1, 2, 3, or 4).

When a message activates an event block, OSx stores the resource ID in the
global variable bcl_user_resource_id. To access this variable, you must include
the following declaration in your BCL program.

extern INT bcl_user_resource_id;

OSx stores the message in the standard OSx message buffer, which you can
access with any appropriate buffer access macro (for instance,
cs_event_data( ) enables you to access network messages).

SIMATIC PCS 7 OSx 4.1.1 Batch Programming Advanced BCL Programming Techniques F-5
F-6 Advanced BCL Programming Techniques SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Appendix G
BCL Application Programming Example
G.1 BCL Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Simple Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Sample Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-2
Configuration Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-4
Program Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5
Program Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-5
Event Block #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G-9

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-1
G.1 BCL Programming Example

This appendix contains a brief description and source code listings for
sample BCL application programs. As is generally the case with BCL
programs, the material in this section is intended for system integrators and
other programmers who are familiar with advanced OSx system
programming techniques.

Simple Program The following code directs the program to write the date and time stamp at
the end of the BCL trace output file.

#include <time.h>

ON EVENT trigger_spec
{
time_t time_now;
char msg[80];

time_now = time(NULL);
strftime(msg,78,”this is a time test message %D %T”,
localtime(&time_now));
print_trace_message(msg);
}

Sample Scenario The example program on the following pages implements a start-up
sequence for a simple batch process. The processing involved is limited to a
tank which processes some amount of raw material. Two tanks, designated
tank 1 and tank 4, are available for processing. The operator is responsible
for requesting that a batch be started and for entering parameters when
prompted by the system.

The control system provides a process control graphic which displays the
state of batches in progress and provides the means for the operator to start
new batches. The graphic includes an icon used as a “start” button.
Selecting this icon provides the event that initiates the processing
implemented in the BCL program.

The start-up procedure requires the operator to enter several parameters


regarding the batch to be started. Information entered by the operator is
stored in the database for display on the graphic. Once all the necessary
items have been entered, the batch is initiated and a unit corresponding to
the selected processing tank is assigned to it.

When processing of the batch completes, the tank unit sets a bit which
triggers an event block in the BCL program that sets the batch ID into a
text tag which is used as a mailbox to communicate the ID to the batch
report. The BCL program then sets a bit which triggers execution of the
report.

G-2 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
When the report finishes, it resets a bit which triggers the BCL program’s
final clean-up block for the batch. At this point, the batch is finished and
becomes inactive.

The action blocks in the BCL program respond to and trigger batch start-up
events as shown in Figure G-1:

Event #1: Operator selects Start button icon.


Response: Triggers action request for operator to enter batch ID.

Event #2: Operator enters batch ID.


Response: Saves and displays batch ID, triggers action request for operator to enter
charge level

Event #3: Operator enters charge level.


Response: Saves and displays charge level, triggers action request for processing
tank selection.

Event #4: Operator enters processing tank selection.


Response: Trigger action request for parameter confirmation.

Event #5: Operator enters parameter confirmation.


Response: Save and display batch status.
Initiate batch processing using parameters entered by operator.
Batch processing begins.
Programming for the processing interval is not included in this example.

Event #6: Batch completion indicator goes on.


Response: Stuff batch ID mailbox for batch report.
Trigger batch report.

Event #7: Batch report signals completion.


Response: Perform cleanup.

Figure G-1 Sequence of Tasks

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-3
BCL Programming Example (continued)

Configuration The example program assumes the existence of the indicated tags and
Prerequisites action requests, the process control graphic display, and an appropriate
batch report. Configuration of these items is not covered in this example.
Refer to the following OSx user manuals for further details:

 SIMATIC PCS 7 OSx Process Configuration Manual

 SIMATIC PCS 7 OSx Reports Manual

 SIMATIC PCS 7 OSx Graphical Editor Manual


A summary of the tags used in the example and their functions is given in
Table G-1.

Table G-1 Example Tags

Tag Function
Numeric batch ID entered by operator in response to request BATCHID; answer tag for action
batchid
request BATCHID
batchid_rst Reset tag for action request BATCHID
charge6_1 Graphic display data: commit confirmation
charge6_2 Graphic display data: batch ID number (entered by operator)
charge6_3 Graphic display data: tank level selection
charge6_4 Graphic display data: tank selection
Charge level entered by operator in response to request CHRG_LVL; answer tag for action
chrg_lvl
request CHRG_LVL
chrg_lvl_rst Reset tag for action request CHRG_LVL
Answer tag for action request COMMIT; operator enters confirmation of batch start-up
commit
parameters
commit_rst Reset tag for action request COMMIT
Batch completion indicator for tank 1; attached to UNIT tag for tank 1; changed by unit’s
do_0 controller program or, for demonstration purposes, manually (that is, from the command line
using the database utility “menu”)
Batch completion indicator for tank 4; attached to UNIT tag for tank 4; changed by unit’s
do_4 controller program or, for demonstration purposes, manually (that is, from the command line
using the database utility “menu”)
start_00 Commanded by “start batch” button on graphic
Tank selection entered by operator in reponse to request TANK; answer tag for action request
tank
TANK
tank_rst Reset tag for action request TANK
Text tag used as mailbox to communicate batch ID to batch report; configured as non-networked
tex1 to allow changes to STATUS attribute; triggers report by setting ACTIVE bit in STATUS; report
resets ACTIVE bit which triggers BCL program to perform post-batch clean-up

G-4 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Program Events Action requests are used to prompt the operator to input the following
parameters required to start a batch. Action requests used in the example
are summarized in Table G-2.

 Numeric batch ID

 Charge level

 Processing tank number

 Parameter confirmation

Table G-2 Example Action Request

Request Names Function

BATCHID Request operator to enter batch ID


CHRG_LVL Request operator to enter charge level
COMMIT Request operator to confirm start-up parameters
TANK Request operator to enter processing tank selection

Program Source Source code for the batch charging example program consists of three files
Code as shown in Table G-3.

Table G-3 Source Code Files

File Name Function


charge.h Definition of constants
charge.bcl BCL program
inb.c Custom C function for initiating batch processing

These files are printed on the following pages.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-5
BCL Programming Example (continued)

The following header file declares constants and variables used in the BCL
program charge.bcl.

/* ===================== */
/* Header file, charge.h */
/* ===================== */

/*
** Constants for the batch charging program, charge.bcl
*/

#define TRACE_MESSAGE_LENGTH 80
#define NEW_BATCH_VAR_HANDLE ”new_batch”

/*
** Error codes;
** Install suitable error messages in the ERR_MSGS table.
*/

#define CHRG_LVL_ERR 9999


#define BATCH_INIT_ERR 9998

/* End of header file, charge.h */

G-6 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
The following pages contain the source code for the BCL program
charge.bcl. The program contains seven event blocks.

/* ============================ */
/* BCL program file, charge.bcl */
/* ============================ */

/*
** Batch charging control program
**
** This file contains blocks for events 1 through 7.
*/

/* ac_defs.h contains the #define’s for


** action request CHOICE_n_VALUE constants.
*/
#include <ac_defs.h>

/* .t and .r header files contain database-related constants.


*/
#include <enum_types/tags.t>
#include <enum_types/b_cmd.t>
#include <enum_types/b_i_d.t>
#include <enum_types/text.r>

/* User-generated, local include file


*/
#include ”charge.h”

/* Variable block definitions for BCL program internal variables


*/
DEFINE h_vars FOR ALL
{
SINT16 batch_id_number;
SINT16 level;
SINT16 tank;
}

DEFINE b_vars FOR ALL


{
SINT16 level;
CHAR batch_id [T_B_I_D_LENGTH];
CHAR unit_name [T_TAGS_LENGTH];
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-7
BCL Programming Example (continued)

/* Event #1
**
** When the ”start” button on the graphic is pushed,
** trigger the request for the batch identifier.
*/

¡ ON EVENT start_00:command CHANGES


{
© SINT16 cmd;
CHAR msg [TRACE_MESSAGE_LENGTH];

¢ EXEC (&cmd) <- start_00:command;

£ if (cmd != 0)
{
¤ if (bc_trigger_request (”BATCHID”) == ERROR)
{
¥ sprintf (msg, ”Request BATCHID trigger failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
¦ print_trace_message (”Request BATCHID triggered OK.\n”);
}
}
}

G-8 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Event Block #1 Event block #1 is triggered when the operator selects the Start button icon.
Event block #1 triggers the action request for the operator to enter the
batch ID.

When the start button icon is selected on the graphic screen the tag start_00
is changed.

1. Event Trigger Specification. The change in state of the tag start_00


triggers the Event block #1 block to perform the following commands:

2. C commands declare local variables to be used in this action block.

3. This command transfers the value in the command attribute of the


start_00 tag to the locally declared variable.

4. The if statement is checking to see if the command attribute is not off


(that is, the start button is on). If the attribute is off, the commands
inside the curly brackets are not performed. If the attribute is on, the
commands are performed.

5. The bc_trigger_request is a standard BCL command that triggers an


action request. In this case, the action request has been configured as
BATCHID. If this BCL function returns an error, then item #6 will be
performed. If no error occurs, item # 7 will be performed.

6. If the BCL function in ¤ returns an error, the standard C function


sprintf sets up the declaration message ”Request BATCHID trigger
failed, %d\n”, followed by the error number returned from the
function. The print_trace_message function actually writes the message
to the trace output file that has been set up. (For information on the
print_trace_message, see Table 4-1.)

7. If the BCL function in ¤ performs with no error, the


print_trace_message function writes the message ”Request BATCHID
triggered OK.\n” to the trace output file.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-9
BCL Programming Example (continued)

/* Event #2
**
** When the batch identifier request has been answered,
** save the identifier information
** and trigger the request for the charge level.
*/
ON EVENT batchid_rst:command:0x8000 RESET
{
static CHAR var_id [] = NEW_BATCH_VAR_HANDLE;
CHAR msg [TRACE_MESSAGE_LENGTH];
print_trace_message (”Request BATCHID has been answered.\n”);
INIT_VAR h_vars, var_id;
if (h_vars == NULL)
{
print_trace_message (”h_vars allocation failed.\n”);
return (ERROR);
}
/* Get batch identification number entered by operator
*/
EXEC (&h_vars->batch_id_number) <- batchid:value;
if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Batch identifier fetch failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}
sprintf (msg, ”ID = %d\n”, h_vars->batch_id_number);
print_trace_message (msg);
/* Put batch identifier on display
*/
EXEC charge6_2:value <- (&h_vars->batch_id_number);
if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Batch identifier display value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

G-10 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
/* Trigger charge level entry request
*/

if (bc_trigger_request (”CHRG_LVL”) == ERROR)


{
sprintf (msg, ”Request CHRG_LVL trigger failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
print_trace_message (”Request CHRG_LVL triggered OK.\n”);
}
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-11
BCL Programming Example (continued)

/* Event #3
**
** When the request for charge level has been answered,
** convert and store the level information
** and trigger the request for the tank number.
*/

ON EVENT chrg_lvl_rst:command:0x8000 RESET


{
static CHAR var_id [] = NEW_BATCH_VAR_HANDLE;

CHAR msg [TRACE_MESSAGE_LENGTH];

print_trace_message (”Request CHRG_LVL has been answered.\n”);

INIT_VAR h_vars, var_id;

if (h_vars == NULL)
{
print_trace_message (”h_vars allocation failed.\n”);
return (ERROR);
}

/* Get charge level entered by operator


*/

EXEC (&h_vars->level) <- chrg_lvl:value;

if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Charge level fetch failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* Translate answer value from action request


** to application-specific level selection.
*/

switch (h_vars->level)
{
case CHOICE_1_VALUE: /* Definitions for CHOICE_n_VALUE */
h_vars->level = 1; /* are found in Action Request */
break; /* header file ac_defs.h. */

G-12 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
case CHOICE_2_VALUE:
h_vars->level = 2;
break;

case CHOICE_3_VALUE:
h_vars->level = 3;
break;

default:
XMT_ERR (”charge.bcl”, CHRG_LVL_ERR, ”Invalid level”);
print_trace_message (”Invalid level\n”);
break;
}

/* Print translated level selection to trace file


*/

sprintf (msg, ”Level = %d\n”, h_vars->level);


print_trace_message (msg);

/* Update level selection in database


*/

EXEC chrg_lvl:value <- (&h_vars->level);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Charge level value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* Update level selection for display


*/

EXEC charge6_3:value <- (&h_vars->level);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Charge level display value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-13
BCL Programming Example (continued)

/* Trigger action request


** for operator to enter tank number
*/

if (bc_trigger_request (”TANK”) == ERROR)


{
sprintf (msg, ”Request TANK trigger failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
print_trace_message (”Request TANK triggered OK.\n”);
}
}

G-14 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
/* Event #4
**
** When the tank number request has been answered,
** convert and store the tank number information
** and trigger the commit request.
*/

ON EVENT tank_rst:command:0x8000 RESET


{
static CHAR var_id [] = NEW_BATCH_VAR_HANDLE;

CHAR msg [TRACE_MESSAGE_LENGTH];

print_trace_message (”Request TANK has been answered.\n”);

INIT_VAR h_vars, var_id;

if (h_vars == NULL)
{
print_trace_message (”h_vars allocation failed.\n”);
return (ERROR);
}

/* Get tank number entered by operator


*/

EXEC (&h_vars->tank) <- tank:value;

if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Tank number fetch failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* Translate answer value from action request


** to application-specific tank numbers.
*/

switch (h_vars->tank)

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-15
BCL Programming Example (continued)

{
case CHOICE_1_VALUE: /* Definitions for CHOICE_n_VALUE */
h_vars->tank = 1; /* are found in Action Request */
break; /* header file ac_defs.h. */

case CHOICE_2_VALUE:
h_vars->tank = 4;
break;

default:
XMT_ERR (”charge.bcl”, 9999, ”Invalid tank”);
print_trace_message (”Invalid tank\n”);
break;
}

/* Print translated tank selection to trace file


*/

sprintf (msg, ”Tank = %d\n”, h_vars->tank);


print_trace_message (msg);

/* Update tank selection in database


*/

EXEC tank:value <- (&h_vars->tank);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Tank number value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* Update tank selection for display


*/

EXEC charge6_4:value <- (&h_vars->tank);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Tank number display value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

G-16 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
/* Trigger request for parameter confirmation
*/

if (bc_trigger_request (”COMMIT”) == ERROR)


{
sprintf (msg, ”Request COMMIT trigger failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
print_trace_message (”Request COMMIT triggered OK.\n”);
}
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-17
BCL Programming Example (continued)

/* Event #5
**
** When the commit request has been answered and confirmed,
** initiate the batch. If the request was not confirmed
** or the initiation operation fails, reset all the information
** collected for the prospective batch. In either case,
** reset the new batch request trigger.
*/

ON EVENT commit_rst:command:0x8000 RESET


{
static CHAR var_id [] = NEW_BATCH_VAR_HANDLE;

SINT16 committed = 0x4000;


SINT16 rejected = 0;
SINT16 cmd_reset = 0;

SINT16 answer;
CHAR batch_id [T_B_I_D_LENGTH];
CHAR system_id [T_B_I_D_LENGTH];
CHAR unit_name [T_TAGS_LENGTH];
CHAR msg [TRACE_MESSAGE_LENGTH];

print_trace_message (”Request COMMIT has been answered.\n”);

INIT_VAR h_vars, var_id;

if (h_vars == NULL)
{
print_trace_message (”h_vars allocation failed.\n”);
return (ERROR);
}

/* Get operator’s response to confirmation request


*/

EXEC (&answer) <- commit:value;

if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Confirmation fetch failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* If batch start-up parameters are confirmed,


** initiate the batch.
*/

G-18 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
if (answer == CHOICE_1_VALUE)
{
/* Print batch parameters to trace file
*/

print_trace_message (”Batch data confirmed.\n”);


sprintf (msg, ” ID = %d, tank = %d, level = %d\n”,
h_vars->batch_id_number,
h_vars->tank,
h_vars->level);
print_trace_message (msg);

/* Update batch status on display


*/

EXEC charge6_1:value <- (&committed);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Confirmation value replace failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}

/* Initiate the batch by calling custom C function


*/

if (initiate_new_batch (h_vars->batch_id_number, h_vars->tank,


system_id, batch_id, unit_name)
== ERROR)
{
XMT_ERR (”charge.bcl”, BATCH_INIT_ERR, ”Batch initiate failed”);
print_trace_message (”Batch initiate failed.\n”);
}
else
{
/* Set up b_vars variable to hold batch parameter info
** for use by batch termination event block.
*/

INIT_VAR b_vars, system_id;

if (b_vars == NULL)
{
print_trace_message (”b_vars allocation failed.\n”);
return (ERROR);
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-19
BCL Programming Example (continued)

/* Store batch_id, unit_name, and level selection


** in variable block.
*/

(VOID) strcpy (b_vars->batch_id, batch_id);


(VOID) strcpy (b_vars->unit_name, unit_name);
b_vars->level = h_vars->level;

/* Dispose of intermediate parameter storage


*/

DROP_VAR h_vars, var_id;

(VOID) sprintf (msg,


”Batch ID = %s, system ID = %s, unit = %s, level = %d\n”,
b_vars->batch_id,
system_id,
b_vars->unit_name,
b_vars->level);
print_trace_message (msg);
}
}
else
{
/* Operator did not confirm batch start-up parameters;
** clear all display fields.
*/

print_trace_message (”Batch data rejected.\n”);


EXEC charge6_1:value <- (&rejected);
EXEC charge6_2:value <- (&rejected);
EXEC charge6_3:value <- (&rejected);
EXEC charge6_4:value <- (&rejected);
DROP_VAR h_vars, var_id;
}

/* Reset the new batch request trigger.


*/

EXEC start_00:command <- (&cmd_reset);

G-20 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Charge initiator reset failed, %d\n”, errno);
print_trace_message (msg);
return (ERROR);
}
return (NO_ERROR);
}
/* This example does not include processing
** associated with the batch once it’s been initiated.
** Event blocks to support that part of the operation
** can be coded here or in a second BCL program file.
*/

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-21
BCL Programming Example (continued)

/* Event #6
**
** When a batch completion button is activated,
** determine which batch is completing and get it’s ID.
** Put the ID in the report mailbox.
** Set the trigger for the batch completion report.
**
** Note: Tag do_0 is part of the UNIT for tank 1.
** Tag do_4 is part of the UNIT for tank 4.
*/
ON EVENT do_0:command:0x0001
OR do_4:command:0x0001
{
static CHAR tag_do_0 [] = ”do_0”;
static CHAR tag_do_4 [] = ”do_4”;
SINT16 reset = 0;
CHAR custom_batch_id [T_B_I_D_LENGTH];
CHAR msg [TRACE_MESSAGE_LENGTH];

CHAR *tag_name;

/* Determine which tank just completed a batch;


** do_0 -> tank 1; do_4 -> tank 4
*/

switch (BCL_block_event_id)
{
case 0:
tag_name = tag_do_0;
break;

case 1:
tag_name = tag_do_4;
break;

default:
(VOID) sprintf (msg, ”Invalid block_event_id, %d\n”,
BCL_block_event_id);
tag_name = NULL;
break;
}

if (tag_name != NULL)
{
(VOID) sprintf (msg, ”Terminating tag is %s\n\n”, tag_name);
print_trace_message (msg);

G-22 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
/* Get the current batch ID
** for the tag that triggered this block.
** The tag’s batch ID was initialized
** when the unit was assigned to the batch.
*/

if (bc_get_batch_id (tag_name, custom_batch_id) == ERROR)


{
(VOID) sprintf (msg, ”bc_get_batch_id failed, %d\n”, errno);
print_trace_message (msg);

return (ERROR);
}
else
{
/* Store batch ID in ”mailbox” so report can get it.
*/

EXEC tex1:text_1 <- (custom_batch_id);

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Batch ID mailbox replace failed, %d\n”, errno);
print_trace_message (msg);
}

/* Trigger the report.


*/

LATCH tex1:status:active;

if (BCL_error == ERROR)
{
(VOID) sprintf (msg,
”Report trigger latch operation failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
print_trace_message (”Report trigger set.\n”);
}
}
}

return (NO_ERROR);
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-23
BCL Programming Example (continued)

/* Event #7
**
** When the report finishes executing,
** clean up and terminate the batch.
** The report is responsible for resetting
** the ”active” bit of tag tex1’s STATUS attribute.
*/
ON EVENT tex1:status:active RESET
{
CHAR custom_batch_id [T_TEXT_TEXT_1_LENGTH];
CHAR system_id [T_B_I_D_LENGTH];
CHAR msg [TRACE_MESSAGE_LENGTH];
SINT16 reset = 0;
print_trace_message (”Report completion signal received.\n”);

/* Fetch batch ID from report mailbox


*/

EXEC (custom_batch_id) <- tex1:text_1;

if (BCL_error == ERROR)
{
(VOID) sprintf (msg, ”Batch ID fetch failed, %d\n”, errno);
print_trace_message (msg);

return (ERROR);
}

/* Print ID of completing batch in trace file


*/

(VOID) sprintf (msg, ”Batch ID = %s\n”, custom_batch_id);


print_trace_message (msg);

/* Get system ID of completing batch


*/

if (bc_get_system_id (custom_batch_id, system_id) == ERROR)


{
(VOID) sprintf (msg, ”bc_get_system_id failed, %d\n”, errno);
print_trace_message (msg);
}
else
{
/* Release all units tied to the completing batch
*/

G-24 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
if (bc_release_all (system_id) == ERROR)
{
(VOID) sprintf (msg, ”bc_get_system_id failed, %d\n”,
errno);
print_trace_message (msg);
}
else
{
/* Command batch to completed state;
** Definitions for batch commands (i.e. B_CMD_*)
** are found in enum_types/b_cmd.t
*/

(VOID) bc_request_batch_state (system_id, B_CMD_COMPLETE);

/* Release batch tag, deallocate variable storage,


** and clear display fields on graphic.
*/

(VOID) bc_request_batch_state (system_id, B_CMD_REMOVE);

DROP_VAR b_vars, system_id;

EXEC charge6_1:value <- (&reset);


EXEC charge6_2:value <- (&reset);
EXEC charge6_3:value <- (&reset);
EXEC charge6_4:value <- (&reset);
}
}

return (NO_ERROR);
}

/* End of BCL source file, charge.bcl */

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-25
BCL Programming Example (continued)

The following pages contain the C source code for creating unit and batch
tags required to initiate a new batch. This program is called from Event
Block #5 of the charge.bcl program.

/* =========================================== */
/* Source for C function, initiate_new_batch() */
/* Source file == inb.c */
/* =========================================== */

/*
**initiate_new_batch
**
**.DESCRIPTION
** This function performs the operations necessary to establish a new
batch.
**
**.METHOD
** Validate input parameters.
** Allocate a batch tag.
** Generate custom batch ID string.
** Assign custom ID to batch.
** Make unit name from tank number.
** Assign unit to batch.
** Set unit start time.
**
**.NOTES
** Compile this file using:
** cc -c -O -I/usr/tistar/include -I/usr/tistar/hist/batch/include inb.c
** Archive object file for BCL link using: usrbcl inb.o
*/

/* ======================================================= */
/* In addition to the header files listed in Section 3.5, */
/* which are inserted automatically when you compile, */
/* this program needs the following #include statements: */
/* ======================================================= */

#include <err_base.h>
#include <enum_types/tag_xref.r>

INT initiate_new_batch (id, tank, sys_id, batch_id, unit_name)

G-26 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
SINT16 id; /* IN: Numeric batch identifier */
SINT16 tank; /* IN: Tank ID number */
CHAR *sys_id; /* OUT: Internal (system) batch identifier */
CHAR *batch_id; /* OUT: Custom batch ID */
CHAR *unit_name; /* OUT: Unit (tag) name */

{
CHAR desc [T_T_DESC_LENGTH];

/* Check for null parameters


*/

if ((sys_id == NULL) || (batch_id == NULL) || (unit_name == NULL))


{
errno = BCL_NULL_ARG;
XMT_ERR (”initiate_new_batch”, errno, ”Null parameter(s)”);
return (ERROR);
}

/* Allocate a batch tag


*/

if (bc_allocate_batch (sys_id, desc) == ERROR)


{
XMT_ERR (”initiate_new_batch”, errno, ”bc_allocate_batch failed”);
return (ERROR);
}

/* Generate ID string
**
** Algorithms for generating custom batch ID strings
** are usually application-specific.
** In this case, the custom ID is generated
** by appending the suffix ”-87”
** to the ID number entered by the operator.
*/

(VOID) sprintf (batch_id, ”%d-87”, id);

/* Assign custom ID to batch


*/

if (bc_assign_id (batch_id, sys_id) == ERROR)


{
XMT_ERR (”initiate_new_batch”, errno, ”bc_assign_id failed”);
(VOID) bc_free_batch (sys_id);
return (ERROR);
}

SIMATIC PCS 7 OSx 4.1.1 Batch Programming BCL Application Programming Example G-27
BCL Programming Example (continued)

/* Make unit name from tank number;


** unit name is the same as unit tag name.
*/

(VOID) sprintf (unit_name, ”R%d”, tank);

/* Assign unit to batch


*/

if (bc_assign (unit_name, sys_id) == ERROR)


{
XMT_ERR (”initiate_new_batch”, errno, ”bc_assign failed”);
(VOID) bc_free_batch (sys_id);
return (ERROR);
}

/* Set unit start time


*/

if (bc_set_unit_start (unit_name) == ERROR)


{
XMT_ERR (”initiate_new_batch”, errno, ”bc_set_unit_start failed”);
(VOID) bc_release_all (sys_id);
(VOID) bc_free_batch (sys_id);
return (ERROR);
}

return (NO_ERROR);
}

/* End of custom C function source file, inb.c */

G-28 BCL Application Programming Example SIMATIC PCS 7 OSx 4.1.1 Batch Programming
Index
components
A BCL, 1-4
Accessing controller-requested commands, 1-4, 5-2
batch directory, 7-8 logs and reports, 1-5
batch logs/reports, 6-3 prerequisites, 1-8
batch unit display, 7-20 responsibilities, 1-2
BCL Program Administration dialog box, 4-2 releasing units, 7-13
unit faceplate, 7-26 security privilege, E-2
unit tag detail (batch), 7-22 database tables, F-2
splitting, 7-17
Active batch starting, 7-14
directory, 7-8 tag detail, viewing, 7-10
tags, 7-9 tracking, 5-2
Assigning unit faceplate, displaying, 7-26
batch tag attributes, A-2 unit tag detail, displaying, 7-22
batch unit tags, A-7 unit tag groups, displaying, 7-18
batch units, 7-12 Batch control language (BCL), 1-4, 3-2
security privileges, batch control, E-2 control functions, C-4
bc_activate_autolog, C-6
bc_add_batch_list_entry, C-7
B bc_allocate_batch, C-8
bc_assign, C-9
Batch bc_assign_graphic, C-10
assigning units, 7-12 bc_assign_id, C-11
changing mode, 7-16 bc_batch_list_entry_exists, C-12
changing state, 7-14 bc_clear_unit_elements, C-13
changing unit mode, 7-25 bc_copy, C-14
changing unit state, 7-24 bc_create_batch_list, C-15
configuration bc_deactivate_autolog, C-16
committing, 7-7 bc_destroy_all_batch_lists, C-17
prerequisites, 2-2, 7-2 bc_destroy_batch_list, C-18
using batch ID, 7-4 bc_exit, C-19
data, hierarchy, 1-3 bc_get_batch_id, C-20
displaying active batch tag group, 7-9 bc_get_batch_id_entry, C-21
displaying active batches, 7-8 bc_get_batch_mode, C-22
ending, 7-18 bc_get_batch_state, C-23
graphic, viewing, 7-10 bc_get_custom_id, C-24
log destination, 2-5 bc_get_printer_mask, C-25
logs and reports, 1-5, 6-2 bc_get_system_id, C-26
operation, viewing, 7-10 bc_get_unit_mode, C-27
OSx database tables, F-3 bc_get_unit_state, C-28
processing bc_load, C-29
component interaction, 1-6

Index-1
Batch control language (BCL) Batch control language (BCL)
control functions (continued) program control functions
bc_lock_batch_id, C-30 bcl_enable_auto_append, D-7
bc_log_comment, C-31 bcl_enable_error_on_empty_delete, D-8
bc_log_operation, C-32 bcl_enable_error_on_not_found, D-9
bc_log_value, C-33 bcl_error_on_empty_delete, D-10
bc_print_batch_list, C-34 bcl_error_on_not_found, D-11
bc_release, C-35 print_trace_message, D-12
bc_release_all, C-36 programming
bc_release_graphic, C-37 avoiding invalid bit names, 3-31, 3-35
bc_remove_batch_list_entry, C-38 compiling, 4-4, 4-14
bc_request_batch_mode, C-40 defining variables, 3-13
bc_request_batch_state, C-42 example, G-2
bc_request_unit_mode, C-44 installing, 4-8, 4-16
bc_request_unit_state, C-46 mapping tag names, 3-14
bc_scale_recipe, C-48 modifying, 4-6
bc_select, C-49 prerequisites, 3-4
bc_set_batch_end, C-50 removing, 4-11, 4-12, 4-13, 4-22
bc_set_batch_operation, C-51 reserved keywords, 3-10
bc_set_batch_product, C-52 runtime options, 4-6
bc_set_batch_start, C-53 starting/halting, 4-9, 4-19
bc_set_first_batch_list_entry, C-54 steps, 3-9
bc_set_log_destination, C-55 translating to C language, 3-12
bc_set_next_batch_list_entry, C-56 triggering event blocks, 3-20
bc_set_unit_end, C-58 UNIX command line options, 4-7, 4-20
bc_set_unit_operation, C-59 reports
bc_set_unit_start, C-60 editor functions, 6-4
bc_split_batch, C-61 generating, 6-4
bc_trigger_request, C-62 running program
bc_unlock_batch_id, C-63 automatically, 4-9
database, accessing tables, F-2 control functions, 3-34, D-2
errors, 3-31 manually, 4-9
error handling code, 3-35 statements
invalid bit names, 3-31 #include, 3-12
event block instructions, user_msg, F-4 define, 3-13
halting program, 4-10 on event, trigger_spec options, 3-20
library functions, controlling batch unit map, 3-14
operations, 3-32 user_msg, F-4
multiple-station systems, 3-7
Batch ID, 6-2, C-4
networked tag:attributes, 3-6
assigning, 7-5
program components, 3-3
log destination, 7-6
program control functions
bcl_auto_append, D-3 Batch request commands, 5-2, 5-3
bcl_disable_auto_append, D-4 Batch tag (BCH), A-2
bcl_disable_error_on_empty_delete, D-5
bcl_disable_error_on_not_found, D-6 BCL. See Batch control language

Index-2
C E
Cascaded menu, 1-11 Error, batch control language (BCL)
error handling code, 3-35
Changing
invalid bit names, 3-31
batch mode, 7-16
batch state, 7-14 Event block
batch unit mode, 7-25 available instructions, 3-24
batch unit state, 7-24 example, 3-30
BCL program, 4-6 syntax, 3-16
trigger_spec options, 3-20
Compiling, BCL program, 4-4
from UNIX command line, 4-14 Executing, BCL program, from UNIX command
line, 4-17
Configuration
batch, 2-2
committing, 7-7
prerequisites, 7-2 F
using batch ID, 7-4
planning sheets, B-1 Faceplate
unit tag, 2-6 active batch tags, 7-9
batch unit, 7-26
Controlling
batch operation, C-4
with library functions, 3-32
BCL program, 3-34, D-2
H
from UNIX command line, 4-17 Halting, BCL program, 4-10
Creating
batch requests, 5-2
BCL program, 3-9 I
event blocks, BCL program, 3-16, F-4
ID. See Batch ID
Include statement, batch control language
D (BCL), 3-12

Data, batch, hierarchy, 1-3 Installing, BCL program, 4-8


from UNIX command line, 4-16
Database event triggers, 3-19
Define statement, batch control language
(BCL), 3-13 K
Defining
batch units, 2-6 Keyword, batch control language (BCL), 3-10
variables, BCL program, 3-13
Deleting
batch, 7-18
L
BCL program, 4-12 Library functions, batch control language,
from UNIX, 4-22 controlling batch operations, 3-32
Directory, active batch, 7-8

Index-3
Linking
APT extension to unit tag, 2-7
R
unit tags to process I/O tags, 2-7 Radio button, 1-10
Log destination, batch, 2-5, 7-6 Releasing, units from a batch, 7-13
Logging batch information, 6-2 Removing
batch, 7-20
BCL program, 4-11, 4-22
M Report, batch control language (BCL), 6-4
Mapping units, BCL program, 3-14 Running BCL program from UNIX command
line, 4-17

N
S
Navigational tools, 1-10
cascaded menu, 1-11 Save pushbutton, 1-11
pushbutton, 1-10
Saving
radio button, 1-10
ok pushbutton, 1-11
slider, 1-10
save pushbutton, 1-11
text browser, 1-10
toggle button, 1-10 Security privilege, functions
batch commands, E-2
batch modes, E-2, E-3
batch unit commands, E-3
O database tables, F-2
OK pushbutton, 1-11 Slider, 1-10
On event statement, batch control language Special event block identifiers, 3-18
(BCL), trigger_spec options, 3-20
Splitting a batch, 7-17
Starting/halting, BCL program, 4-9
P from UNIX command line, 4-19
Starting/stopping, batch, 7-14, 7-18
Planning
batch program, 2-2
BCL program, 3-4
Planning sheets, configuration, B-1
T
PLC. See Controller models Tag detail, display
batch (BCH), 7-10
Primary, new primary command, and BCL unit (UNIT), 7-22
program, 4-3
Tag group
Printer, log destination, batch, 7-6 active batch, displaying, 7-9
Process control, batch, 1-2 batch units, displaying, 7-20
Pushbutton, 1-10 Text browser, 1-10

Index-4
Toggle button, 1-10 Updating, BCL program, 4-13
Troubleshooting
BCL errors, 3-35
halting BCL program, 4-10 W
WHERE clause
delete format, 3-29
U replace format, 3-28
retrieve format, 3-27
Unit map statement, batch control language
(BCL), 3-14 WHERE clauses, referencing controller-resident
data, 3-19
Unit tag (UNIT), A-7
APT extensions, 2-7
configuration, 2-6

Index-5
Index-6
Customer Response

We would like to know what you think about our user manuals so that we can serve you better.
How would you rate the quality of our manuals?

Excellent Good Fair Poor


Accuracy
Organization
Clarity
Completeness
Graphics
Examples
Overall design
Size
Index

Would you be interested in giving us more detailed comments about our manuals?

Yes! Please send me a questionnaire.

No. Thanks anyway.

Your Name:

Title:

Telephone Number: ( )

Company Name:

Company Address:

Manual Name: SIMATIC PCS 7 OSx 4.1.1 Batch Programming Manual Edition: Original
Manual Assembly Number: 2806854-0001 Date: 1/01
Order Number: 6ES7 6550XX048BC4
FOLD

SIEMENS ENERGY & AUTOMATION INC NO POSTAGE


3000 BILL GARLAND ROAD NECESSARY
P O BOX 1255 IF MAILED
IN THE
JOHNSON CITY TN 37605--1255
UNITED STATES

BUSINESS REPLY MAIL


FIRST CLASS PERMIT NO.3 JOHNSON CITY, TN

POSTAGE WILL BE PAID BY ADDRESSEE

ATTN TECHNICAL COMMUNICATIONS M/S 519


SIEMENS ENERGY & AUTOMATION INC
P O BOX 1255
JOHNSON CITY TN 37605--1255

FOLD

Você também pode gostar