Ba2

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ba2 as PDF for free.

More details

  • Words: 73,116
  • Pages: 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 situation 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 Cover/Copyright History/Effective Pages Trademarks iii — xvii 1-1 — 1-11 2-1 — 2-7 3-1 — 3-36 4-1 — 4-22 5-1 — 5-6 6-1 — 6-4 7-1 — 7-26 A-1 — A-10 B-1 — B-1 C-1 — C-63 D-1 — D-12 E-1 — E-3 F-1 — F-5 G-1 — G-28 Index-1 — Index-5 Registration

Description Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original Original

Pages

Description

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? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Components of Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interaction of Batch Processing Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-2 1-2 1-4 1-6

1.2

Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-8 1-9

1.3

Working with Screen Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Navigational Tools to Enter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-10 1-10

Chapter 2

Configuring OSx for Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-1

2.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Does OSx Configuration Change? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-2 2-2 2-2 2-3

2.2

Configuring Security Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-4

2.3

Configuring the Batch Log Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-5 2-5 2-5 2-5

2.4

Configuring Unit Tags and Establishing Links to Other Tags . . . . . . . . . . . . . . . . . . . . . . . Defining Units and Their Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuring Tag Capacities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-6 2-6 2-7

Chapter 3

Controlling Batch Operation Using BCL . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-1

3.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Is the Batch Control Language? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Components of a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-2 3-2 3-3

3.2

Planning a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Handling of Network Writes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Considerations for Multiple-Station Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-4 3-4 3-5 3-6 3-7

Contents

iii

3.3

Creating a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Create a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referencing Tag Names in BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-9 3-9 3-9

3.4

Using Keywords to Write a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reserved Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-10 3-10

3.5

Using #include Statements in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Translating BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-12 3-12

3.6

Using Variable Definitions in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Variable Definition Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-13 3-13 3-13 3-13

3.7

Using Unit Mapping in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unit Mapping Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-14 3-14 3-14 3-15

3.8

Using Event Blocks in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Special Event Block Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Database Event Trigger Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referencing Controller-Resident Data in WHERE Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block trigger_spec Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Retrieve Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Replace Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Bit Conversion Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invalid Bit Type Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-16 3-16 3-17 3-17 3-18 3-19 3-19 3-20 3-24 3-27 3-28 3-29 3-30 3-31 3-31

3.9

Controlling Batch Operation with Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-32

3.10

Controlling the Operation of BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-34 3-34

3.11

Creating BCL Code to Handle Error Conditions in Event Blocks . . . . . . . . . . . . . . . . . . . . BCL Error Handling Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-35 3-35

Chapter 4

BCL Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-1

4.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Managing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL and Station Role Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Primary Role Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-2 4-2 4-3 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Cannot Be Halted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-9 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Debug Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-14 4-15

4.10

Installing a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-16

4.11

Controlling BCL Programs from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Executing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Halting and Starting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-17 4-17 4-19 4-20

4.12

Removing and Deleting a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . Removing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-22 4-22 4-22

Chapter 5

Batch Operations and the Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-1

5.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Controller Program and OSx Batch Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How Does the Controller Program Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Request Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-2 5-2 5-2 5-2 5-2

5.2

Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List of Batch Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-3 5-3

Chapter 6

Batch Logs and Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-1

6.1

Understanding Batch Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Is a Batch Log? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Internal ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-2 6-2 6-2

6.2

Guidelines for Generating Batch Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Report Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Report Format Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-4 6-4 6-4 6-4

Contents

v

Chapter 7

Running and Supervising a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-1

7.1

Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-2 7-3

7.2

Configuring a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-4 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Batch-Related Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Batch-Related Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-10 7-10 7-10 7-10

7.6

Assigning Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-12

7.7

Releasing Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-13

7.8

Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the State of a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-14 7-14 7-14

7.9

Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-16

7.10

Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-17

7.11

Ending a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Completing or Aborting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Removing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-18 7-18 7-19

7.12

Viewing Batch-Related Tag Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-20

7.13

Viewing the Unit Tag Detail and Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the State of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the Mode of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing the Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-22 7-22 7-24 7-25 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Custom and Internal Batch IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

C-4 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Who Should Read This Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Custom Database Table Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Privilege Masks of Standard Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

F-2 F-2 F-2 F-3

F.2

USER_MSG Event Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the USER_MSG Event Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

F-4 F-4 F-4

Appendix G G.1

BCL Application Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . G-1

BCL Programming Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

G-2 G-2 G-2 G-4 G-5 G-5 G-9

Index-1

Contents

ix

List of Figures 1-1 1-2 1-3 1-4

Responsibilities of SIMATIC PCS 7 OSx During Batch Processing . . . . . . . . . . . . . . . . . . . . . . Hierarchy of OSx Batch Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Processing Components and Their Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tasks for Configuring OSx Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-2 1-3 1-6 1-9

2-1 2-2

Tasks for Configuring Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example Unit Tag Configuration Using a Spreadsheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-3 2-6

3-1 3-2 3-3 3-4

BCL Program Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tasks for Developing and Installing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample BCL Program with #include Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample BCL Program with Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-3 3-5 3-12 3-36

4-1 4-2 4-3 4-4 4-5 4-6 4-7 4-8

Displaying the BCL Program Administration Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compile BCL Program Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modifying a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Installing a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Halting a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Removing a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Updating the BCL Program List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-3 4-4 4-6 4-8 4-9 4-11 4-12 4-13

6-1 6-2

Example of Batch ID Fields in the Batch Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Log File Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-2 6-3

7-1 7-2 7-3 7-4 7-5 7-6 7-7 7-8 7-9 7-10 7-11 7-12 7-13 7-14 7-15 7-16 7-17

Recommended Order of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Committing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Active Batch Directory Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displaying Active Batch Tag Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample Batch Tag Detail Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Assigning Units to a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Releasing Units from a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ending a Batch Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displaying Assigned Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displaying Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing Unit Tag State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the Unit Operational Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-3 7-4 7-7 7-8 7-9 7-11 7-12 7-13 7-15 7-16 7-17 7-18 7-21 7-23 7-24 7-25 7-26

x

Contents

A-1 A-2

Bit Locations for Batch Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Locations for UNIT Status Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A-4 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 3-2 3-3 3-4

BCL Keywords (Outside Event Blocks) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Keywords (Inside Event Blocks) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-10 3-11 3-32 3-34

4-1 4-2

Modify BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-7 4-20

5-1

Batch Controller Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-3

A-1 A-2 A-3 A-4 A-5 A-6 A-7 A-8 A-9 A-10 A-11 A-12

BCH Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Locations for Batch Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Status Bit Settings for Batch States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Status Bit Settings for Batch Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values for the Batch Command Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values for the Batch MODE_CMD Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UNIT Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Locations for Unit Status Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Status Bit Settings for Unit States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Status Bit Settings for Batch Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values for the Unit Command Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values for the Unit MODE_CMD Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A-2 A-3 A-4 A-5 A-6 A-6 A-7 A-8 A-9 A-9 A-10 A-10

E-1 E-2 E-3 E-4

Security Privileges for Batch Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Security Privileges for Batch Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Security Privileges for Unit Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Security Privileges for Unit Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

E-2 E-2 E-3 E-3

G-1 G-2 G-3

Example Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example Action Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Source Code Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

G-4 G-5 G-5

xii

Contents

Preface New Features of PCS 7 OSx

SIMATIC PCS 7 OSx Release 4.1.1 supports the following new features: 

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 in the Manual Set

The procedures in the various manuals give you step-by-step instructions 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 Logoff Logon OSx Terminal

Change System State Operate Offline Shutdown OSx Shutdown OSx and Linux OK

xiv

Preface

Cancel

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Purpose of This Manual

The SIMATIC PCS 7 OSx Batch Programming Manual describes how to 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

xvi

Preface

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.

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.

If You Need Help



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 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? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Components of Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interaction of Batch Processing Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-2 1-2 1-4 1-6

1.2

Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-8 1-9

1.3

Working with Screen Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Navigational Tools to Enter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-10 1-10

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Overview of Batch Processing

1-1

1.1

What Is OSx Batch Processing? 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.

Overview

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 Station

Supervisory 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 remote

Offers configurable action 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

1-2

Responsibilities of SIMATIC PCS 7 OSx During Batch Processing

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

Tag

Tag

Unit

Tag

Unit 1

Unit 2

Figure 1-2

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Tag

Unit

Tag

Tag

Tag

Tag

Unit 3

Hierarchy of OSx Batch Data

Overview of Batch Processing

1-3

What is Batch Processing? (continued) Components of Batch Processing

To enable OSx to supervise and manipulate batch-related data, batch 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 Processing Components

Supervisory Station (Primary)

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

Operator Station Display

AA

E

Action Requests

B

Batch Log

C

D

Batch Control Language

F 6 F

Batch Reports

H

I

J

L

Historical Trends

G

Tag Configuration

K

Database

Control Node

Figure 1-3

1-6

Batch Processing Components and Their Interactions

Overview of Batch Processing

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Table 1-1

Interactions between Batch Processing Components

Interaction

Description

A

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 Operator Station Display. If a batch requires operator interaction, an action request can prompt the operator for a response.

B

This interaction logs an action request to the batch log if a tag in the action request is part of a batch.

C

This interaction enables you to develop a program of batch control instructions that pull 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.

D

This interaction enables you to create report formats that pull data from a batch log and 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.

E

This interaction enables you to create action requests that constantly monitor the appropriate attributes in the OSx database for any changes. If any changes occur in the monitored attributes, OSx triggers the corresponding action requests.

F

This interaction uses changes to tags from the OSx database to generate a batch log for the batch associated with the changing tags.

G

This interaction causes data changes in the OSx database to be reflected in the corresponding graphics. While OSx is in the Operate state, any change that you enter through the Operator Station Display updates the database.

H

This interaction enables you to develop a program of batch control instructions that pull specific data from the OSx database, manipulate the data (if required), and place the data back in the database.

I

This interaction enables you to create report formats that pull data from the OSx database and create customized reports. You can also write data to the database with the #writetag function.

J

This interaction enables you to create report formats that pull historical trend data from the OSx database and create customized reports.

K

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 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.

L

This interaction causes data changes in the OSx database to be reflected in the corresponding 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.

1-8



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.

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 Recipe Repeat

OSx

var1:=A*B mv var1 C z:=C/D^^2

Configure OSx for a batch.

Develop a program that supervises and/or controls a batch.

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 Tools to Enter Data

Use the navigational tools to display menus and lists, choose options, and 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Does OSx Configuration Change? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-2 2-2 2-2 2-3

2.2

Configuring Security Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-4

2.3

Configuring the Batch Log Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-5 2-5 2-5 2-5

2.4

Configuring Unit Tags and Establishing Links to Other Tags . . . . . . . . . . . . . . . . . . . . . . . Defining Units and Their Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuring Tag Capacities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-6 2-6 2-7

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Configuring OSx for Batch Processing

2-1

2.1

Overview

Does OSx Configuration Change?

The configuration of your system remains essentially unchanged in batch processing. You still configure forms, symbols, graphics, and animation 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.

2-2



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.

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 Configuration

Refer to the SIMATIC PCS 7 OSx System Administration Manual for 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

T A

Control Node PC1

Tag Type

Tag

Description

UNIT

UNIT1

Bake_Unit_2

Process Manual Group Set 0xffffffff

A A A A A

Parent

Attribute

Memory

Locations Upload Twenty %

STATUS COMMAND MODE_CMD

V100 V101 V102

1 1 1

N N N

BCH_REQ BCH_REQ_ INFO BCH_REQ_ RESP

V103

1

V104

8

V112

1

N

Autolog

N N N

N N N

N

N

N

N

N

N

N

N

Init Value

E

Figure 2-2

Defining Units and Their Links

Example Unit Tag Configuration Using a Spreadsheet

In preparing to define a unit to the OSx system, follow these guidelines. 

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 OSx Type

Unit Tag Types and Extensions

APT Extension

OSx Attributes

Unit tag on OSx

Unit name (no extension)

UNIT

Descriptor

Unit name.STATUS

Status

Current status

Unit name.COMMAND

Command

Command request

Unit name.MODE_CMD

Mode_cmd

Mode request

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 Capacities

To reconfigure tag capacities, refer to the SIMATIC PCS 7 OSx Process 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Is the Batch Control Language? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Components of a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-2 3-2 3-3

3.2

Planning a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-4

3.3

Creating a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Create a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referencing Tag Names in BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-9 3-9 3-9

3.4

Using Keywords to Write a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-10

3.5

Using #include Statements in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Translating BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-12 3-12

3.6

Using Variable Definitions in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Variable Definition Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-13 3-13 3-13 3-13

3.7

Using Unit Mapping in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unit Mapping Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-14 3-14 3-14 3-15

3.8

Using Event Blocks in a BCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Special Event Block Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Database Event Trigger Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Referencing Controller-Resident Data in WHERE Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block trigger_spec Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Retrieve Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Replace Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Delete Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Bit Conversion Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invalid Bit Type Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3-16 3-16 3-17 3-17 3-18 3-19 3-19 3-20 3-24 3-27 3-28 3-29 3-30 3-31 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 Control Language?

The Batch Control Language (BCL) consists of several programming tools 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 BCL Program

A typical BCL program consists of two major types of statements: definition 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.

Definition statements

Variable definitions enable the BCL program to set up a block (structure) of variables that can be used throughout the program.

BCL program* #include statements Variable definitions

Unit maps enable the BCL program to establish unit element names that are used to pass process information from one unit to another.

Action statements

Event blocks enable the BCL program to perform activities when specific events occur. Any bit transition or value change can trigger an event.

Figure 3-1

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Unit maps Event blocks * The program components must appear in the order shown here.

BCL Program Components

Controlling Batch Operation Using BCL

3-3

3.2

Planning a BCL Program

Prerequisites

3-4

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.

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 mv var1 C z:=C/D^^2

Use any of the editors to compose a BCL program source file.

01001110 01110010 00001011 11000001 01010000

01001110 01110010 00001011 11000001 01010000

01001110 01110010 00001011 11000001 01010000

Figure 3-2

Translate and compile the program. Correct any errors that might occur.



Validate the program. Correct any errors that might occur.

Translate, compile, and install the BCL program.

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 Network Writes

If your BCL program writes networked tag:attributes to a given control 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 Multiple-Station Systems

Keep these points in mind when you write a BCL program for a system with more than one supervisory station. 

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.

3-8



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.

Controlling Batch Operation Using BCL

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

3.3

Creating a BCL Program

Steps to Create a BCL Program

To create a BCL program, follow these steps. 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 Tag Names in BCL Programs

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

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 Keywords

The Batch Control Language consists of several reserved keywords that 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

3-10

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

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 Programs

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

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>

. . .

Translator: Converts BCL to C code and inserts #include statements

#include #include #include #include #include #include #include . . .

Figure 3-3

3-12

Sample BCL Program with #include Statements

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 Syntax

DEFINE var_block_name FOR ALL

Parameter Description

var_block_name

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 Syntax

UNIT MAP unit_name { tag:attr AS element_name; }

Parameter Descriptions

unit_name

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 Definition

This section describes the BCL statements that enable you to create event 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 Description

trigger_spec_0 -- trigger_spec_n

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 Block Identifiers

The BCL_special_event_id variable consists of an identifier that indicates 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 Trigger Values

When a database event triggers an action block, the data value causing the 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 Controller-Resident Data in WHERE Clauses

Queries that reference controller-resident data as part of the key for selecting tuples from the database usually take longer than queries where all components of the key are resident in the OSx station. The extra time is 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 trigger_spec Options

The following trigger_spec options are available for the ON EVENT statement: 

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 trigger_spec Options (continued)

The following trigger_spec options are available for the ON EVENT statement: 

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

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 inputqueue 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 Instructions

The following instructions are available for the event block controlled by the 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 Instructions (continued)

The following instructions are available for the event block controlled by the ON EVENT statement: 

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 Example

The following example defines an event block that executes when the 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 Conversion Error

BCL runtime routines must convert the contents of the bit position field in a 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

 Invalid Bit Type Examples

Your BCL program terminates.

The BCL database reference statements with bit position fields include: 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 bc_set_unit_end

Set list position to next entry 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 Control Functions

In addition to the batch control functions described in Table 3-3, BCL offers 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 Code

OSx provides a built-in method for detecting error conditions. Your BCL 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

3-36

Controlling Batch Operation Using BCL

Sample BCL Program with Error Handling

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Chapter 4

BCL Administration 4.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Managing BCL Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL and Station Role Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Primary Role Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-2 4-2 4-3 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Cannot Be Halted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-9 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Debug Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-14 4-15

4.10

Installing a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-16

4.11

Controlling BCL Programs from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Executing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Halting and Starting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCL Program Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-17 4-17 4-19 4-20

4.12

Removing and Deleting a Program from the Command Line . . . . . . . . . . . . . . . . . . . . . . . Removing a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting a Program from the Operating System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4-22 4-22 4-22

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

BCL Administration

4-1

4.1

Overview

Managing BCL Programs

After you write a BCL program, you can manage it interactively from the 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

BCL and Station Role Changes

Displaying the BCL Program Administration Dialog Box

If a BCL Program Administration dialog box remains on the screen during 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 Change

Do not use BCL Program Administration during a role change to a new 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/ .exe, where 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

4-4

BCL Administration

Compile BCL Program Dialog Box

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/, where 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

4-6

BCL Administration

Modifying a BCL Program

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Table 4-1 Option

Inhibit Automatic Append

Run Time Options

Ignore Network Response

Report Delete Errors

Enable Trace Output

Output Options

Enable Debug Output

Output Directory

Modify BCL Program Options

Command Line Syntax

Description

--a

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 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.

--r

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 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.

--d

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 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.

--t

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 output is /usr/tistar/hist/batch/output.

--d

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 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.

Places the trace and verbose output files in the directory specified by the parameter output_dir. BCL normally places these output files in /usr/tistar/hist/batch/output. The output directory must exist on all --o output_dir 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

4-8

BCL Administration

Installing a BCL Program

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Halting a BCL Program

BCL Administration

4-9

Starting and Halting a Program Interactively (continued) BCL Program Cannot Be Halted

If a BCL program executes an infinite loop, it can never return to an idle 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 where 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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Removing a BCL Program

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

4-12

BCL Administration

Deleting a BCL Program

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Updating the BCL Program List

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 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 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 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 .bcl at the prompt. The system installs the BCL program. The 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 Program from the Operating System

You can execute a BCL program from the operating system command line. Typically, you do this operation from the command line when you are testing 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 .exe 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 Starting a Program from the Operating System

You can halt and start a BCL program from the operating system command line. To halt a program that has been started, enter the following command at the command line: bcl_admin -h .bcl To start a program that has been halted, enter the following command at the command line: bcl_admin -s .bcl

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

BCL Administration

4-19

Controlling BCL Programs from the Command Line (continued) Table 4-2 lists the BCL program options that you can specify when you 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.

BCL Program Options

Table 4-2

BCL Program Options

Option

Description

--a

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 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.

--d

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 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.

--e

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 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.

--o output_dir

Places the trace and verbose output files in the directory specified by the parameter output_dir. BCL normally places these output files in /usr/tistar/hist/batch/output.

--p db_path

--r

Accesses the database in the directory specified by the parameter db_path. This option is 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 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

--t

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 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.

--v

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 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.

--x

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 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 Program from the Operating System

You can remove a BCL program from the operating system command line. 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. If the program is running, you must halt the program before removing it. To remove a program, follow these steps.

Deleting a Program from the Operating System

1.

Select Controls ->OSx Terminal on the menu bar.

2.

Enter your login and password.

3.

Enter bcl_admin -r .bcl at the prompt. The system de-installs the BCL program.

You can delete a compiled BCL program from the operating system command line. The Delete feature deletes only a compiled 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. If the program is running, you must halt the program before deleting it. To delete a BCL program, follow these steps.

4-22

BCL Administration

1.

Select Controls ->OSx Terminal on the menu bar.

2.

Enter your login and password.

3.

Enter bcl_admin -d .bcl at the prompt. The system deletes the BCL program.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Chapter 5

Batch Operations and the Controller 5.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Controller Program and OSx Batch Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How Does the Controller Program Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Request Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-2 5-2 5-2 5-2 5-2

5.2

Batch Request Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List of Batch Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-3 5-3

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Batch Operations and the Controller

5-1

5.1

Overview

The Controller Program and OSx Batch Tracking

A mechanism has been devised to permit the controller program to contain the batch control, but still allow OSx to assist in batch tracking/reports. The mechanism is to use the following three attributes, available in the unit tag relation: 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) bch_req

How Does the Controller Program Work?

The controller program can set these attributes as needed to perform the appropriate connections between the control node and the OSx station. OSx 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 Commands

The bch_req can be set to valid batch and unit commands. Refer to Table 5-1 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 Response

5-2

Each time the bch_req is set to a batch or unit command, the OSx batch 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.

Batch Operations and the Controller

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

5.2

Batch Request Commands

List of Batch Requests

Table 5-1 lists controller batch requests. Table 5-1

bch_req name

bch_req value Hex Dec

Batch Controller Request Commands Contents of bch_req_info

Comments

new batch ID

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_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.

BCH_REQ_B_COMMIT

0xcf00 --12544

BCH_REQ_B_REMOVE

0xc000 --16384

The batch to which this unit is assigned sends the U_CMD_RELEASE command to all units assigned to it and then the batch is removed permanently.

0x9a00 --26112

product name

The batch to which this unit is assigned is given the product name indicated in bch_req_info. Then all units assigned to this batch are sent the U_CMD_START command.

batch ID

A new sub-batch is created and committed with the batch ID found in bch_req_info. This sub-batch is 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.

tag name

The tag name found in bch_req_info is assigned to the first encountered sub-batch with no units assigned that was split from the batch ID of the unit making the split assign request, then the tag is sent the U_CMD_ASSIGN command.

BCH_REQ_B_START

BCH_REQ_B_SPLIT

BCH_REQ_B_SPLIT_ASN

BCH REQ B ABORT BCH_REQ_B_ABORT

0xcB00 --13568

0xca00 --13824

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.

0xaf00 --20736 20736 tag name

BCH REQ B COMPLETE BCH_REQ_B_COMPLETE

The batch command B_CMD_ABORT is processed for the batch ID of the unit identified by tag name. The 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.

0xab00 --21760 21760 tag name

The batch command B_CMD_COMPLETE is processed for the batch ID of the unit identified by tag name. The 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 bch_req name

BCH REQ B HOLD BCH_REQ_B_HOLD

Batch Controller Request Commands (continued)

bch_req value Hex Dec

Contents of 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.

0x9d00 --25344 25344 tag name

BCH REQ B RESUME BCH_REQ_B_RESUME

0x8d00 --29440 29440 tag name

BCH REQ B SET ALARM BCH_REQ_B_SET_ALARM

BCH_REQ_U_ASSIGN

0x9e00 --25088 25088

The batch command B_CMD_RESUME is processed for the batch ID of the unit identified by tag name. The 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 identified by tag 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.

0x8e00 --29184 29184

0x1700 5888

The batch command B_CMD_HOLD is processed for the batch ID of the unit identified by tag name. The 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.

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.

tag name

BCH REQ B CLR ALARM BCH_REQ_B_CLR_ALARM

Comments

tag name

The batch command B_CMD_CLR_ALARM is processed for the batch ID of the unit identified by tag name. The unit command U_CMD_CLR_ALARM is sent to all units currently assigned to the batch being cleared.

tag name

Tag name will represent the tag name of another unit in the system. The unit making the request is assigned 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 bch_req name

BCH_REQ_U_RELEASE

BCH REQ U START BCH_REQ_U_START

Batch Controller Request Commands (continued)

bch_req value Hex Dec

Contents of bch_req_info

The unit making the request is released from the batch in which it is currently assigned and is sent the U_CMD_RELEASE command.*

0x0700 1792

The unit making the request is sent the U_CMD_START command.*

0x1a00 6656 tag name

BCH REQ U DONE BCH_REQ_U_DONE

0x0a00 2560

0x1d00 7424

0x0d00 3328

0x1b00 6912

0x0b00 2816

0x1f00 7936

The unit identified by tag name is sent the U_CMD_ABORT command. The unit making the request is sent the U_CMD_CLR_ABORT command.*

0x0f00 3840 tag name

*

The unit identified by tag name is sent the U_CMD_JOG command. The unit making the request is sent the U_CMD_ABORT command.*

tag name

BCH REQ U CLR ABORT BCH_REQ_U_CLR_ABORT

The unit identified by tag name is sent the U_CMD_WAIT command. The unit making the request is sent the U_CMD_JOG command.*

tag name

BCH REQ U ABORT BCH_REQ_U_ABORT

The unit identified by tag name is sent the U_CMD_RESUME command. The unit making the request is sent the U_CMD_WAIT command.*

tag name

BCH REQ U JOG BCH_REQ_U_JOG

The unit identified by tag name is sent the U_CMD_HOLD command. The unit making the request is sent the U_CMD_RESUME command.*

tag name

BCH REQ U WAIT BCH_REQ_U_WAIT

The unit identified by tag name is sent the U_CMD_DONE command. The unit making the request is sent the U_CMD_HOLD command.*

tag name

BCH REQ U RESUME BCH_REQ_U_RESUME

The unit identified by tag name is sent the U_CMD_START command. The unit making the request is sent the U_CMD_DONE command.*

tag name

BCH REQ U HOLD BCH_REQ_U_HOLD

Comments

The unit identified by tag name is sent the 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 bch_req name

BCH REQ U SET ALARM BCH_REQ_U_SET_ALARM

BCH REQ U CLR ALARM BCH_REQ_U_CLR_ALARM

Batch Controller Request Commands (continued)

bch_req value Hex Dec

0x1e00 7680

Contents of bch_req_info

The unit making the request is sent the U_CMD_SET_ALARM command.* tag name

0x0e00 3584

0x0600 1536

5-6

The unit identified by tag name is sent the U_CMD_IN_SERVE command. The unit making the request is sent the U_CMD_OUT_SERVE command.*

0x1600 5632 tag name

*

The unit identified by tag name is sent the U_CMD_CLR_ALARM command. The unit making the request is sent the U_CMD_IN_SERVE command.*

tag name

BCH REQ U OUT SERVE BCH_REQ_U_OUT_SERVE

The unit identified by tag name is sent the U_CMD_SET_ALARM command. The unit making the request is sent the U_CMD_CLR_ALARM command.*

tag name

BCH REQ U IN SERVE BCH_REQ_U_IN_SERVE

Comments

The unit identified by tag name is sent the 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.

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What Is a Batch Log? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Internal ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-2 6-2 6-2

6.2

Guidelines for Generating Batch Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Report Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch Report Format Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6-4 6-4 6-4 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 Log?

The batch log consists of all messages that OSx generates during batch 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

LL_ALARM

WARN

Temperature of Oven #1

BID920729--0002

GINGER_SNAP_1

BID920729--0003

START TIME: 10:27:17

325.0

WARN

Earl Login

OPERATE

ASSIGNED

MIXER_1

Start of Mixer #1

BID920729--0003

0x0003

WARN

SPOOLER SYSTEM ALARM

*

Figure 6-1

6-2

*

DATE: 10--DEC--91

Batch Logs and Reports

Temperature of Oven #1

BID920729--0002

Internal Batch ID associated with the log message.

Asterisk denotes a log message that applies to all batches. Log message does not apply to any batch if this field is blank. System messages often do not have corresponding batch IDs.

Example of Batch ID Fields in the Batch Log

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.--<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 destination depending on the items selected during printer configuration

Hard copy of log file data

Log files

Printer configuration

Report editor: Enables you to pull data from log files

current

Custom reports

1 day old 2 days old

Figure 6-2

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Log File Generation

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 Format Functions

Several report functions exist that are especially useful for batch reports: @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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sequence of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-2 7-3

7.2

Configuring a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Batch Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-4 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Batch-Related Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Batch-Related Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-10 7-10 7-10 7-10

7.6

Assigning Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-12

7.7

Releasing Batch Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-13

7.8

Changing Batch State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the State of a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-14 7-14 7-14

7.9

Changing Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-16

7.10

Splitting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-17

7.11

Ending a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Completing or Aborting a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Removing a Batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-18 7-18 7-19

7.12

Viewing Batch-Related Tag Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-20

7.13

Viewing the Unit Tag Detail and Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Unit Tag Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the State of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing the Mode of a Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing the Unit Faceplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7-22 7-22 7-24 7-25 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.

7-2



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.

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 product.

ID 2

Start the batch.

Observe the operation of the batch.

ON

Figure 7-1

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

OFF

Change the state or mode of a batch, if required.

Recommended Order of Tasks

Running and Supervising a Batch

7-3

7.2

Configuring a Batch OSx enables you to associate a unique batch ID with every product. If, for 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.

Using Batch Identification

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

7-4

Running and Supervising a Batch

Accessing Batch Identification

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Committing a Batch

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

7-8

Running and Supervising a Batch

Active Batch Directory Example

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 Execution

If your station is in Operate state, you may observe some delay in the 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 Batch-Related Graphics

To view the graphic associated with a batch, access the Active Batch Directory and select a batch ID. OSx displays the currently associated 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 Batch-Related Detail

To view the tag detail associated with a batch graphic, select Tag Detail from the navigation area Directory pushbutton while the batch graphic is 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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Sample Batch Tag Detail Screen

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

7-12

Running and Supervising a Batch

Assigning Units to 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.

2. 3.

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. Select the unit(s) you want to release from the batches, or choose Select

All & OK to release all assigned units from the batch.

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Releasing Units from a Batch

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 of a Batch

To change the operational state of a batch and its assigned units, select the 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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Changing Batch State

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

7-16

Running and Supervising a Batch

Changing Batch Mode

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Splitting a Batch

Running and Supervising a Batch

7-17

7.11

Ending a Batch

Completing or Aborting a Batch

To end a batch, perform the steps below. 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

7-18

Running and Supervising a Batch

Ending a Batch Example

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Displaying Assigned Units

Running and Supervising a Batch

7-21

7.13

Viewing the Unit Tag Detail and Faceplate

Viewing Unit Tag Detail

The unit tag detail enables an operator to monitor the status of a unit and 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.

7-22

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.

Running and Supervising a Batch

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Selection List Incremental

Single Selection _ACTREQ _ALARMING _ARCHIVING _BATCH _CHANGE_LOG _CONFIG _DATA_BASE _DATA_XFER _DIAGNOSTIC _FO_CIRCUIT _GENERAL _H1_COMM _HT_COLLECT _HT_DISPLAY _HT_UPDATE _LIBRARIAN

SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS

ACTION REQUEST SYSTEM ALARM ALARMING SYSTEM ALARM ARCHIVING SYSTEM ALARM BATCH SYSTEM ALARM OPERATOR CHANGE LOG SYSTEM CONFIGURATION SYSTEM ALARM DATABASE SYSTEM ALARM REMOTE DATA TRANSFER ALARM DIAGNOSTICS SYSTEM ALARM FAILOVER CIRCUIT ALARM GENERAL SYSTEM ALARM H1 COMM. SYSTEM ALARM HT COLLECTION SYSTEM ALARM HT DISPLAY SYSTEM ALARM HTU SYSTEM ALARM LIBRARIAN SYSTEM ALARM

OK

Filter...

Next

Top

Cancel

Help

Figure 7-14

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Displaying Unit Tag Detail

Running and Supervising a Batch

7-23

Viewing the Unit Tag Detail and Faceplate (continued) Changing the State of a Unit

To change the operational state of a unit, select the State option on the 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

7-24

Running and Supervising a Batch

Changing Unit Tag State

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Changing the Mode of a Unit

To change the operational mode of a unit, select the Mode option on the 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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Changing the Unit Operational Mode

Running and Supervising a Batch

7-25

Viewing the Unit Tag Detail and Faceplate (continued) Viewing the Unit Faceplate

You can view the unit faceplate by selecting the Display Units option from the 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

7-26

Running and Supervising a Batch

Unit Faceplate

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 Attribute

BCH Attributes

Domain

Definition

tag

CISTRING[12]

Tag name

pseudo_tag

SINT16

Tag reference ID

status

{Active, Alrm UnAck, Manual Set, Mode 2, Mode 1, Spare 4, Commit, Spare 3, Spare 2, Ready; Run, Complete, Spare 1, Hold, Alarm, Abort}

Current status

alt_stat

UINT32

Name and color code for current highest priority alarm

command

{Commit, Start, Hold, Resume, Complete, Remove, Abort, Set Alarm, Clear Alarm, Set Spare 1, Clear Spare 1, Set Spare 2, Clear Spare 2, Set Spare 3, Clear Spare 3, Set Spare 4, Clear Spare 4, Split, Split Assign, Reset}

Batch state commands; see the description for the bc_request_batch_state( ) function in Appendix C for information on issuing state commands to a batch

batch_id

CISTRING[16]

internal_id

CISTRING[13]

Custom batch ID associated with batch; defaults to internal_id if a custom ID is not specified System-generated batch ID

parent_id

CISTRING[13]

Internal_id of parent batch

operation

CISTRING[10]

User-defined string for indicating the operational state of the batch

u_start

LONG

Operating system time stamp indicating when the batch started

start_time

CISTRING[8]

Time-of-day portion of u_start

start_date

CISTRING[9]

Date portion of u_start

u_end

LONG

Operating system time stamp indicating when 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: Mode

00 = manual 01 = undefined 10 = auto 11 = semi-automatic)

0x0018

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 COMMIT

READY

ACTIVE ALRM_UNACK MAN_SET

SPARE_4

RUN COMPLETE 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 States

Abort

Alarm

Hold

Spl Complete

Run

Ready

Abort

1

X

X

X

Alarm

X

1

X

X

Hold

X

X

1

Spare_1

X

X

Complete

X

X

Run

X

Ready

X

Spare_2

Sp2 Sp3 Commit

Sp4 Md1 Md2

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

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 Mode

Abort Alarm

Hold

Spl

Complete Run

Ready Sp2 Sp3 Commit Sp4 Md1 Md2

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

X

X

X

X

X

1

1

SemiX X X X X X 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 Command

Values for the Batch Command Attribute

Hexadecimal Value

Decimal Value

Unit Command * —

Commit

0xCF00

--12544

Start

0x9A00

--26112

Start

Hold

0x9D00

--25344

Hold

Resume

0x8D00

--29440

Resume

Complete

0x0AB00

--21760

Done

Remove

0xC000

--16384

Abort

0xAF00

--20736

Abort

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



*

Comment Also sets start time.

Also sets end time. — Also sets end time.

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 Command

Values for the Batch MODE_CMD Attribute

Hexadecimal Value

Decimal Value

Unit Command *

Auto

0x4000

16384

Manual

0x8000

--32768

Manual

Semi-Auto

0xC000

--16384

Semi-Auto

*

A-6

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.

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

Attribute

UNIT Attributes

Domain

Definition

tag

CISTRING[12]

Tag name

pseudo_tag

SINT16

Tag reference ID

status

{Active, Alrm_UnAck, Man_Set, Mode 2, Mode 1, Spare_4, OOS, In_Use, Spar_ 3, Spare_2, Run, Wait, Spare_1, Hold, Alarm, Abort}

Current status

alt_stat

UINT32

Name and color code for current highest priority alarm

command

{Assign, Start, Hold, Done, Jog, Resume, Release, Abort, Wait, In Serve, Clear Abort, Set Alarm, Clear Alarm, Out Serve, Set Spare 1, Clear Spare 1, Set Spare 2, Clear Spare 2, Set Spare 3, Clear Spare 3, Set Spare 4, Clear Spare 4, Reset}

Unit state commands; see the description for the bc_request_unit_state( ) function in Appendix C for information on issuing state commands to a unit

mode_cmd

{Auto, Manual, Semi}

Unit mode commands; see the description for the bc_request_unit_mode( ) function in Appendix C for information on issuing unit mode commands

batch_id

CISTRING[16]

Batch ID associated with unit

operation

CISTRING[10]

User-defined string for indicating the operational state of the unit

u_start

LONG

Operating system time stamp indicating 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

u_end

LONG

Operating system time stamp indicating 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]

bch_req

{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 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: Mode

00 = manual 01 = undefined 10 = auto 11 = semi-automatic)

0x0018

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 SPARE_3 SPARE_2 RUN

MODE OOS SPARE_4

WAIT

ACTIVE ALRM_UNACK MAN_SET

SPARE_1 HOLD ALARM ABORT

Figure A-2

A-8

Bit Locations for UNIT Status Word

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 States

Abort

Alarm

Hold

Sp1 Wait

Run Sp2 Sp3

In_Use

OOS

Abort

1

X

X

X

X

X

X

Alarm

X

1

X

X

X

X

X

Hold

X

X

1

X

X

X

Spare_1

X

X

X

1

X

X

Wait

X

X

X

X

1

Run

X

X

X

X

Spare_2

X

X

X

X

Spare_3

X

X

X

In_Use

X

X

X

OOS

X

X

Spare_4

X

X

Available

X

X

Sp4 Md1

Md2

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

X

1

X

X

X

X

X

X

X

X

X

X

X

1

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 Mode

Abort

Alarm

Hold

Spl

Wait Run

Sp2

Sp3 Sp3

OOS

Sp4 Md1 Md2

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 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 Command

A-10

Values for the Unit Command Attribute

Values for the Unit MODE_CMD Attribute Hexadecimal Value

Decimal Value

Auto

0x4000

16384

Manual

0x8000

--32768

Semi-Auto

0xC000

--16384

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:

ATTRIBUTES

MEMORY

NUMBER OF

TYPE/ADDRESS

LOCATIONS

UPLOAD

AUTOLOG

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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

INITIAL VALUE

Example Planning Sheet

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.

Custom and Internal Batch IDs



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

In order to understand and apply the batch control functions described in 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( parameter definitions.

) function is defined with the following

INT bc_activate_autolog(tag_name, attribute_name) CHAR *tag_name; CHAR *attribute_name;

(in) Name of a tag (in) Name of an attribute within the specified tag

Parameters

tag_name attribute_name

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

C-6

bc_deactivate_autolog

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( parameter definitions.

) function is defined with the following

INT bc_add_batch_list_entry(l_name, batch_id) CHAR *l_name; CHAR *batch_id;

(in) Name of the list (in) Batch ID string to be added to the list

Parameters

l_name batch_id

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( definitions.

) function is defined with the following parameter

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

C-8

bc_set_batch_start bc_set_batch_product

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.5

bc_assign( )

Synopsis

The bc_assign( definitions.

) function is defined with the following parameter

INT bc_assign(unit_name, system_batch_id) CHAR *unit_name; CHAR *system_batch_id;

(in) Name of the unit tag to be assigned to a batch (in) System-generated batch ID string

Parameters

unit_name system_batch_id

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( definitions.

) function is defined with the following parameter

INT bc_assign_graphic(graphic_name, system_batch_id) CHAR *graphic_name; CHAR *system_batch_id;

(in) Name of the graphic to be associated with the batch (in) System-generated batch ID string

Parameters

graphic_name system_batch_id

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

C-10

bc_release_graphic

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.7

bc_assign_id( )

Synopsis

The bc_assign_id( definitions.

) function is defined with the following parameter

INT bc_assign_id(user_batch_id, system_batch_id) CHAR *user_batch_id; CHAR *system_batch_id;

(in) Custom batch ID string (in) System-generated batch ID string

Parameters

user_batch_id system_batch_id

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( parameter definitions.

) function is defined with the following

BOOLEAN bc_batch_list_entry_exists(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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(

)

Current entry is not active. Current entry is active.

Return Value

FALSE TRUE

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

C-12

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

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.9

bc_clear_unit_elements( )

Synopsis

The bc_clear_unit_elements( parameter definitions.

) function is defined with the following

INT bc_clear_unit_elements(unit_name) CHAR *unit_name;

(in) Name of the unit tag containing elements

Parameters

unit_name

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;

(in) Name of the source unit with elements to be copied (in) Name of the destination unit receiving element data

Parameters

src_unit_name dest_unit_name

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

C-14

bc_clear_unit_elements

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.11

bc_create_batch_list( )

Synopsis

The bc_create_batch_list( parameter definitions.

) function is defined with the following

INT bc_create_batch_list(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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( parameter definitions.

) function is defined with the following

INT bc_deactivate_autolog(tag_name, attribute_name) CHAR *tag_name; CHAR *attribute_name;

(in) Name of a tag (in) Name of an attribute within the specified tag

Parameters

tag_name attribute_name

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

C-16

bc_activate_autolog

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( parameter definitions. VOID bc_destroy_all_batch_lists(

) function is defined with the following

)

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( parameter definitions.

) function is defined with the following

INT bc_destroy_batch_list(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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

C-18

bc_create_batch_list bc_destroy_all_batch_lists bc_print_batch_list

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( definitions.

) function is defined with the following parameter

INT bc_get_batch_id(tag_name, custom_batch_id) CHAR *tag_name; CHAR *custom_batch_id;

Parameters

Description

tag_name custom_batch_id

(in) Name of the tag associated with the custom batch ID (out) Custom batch ID string

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

C-20

bc_get_custom_id bc_get_system_id

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( parameter definitions.

) function is defined with the following

CHAR *bc_get_batch_id_entry(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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( definitions.

) function is defined with the following parameter

INT bc_get_batch_mode(system_batch_id, mode) CHAR *system_batch_id; T_B_QUAL *mode;

Parameters

Description

system_batch_id mode

(in) System-generated batch ID string (out) Bit pattern that defines the mode status of the batch. See Appendix A for more information.

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

C-22

bc_request_batch_mode

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.19

bc_get_batch_state( )

Synopsis

The bc_get_batch_state( definitions.

) function is defined with the following parameter

INT bc_get_batch_state(system_batch_id, state) CHAR *system_batch_id; T_B_QUAL *state;

Parameters

Description

system_batch_id state

(in) System-generated batch ID string (out) Bit pattern that defines the status of the batch. See Appendix A for more information.

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( definitions.

) function is defined with the following parameter

INT bc_get_custom_id(system_batch_id, custom_batch_id) CHAR *system_batch_id; CHAR *custom_batch_id;

(in) System-generated batch ID string (out) Custom batch ID string

Parameters

system_batch_id custom_batch_id

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

C-24

bc_get_batch_id bc_get_system_id

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);

(in) printer name (out) printer bit mask

Parameters

name 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( definitions.

) function is defined with the following parameter

INT bc_get_system_id(custom_batch_id, system_batch_id) CHAR *custom_batch_id; CHAR *system_batch_id;

(in) Custom batch ID string (out) System-generated batch ID string

Parameters

custom_batch_id system_batch_id

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

C-26

bc_get_batch_id bc_get_custom_id

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.23

bc_get_unit_mode( )

Synopsis

The bc_get_unit_mode( definitions.

) function is defined with the following parameter

INT bc_get_unit_mode(unit_name, mode) CHAR *unit_name; T_U_QUAL *mode;

(in) Unit tag name (out) Bit pattern that defines the mode status of the unit. See Appendix A for more information.

Parameters

unit_name mode

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( definitions.

) function is defined with the following parameter

INT bc_get_unit_state(unit_name, state) CHAR *unit_name; T_U_QUAL *state;

Parameters

Description

unit_name state

(in) Unit tag name (out) Bit pattern that defines the status of the unit. See Appendix A for more information.

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

C-28

bc_request_unit_state

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;

(in) Unit tag name

Parameters

unit_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( definitions.

) function is defined with the following parameter

INT bc_lock_batch_id(system_batch_id) CHAR *system_batch_id;

(in) System-generated batch ID string

Parameters

system_batch_id

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

C-30

bc_unlock_batch_id

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.27

bc_log_comment( )

Synopsis

The bc_log_comment( definitions.

) function is defined with the following parameter

INT bc_log_comment(batch_id, keyword, comment) CHAR *batch_id; CHAR *keyword; CHAR *comment;

(in) Custom batch ID string (in) Value for keyword field in message (in) Value for comment field in message

Parameters

batch_id keyword comment

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( definitions.

) function is defined with the following parameter

INT bc_log_operation(unit_name, unit_event) CHAR *unit_name; INT unit_event;

(in) Unit tag name (in) Unit phase; EVENT_START and EVENT_FINISH are the only valid events; suitable constants are defined in header file ba_user.h

Parameters

unit_name unit_event

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 ON EVENT oven1:status:run { bc_log_operation(”oven1”, EVENT_START); }

See Also

C-32

bc_log_comment bc_log_value

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.29

bc_log_value( )

Synopsis

The bc_log_value( definitions.

) function is defined with the following parameter

INT bc_log_value(batch_id, tag_name, attr_name) CHAR *batch_id; CHAR *tag_name; CHAR *attr_name;

Parameters

Description

batch_id tag_name attr_name

(in) Custom batch ID string (in) Name of tag where log value is found (in) Name of attribute where log value is found

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( definitions.

) function is defined with the following parameter

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

C-34

bc_create_batch_list, bc_destroy_all_batch_lists, bc_destroy_batch_list

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.31

bc_release( )

Synopsis

The bc_release( definitions.

) function is defined with the following parameter

INT bc_release(unit_name, system_batch_id) CHAR *unit_name; CHAR *system_batch_id;

(in) Name of the unit tag to be released from a batch (in) System-generated batch ID string

Parameters

unit_name system_batch_id

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( definitions.

) function is defined with the following parameter

INT bc_release_all(system_batch_id) CHAR *system_batch_id;

Parameters Description

system_batch_id

(in) System-generated batch ID string

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

C-36

bc_assign bc_release

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.33

bc_release_graphic( )

Synopsis

The bc_release_graphic( definitions.

) function is defined with the following parameter

INT bc_release_graphic(system_batch_id) CHAR *system_batch_id;

Parameters Description

system_batch_id

(in) System-generated batch ID string

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( parameter definitions.

) function is defined with the following

INT bc_remove_batch_list_entry(l_name, batch_id) CHAR *l_name; CHAR *batch_id;

(in) Name of the list (in) Batch ID string to be removed from the list

Parameters

l_name batch_id

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

C-38

ERROR Error occurred. The variable errno indicates the specific error. NO_ERROR Normal return.

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( parameter definitions.

) function is defined with the following

INT bc_request_batch_mode(system_batch_id, mode_command) CHAR *system_batch_id; T_B_MD_CMD mode_command;

Parameters

system_batch_id mode_command

(in) System-generated batch ID string (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 B_MD_CMD_MANUAL B_MD_CMD_SEMI

Description

Set batch to automatic mode Set batch to manual mode Set batch to semi-automatic mode

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

C-40

ERROR Error occurred. The variable errno indicates the specific error. NO_ERROR Normal return.

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( parameter definitions.

) function is defined with the following

INT bc_request_batch_state(system_batch_id, command) CHAR *system_batch_id; T_B_CMD command;

Parameters

system_batch_id command

(in) System-generated batch ID string (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 B_CMD_CLR_ALARM B_CMD_COMMIT B_CMD_COMPLETE B_CMD_HOLD B_CMD_REMOVE B_CMD_RESUME B_CMD_SET_ALARM B_CMD_START

Abort batch Clear batch alarm flag Commit batch setup Mark batch as completed Place batch in hold state Remove batch from active state Resume batch Set batch alarm flag 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( parameter definitions.

) function is defined with the following

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 unit_name mode_command

(in) System-generated batch ID string (in) Unit tag name (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 B_MD_CMD_MANUAL B_MD_CMD_SEMI

Set unit to automatic mode Set unit to manual mode 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( parameter definitions.

) function is defined with the following

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 unit_name command

(in) System-generated batch ID string (in) Unit tag name (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 U_CMD_CLR_ABORT U_CMD_CLR_ALARM U_CMD_DONE U_CMD_HOLD U_CMD_IN_SERVE U_CMD_JOG U_CMD_OUT_SERVE U_CMD_RELEASE U_CMD_RESUME U_CMD_SET_ALARM U_CMD_START U_CMD_WAIT

Abort unit processing Clear unit abort field Clear unit alarm flag Mark unit as done with processing Place unit in hold state Place unit in service Jog unit to next processing state Place unit out of service Release unit from batch Resume unit processing Set unit alarm flag Start unit processing 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( definitions.

) function is defined with the following parameter

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

C-48

bc_load bc_select bc_set_batch_product

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.40

bc_select( )

Synopsis

The bc_select( definitions.

) function is defined with the following parameter

INT bc_select(system_batch_id, unit_name) CHAR *system_batch_id; CHAR *unit_name;

(in) System-generated batch ID string (in) Unit tag name

Parameters

system_batch_id unit_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( definitions.

) function is defined with the following parameter

INT bc_set_batch_end(system_batch_id) CHAR *system_batch_id;

(in) System-generated batch ID string

Parameters

system_batch_id

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

C-50

bc_set_batch_start

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.42

bc_set_batch_operation( )

Synopsis

The bc_set_batch_operation( parameter definitions.

) function is defined with the following

INT bc_set_batch_operation(system_batch_id, operation_name) CHAR *system_batch_id; CHAR *operation_name;

Parameters

Description

system_batch_id operation_name

(in) System-generated batch ID string (in) Batch operation string

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( parameter definitions.

) function is defined with the following

INT bc_set_batch_product(system_batch_id, product) CHAR *system_batch_id; CHAR *product;

Parameters

Description

system_batch_id product

(in) System-generated batch ID string (in) Any character string representing a batch product

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

C-52

bc_set_batch_end bc_set_batch_operation bc_set_batch_start

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.44

bc_set_batch_start( )

Synopsis

The bc_set_batch_start( definitions.

) function is defined with the following parameter

INT bc_set_batch_start(system_batch_id) CHAR *system_batch_id;

(in) System-generated batch ID string

Parameters

system_batch_id

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( parameter definitions.

) function is defined with the following

INT bc_set_first_batch_list_entry(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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

C-54

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

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.46

bc_set_log_destination( )

Synopsis

The bc_set_log_destination( parameter definitions.

) function is defined with the following

INT bc_set_log_destination (system_batch_id, destinations) CHAR *system_batch_id; T_DEV_SET destinations;

(in) System-generated batch ID string (in) Set of printer devices

Parameters

system_batch_id destinations

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( parameter definitions.

) function is defined with the following

INT bc_set_next_batch_list_entry(l_name) CHAR *l_name;

(in) Name of the list

Parameters

l_name

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

C-56

ERROR Error occurred. The variable errno indicates the specific error. NO_ERROR Normal return.

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( definitions.

) function is defined with the following parameter

INT bc_set_unit_end(unit_name) CHAR *unit_name;

(in) Unit tag name

Parameters

unit_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

C-58

bc_set_unit_operation bc_set_unit_start

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.49

bc_set_unit_operation( )

Synopsis

The bc_set_unit_operation( parameter definitions.

) function is defined with the following

INT bc_set_unit_operation(unit_name, operation_name) CHAR *unit_name; CHAR *operation_name;

(in) Unit tag name (in) Batch operation string

Parameters

unit_name operation_name

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( definitions.

) function is defined with the following parameter

INT bc_set_unit_start(unit_name) CHAR *unit_name;

(in) Unit tag name

Parameters

unit_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

C-60

bc_set_unit_end bc_set_unit_operation

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.51

bc_split_batch( )

Synopsis

The bc_split_batch function( definitions.

) is defined with the following parameter

INT bc_split_batch(system_batch_id, new_batch_id) CHAR *system_batch_id; CHAR *new_batch_id;

(in) (in)

System-generated batch ID string Name desired for new split batch

Parameters

system_batch_id new_batch_id;

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( definitions.

) function is defined with the following parameter

INT bc_trigger_request(request_name) CHAR *request_name;

(in) Name of an action request

Parameters

request_name

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

C-62

None

Batch Control Functions

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

C.53

bc_unlock_batch_id( )

Synopsis

The bc_unlock_batch_id( definitions.

) function is defined with the following parameter

INT bc_unlock_batch_id(system_batch_id) CHAR *system_batch_id;

(in) System-generated batch ID string

Parameters

system_batch_id

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.

D-2

shows the syntax and data types for the parameters used by the function.



Synopsis



Parameters

describes the parameters required by the function.



Description

describes the operation of the function.



Return value

produce.

BCL Program Control Functions

lists the possible return codes that the function may

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

D.2

bcl_auto_append( )

Synopsis

The bcl_auto_append( definitions.

) function is defined with the following parameter

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 FALSE

Automatic append for a failed replace operation is enabled. 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( parameter definitions. VOID bcl_disable_auto_append(

) function is defined with the following

)

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( following parameter definitions. VOID bcl_disable_error_on_empty_delete(

) function is defined with the

)

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( following parameter definitions. VOID bcl_disable_error_on_not_found(

) function is defined with the

)

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( parameter definitions. VOID bcl_enable_auto_append(

) function is defined with the following

)

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( following parameter definitions. VOID bcl_enable_error_on_empty_delete(

) function is defined with the

)

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( following parameter definitions. VOID bcl_enable_error_on_not_found(

) function is defined with the

)

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( parameter definitions.

) function is defined with the following

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

delete FALSE

D-10

BCL Program Control Functions

Error messages are generated if an attempt is made to a nonexistent record. Error messages are not generated if an attempt is made to delete a nonexistent record.

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

D.10

bcl_error_on_not_found( )

Synopsis

The bcl_error_on_not_found( parameter definitions.

) function is defined with the following

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

error FALSE

Retrieve operations resulting in ‘‘not found” produce an message. 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( parameter definitions.

) function is defined with the following

VOID print_trace_message(message) CHAR *message

(in) Pointer to the character array containing the string that the function sends to the trace file

Parameters

message

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 Command

Security Privileges for Batch Commands

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

Commit

Primary Control

Batch identification, BCL program, controller 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

Split

Primary Control or Batch Control

std displays, BCL program, controller request

Split/Assign

Primary Control or Batch Control

controller request

Start

Primary Control

std displays,* BCL program, controller request

* Batch tag detail and faceplate

Table E-2 Command

Security Privileges for Batch Mode Commands

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 Command

Security Privileges for Unit Commands

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 Command

Security Privileges for Unit Mode Commands

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Who Should Read This Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Custom Database Table Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Privilege Masks of Standard Database Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

F-2 F-2 F-2 F-3

F.2

USER_MSG Event Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the USER_MSG Event Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

F-4 F-4 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 This Appendix

The information in this section is intended for SIMATIC PCS 7 OSx 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 Table Privileges

Each OSx database table has a privilege mask. This privilege mask is 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 Standard Database Tables

The following warning must be adhered to in regard to privilege masks in standard database 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 USER_MSG Event Block

A USER_MSG event block executes when the BCL program receives an input queue message that is not 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. 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 #define BM_MGR_RSRC_ID #define BM_BCPGM_RSRC_ID

1 3 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Event Block #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

BCL Application Programming Example

G-2 G-2 G-2 G-4 G-5 G-5 G-9

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 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

SIMATIC PCS 7 OSx 4.1.1 Batch Programming

Sequence of Tasks

BCL Application Programming Example

G-3

BCL Programming Example (continued) Configuration Prerequisites

The example program assumes the existence of the indicated tags and 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

batchid

Numeric batch ID entered by operator in response to request BATCHID; answer tag for action 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

chrg_lvl

Charge level entered by operator in response to request CHRG_LVL; answer tag for action request CHRG_LVL

chrg_lvl_rst

Reset tag for action request CHRG_LVL

commit

Answer tag for action request COMMIT; operator enters confirmation of batch start-up parameters

commit_rst

Reset tag for action request COMMIT

do_0

Batch completion indicator for tank 1; attached to UNIT tag for tank 1; changed by unit’s controller program or, for demonstration purposes, manually (that is, from the command line using the database utility “menu”)

do_4

Batch completion indicator for tank 4; attached to UNIT tag for tank 4; changed by unit’s 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

Tank selection entered by operator in reponse to request TANK; answer tag for action request TANK

tank_rst

Reset tag for action request TANK

tex1

Text tag used as mailbox to communicate batch ID to batch report; configured as non-networked 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 Code

Source code for the batch charging example program consists of three files as shown in Table G-3. Table G-3

File Name

Source Code Files 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 #define

TRACE_MESSAGE_LENGTH NEW_BATCH_VAR_HANDLE

80 ”new_batch”

/* ** Error codes; ** Install suitable error messages in the ERR_MSGS table. */ #define #define

CHRG_LVL_ERR BATCH_INIT_ERR

9999 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 /* .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: h_vars->level = 1; break;

G-12

BCL Application Programming Example

/* Definitions for CHOICE_n_VALUE */ /* are found in Action Request */ /* header file ac_defs.h. */

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: h_vars->tank = 1; break;

/* Definitions for CHOICE_n_VALUE */ /* are found in Action Request */ /* 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 SINT16 SINT16

committed = 0x4000; rejected = 0; cmd_reset = 0;

SINT16 CHAR CHAR CHAR CHAR

answer; batch_id [T_B_I_D_LENGTH]; system_id [T_B_I_D_LENGTH]; unit_name [T_TAGS_LENGTH]; 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 CHAR

custom_batch_id [T_B_I_D_LENGTH]; 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 print_trace_message (msg);

= %s\n”, custom_batch_id);

/* 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 EXEC EXEC EXEC

charge6_1:value charge6_2:value charge6_3:value charge6_4:value

<<<<-

(&reset); (&reset); (&reset); (&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; SINT16 tank; CHAR *sys_id; CHAR *batch_id; CHAR *unit_name;

/* /* /* /* /*

IN: IN: OUT: OUT: OUT:

Numeric batch identifier */ Tank ID number */ Internal (system) batch identifier */ Custom batch ID */ 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 A Accessing batch directory, 7-8 batch logs/reports, 6-3 batch unit display, 7-20 BCL Program Administration dialog box, 4-2 unit faceplate, 7-26 unit tag detail (batch), 7-22 Active batch directory, 7-8 tags, 7-9 Assigning batch tag attributes, A-2 batch unit tags, A-7 batch units, 7-12 security privileges, batch control, E-2

B Batch assigning units, 7-12 changing mode, 7-16 changing state, 7-14 changing unit mode, 7-25 changing unit state, 7-24 configuration committing, 7-7 prerequisites, 2-2, 7-2 using batch ID, 7-4 data, hierarchy, 1-3 displaying active batch tag group, 7-9 displaying active batches, 7-8 ending, 7-18 graphic, viewing, 7-10 log destination, 2-5 logs and reports, 1-5, 6-2 operation, viewing, 7-10 OSx database tables, F-3 processing component interaction, 1-6

components BCL, 1-4 controller-requested commands, 1-4, 5-2 logs and reports, 1-5 prerequisites, 1-8 responsibilities, 1-2 releasing units, 7-13 security privilege, E-2 database tables, F-2 splitting, 7-17 starting, 7-14 tag detail, viewing, 7-10 tracking, 5-2 unit faceplate, displaying, 7-26 unit tag detail, displaying, 7-22 unit tag groups, displaying, 7-18 Batch control language (BCL), 1-4, 3-2 control functions, C-4 bc_activate_autolog, C-6 bc_add_batch_list_entry, C-7 bc_allocate_batch, C-8 bc_assign, C-9 bc_assign_graphic, C-10 bc_assign_id, C-11 bc_batch_list_entry_exists, C-12 bc_clear_unit_elements, C-13 bc_copy, C-14 bc_create_batch_list, C-15 bc_deactivate_autolog, C-16 bc_destroy_all_batch_lists, C-17 bc_destroy_batch_list, C-18 bc_exit, C-19 bc_get_batch_id, C-20 bc_get_batch_id_entry, C-21 bc_get_batch_mode, C-22 bc_get_batch_state, C-23 bc_get_custom_id, C-24 bc_get_printer_mask, C-25 bc_get_system_id, C-26 bc_get_unit_mode, C-27 bc_get_unit_state, C-28 bc_load, C-29

Index-1

Batch control language (BCL) control functions (continued) bc_lock_batch_id, C-30 bc_log_comment, C-31 bc_log_operation, C-32 bc_log_value, C-33 bc_print_batch_list, C-34 bc_release, C-35 bc_release_all, C-36 bc_release_graphic, C-37 bc_remove_batch_list_entry, C-38 bc_request_batch_mode, C-40 bc_request_batch_state, C-42 bc_request_unit_mode, C-44 bc_request_unit_state, C-46 bc_scale_recipe, C-48 bc_select, C-49 bc_set_batch_end, C-50 bc_set_batch_operation, C-51 bc_set_batch_product, C-52 bc_set_batch_start, C-53 bc_set_first_batch_list_entry, C-54 bc_set_log_destination, C-55 bc_set_next_batch_list_entry, C-56 bc_set_unit_end, C-58 bc_set_unit_operation, C-59 bc_set_unit_start, C-60 bc_split_batch, C-61 bc_trigger_request, C-62 bc_unlock_batch_id, C-63 database, accessing tables, F-2 errors, 3-31 error handling code, 3-35 invalid bit names, 3-31 event block instructions, user_msg, F-4 halting program, 4-10 library functions, controlling batch operations, 3-32 multiple-station systems, 3-7 networked tag:attributes, 3-6 program components, 3-3 program control functions bcl_auto_append, D-3 bcl_disable_auto_append, D-4 bcl_disable_error_on_empty_delete, D-5 bcl_disable_error_on_not_found, D-6

Index-2

Batch control language (BCL) program control functions bcl_enable_auto_append, D-7 bcl_enable_error_on_empty_delete, D-8 bcl_enable_error_on_not_found, D-9 bcl_error_on_empty_delete, D-10 bcl_error_on_not_found, D-11 print_trace_message, D-12 programming avoiding invalid bit names, 3-31, 3-35 compiling, 4-4, 4-14 defining variables, 3-13 example, G-2 installing, 4-8, 4-16 mapping tag names, 3-14 modifying, 4-6 prerequisites, 3-4 removing, 4-11, 4-12, 4-13, 4-22 reserved keywords, 3-10 runtime options, 4-6 starting/halting, 4-9, 4-19 steps, 3-9 translating to C language, 3-12 triggering event blocks, 3-20 UNIX command line options, 4-7, 4-20 reports editor functions, 6-4 generating, 6-4 running program automatically, 4-9 control functions, 3-34, D-2 manually, 4-9 statements #include, 3-12 define, 3-13 on event, trigger_spec options, 3-20 unit map, 3-14 user_msg, F-4 Batch ID, 6-2, C-4 assigning, 7-5 log destination, 7-6 Batch request commands, 5-2, 5-3 Batch tag (BCH), A-2 BCL. See Batch control language

C Cascaded menu, 1-11 Changing batch mode, 7-16 batch state, 7-14 batch unit mode, 7-25 batch unit state, 7-24 BCL program, 4-6 Compiling, BCL program, 4-4 from UNIX command line, 4-14 Configuration batch, 2-2 committing, 7-7 prerequisites, 7-2 using batch ID, 7-4 planning sheets, B-1 unit tag, 2-6 Controlling batch operation, C-4 with library functions, 3-32 BCL program, 3-34, D-2 from UNIX command line, 4-17 Creating batch requests, 5-2 BCL program, 3-9 event blocks, BCL program, 3-16, F-4

E Error, batch control language (BCL) error handling code, 3-35 invalid bit names, 3-31 Event block available instructions, 3-24 example, 3-30 syntax, 3-16 trigger_spec options, 3-20 Executing, BCL program, from UNIX command line, 4-17

F Faceplate active batch tags, 7-9 batch unit, 7-26

H Halting, BCL program, 4-10

I ID. See Batch ID

D Data, batch, hierarchy, 1-3 Database event triggers, 3-19 Define statement, batch control language (BCL), 3-13 Defining batch units, 2-6 variables, BCL program, 3-13 Deleting batch, 7-18 BCL program, 4-12 from UNIX, 4-22

Include statement, batch control language (BCL), 3-12 Installing, BCL program, 4-8 from UNIX command line, 4-16

K Keyword, batch control language (BCL), 3-10

L Library functions, batch control language, controlling batch operations, 3-32

Directory, active batch, 7-8

Index-3

Linking APT extension to unit tag, 2-7 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 Mapping units, BCL program, 3-14

N Navigational tools, 1-10 cascaded menu, 1-11 pushbutton, 1-10 radio button, 1-10 slider, 1-10 text browser, 1-10 toggle button, 1-10

O

R

Report, batch control language (BCL), 6-4 Running BCL program from UNIX command line, 4-17

S Save pushbutton, 1-11 Saving ok pushbutton, 1-11 save pushbutton, 1-11 Security privilege, functions batch commands, E-2 batch modes, E-2, E-3 batch unit commands, E-3 database tables, F-2

OK pushbutton, 1-11

Slider, 1-10

On event statement, batch control language (BCL), trigger_spec options, 3-20

Special event block identifiers, 3-18

P Planning batch program, 2-2 BCL program, 3-4 Planning sheets, configuration, B-1 PLC. See Controller models Primary, new primary command, and BCL program, 4-3

Splitting a batch, 7-17 Starting/halting, BCL program, 4-9 from UNIX command line, 4-19 Starting/stopping, batch, 7-14, 7-18

T Tag detail, display batch (BCH), 7-10 unit (UNIT), 7-22

Process control, batch, 1-2

Tag group active batch, displaying, 7-9 batch units, displaying, 7-20

Pushbutton, 1-10

Text browser, 1-10

Printer, log destination, batch, 7-6

Index-4

Toggle button, 1-10 Troubleshooting BCL errors, 3-35 halting BCL program, 4-10

U Unit map statement, batch control language (BCL), 3-14 Unit tag (UNIT), A-7 APT extensions, 2-7 configuration, 2-6

Updating, BCL program, 4-13

W WHERE clause delete format, 3-29 replace format, 3-28 retrieve format, 3-27 WHERE clauses, referencing controller-resident data, 3-19

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

Manual Assembly Number: 2806854-0001 Order Number:

6ES7 6550XX048BC4

Edition: Date:

Original 1/01

FOLD NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES

SIEMENS ENERGY & AUTOMATION INC 3000 BILL GARLAND ROAD P O BOX 1255 JOHNSON CITY TN 37605--1255

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

Related Documents

Ba2
May 2020 3
Class Notes Ba2 Sep Oct
November 2019 12