26548467_OPC_AE_DOKU_V20_e

87
Applications & Tools Answers for industry. Cover Individual Signaling System Based on OPC Alarm and Events with the SIMATIC NET OPC Alarm and Event Server (COM/DCOM) SIMATIC NET OPC Server (CD Edition V 8.0) Application Description April 2011

description

simatic opc fundamentals

Transcript of 26548467_OPC_AE_DOKU_V20_e

Page 1: 26548467_OPC_AE_DOKU_V20_e

Applications & Tools

Answers for industry.

Cover

Individual Signaling System Based on OPC Alarm and Events with the SIMATIC NET OPC Alarm and Event Server (COM/DCOM)

SIMATIC NET OPC Server (CD Edition V 8.0)

Application Description April 2011

Page 2: 26548467_OPC_AE_DOKU_V20_e

2 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Siemens Industry Online Support

This article is taken from the Siemens Industry Online Support. The following link takes you directly to the download page of this document:

http://support.automation.siemens.com/WW/view/en/26548467

Caution The functions and solutions described in this article confine themselves to the realization of the automation task predominantly. Please take into account furthermore that corresponding protective measures have to be taken up in the context of Industrial Security when connecting your equipment to other parts of the plant, the enterprise network or the Internet. Further information can be found under the Item-ID 50203404.

http://support.automation.siemens.com/WW/view/en/50203404

If you have any questions concerning this document please e-mail us to the following address:

mailto:[email protected]

You can also actively use our Technical Forum from the Service & Support Portal regarding this subject. Add your questions, suggestions and problems and discuss them together in our strong forum community:

http://www.siemens.com/forum-applications

Page 3: 26548467_OPC_AE_DOKU_V20_e

Alarm Client with OPC A&E V2.0, ID Number: 26548467 3

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

s

SIMATIC Alarm Client with OPC A&E

for SIMATIC NET CD Edition 2010

Automation Problem

1

Automation Solution

2 General Functional Mechanisms

3

Functionality of the Client Application

4

Explanation of the S7 Sample Program

5

Installation and Startup

6

Configuration

7 Operation of the Application

8

Related literature

9

History

10

Page 4: 26548467_OPC_AE_DOKU_V20_e

Warranty and Liability

4 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Warranty and Liability Note The application examples are not binding and do not claim to be complete

regarding the circuits shown, equipping and any eventuality. The application examples do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for ensuring that the described products are correctly used. These application examples do not relieve you of the responsibility of safely and professionally using, installing, operating and servicing equipment. When using these application examples, you recognize that Siemens cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these application examples at any time without prior notice. If there are any deviations between the recommendations provided in these application examples and other Siemens publications – e.g. Catalogs – then the contents of the other documents have priority.

We do not accept any liability for the information contained in this document.

Any claims against us – based on whatever legal reason – resulting from the use of the examples, information, programs, engineering and performance data etc. described in this application example shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract (“wesentliche Vertragspflichten”). However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions do not imply a change in the burden of proof to your detriment.

It is not permissible to transfer or copy these application examples or excerpts of them without first having prior authorization from Siemens Industry Sector in writing.

Page 5: 26548467_OPC_AE_DOKU_V20_e

Table of Contents

Alarm Client with OPC A&E V2.0, ID Number: 26548467 5

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table of Contents Warranty and Liability ................................................................................................. 4 1 Task..................................................................................................................... 6

1.1 Overview .............................................................................................. 6 1.2 Requirements ....................................................................................... 7

2 Solution............................................................................................................... 8 2.1 Overview of the overall solution ........................................................... 8 2.2 Description of the core functionality ..................................................... 9 2.3 Required hardware and software components .................................. 13 2.4 Performance data............................................................................... 14

3 General Functional Mechanisms ................................................................... 15 3.1 OPC basics ........................................................................................ 15 3.2 OPC Alarm & Events basics .............................................................. 16 3.2.1 OPC A&E basics and delimitation from OPC DA............................... 16 3.2.2 OPC Alarm and Events model ........................................................... 17 3.3 Functional mechanisms of OPC Alarm & Events............................... 21 3.3.1 Methods of the EventServer object .................................................... 21 3.3.2 Methods of the EventSubscription object........................................... 22 3.3.3 Receiving messages from the A&E server......................................... 23

4 Functionality of the Client Application.......................................................... 26 4.1 Functionality of the alarm client.......................................................... 26 4.2 Functional mechanisms of the alarm client ........................................ 27 4.3 Class diagrams of the alarm client ..................................................... 29 4.3.1 OPC Alarm and Event Client API....................................................... 30 4.3.2 OPC A&E client sample application ................................................... 34 4.4 Sequence diagrams of the alarm client.............................................. 36

5 Explanation of the S7 Sample Program ........................................................ 43 5.1 Extended alarm configuration for STEP 7 V5.5 and higher ............... 43 5.2 Alarms of the SIMATIC S7 station ..................................................... 46 5.3 Display of attributes in OPCEventNotification.................................... 50 5.4 User program of this example ............................................................ 53 5.5 Sample configuration of a SCAN alarm ............................................. 56 5.6 Sample call of an ALARM_8P............................................................ 59 5.7 Sample configuration of system error messages............................... 62 5.8 Information on the alarm configuration of the S7-300........................ 65

6 Installation and Startup................................................................................... 66 6.1 Hardware and software installation .................................................... 66 6.2 Application software installation ......................................................... 67 6.3 Configuration of the SIMATIC S7 stations ......................................... 67 6.4 Commissioning of the PC station ....................................................... 70

7 Configuration ................................................................................................... 72 7.1 Configuration of the SIMATIC S7 stations ......................................... 72 7.2 Configuration of the PC station .......................................................... 75 7.3 Configuration of the OPC A&E server < V8.0 .................................... 79

8 Operation of the Application .......................................................................... 81 9 Related literature ............................................................................................. 86

9.1 Bibliography........................................................................................ 86 9.2 Internet link specifications .................................................................. 86

Page 6: 26548467_OPC_AE_DOKU_V20_e

1 Task

1.1 Overview

6 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

1 Task

1.1 Overview

Introduction

In order to realize a data link, standardized mechanisms are preferably used today to ensure that such a data exchange remains independent of the used bus system or protocol or even manufacturer. A standardized mechanism for connecting different subsystems is also to be used for the exchange of event and alarm messages.

Overview of the automation problem

The figure below provides an overview of the automation problem.

Figure 1-1

Description of the automation problem

In an automation system, different devices are used to control the process. In this case, these devices are two SIMATIC S7 controllers. Figure 1-1 shows the components involved.

The automation problem consists of acquiring event messages and alarms from the automation systems in a central signaling system on a PC station. The PC station collects the alarms and displays them in the correct order. Furthermore, the PC station can acknowledge alarms if this is necessary. Automation systems and PC station are to communicate via Ethernet.

A communications link to the PC stations via Profibus is basically also possible; however, it will not be discussed here to simplify matters.

PC application

Signaling system

Display Acknowl-edgement

Page 7: 26548467_OPC_AE_DOKU_V20_e

1 Task

1.2 Requirements

Alarm Client with OPC A&E V2.0, ID Number: 26548467 7

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

1.2 Requirements

Automation problem requirements

The alarm and event mechanism is not used for cyclic transmission of large data volumes; rather, it is used to signal important events from the controller without generating unnecessary communication load on the controller by polling the PC station.

Controller requirement

The controller should be capable of actively sending a message from the user program in the event of unexpected events without requiring the PC station to poll the controller.

The controller must have a communication option to a central signaling system, preferably via Ethernet.

PC station requirements

The PC station must have the necessary physical connection to the respective hardware and software for the communication with the controller.

The application for the display and acknowledgement of event messages is to use a standardized interface to the communications software to be able to integrate any event sources.

Page 8: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.1 Overview of the overall solution

8 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

2 Solution

2.1 Overview of the overall solution

Diagrammatic representation

The diagrammatic representation below shows the most important components of the solution:

Figure 2-1

SIMATIC PC Station

• Windows 7• Standard Ethernet Card• SIMATIC NET CD 2010 (V8.0)• SOFTNET S7 IE/Lean• STEP 7 V 5.5• Visual Studio 2005 (C#)• AE Alarm-Client

SIMATIC S7-300 Station

• CPU 315-2 DP• CP 343-1

SIMATIC S7-400 Station

• CPU 416-3 DP• CP 443-1 Advanced

Configuration

Via Ethernet, a PC station is connected to a CPU 315-2 DP and a CPU 416-3 DP using the relevant Ethernet CPs. A standard Ethernet card (alternatively a CP 1613 or 1612) is used in the PC.

Scope

This application does not include a description of the following:

• Basics of configuring and programming SIMATIC stations with STEP 7.

• Principle of operation of .NET and language syntax of C#.

• COM/DCOM basic technology and its configuration.

Basic knowledge of these topics is required.

Page 9: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.2 Description of the core functionality

Alarm Client with OPC A&E V2.0, ID Number: 26548467 9

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

2.2 Description of the core functionality

The SIMATIC NET OPC Alarm and Event (A&E) server forms the core of the functionality of this example, which, unlike an OPC Data Access server, is capable of receiving messages directly from the controller without having access the controller on a polling basis.

The figure below shows the functional chain for such a message.

• If an event occurs, e.g. an E0.3 error input is set, an alarm block, for example ALARM_8P, can be called in the S7 program.

• Via the S7 protocol, the S7 station sends an event to the SIMATIC NET OPC server.

• The OPC A&E server converts all information to OPC parameters and sends an alarm to the OPC client application.

Figure 2-2

The OPC client application shown here offers the option to display OPC alarms and, depending on the alarm type, to acknowledge these alarms. For this purpose, the application provides the following functionality:

Display:

• Registering for the reception of events.

• Selecting and displaying attributes.

• Browsing sources and areas.

• Filtering alarms by severity and type as well as source and area.

• Displaying message texts and associated values.

Acknowledgement:

• Highlighting messages requiring acknowledgement.

• Acknowledging indicating the user.

Display

S7 protocol

S7 connection

Page 10: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.2 Description of the core functionality

10 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Overview and description of the user interface

The window of the user interface in Figure 2-3 displays the list of alarms and event messages. The Server and Subscription menus are used for the connection establishment to the server and the communication configuration. Alarms are acknowledged using a context menu on the alarm message or via the Server menu.

The alarms and event messages are inserted into the list from the top in the order of their occurrence. The message type, for example event message or alarm, is indicated by the color of the message. The status of an alarm with regard to acknowledgement and activity is indicated by the shading of the color and icons in the message line.

The user can select additional associated values for the display and make filter settings for the signaled events and alarms.

Figure 2-3

Page 11: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.2 Description of the core functionality

Alarm Client with OPC A&E V2.0, ID Number: 26548467 11

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Sequence of the core functionality

Figure 2-4 schematically shows the most important components of this solution.

Figure 2-4

The following table describes which steps have to be performed to trigger different alarms and to operate the sample application.

Table 2-1

Action Note

1. Select the OPC A&E server The server must be an A&E server

2. Register for the reception of events Buffer time and filters are indicated for the subscription

3. Trigger alarms on the process Initiation of programmed alarms with associated values in the PLC

4. Trigger alarms of the connection Simulation of an interruption of the connection by removing the Ethernet cable or switching off the CP

5. Trigger diagnostic alarms of the controllers

Simulation by start/stop or warm restart of the controller

6. Change the filter criteria Severity, category and event type

7. Acknowledge selected alarms Different behavior of active and inactive alarms

PC application A & E client

Display of eventsConfiguration Acknowledgement

S7 protocol

Page 12: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.2 Description of the core functionality

12 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Advantages of this solution

The advantages of the solution presented here include the use of the manufacturer-independent and widely used OPC technology. This sample implementation shows the most important possibilities of the OPC Alarm and Events interface.

Advantages of the solution in detail:

• Use of the international OPC Alarm and Events standard.

• Investment protection by expansion capability.

• Easy realization of a connection to different event and alarm sources.

• Configurable, thus flexible solution.

• Connection of non-Siemens systems with identical mechanism.

• High-performance data transmission by using the event mechanisms at all communication levels without the necessity for polling access.

• Acknowledgement of alarms via the OPC Alarm and Events standard.

Page 13: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.3 Required hardware and software components

Alarm Client with OPC A&E V2.0, ID Number: 26548467 13

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

2.3 Required hardware and software components

Hardware components

Table 2-2

Component Qty. MLFB/order number Note

Industrial PC SIMATIC Rack PC IL 40 S

1 6AG4 001-0AA21-0KX0 Configurator: See FAQ ID 17128155. Alternatively: Standard PC (e.g., PG) with Windows 7 (32-bit).

CP 1613 communications processor for ETHERNET, PCI card

1 6GK1 161-3AA00 Optionally, the onboard Ethernet card can also be used.

CPU 416-3 DP 1 6ES7416-3XR05-0AB0 S7 CPU.

CP 443-1 Advanced 1 6GK7443-1GX20-0XE0 Ethernet communications processor.

SM474 1 DI/DO simulator Simulation module, digital, 32xIO.

CPU315-2 DP 1 6ES7 315-2AG10-0AB0 S7 CPU, Ethernet onboard.

CP 343-1 1 6GK7343-1EX30-0XE0 Ethernet communications processor.

SM374 1 DI/DO simulator Simulation module, digital, 8xIO.

Standard software components

Table 2-3

Component Qty. MLFB/order number Note

STEP 7 V5.5 1 6ES7 810-4CC08-0YA7 To configure and program S7 300 / 400 CPUs.

SIMATIC NET CD 2010 (V8.0) SOFTNET S7 IE

1 6GK1704-1LW71-3AA0 6GK1704-1CW71-3AA0

LW=8 S7 connections (Lean), CW=64 S7 connections.

Microsoft .NET Framework 2.0

1 (Optional) When using an older SIMATIC NET version.

Download from the Microsoft home page \8\

Microsoft Visual Studio .NET 2005 Professional

1 To order this component, contact your administrator or visit the Microsoft home page \8\

(Optional) Only if changes to the sample code are necessary.

Sample files and projects

The following list contains all files and projects that are used in this example.

Table 2-4

Component Note

26548467_OPC_AE _DOKU_v20_e.pdf This document.

OPC_AE_STEP7_v20.zip This zip file contains the STEP 7 project (incl. hardware configuration for the PC station and the SIMATIC stations).

OPC_AE _CODE_v20.zip This zip file contains the executable files for the OPC client and the Visual C# project with the source code.

Page 14: 26548467_OPC_AE_DOKU_V20_e

2 Solution

2.4 Performance data

14 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

2.4 Performance data

The Alarm & Event functionality is integrated in the SIMATIC NET product. The OPC A&E server is installed by default during setup and does not have to be selected or configured separately. The OPC A&E server complies with the current OPC specification and the OPC Foundation’s latest OPC Compliance Test Tool was used to test its conformity with the OPC specification.

The S7 protocol is the only protocol that is capable of actively sending alarms from the programmable controller. Therefore, the OPC A&E functionality is only provided via the S7 protocol. It is irrelevant whether the S7 protocol is operated via Profibus or Ethernet.

Note The SIMATIC NET product includes an additional OPC Alarm & Event server that can receive alarms of SNMP devices. This document refers only to the A&E server of the S7 protocol.

Number and scope of possible alarm blocks depend on the S7 CPU type. Alarm blocks are system functions (SFC) and thus an integral part of the S7 CPU operating system.

Hardware

The SIMATIC S7 300 or 400 station and the PC must feature communications processors that support the S7 protocol.

On the PC side, this example uses S7 connections (RFC1006) via a standard Ethernet card (alternatively, a CP1613 or CP1612 would also be possible). On the S7 side, the Ethernet interface of an S7-300 with a CP343-1 and a CP443-1 in an S7-400 controller are used.

The example can also be operated on Profibus hardware in the same way. S7 connections are then configured via a respective Profibus card (CP5613/14 or CP5611). The suitable Profibus interfaces have to be used in the S7 300/400.

S7 user program

When calling the SFC blocks in the S7 CPU, system resources will be occupied for the duration of one signal cycle, thus while an alarm is present. These resources will be released as soon as the alarm cycle is completed. The current status of the dynamically occupied system resources can be checked using the SFC 105 block.

Only a limited number of resources is available, which ensures that the maximum number of simultaneously active alarms is approx. 50 (even less, depending on the CPU type).

For more information, please refer to the Step7 online help of the relevant system functions and the S7 CPU manual.

Page 15: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.1 OPC basics

Alarm Client with OPC A&E V2.0, ID Number: 26548467 15

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

3 General Functional Mechanisms

Contents

This part describes the detailed functional sequences of the involved hardware and software components, the solution structures and – where useful – the specific implementation of this application. You only require this part if you are interested in the interaction of the solution components.

3.1 OPC basics

Overview

In recent years, the OPC Foundation (an interest group of well-known manufacturers for the definition of standard interfaces) has defined a large number of software interfaces to standardize the information flow from process level to management level. According to the different requirements in an industrial application, four OPC specifications have been developed: Data Access (DA), Alarm & Events (A&E), Historical Data Access (HDA) and Data eXchange (DX). Access to process data is described in the DA specification, A&E describes an interface for event-based information, including acknowledgement, HDA describes functions for archived data and DX defines a lateral server to server communication.

This example deals with the OPC Alarm and Events 1.10 interface. A detailed documentation is available on the SIMATIC NET CD-Rom. For more information, please go to www.opcfoundation.org.

What is OPC

OPC is a collection of software interfaces for data exchange between PC applications and process devices. These software interfaces have been defined according to the rules of Microsoft COM (Component Object Model) and can therefore be easily integrated into Microsoft operating systems. COM or DCOM (distributed COM) provides the interprocess communication functionality and organizes the exchange of information between applications even across computer boundaries (DCOM). Using mechanisms of the Microsoft operating system, an OPC client (COM client) can use it to exchange information with an OPC server (COM server).

The OPC server provides process information of a device at its interface. The OPC client starts the server and can access the offered data.

The OPC A&E server collects events from the process, a client registers for notification and can set filters to have only very specific alarms signaled.

OPC DX also allows direct data exchange between two OPC DA servers.

Note If the client is located on a computer other than the server and accesses the data “remotely”, this is referred to as a DCOM connection.

Page 16: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.2 OPC Alarm & Events basics

16 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

3.2 OPC Alarm & Events basics

This chapter explains the basics of the OPC Alarm and Events (A&E) interface that are necessary for the example.

3.2.1 OPC A&E basics and delimitation from OPC DA

OPC Data Access

The OPC Data Access interface allows reading, writing and monitoring variables.

The OPC DA client explicitly defines the variables (OPC items) it wants to read, write or monitor from the server. The OPC client makes this definition by establishing a connection to the server in the first step, thus creating an OPCServer object in the OPC server, by creating an OPCGroup in which it can group items with identical settings such as update time in the second step and then by inserting items into the group in the third step. Figure 3-1 shows the different objects the OPC client creates in the server.

These items can then be read or written by the client. However, the preferred way for the data exchange from server to client is monitoring during which the server, after the set update time, signals the values of items to the client that have changed since the last cycle.

This means that events with changed data are also sent to the client when using OPC Data Access if the values of the selected items have changed. However, the OPC client explicitly selects the items to be monitored.

Figure 3-1

OPC Alarm and Events

The OPC Alarm & Events interface allows the reception of event messages and alarm messages. Event messages are single messages that inform the client on the occurrence of an event. Alarm messages are messages that inform the client on the change of a status in the process. Such a status can, for example, be the level of a tank. In this example, a status change can occur when a maximum level is exceeded or a minimum level is fallen below. Alarms mostly additionally require that the alarm be acknowledged. This acknowledgement is also possible via the OPC Alarm & Events interface.

OPC Alarm & Events thus provides a flexible interface for transmitting process alarms and events from most diverse event sources.

To receive messages, the OPC A&E client logs on to the server and then receives all messages that are triggered in the server. To limit the number of messages, the OPC client can specify filter criteria.

The OPC client logs on by establishing a connection to the A&E server, consequently creating an OPCEventServer object in the OPC server, in the first step and by generating an OPCEventSubscription via which the messages are received in the second step. Filters for messages can be configured on the

Page 17: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.2 OPC Alarm & Events basics

Alarm Client with OPC A&E V2.0, ID Number: 26548467 17

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

subscription. Figure 3-2 shows the different objects the OPC client creates in the server.

In contrast to OPC DA, there is no explicit request of specific information when using OPC Alarm & Events, but all events are provided in the process and the client can limit the number of events by filter criteria.

Figure 3-2

3.2.2 OPC Alarm and Events model

Types of event messages

OPC Alarm & Events defines three types of event messages that are described in Table 3-1.

Table 3-1

Event type Description

Simple Events Single signaling of events without condition such as a system message providing information on the failure of components.

Tracking Events Single signaling of changes to the process without condition such as the change of a setpoint.

Condition Events Alarm messages informing on the change of a condition in the process. Each condition change triggers an event message. An alarm is typically a fault condition of the process that requires special handling. If the condition of the process is normal, the condition is inactive. If the defined condition changes to a fault condition, the condition is active. Such a condition can, for instance, be a limit value whose violation causes the activation of the condition and triggers a Condition Event.

Conditions of alarm messages

A status description (condition) for a part of a process has several properties that can trigger a condition change. Table 3-2 describes the different properties. The properties are described using the example of the level of a tank.

Page 18: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.2 OPC Alarm & Events basics

18 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 3-2

Property Description

Enabled/Disabled Indicates whether condition monitoring is active. If the tank is in operation, condition monitoring is enabled and violations of the selected level limit values are provided. If the process is not active, the limit values are not monitored. This can, for example, be the case when the tank is emptied in order to clean it.

Active/Inactive Indicates whether the condition is normal. If the tank level is within the limit values, the condition is inactive. If the limit values are violated, the condition is active.

SubCondition Subconditions can be defined for a condition. For the level, there are typically the HI conditions for a violation of the high limit, HI_HI for the violation of a critical high limit and accordingly LO and LO_LO for the underflow of the low limits.

Acknowledged An alarm typically requires an acknowledgement by the operator. This property indicates whether the condition was acknowledged.

Sources for event messages

An OPC Alarm & Event server can manage several sources for event messages. The source is included in all event messages. A source is typically a device, for example a PLC or the specific block in this PLC that triggers the alarm.

If the server manages a large number of sources, OPC A&E offers the option to segment them into areas. The areas can be structured hierarchically in a tree.

The tree structure with the areas and sources can be determined using the optional IOPCEventAreaBrowser interface. Figure 3-3 shows the address space of the OPC Foundation sample server with areas, for example boiler1, and sources, for instance FIC1001.

Figure 3-3

Note SIMATIC NET A&E server version V7.0 (CD 2008) and higher supports the optional interface for browsing.

Page 19: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.2 OPC Alarm & Events basics

Alarm Client with OPC A&E V2.0, ID Number: 26548467 19

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Note SIMATIC NET uses the configured S7 connections as sources for events. The source name corresponds to the path to the block name that initiates the call, thus the S7 connection name, followed by the CPU name and the program name and the block. These default settings can be overwritten in the configuration and replaced by other texts.

Categories for event messages

The OPC A&E server divides possible event messages into event categories. The event categories are defined by the server and allow a further subdivision of the event types defined by OPC Alarm and Events.

A list of event categories can be defined for each event type. Table 3-3 shows examples of event categories.

Table 3-3

Event type Event category

System message Simple Event

Device error

System configuration Tracking Event

Change default values

Level alarm

Deviation from setpoint

Condition Event

System error

Filter options for event messages

Filtering enables an OPC A&E client to determine which events it wants to receive and to thus adjust the number of delivered messages to its requirements. Table 3-4 describes the possible filter criteria.

An event is forwarded to the client only if all of its criteria correspond to the filter values. If a filter criterion is not set by the client, it will not be used.

The OPC A&E server does not have to support all filter criteria. The list of filters supported by the server can be determined by the client.

Page 20: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.2 OPC Alarm & Events basics

20 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 3-4

Filter Description

Event Type Defines which of the possible event types are to be provided. The event types given by OPC Alarm and Events are Simple, Tracking and Condition Events.

Event Category Defines a list of possible event categories to be provided. The event categories are defined by the OPC A&E server.

Severity Defines the range of severity of events to be provided. The possible range of values for the severity from 1 to 1000 is defined by OPC A&E.

Area Defines a list of areas from which events are to be provided. The possible areas are defined by the OPC A&E server.

Source Defines a list of sources from which events are to be provided. The possible sources are defined by the OPC A&E server.

Page 21: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.3 Functional mechanisms of OPC Alarm & Events

Alarm Client with OPC A&E V2.0, ID Number: 26548467 21

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

3.3 Functional mechanisms of OPC Alarm & Events

This chapter explains the functional mechanisms of the OPC Alarm and Events interface that are necessary for the example.

3.3.1 Methods of the EventServer object

The OPCEventServer object is generated by the connection establishment of the client in the OPC A&E server. This object enables the client to determine the server configuration via the IOPCEventServer interface and to create subscriptions. Table 3-5 explains the most important methods of this interface.

Table 3-5

Method Description

QueryAvailableFilters Using this method, the filters supported by the server can be determined.

QueryEventCategories This method provides the list of event categories for the transferred event type. This list enables the client to determine which event categories the server can send for the different event types. The method provides a numeric ID and a description for each event category.

QueryEventAttributes Using this method, the client can determine the available associated values for an event category. For a subscription, these associated values can be requested in addition to the default associated values. For each attribute, the method provides a numeric ID, a description and the data type of the attribute.

CreateEventSubscription Using this method, a subscription can be created in the server. When creating the subscription, properties such as active status, buffer time and maximum number of events per callback can be specified. The buffer time indicates how long events are collected until a callback with a list of events is sent to the client. The aim is to prevent that a separate callback is sent for each event. The maximum number of events ensures that a callback is sent in any case when the defined number of events per callback is reached. If filters are to be set for the subscription, it is advisable to create the subscription as inactive, to set the filters on the subscription and to subsequently activate the subscription.

AckCondition This method can be used to acknowledge a list of alarms requiring acknowledgement. A text ID, a comment for the acknowledgement and information for the identification of the alarm must be transferred for an alarm to be acknowledged. Source name, condition name, instant of condition change to active and a cookie that was supplied with the event are transferred for the identification.

Page 22: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.3 Functional mechanisms of OPC Alarm & Events

22 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

3.3.2 Methods of the EventSubscription object

The OPCEventSubscription object is generated by calling the CreateEventSubscription method on the OPCEventServer object.

This object enables the client to configure the properties and filters of the subscription via the IOPCEventSubscriptionMgt interface and, after creating the subscription, to determine the currently active alarms from the server. Table 3-6 explains the most important methods of this interface.

Table 3-6

Methods Description

SetFilter Using this method, the filter criteria for a subscription can be defined. Possible filters are event type, event categories, severity, areas or sources. The QueryAvailableFilters method enables the client to determine which filter criteria are supported by the server.

GetFilter This method provides the filter criteria that have been set for the subscription.

SelectReturnedAttributes Using this method, additional associated values can be selected for an event category. These associated values are then supplied in addition to the associated values defined by A&E if an event of the category is signaled. The method must be called for each event category for which additional associated values are to be requested.

Refresh The call of this method triggers event messages for all active conditions in the server. After activating a subscription, all event messages after this instant are sent to the client. Messages before the instant are not sent and can be retrieved with Refresh only for active conditions.

SetState Using this method, the subscription properties such as active status, buffer time and maximum number of events per callback can be changed. The buffer time indicates how long events are collected until a callback with a list of events is sent to the client. The aim is to prevent that a separate callback is sent for each event. The maximum number of events ensures that a callback is sent in any case when the defined number of events per callback is reached. If filters are to be set for the subscription, it is advisable to create the subscription as inactive, to set the filters on the subscription and to subsequently activate the subscription.

GetState Using this method, the settings for the subscription such as active status, buffer time and maximum number of events per callback can be determined.

Page 23: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.3 Functional mechanisms of OPC Alarm & Events

Alarm Client with OPC A&E V2.0, ID Number: 26548467 23

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

3.3.3 Receiving messages from the A&E server

Register mechanism for events

A client is registered for events in four steps. Figure 3-4 shows the steps and objects involved in an overview.

Figure 3-4

The four steps for registering are:

• Step 1 – Establishing the connection to the OPC server COM mechanisms are used to establish the connection from the OPC A&E client to the server. The OPC Event Server object is generated during this process.

• Step 2 – Creating a subscription Using the CreateEventSubscription method on the OPC Event Server object, the client can create a subscription. During this process, the OPC Event Subscription object is created in the server. The subscription should be created as inactive. The SetFilter method on the subscription is used to make the filter settings.

• Step 3 – Establishing the callback connection To receive the event messages, the OPC A&E client must implement the IOPCEventSink interface with the OnEvent method. This callback interface is registered via the connection point container and the associated connection point in the Subscription object. After registering the callback interface, the client can activate the subscription using the SetState method.

• Step 4 – Sending the event messages After the subscription has been activated, the server uses the OnEvent method to send a respective list of event messages to the client. After activating, the client can request the messages for the active conditions using the Refresh method. The OnEvent method is also used for signaling.

Associated values of Simple Events

The OPC A&E specification defines a set of associated values that is provided by the server for Simple Events. Table 3-7 describes these associated values. The other event types are also based on these associated values, but they supply additional associated values for the respective type.

Additional associated values can additionally be requested depending on event categories.

Page 24: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.3 Functional mechanisms of OPC Alarm & Events

24 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 3-7

Associated value Description

Source Name of the event message source.

Time Instant when the event has occurred.

Type Event type of the event message. Value Meaning 1 Simple Event 2 Tracking Event 4 Condition Event

Event Category Numeric ID of the event category defined by the server. The list of event categories supported by the server with numeric ID and a description can be determined using the QueryEventCategories method on the Event Server object.

Severity Severity of the event message. The range of values of the severity is from 1 to 1000. 1000 corresponds to the highest severity.

Message Descriptive text for the event message.

Associated values of Tracking Events

The OPC A&E specification defines a set of associated values that is provided by the server for Tracking Events. This set consists of the associated values defined for Simple Events and an additional associated value for Tracking Events. Table 3-8 describes this additional associated value.

Additional associated values can additionally be requested depending on event categories.

Table 3-8

Associated value Description

Actor ID Text ID identifying the application that has triggered the event, for example, by changing a setpoint. If this application is an OPC client, this is the OPC client name that can be set when establishing the connection.

Page 25: 26548467_OPC_AE_DOKU_V20_e

3 General Functional Mechanisms

3.3 Functional mechanisms of OPC Alarm & Events

Alarm Client with OPC A&E V2.0, ID Number: 26548467 25

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Associated values of Condition Events

The OPC A&E specification defines a set of associated values that is provided by the server for Condition Events. This set consists of the associated values defined for Simple Events and additional associated values for Condition Events. Table 3-9 describes these additional associated values.

Additional associated values can additionally be requested depending on event categories.

Table 3-9

Associated value Description

Condition Name Name of the condition at which a condition change has occurred.

Sub Condition Name Name of the active subcondition within the condition.

Change Mask A bit mask indicating which condition properties have changed and thus triggered the event. Bit number Meaning 0 Active status 1 Acknowledgement status 2 Enabled / Disabled 3 Quality of the value for condition monitoring 4 Severity 5 Subcondition 6 Message text 7 Additional attributes

New State A bit mask indicating the condition status at the time of the event. If the bit for the relevant property is set, this property is active. Bit number Property Meaning when bit set 0 Enabled / Disabled TRUE = Enabled 1 Active status TRUE = Active 2 Acknowledgement status TRUE = Acknowledged

Condition Quality Indicates the quality of the value on which the condition is based. This can, for instance, be the level of a tank.

Ack Required A flag indicating whether the alarm must be acknowledged.

Active Time Instant when the status of the condition has changed to active or the change to the current subcondition has occurred.

Cookie A server-defined cookie that uniquely identifies the event together with other parameters from the event. When calling AckCondition on the Event Server object, this identification is necessary to acknowledge the alarm.

Actor ID Text ID identifying the application that has acknowledged the alarm. If this application is an OPC client, this is the text ID that is transferred when acknowledging with AckCondition. This associated value is an empty string if the event is not triggered by an acknowledgement.

Page 26: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.1 Functionality of the alarm client

26 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4 Functionality of the Client Application

4.1 Functionality of the alarm client

The OPC client application is used for the following tasks:

• Display of event messages and alarms of any OPC Alarm and Events servers.

• Selection and display of additional associated values, depending on the event categories provided by the server and their associated values.

• Acknowledgement of alarms.

• Configuration of filter criteria to be able to limit the signaled events.

User interface of the application

The following figure shows the user interface of the OPC client.

Figure 4-1

Configuration of the OPC A&E communication

The user interface is used to visualize the event and alarm messages and to change the settings for the number of delivered messages and their associated values. Based on the instant they were received, the messages are arranged in the list from bottom to top. The latest message is thus always displayed on the top of the list. The list length is limited to 100 items, old messages are deleted.

The following actions can be performed using the user interface elements (menu, context menu in the list or buttons):

• Connecting to the set OPC A&E server.

• Disconnecting from the OPC A&E server.

• Configuring the settings for the transfer of messages.

Page 27: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.2 Functional mechanisms of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 27

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

• Configuring the settings for the filters that are applied to the messages.

• Selecting additional associated values.

• Acknowledging alarm messages.

4.2 Functional mechanisms of the alarm client

The figure below shows the function blocks in the OPC client and the interaction with the OPC server.

Figure 4-2

The following table explains the individual function blocks and steps.

Table 4-1

No. Description

1 When establishing the connection between user interface and OPC server, a Server object is generated on the client side. This object encapsulates the .NET accesses to the EventServer object of the OPC Alarm and Events COM interface (2).

2 The OPCEventServer object is generated in the server via the OPC A&E interface.

3 When establishing the connection between user interface and OPC server, a Subscription object is generated on the client side. This object encapsulates the .NET accesses to the EventSubscription object of the OPC Alarm and Events COM interface (4).

4 The OPCEventSubscription object is generated in the server via the OPC A&E interface. On the subscription, the filters for the messages are set and additional associated values are requested.

Pro

cess

P

roce

ss

Administration

Administration

OPC A&E interface

Protocol layer / driver

Page 28: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.2 Functional mechanisms of the alarm client

28 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5 To be able to receive event messages from the server, a callback connection is established. A Callback object is created in the client and connected to the subscription in the server. When messages are sent from the server to the client, the client enters the messages in the list.

Page 29: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 29

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4.3 Class diagrams of the alarm client

This chapter explains the static structure of the OPC client using a UML class diagram.

The following table provides an overview of the most important C# classes and classifies them according to their tasks.

The classes are divided into three modules:

• OPC Alarm and Event Client API The module in the AEClientApi directory provides a .NET interface for access to OPC A&E servers. The module can be used independently of the sample application.

• Event View Control Based on a subscription from the OPC A&E Client API, this .NET Control displays event messages of OPC servers. The module can be used independently of the sample application.

• Sample application The sample application in the AEClient directory implements the OPC A&E client using the EventView and OPC A&E Client API modules.

Table 4-2

Class Task Description

Server OPC A&E Client API

A wrapper class that encapsulates the OPCEventServer functionality and thus allows simplified access to the COM object via .NET methods.

Subscription OPC A&E Client API

A wrapper class that encapsulates the OPCEventSubscription functionality and thus allows simplified access to the COM object via .NET methods.

AreaBrowser OPC A&E Client API

A wrapper class that encapsulates the OPCEventAreaBrowser functionality and thus allows simplified access to the COM object via .NET methods.

EventNotification OPC A&E Client API

This class encapsulates the data of an event.

SampleClient Sample application

This class implements the functionality of the main dialog box of the sample application.

EventView Display of events

This class implements the functionality to display event messages.

SubscriptionSettingsDlg Sample application

This class implements the dialog box for configuring the general subscription settings.

FilterSettingsDlg Sample application

This class implements the dialog box for configuring the filter settings for the subscription.

AttributeSelectionDlg Sample application

This class implements the dialog box for selecting the additional associated values for the subscription.

Page 30: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

30 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4.3.1 OPC Alarm and Event Client API

The following class diagram shows the OPC A&E Client API classes. These classes encapsulate the accesses to the COM interface in a .NET API. The individual classes are explained in detail on the following pages.

Figure 4-3

Server class

The Server wrapper class described in the following table encapsulates the OPCEventServer functionality and thus allows simplified access to the COM object using C# methods.

The class is implemented in the OpcAeServer.cs file in the AEClientApi module.

Table 4-3

Method Functionality

Server Constructor for the Server class.

Connect Establishes the connection to the server using COM mechanisms.

Disconnect Enables all COM interfaces of the server and thus terminates the connection to the OPC server.

CreateSubscription Creates a subscription with the transferred settings.

QueryAvailableFilters Provides the filter criteria that are accepted by the OPC server.

QueryEventCategories Provides the event categories that are provided by the OPC server. These event categories can be used for filtering.

QueryEventAttributes Provides the possible additional attributes that can be requested for an event category in a subscription.

AcknowledgeCondition Acknowledges one or several alarm messages.

Dispose Enables all COM interfaces of the server and thus terminates the connection

Page 31: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 31

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

to the OPC server.

Subscription class

The Subscription class described in the following table is a wrapper class that encapsulates the OPCEventSubscription functionality and thus allows simplified access to the COM object using C# methods.

The class is implemented in the OpcAeSubscription.cs file in the AEClientApi module.

Table 4-4

Method Functionality

Subscription Constructor for the Subscription class.

SetFilters Sets the filter criteria to be used for the event messages of this subscription.

GetFilters Provides the currently set filter criteria.

SelectReturnedAttributes Allows the selection of additional attributes for an event category and must be called for each event category.

Refresh Using this method, all messages for currently active conditions can be requested.

SetState Sets the subscription settings, for example active status.

GetState Provides the current subscription settings.

Dispose The call of this method is necessary if the subscription is no longer required and if all COM interfaces of the subscription are to be enabled. Allows defined disconnecting from the subscription.

EventChanged Property of the class via which the delegate can be registered for event callbacks to the application. When registering, the callback connection to the OPC server is also established. The mechanism for registering the callback to the OPC server is described in chapter 3.3.3.

AreaBrowser class

The AreaBrowser class described in the following table is a wrapper class that encapsulates the OPCEventAreaBrowser functionality and thus allows simplified access to the COM object using C# methods.

The class is implemented in the OpcAeAreaBrowser.cs file in the AEClientApi module.

Table 4-5

Method Functionality

AreaBrowser Constructor for the AreaBrowser class.

BrowseOPCAreas Provides areas or sources at the address area position where the AreaBrowser is located. The position can be changed using ChangeBrowsePosition. BrowseFilterType can be used to determine whether areas or sources are provided.

ChangeBrowsePosition Changes the current AreaBrowser position, i.e. the position in the address area where browsing takes place. The BrowseDirection parameter indicates whether the position in the hierarchy is changed towards the top, the bottom or directly to a specific position.

GetQualifiedAreaName Allows to get a name that is unique in the entire address area (fully qualified area name) from an area name (obtained through BrowseOPCAreas). This is, for example, necessary to expand an Area filter.

GetQualifiedSourceName Allows to get a name that is unique in the entire address area (fully qualified source name) from a source name (obtained through BrowseOPCAreas).

Page 32: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

32 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

This is, for example, necessary to expand a Source filter.

Page 33: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 33

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Dispose The call of this method is necessary if the AreaBrowser is no longer required and if all COM interfaces of the AreaBrowser are to be enabled. Allows defined disconnecting from the AreaBrowser interface.

EventNotification class

The EventNotification class encapsulates the data of an event. The properties of the class correspond to the associated values of the event messages described in chapter 3.3.3.

The class is implemented in the OpcAeSubscriptionHelper.cs file in the AEClientApi module.

Subscription.Callback class

The Subscription.Callback class described in the table below is an internal utility class to implement the callback interface from the OPC server to the OPC client for signaling events. The conversion of the OnEvent callback to the EventChanged delegate of the subscription is realized in this class.

The class is implemented in the OpcAeSubscription.cs file in the AEClientApi module.

Table 4-6

Method Functionality

OnEvent This method implements the callback interface for the signaling of events from the server to the client. When this method is called by the server, the transferred event information for each event is packed in the EventNotification class and forwarded to the application via the EventChanged delegate.

Page 34: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

34 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4.3.2 OPC A&E client sample application

The following class diagram shows the classes of the OPC A&E sample client. These classes realize the functionality of the user interface and use the A&E Client API classes. The individual classes are explained in detail on the following pages.

Figure 4-4

SampleClient class

The SampleClient class described in the following table implements the main dialog box functionality of the client application.

The class name corresponds to the file name in the AEClient module.

Table 4-7

Method Functionality

OnConnect Implements the functionality to connect to the server, to query the settings for the subscription and to create the subscription.

OnDisconnect Deletes the subscription and disconnects from the server.

OnSubscriptionSettings Opens the dialog box for the subscription settings and updates the subscription settings.

OnSubscriptionFilterSettings Opens the dialog box for the filter criteria settings and updates the filter criteria for the subscription.

OnSelectAttributes Opens the dialog box for selecting the attributes.

OnAcknowledgeAlarm Acknowledges an alarm.

Page 35: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.3 Class diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 35

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

EventView class

The EventView class described in the table below implements the functionality to display event messages.

The class name corresponds to the file name in the EventView module.

Table 4-8

Method Functionality

SetSubscription Sets the subscription for EventView and registers the callback for EventView.

DeleteSubscription Deletes the subscription.

OnEventChanged Receives new events and enters them in the list.

SubscriptionSettingsDlg class

The SubscriptionSettingsDlg class described in the following table implements the dialog box for configuring the general subscription settings.

The class name corresponds to the file name in the AEClient module.

Table 4-9

Method Functionality

ShowDialog Transfers the current status of the subscription to the dialog box and displays the dialog box. When closing the dialog box with OK, the new settings for the subscription are read out of the dialog box and returned.

FilterSettingsDlg class

The FilterSettingsDlg class described in the table below implements the dialog box for configuring the filter settings for the subscription.

The class name corresponds to the file name in the AEClient module.

Table 4-10

Method Functionality

ShowDialog Transfers the current filter settings of the subscription to the dialog box and displays the dialog box. When closing the dialog box with OK, the new filter settings for the subscription are read out of the dialog box and returned.

AttributesDlg class

The AttributesDlg class described in the following table implements the dialog box for selecting the additional associated values for the subscription.

The class name corresponds to the file name in the AEClient module.

Table 4-11

Method Functionality

ShowDialog Transfers the saved filter settings to the dialog box and displays the dialog box. When closing the dialog box with OK, the selected attributes are read out of the dialog box and returned.

Page 36: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

36 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4.4 Sequence diagrams of the alarm client

Connecting to the OPC server

The following sequence diagram shows the sequences when the user of the application performs the “Connect Server” action to establish the connection to the OPC server. This action can be started using the Connect button on the user interface or via the Server menu.

Page 37: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 37

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Figure 4-5

2

3 4

6

5

1

7

8

9

10

Page 38: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

38 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 4-12

No. Description

1 The OnConnect method on the SampleClient object is called by the “Connect Server” user action. The actions for connecting to the server and creating the subscription are performed in this method. In the first step, the Server object from the Client API is created and the Connect method on the Server object is called. This ensures that the connection to the OPC server defined by the URL is established.

2 The dialog box for the subscription settings is created and initialized using the SubscriptionSettings auxiliary function of the SampleClient class. Default values are transferred as a status. Subsequently, the dialog box for the settings opens to enable the user to make the desired settings. When the user closes the dialog box, the settings are determined from the dialog box.

3 The QueryAvailableFilters and QueryEventCategories methods on the Server object are used to determine the necessary configuration parameters for the filter dialog box by the OPC server. QueryEventCategories is called for each event type.

4 An AreaBrowser is created. It is transferred to FilterSettingsDlg to browse for areas and sources on the server and to display them to the user.

5 The dialog box for the filter settings is generated and initialized with the information from the server. The configuration parameters determined in step 3 and blank filter settings are transferred. Subsequently, the dialog box for the filter settings opens to enable the user to select the desired filters. When the user closes the dialog box, the settings are determined from the dialog box.

6 The dialog box uses the AreaBrowser to recursively retrieve all areas and sources on the server.

7 Using the CreateSubscription method on the Server object, a subscription is created as inactive.

8 The subscription created in step 5 is transferred to the EventView object with SetSubscription. In this method, EventView connects the Callback method in the EventView object to the delegate of the subscription. The subscription activates the callback connection to the OPC server.

9 After creating the subscription and establishing the callback connection, the filter settings for the subscription are made on the Subscription object using the SetFilter method. By calling the SetState method on the Subscription object, the desired status of the subscription is set. If the user has configured the subscription as active, the subscription is activated with this call and events can be sent from the server to the client.

10 By calling the Refresh method on the subscription, the messages for active conditions are requested from the server. Like all other event messages, these messages are delivered to the client via the callback mechanism.

Page 39: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 39

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Disconnecting from the OPC server

The following sequence diagram shows the sequences when the user of the application performs the “Disconnect Server” action. This action can be started using the Disconnect button on the user interface or via the Server menu.

Figure 4-6

Table 4-13

No. Description

1 The OnDisconnect method on the SampleClient object is called by the “Disconnect Server” user action. The actions for deleting the subscription and disconnecting from the server are performed in this method. In the first step, the subscription is deleted in the server. This is done by calling the DeleteSubscription method on the EventView object that calls the Dispose method on the AeSubscription object. In this method, the COM interfaces of the Subscription object are enabled in the OPC A&E server, which deletes the subscription.

2 In the second step, the Disconnect method on the AeServer object is called. In this method, the COM interfaces of the Server object are enabled in the OPC A&E server, which clears the connection.

1

2

Page 40: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

40 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Changing the subscription settings

The sequence diagram below shows the sequences when the user of the application performs the “Change Subscription Settings” action. This action can be started via the Subscription menu.

Figure 4-7

Table 4-14

No. Description

1 The OnSubscriptionSetting method on the SampleClient object is called by the “Change Subscription Setting” user action.

2 The current subscription status is read out using the GetState method.

3 The dialog box for the subscription settings is created and initialized using the SubscriptionSettings auxiliary function of the SampleClient class. The current subscription settings are transferred as a status.

4 Subsequently, the dialog box for the settings opens to enable the user to make the desired settings. When the user closes the dialog box, the settings are determined from the dialog box.

5 The SetState method is used to change the subscription status to the new settings.

1

2

3

4

5

Page 41: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

Alarm Client with OPC A&E V2.0, ID Number: 26548467 41

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Changing the subscription filters

The sequence diagram below shows the sequences when the user of the application performs the “Change Subscription Filter” action. This action can be started via the Subscription menu.

Figure 4-8

Table 4-15

No. Description

1 The OnSubscriptionFilterSetting method on the SampleClient object is called by the “Change Subscription Filter” user action.

2 Using the QueryEventCategories method, the event categories are determined from the server. The method is called for each event type.

3 The GetFilters method is used to read the current filter configuration from the server.

4 The FilterSettings auxiliary function is used to determine the new settings. QueryAvailableFilters

78

9

1

2

3

4 5

6

Page 42: 26548467_OPC_AE_DOKU_V20_e

4 Functionality of the Client Application

4.4 Sequence diagrams of the alarm client

42 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

is used to query the possible filter settings from the server.

5 An AreaBrowser is generated. It is transferred to FilterSettingsDlg to browse for areas and sources on the server and to display them to the user.

6 The dialog box for the filter settings is generated and initialized with the information from the server. The information determined in step 2, step 3 and step 4 is transferred.

7 The dialog box uses the AreaBrowser to recursively retrieve all areas and sources on the server.

8 Subsequently, the dialog box for the filter settings opens to enable the user to select the desired filters. When the user closes the dialog box, the settings are determined from the dialog box.

9 The SetFilter method is used to change the subscription filter settings to the new settings.

Page 43: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.1 Extended alarm configuration for STEP 7 V5.5 and higher

Alarm Client with OPC A&E V2.0, ID Number: 26548467 43

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5 Explanation of the S7 Sample Program The type and number of alarms supported by an S7 CPU depend on its type and firmware version. ID Number: 841294 on the Customer Support website provides an overview. http://support.automation.siemens.com

5.1 Extended alarm configuration for STEP 7 V5.5 and higher

This chapter explains the concepts of the alarm signaling procedure and the basic steps for its configuration. The message number procedure is examined, which, unlike the bit message procedure in which the operating system or the OPC server monitors individual bits on a polling basis, actually actively throws events out of the automation system and thus causes a significantly lower bus load. The message texts of the message number procedure are generated from a shared database, additional texts can be configured and the messages include the time stamp from the automation system.

The actual configuration is not new, but, when using STEP 7 V5.5 or higher, the configured alarm information is edited for the SIMATIC NET OPC server (V7.1 and higher) when “saving and compiling”. When the PC station containing the OPC server is loaded (or XDB import), the OPC Alarm&Event server also knows the configuration and displays message texts, sources and areas as OPC attributes. The configuration using an additional file (scores7.msg) that was necessary in earlier OPC A&E server versions is thus no longer necessary and the configuration is continuous and consistent.

Introduction

Basically, there are three different types of messages that differ in their area of application:

• Block-related messages Signaling of program-synchronous events, programming via alarm signaling blocks.

• Symbol-related messages Signaling of program-independent events, configuration via the symbol table (only S7-400).

• User-defined messages Signaling of program-synchronous diagnostic events, programming via system functions.

Configuration

STEP 7 supports the configuration of the message number procedure with the following languages or tools:

• LAD/FBD/STL/SCL

• Symbol table

• PDIAG

• CFC

• S7-GRAPH

In this example, only STEP 7 (STL and symbol table) is used for the configuration.

Page 44: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.1 Extended alarm configuration for STEP 7 V5.5 and higher

44 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Block-related messages

The alarm signaling block is the most frequently used alarm. Different blocks (SFB/SFC) exist, which differ in the number of monitored signals, the number of associated values and the acknowledgement capability.

Each of these blocks represents a message type once it is, supplied with respective formal parameters, called, for example, in an FB and thus represents a message-type FB. This type can now be configured in STEP7 and the properties can be defined and even locked.

The type is configured in the Simatic Manager: Right mouse button on the FB (that calls the SFB), Special Object Properties Message… and the dialog box for configuring the type opens. The message number=0 column indicates that it is a configuration of the type.

Figure 5-1

Configuring the type and locking the parameters is used when you want to use a block to signal events that are always identical. For example, the structure of analog measuring points is always identical with regard to their alarms and the measuring points provide alarms whenever a limit value is exceeded or fallen below, a threshold value is exceeded or fallen below and a general error interrupt if the measuring point is faulty. A respective alarm type is generated, of which instances will be generated later in the program; the structures of these instances are always identical.

When calling the FB in OB1, an instance data block is generated (Call FB200, DB200). The messages of these instances look exactly as defined in the message type. On the instance, the parameters that have not been locked can now be filled, i.e. the instance-specific parameters.

The instance is configured in the Simatic Manager: Right mouse button on the DB (multi-instance DB of the FB), Special Object PropertiesMessage… and the dialog box for configuring the instance opens. The message number=<no.> (not “0”) column indicates that it is a configuration of the instance.

Page 45: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.1 Extended alarm configuration for STEP 7 V5.5 and higher

Alarm Client with OPC A&E V2.0, ID Number: 26548467 45

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Figure 5-2

Parameters that still correspond to the ones of the original type are displayed in green, all other parameters for this instance have already been changed.

Symbol-related messages

The symbol-related message is used rarely and only to monitor asynchronous events; in this case, asynchronous means asynchronous to the OB1 cycle. It uses up system resources, loads the CPU cycle time and is possible only when using the S7-400. Monitoring of a binary signal is configured using the symbol table. Independently of the OB1 cycle, this bit is monitored at a fixed interval (100, 500, 1000 ms) (SCAN). The time interval depends on the CPU type.

After completing the configuration in the symbol table, system blocks (SDB) have to be generated and loaded to the controller.

All binary symbols can be monitored (inputs, outputs and flags). Once a signal change is detected, the configured “scan alarm” is initiated. This alarm can contain up to 10 associated values.

User-defined messages

Using the SFC52 (WR_USMSG) system function, user entries are written to the diagnostic buffer of the CPU and a message is simultaneously sent. This message type is thus used exclusively for system-relevant events. 255 event numbers are available for each of the two error classes (A and B), for which one text can be configured for an incoming message and one can be configured for an outgoing message.

In the user program, the system function (Call SFC 52) is called at an appropriate location (e.g., in OB100, the warm start OB) and provided with the desired event ID (0xA101).

Page 46: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.2 Alarms of the SIMATIC S7 station

46 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Figure 5-3

Unlike the “Report System Error” function, the user assigns event numbers and calls SFC 52 in the program. When using “Report System Error”, the numbers (a special number range) and also the texts are specified by the system or compiled during the call by determining diagnostics information.

5.2 Alarms of the SIMATIC S7 station

This chapter shows the possible event messages of a SIMATIC S7 station and describes their display in OPC Events (SIMATIC NET V8.0) in greater detail.

Categories

Event messages that can be signaled by an S7 station are divided into ten categories:

• System message

• Programmed alarm (off normal)

• Programmed alarm (level)

• Programmed alarm (deviation)

• Programmed alarm (rate of change)

• Programmed alarm (trip)

• Programmed alarm (change of state)

• Programmed alarm (device failure)

• Programmed alarm (system failure)

• Connection alarm (statepath)

Page 47: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.2 Alarms of the SIMATIC S7 station

Alarm Client with OPC A&E V2.0, ID Number: 26548467 47

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Note Categories 2 to 14 were used in SIMATIC NET version < V8.0. Categories 40 to 60 are used in version V8.0 and higher.

Event types

The OPC Alarm & Events specification defines three types of events; the SIMATIC NET OPC server supports two of these types. The events are displayed as shown in the following table:

Table 5-1

OPC event type OPC.SimaticNETAlarms.1

Simple Events Diagnostic event (system message) System message

Conditional Events Programmed alarms (all) Connection alarm (statepath)

Tracking Events Not supported

Simple alarms

The SIMATIC NET A&E OPC server offers simple alarms of the “SIMATIC S7 simple alarm” type with clearly reduced information contents only for compatibility reasons with earlier SIMATIC NET software versions. The use of these alarms is not recommended and should be disabled in the S7 connection configuration (NetPro). Nowadays, respective alarms are sent as conditional events and it is absolutely necessary to avoid “double” sending.

Note Disable simple alarms in the connection configuration (NetPro) to avoid “double” signaling of the same event. Where possible, use ALARM_D and the acknowledgeable ALARM_DQ variant instead of the older variants.

The figure below shows the disabling of the alarms of the “SIMATIC S7 simple alarm” type in the Properties dialog box of the connection configuration.

Page 48: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.2 Alarms of the SIMATIC S7 station

48 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Figure 5-4

More recent OPC server versions, i.e. SIMATIC NET V8.0 or higher, no longer have this setting since block messages are no longer sent as Simple Events.

System messages

Events of the system error message class (formerly diagnostic events) are independently triggered by the S7 CPU or CP or the I/O module (e.g., DP slaves or PNIO device) and filled in the diagnostic buffer of the relevant component. The respective error OBs are called and the hexadecimal ID number of the diagnostic event enables the user to determine the cause using the module description (for example, cold restart/warm restart request, restart, I/O access error, insert/remove interrupt, etc.).

Events of the user-defined diagnostic messages (SFC52) class are always entered in the diagnostic buffer of the CPU and can additionally be made available as a system message via OPC. In the user program, the WR_USMSG function is called, which has previously been configured with text messages for an incoming and an outgoing event.

Programmed alarms

As a part of the operating system, the SIMATIC S7 controller family offers system function blocks (SFB/SFC) that are capable of sending events via the S7 protocol. Scope and type of these SFC depend on the respective S7 CPU type. These blocks must be called in the S7 control program (e.g., STL code) to trigger a respective alarm. Hence the name “SIMATIC S7 programmed alarm”.

The following table contains all block-related S7 events. It lists the names of the blocks and their core functions. The listed blocks differ in the number of channels (number of monitored signals) and the number of possible associated values that

Page 49: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.2 Alarms of the SIMATIC S7 station

Alarm Client with OPC A&E V2.0, ID Number: 26548467 49

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

can be included in the transfer. Furthermore, some alarms can be acknowledged, others cannot.

Table 5-2

Event Description

ALARM_8 (SFB34) 8 channels, acknowledgeable, no associated values

ALARM_8P (SFB35) 8 channels, acknowledgeable, up to 10 associated values

NOTIFY (SFB36) 1 channel, non-acknowledgeable, up to 10 associated values

ALARM (SFB33) 1 channel, acknowledgeable, up to 10 associated values

ALARM_S (SFC18) 1 channel, non-acknowledgeable, 1 associated value

ALARM_SQ (SFC17) 1 channel, acknowledgeable, 1 associated value

AR_SEND (SFB37) For sending archives

NOTIFY_8P (SFB 31) 8 channels, non-acknowledgeable, up to 10 associated values

ALARM_DQ (SFC 107) 1 channel, acknowledgeable, 1 associated value

ALARM_D (SFC 108) 1 channel, non-acknowledgeable, 1 associated value

The S7-300 does not have the full scope of alarm functions.

Note SIMATIC S7-300 supports only ALARM_S and ALARM_D and the acknowledgeable ALARM_SQ and ALARM_DQ variants.

Each time the status of one of the monitored channels changes, an alarm is triggered and sent (rising and falling edge of a channel input form an incoming and an outgoing event). The duration of a pending alarm is referred to as an alarm cycle, thus the time between rising and falling edge of the signal input while the signal input (SIG) of the block has the “high” (true) status. During this time, the alarm occupies system resources, its status and time stamp are kept in the memory and can, for example, be queried by a refresh. Once the state machine has been completely processed, i.e. an acknowledged alarm event has “gone” and the SIG input has accordingly fallen to “low” (false), the S7 CPU “forgets” this alarm and releases the resource. Thus no history is kept in the controller.

In addition to the programmed alarms described above, the S7-400 offers the SCAN alarm, the so-called symbolic message. This is cyclic monitoring of individual binary signals (input, output and flag). The SCAN alarm is configured using the symbol table and should be used “economically” since it loads the system due to the cyclic test. No program block is called for the SCAN alarm, it is therefore also referred to as a “configured” alarm (in contrast to the “programmed alarm”).

Connection alarms

The connection or statepath alarm class is not initiated in the S7 station but in the actual OPC A&E server. A failure of an S7 connection or an interruption of the connection (for example, CP goes to stop or a cable is removed) is detected by the OPC server, a respective alarm is generated and sent to all accordingly registered clients.

Page 50: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.3 Display of attributes in OPCEventNotification

50 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5.3 Display of attributes in OPCEventNotification

The OPC Alarm & Events specification defines attributes that must be contained in an OPC event notification and attributes that have to be additionally included depending on the alarm type (event type). Furthermore, there are attributes that can be optionally (manufacturer-specifically) included.

This chapter describes the OPC attributes and their contents according to the S7 alarms. It describes the default selections of these attributes. Some attributes such as “Source”, “Area”, “Message” and “Time” can also be filled with different contents using configuration options. (See chapter 5.3.)

Default attributes of OPCEventNotification

The following table shows all default attributes that are provided with each event:

Table 5-3

OPC attribute Content (description)

Source <ConnectionName\PathToBlock> (can be changed in the STEP7 block configuration)

Area <ConnectionName\PathToBlock> (can be changed in the STEP7 block configuration)

Time <S7 time when the alarm was called> (can be changed in the NetPro S7 connection configuration, note: PC time in UTC is provided only for statepath)

Type <SIMPLE> or <CONDITION> (no Tracking Events)

Category <Number> 14=Statepath, 40=Level, 41=Deviation, 42=RateOfChange, 43=OffNormal, 44=Trip, 45=ChangeOfState, 46=DeviceFailure, 47=SystemFailure, 60=SystemMessage

Severity <1..1000> (default=500, can be set via NetPro, S7 connection configuration or directly when calling the block)

Message <Text#> The text corresponds to the condition and EventID. The text can be changed via STEP7 when using version 8.0 or higher. Chapter 5.3 describes the configuration.

Note For some blocks, e.g. ALARM, ALARM_8P or NOTIFY, the severity (0-16) is specified directly at the block in the S7 program; this severity wins through against the default priority for alarm messages that can be configured in NetPro and is automatically converted to OPC severity (1000-1) according to linear conversion. The highest block severity “0” corresponds to the highest OPC severity “1000”.

The alarm severities for specific alarm numbers configured in NetPro win through against the general default severity for alarm messages and also against programmed message weights.

ALARM_S/D and ALARM_SQ/DQ have no severity so that the configured message weights are always used.

Page 51: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.3 Display of attributes in OPCEventNotification

Alarm Client with OPC A&E V2.0, ID Number: 26548467 51

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Additional attributes of OPCEventNotification for conditional events

The following table shows attributes that are provided for “conditional events” in addition to the ones shown table 5-3.

Table 5-4

OPC attribute Content (description)

ConditionName <FixedText#> (default text, consisting of Category & EventID)

SubConditionName <ConditionName> if this alarm has no SubCondition, otherwise <SubconditionName>

ActiveTime <S7 time when the condition has occurred> (PC time in UTC is provided for statepath alarms)

Attributes for Category 2 (Alarm)

Version 8.0 no longer includes Category 2 alarms; therefore, their attributes are not described in detail at this point.

Attributes for Category 60 (System Message)

In manufacturer-specific attributes, Category 60 system messages provide additional information as shown in the following table:

Table 5-5

Attribute ID Content = example (description)

0xFF FF FF FB <Event Type> (VT_I4) =“16” (simple)

0xFF FF FF FA <Severity> (VT_I4) =“500”

0xFF FF FF F7 <Category Identifier> (VT_I4) =“60”

0xFF FF FF F6 <Category Description> (VT_BSTR)=“SIMATIC S7 diagnosis event”

0x00 00 17 70 <PC Time> (VT_Date)

0x00 00 17 71 <S7 Time> (VT_Date)

0x00 00 17 A0 <Diagnostic ID> (VT_I4) =“12345” (decimal)

0x00 00 17 A1 <Diagnostic Data> (Array of VT_UI1)=“255|70|199|114|67|4|8|20|23|20”

0x00 00 17 A2 <S7ConnectionName> (VT_BSTR) =“S7Conn”

0x00 00 17 A3 <Areas> (Array of VT_BSTR) = [“”]

Attributes for Category 40 to 47 (Programmed)

In manufacturer-specific attributes, Category 40 to 47 programmed alarms provide additional information as shown in the following table. Up to 10 associated values (each with data type, length and the actual data) can be included in EventNotification as attributes.

Table 5-6

Attribute ID Content = example (description)

0xFF FF FF FB <Event Type> (VT_I4) =“32” (conditional)

0xFF FF FF FA <Severity> (VT_I4) =“500”

0xFF FF FF F7 <Category Identifier> (VT_I4) =“43”

Page 52: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.3 Display of attributes in OPCEventNotification

52 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Attribute ID Content = example (description)

0xFF FF FF F6 <Category Description> (VT_BSTR)=”SIMATIC S7 programmed alarm”

0x00 00 17 70 <PC Time> (VT_Date)

0x00 00 17 71 <S7 Time> (VT_Date)

0x00 00 17 72 <Status> (VT_UI2) =“0”

0x00 00 17 73 <Acknowledgement Status> (VT_UI2) =“256”(unack);“257”(ack)

0x00 00 17 74 <Event State> (VT_UI2) =“0”

0x00 00 17 75 <# Additional Data> (VT_UI2) =“1”

0x00 00 17 76 <Data Type> (VT_UI2)

0x00 00 17 77 <Length> (VT_UI2)

0x00 00 17 78 <Data> (array of VT_UI1)

to 0x00 00 17 9C <DataType><Length><Data> (one triple per associated value, as above)

0x00 00 17 9E <Event ID> (VT_UI4) =“5”

0x00 00 17 9F <Subevent ID> (VT_UI4) =“3”

Attributes for Category 14 (Statepath)

In manufacturer-specific attributes, Category 14 connection alarms provide additional information as shown in the following table.

Table 5-7

Attribute ID Content = example (description)

0x00 00 00 05 <Event Type> (VT_I4) =“32” (conditional)

0x00 00 00 06 <Severity> (VT_I4) =“500”

0x00 00 00 09 <Category Identifier> (VT_I4) =“14”

0x00 00 00 0A <Category Description> (VT_BSTR)=“SIMATIC S7 statepath alarm”

Page 53: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.4 User program of this example

Alarm Client with OPC A&E V2.0, ID Number: 26548467 53

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5.4 User program of this example

Introduction

A block call that is, as far as possible, executable in all S7 CPUs and that illustrates the basic functions of “programmed alarms” was selected for this application example. For reasons of clarity, the status word was not evaluated.

The necessary STL code fragment is executable in the S7-300 and the S7-400 and thus used here as a general example.

User program

Basically, the S7 program consists of two parts. Initially, the binary signals for the alarms are simulated and then the signals are allocated to the alarm blocks and called in FB 200.

Figure 5-5

Page 54: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.4 User program of this example

54 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Simulation of binary signals

The table below provides a brief overview of the program parts and their function for the signal simulation. It was a deliberate decision to avoid details; further comments can be found in the STL code.

Table 5-8

Block Comment

OB1 Cyclic Main Initially, a variable timer is set here, whose interval is used to call the other program functions. The data rate of change can be set via DB11 byte 0.

FC15 ChangeSignalBits Toggles Boolean variables in DB11 and flag bit 20.0 (symbolic message).

DB11 SimulationAlarms Contains global variables to configure the data simulation.

DB20 AssociatedValues Contains several associated values as examples, which are to be sent with triggered alarms.

Programmed alarms

The table below provides a brief overview of the program parts and their function for the signal simulation. It was a deliberate decision to avoid details; further comments can be found in the STL code.

Table 5-9

Block Comment

OB1 Cyclic Main Call of the alarm block (SFC107) for ALARM_DQ and the alarm block (SFB35) for ALARM_8P using function block 200. SFB35 exists only in the S7-400.

SFB35 + multi-instance DB200

ALARM_8P The alarm block has 8 signal inputs and 10 possible associated values. It is equipped with 8 signal bits from DB11 and the associated values from DB20.

SFC107 ALARM_DQ The alarm block has a signal input and can provide an associated value.

Page 55: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.4 User program of this example

Alarm Client with OPC A&E V2.0, ID Number: 26548467 55

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Signal status overview

The graphic representation below shows the most important signals of the block calls in the user program according to the above example and the associated response of the Simatic NET OPC A&E server.

Figure 5-6

Each status change at one of the signal inputs of the alarm block triggers a notification. The status of an OPC alarm can only change within the scope of the state machine specified by OPC. When an alarm comes in (t1: SIG = 1) and goes out without being acknowledged (t2: SIG = 0), this alarm is implicitly signaled as acknowledged the next time it occurs. Implicit acknowledgement is no longer signaled when using CD 2010 V8.0 and later. Simultaneously the alarm enters a new signal cycle (here: t3: SIG = 1) and is signaled as “came in” (SIG = 1). When the alarm is acknowledged while the signal is present (t4), the OPC server provides an acknowledgement notification (ACKED). The current status of each notification can be read out via a bit mask.

The A&E client of this application example uses this information to color the alarms in the view (e.g., an active, pending alarm is “red”) or to display specific symbols (for example, green checkmark if the alarm has been acknowledged).

Page 56: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.5 Sample configuration of a SCAN alarm

56 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5.5 Sample configuration of a SCAN alarm

Introduction

The S7-400 offers the option to configure symbol-related messages. These SCAN alarms are configured using the symbol table of STEP 7. The following sections describe a sample configuration of a SCAN alarm to explain the basic procedure.

Note Symbol-related messages (SCAN) are only available in S7-400 CPUs. They are transferred via system data blocks (SDB); accordingly, these blocks and the PC station (OPC server) must be downloaded when changes are made.

Procedure

For symbolic messages, binary signal statuses are checked acyclically to the program execution at a fixed interval. Therefore, they are particularly suitable for events that are not directly linked to the program flow. If, for example, the S7 program represents a step sequence to control a freight elevator, temperature monitoring of the drive motor would be monitored using a Scan alarm. The limit switches of the doors, however, would be displayed with programmed alarms (SFC) since they directly influence the program flow.

Table 5-10

No. Action Comment

1. Initially, the Symbol Editor is opened in STEP7 and two symbols are added. A flag bit that represents the signal to be monitored and a flag word that is to be used as an associated value.

After creating the symbols, the symbol file must be saved.

Page 57: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.5 Sample configuration of a SCAN alarm

Alarm Client with OPC A&E V2.0, ID Number: 26548467 57

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

2. Right-click on the symbol to be scanned (here: “Scan_Signalbit”) and select “Special Object PropertiesMessage…” to display the configuration dialog box.

3. The configuration dialog box of the Message Configuration displays the extended view.

The entered Message text and Info text can also comprise multiple lines. If associated values are to be displayed in the Message text, they must be put into “@”.

4. The wildcard is edited according to the desired format.

The wildcard structure is as follows: @<No. of the associated value><element type><format>@ The format starts with “%”, followed by the number of digits and the format qualifier. For a detailed description, please refer to the STEP7 online help.

5. In the “SCAN attributes” tab, the associated value is configured.

Up to 10 associated values can be configured; for a better overview, filters can be set to make it easier to find the desired associated values. The SCAN interval is preset to 500 ms.

Page 58: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.5 Sample configuration of a SCAN alarm

58 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

6. In the “Additional text” tab, up to 9 additional texts can be entered. The “Source” OPC attribute is created from the first additional text and the “Area” attribute is created from the second additional text. Other settings such as Alarm class and Severity can be made separately for each Scan alarm. “Warning – high” is set here as an example. Priority can be set between “0” and “16”.

Unlike programmed alarms, a low value also means low priority for configured, symbolic messages. “8” is set here to obtain a mean value of 500 as OPC severity.

7. After completing the configuration of the SCAN alarms, the system data blocks (SDB) must be generated and loaded to the S7-400.

The green flag indicates that a Scan alarm has been configured for this symbol.

Note System data blocks are generated for each configured SCAN rate. The configured signals are checked asynchronously to the running program. Please note that the SCAN function loads the system and should therefore only be used to a small extent.

Note The PC station (OPCServer) must also be recompiled (e.g., in NetPro) and then downloaded again.

Page 59: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.6 Sample call of an ALARM_8P

Alarm Client with OPC A&E V2.0, ID Number: 26548467 59

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5.6 Sample call of an ALARM_8P

Introduction

The most frequently used alarm block in S7-400 stations is SFB35 (ALARM_8P). This block provides the maximum functionality possible with regard to Alarm and Events. The call parameters are explained as examples and their meaning for OPC Events is explained.

Note The block is only available in S7 400 CPUs. In CPU Configuration (HW Config), the “Acknowledgement Triggered Reporting” setting has to be disabled; this is the only way to ensure that ALARM_8P actually sends alarms.

Note To demonstrate the functionality, the block is called cyclically in OB1 as an example. Depending on the desired application, a call in the time-controlled OB35 or other OBs (e.g., OB40) is advisable.

The figure below shows the block call in STL code of an S7-400. An instance data block (here: DB35) is generated that contains the local data of the call. If the SFB is called within an FB, the parameters can be stored in the multi-instance DB. The required system attributes (e.g., S7_server and S7_a_type) and the respective values are automatically assigned once a symbolic IN parameter has been created and specified on the SFB call. For reasons of clarity, error bit and status word were not evaluated. For a detailed description of the parameters, please refer to the STEP7 online help.

Figure 5-7

Any pointers to associated values

Signal input of the monitored binary signal

Page 60: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.6 Sample call of an ALARM_8P

60 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Channel parameters

For example, the inputs of an I/O module are connected to the SIG_1 to SIG_8 signal inputs (also channels) of the block. As soon as one of the signal inputs changes its status, an alarm is triggered. A positive change is assessed as an “incoming” event and a negative change as an “outgoing” event.

Management parameters

The event number (EV_ID) uniquely identifies the block for the entire controller and is assigned by Step7 to ensure consistency (“0” is not permitted).

The severity (also weighting) of the alarm is set on the SEVERITY parameter with a range of values from “0” to “127” and a low number represents a high severity.

The current acknowledgement status of the individual channels is represented in the ACK_STATE parameter. The bit array shows “1” for acknowledged and “0” for unacknowledged. Bits 0 to 7 are required for “incoming” events and bits 8 to 15 for “outgoing” events of the 8 channels.

Note Unlike the S7 CPU, the OPC A&E state machine does not allow separate acknowledgement of signal edges that “came in” and “went out”. The signal status can be acknowledged only once via OPC.

Associated value parameters

Up to 10 associated values can be parameterized. These values are ANY pointers that point, for example, to the DB10 data block as shown here. The value included there is provided as an associated value when triggering the alarm.

Note All currently pending associated values are always included in the sending, irrespective of the specific channel (signal input) that triggered the alarm.

Page 61: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.6 Sample call of an ALARM_8P

Alarm Client with OPC A&E V2.0, ID Number: 26548467 61

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Response

The figure below shows the response of the components when an alarm is triggered:

Figure 5-8

The following table describes the sequences between the components when an alarm is triggered.

Table 5-11

No. Description

1 The status of the E0.3 input changes from “0” to “1”. A call of the ALARM_8P block is triggered.

2 Via the S7 protocol, the S7 station sends an event to the connection partner (the PC station). The SIMATIC NET OPC server identifies the alarm by its origin (S7 connection) and its event ID (here: “1”). Furthermore, the triggering channel (here SIG_3) is known (see parameters of the block call).

3 The OPC server now checks the received parameters and maps them to an OPC Event Notification. The “ALARM1,3” identifier (event ID=1 and signal=3) is assigned to the event and the OPC attributes are filled. The S7 block severity is converted to OPC event severity (here: “0” becomes default = “500”). The S7 connection name (here: “S7:\400”) is entered as an OPC Event Source, the Time and ActiveTime parameters and the OPC Category are filled.

4 Before the alarm is now signaled to the OPC clients, the scores7.msg file is searched to determine whether a message text is stored for “ALARM1,3”; if this is the case, this text is copied to the OPC Message parameter. If necessary, associated values are extracted, formatted and inserted into the text. When using CD 2010 V8.0 or later, the OPC server uses a binary text database instead of the scores7.msg file to map the texts to the OPC alarm.

5 If not prevented by a filter criterion, the notification is sent to the OPC client.

Page 62: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.7 Sample configuration of system error messages

62 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

6 The event is displayed in the OPC client. The status is ACTIVE and ACK_REQUIRED, this corresponds to “came in” and “requiring acknowledgement”. When the alarm is acknowledged in the client, the OPC A&E server sends a message to the S7-400 CPU. The status can be checked in the flag word.

Note A separate acknowledgement for the “incoming” and “outgoing” edge of the signal is only possible within the S7 CPU. Via OPC Alarm and Events, merely the signal status can be acknowledged. When the alarm has “come in” (signal input to “true”) and changes to the “went out” status without being acknowledged (signal input to “false”), the event is implicitly acknowledged the next time it occurs. When using CD 2010 V8.0 or later, the implicit acknowledgement event is no longer initiated.

Note The name of the alarm with “ALARM<EV_ID>,<SIG#>” does not exist for the first channel (SIG_1); this channel is provided without a signal number. In the above example, 5 out of 8 channels are connected and events can occur with the following identifiers: “ALARM1”, “ALARM1,2”, “ALARM1,3”, “ALARM1,5” and “ALARM1,6”.

Note For more information on the parameters of the alarm blocks, please refer to the STEP7 online help.

5.7 Sample configuration of system error messages

Introduction

SIMATIC stations offer the option to configure messages that describe system errors. The required blocks and text messages are preconfigured and read out, for example, hardware information and insert it into texts. The following example shows how these messages are generated.

Note The required blocks and message texts are generated by STEP 7. The user only has to load the generated blocks to the CPU. Then also the OPC server has to be reloaded to update the text database.

Procedure

The components of the S7-300 stations, S7-400 stations, PROFINET IO devices, DP slaves and WinAC are supported by “Report System Error” provided that they support functions such as diagnostic interrupt, insert/remove interrupt and channel-specific diagnostics. The diagnostic data records according to the Profibus/Profinet modules are read using SFB52 (RDREC) and SFB54 (RALRM).

The necessary blocks are generated by STEP 7.

Page 63: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.7 Sample configuration of system error messages

Alarm Client with OPC A&E V2.0, ID Number: 26548467 63

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 5-12

No. Action Comment

1. In HW Config, the CPU is selected first and then Options Report System Error…

These steps must be repeated for each CPU for which system errors are to be reported.

2. In the “General” tab, the target FB and the DB numbers are defined.

Please make sure that these numbers are not already used for other purposes in the program. If necessary, corrections have to be made.

Page 64: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.7 Sample configuration of system error messages

64 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

3. In the “Messages” tab, the messages are configured.

In this tab, the correct message class should be assigned to each reporting component and the priority should be adjusted accordingly.

4. Generating After generating the blocks, also the OPC server has to be reloaded (e.g., NetPro -> save and compile all and then download).

Principle of operation

The diagnostic block generated by “Report System Error” (FB with assigned instance DB and one or several global DB(s) and one FC) evaluates the local data of the error OB and reads possible additional diagnostic information of the hardware component that causes the error.

If, for example, a module is removed from/inserted into the rack, the associated error OB (OB8x) is called. Then the SFM block that generates the message is called in this OB (an alarm_s is triggered internally).

Depending on the used CPU, error OBs are generated 7 x (redundancy error) and 8 x (time/hardware error). If they already exist, the code for generating messages, the call of the generated FB, is added to the end.

Note For a detailed description of the individual parameters, please refer to the STEP7 online help.

Page 65: 26548467_OPC_AE_DOKU_V20_e

5 Explanation of the S7 Sample Program

5.8 Information on the alarm configuration of the S7-300

Alarm Client with OPC A&E V2.0, ID Number: 26548467 65

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5.8 Information on the alarm configuration of the S7-300

General

The controllers of the SIMATIC S7-300 family support only the ALARM_S and ALARM_SQ alarm blocks and the ALARM_D and ALARM_DQ blocks. (D and DQ only when using firmware version 2.5.0 or higher). In addition, the S7-300 supports system error messages.

Furthermore, the CPU type defines the number of alarm blocks that can be called simultaneously since this occupies system resources. Thus, depending on the CPU, 20, 40 or 300 alarms can be pending simultaneously. For an overview, please refer to ID Number: 841294.

Configuration of alarm texts

To configure the alarm texts with STEP7, a project is necessary, in which the S7-300 exists and a PC station with OPC server. An S7 connection must be established between these two components. This is the only way to ensure that the alarm configuration, including the text database for the OPC server, is generated when “saving and compiling”. The OPC server must be reloaded each time changes are made to the alarm texts.

Note Configuring alarm texts for a unilaterally connected S7-300 using STEP7 is only possible when using STEP7 version 5.5 or higher, including HotFix 3.

Page 66: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.1 Hardware and software installation

66 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

6 Installation and Startup

6.1 Hardware and software installation

This chapter describes which hardware and software components have to be installed. The descriptions and manuals as well as delivery information included in the delivery of the respective products should be observed in any case.

Hardware installation

For the hardware components, please refer to chapter 2. For the hardware configuration, follow the instructions listed in the table below:

Table 6-1

No. Action Comment

1. PC station: Install the CP1613 PCI plug-in card in the PC station as described in the installation instructions included in the delivery.

Instead of the CP1613, the onboard Ethernet card can also be used.

2. SIMATIC stations: Install the S7 controllers as shown in the figure in chapter 2.

Deviations in the hardware configuration must be considered when configuring.

3. Connect the PC station to the two SIMATIC stations via Ethernet as shown in the figure in chapter 2.

Please note the setting of subnet masks.

Note The installation guidelines for Industrial Ethernet networks must always be observed.

Standard software installation

For the software components, please refer to chapter 2.

Starting up the example requires the following components from the SIMATIC NET CD 2010 (V8.0):

• SIMATIC NET PC products

• SIMATIC NCM PC/S7

Note SIMATIC NCM PC/S7 must only be installed if STEP 7 is not installed on the PC.

The SIMATIC STEP 7 V5.5 configuration tool is only required on the PC station if the S7 controllers are to be changed or loaded. As an alternative, this software package can also be installed on a separate computer.

Note If neither STEP 7 nor SIMATIC NET is installed on the PC station, install STEP 7 first.

Microsoft Visual Studio .Net Professional is only necessary on the SIMATIC PC station if the sample code is to be changed. As an alternative, the development environment can be installed on a separate PC (e.g., engineering station).

Page 67: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.2 Application software installation

Alarm Client with OPC A&E V2.0, ID Number: 26548467 67

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Note During the Visual Studio .Net installation, the security settings of the Windows operating system are relaxed. After installing the development environment, please check the security of the SIMATIC PC station and, if necessary, install Windows updates.

Table 6-2

No. Action Comment

1. Install the SIMATIC STEP 7 software as described in the installation instructions.

Restart necessary.

2. Install the SIMATIC NET PC products driver software (without NCM PC).

Restart necessary.

3. Install Microsoft Visual Studio .Net. Optional.

6.2 Application software installation

The user interface and the source code of the application are supplied as a ZIP file.

To start the user interface on the SIMATIC PC station, follow the steps listed in the table below.

Table 6-3

No. Action Comment

4. Unzip the following file: 26548467_OPC_AE _CODE_v20.zip

Contains the executable file and the source code.

5. Double-click on the AEClient.exe file. Starts the sample application.

6.3 Configuration of the SIMATIC S7 stations

All hardware and software components must have been successfully installed and cabled accordingly.

Note The project file provided with this example contains the fully configured SIMATIC S7 stations according to the description in chapter 2.3. This STEP7 project can only be used without adaptation if the hardware is identical to the configuration.

If different hardware is used, the configuration of the SIMATIC stations has to be adjusted. This is particularly necessary if the hardware releases differ or if the Ethernet addresses are not identical. The STEP 7 project included in the delivery then has to be opened and adapted accordingly. After saving and compiling, all configuration information is overwritten.

The following table shows the configuration of the SIMATIC S7 station by means of download from the SIMATIC Manager.

Page 68: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.3 Configuration of the SIMATIC S7 stations

68 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Table 6-4

No. Action Comment

1. Retrieve the project. Unzip the following file: 26548467_OPC_AE_STEP7_v20.zip

2. Open the SIMATIC Manager

by double-clicking on the icon on the desktop.

3. Set the S7ONLINE access point for STEP7. Select Options --> Set PG/PC Interface...

Set the access point to the card with which you are connected to the controllers.

4. Open the HWConfig tool to check the IP addresses and other hardware settings.

Perform this step for the S7-300 and the S7-400 station and the PC station.

Page 69: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.3 Configuration of the SIMATIC S7 stations

Alarm Client with OPC A&E V2.0, ID Number: 26548467 69

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

5. Open the Properties of the communications processor. Adjust the IP address.

6. Open the NetPro tool to set/check the connection configuration.

Perform this step for the S7-300 and the S7-400 station and the PC station.

7. Select the station to download the configuration. Click on the

icon in the SIMATIC Manager.

Perform this step for the S7-300 and the S7-400 station. Select the S7 station or the OPC server and start the download. Confirm the dialog boxes with “Yes” to completely overwrite the station.

8. Restart the modules. The stations are restarted (warm restart). Confirm respective dialog boxes with “Yes”.

9. Configure and download the PC station with the SIMATIC Manager.

This step is not necessary when importing the XDB file. Alternative: Remote configuration of the PC station with the SIMATIC Manager is also possible performing the two steps Configure and Download. To do so, right-click on the PC station and select PLC --> Configure... After successful configuration, select PLC --> Download.

Page 70: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.4 Commissioning of the PC station

70 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

6.4 Commissioning of the PC station

All hardware and software components must have been successfully installed and cabled.

Note The project file (XDB) provided with this example contains the fully configured PC station. This file can only be used without adjustment if the hardware is identical to the configuration.

If different hardware is used, the configuration of the PC station has to be adjusted. This is particularly necessary if the hardware releases differ or if the Ethernet addresses are not identical. The STEP 7 project included in the delivery then has to be opened and adapted accordingly (see chapter 7). After saving and compiling, all configuration information in the XDB file is overwritten.

The following table shows the configuration of the PC station by means of importing an XDB file.

Table 6-5

No. Action Comment

1. Retrieve the project. Unzip the following file: 26548467_OPC_AE_STEP7_v20.zip

2. Open the Station Configurator by double-

clicking on the icon in the taskbar.

3. Click on Import Station. Confirm the following query with Yes.

4. Select the XDB file. The XDB file is located in the XDBs subdirectory of the unzipped ZIP file in the directory tree of the STEP7 project.

Page 71: 26548467_OPC_AE_DOKU_V20_e

6 Installation and Startup

6.4 Commissioning of the PC station

Alarm Client with OPC A&E V2.0, ID Number: 26548467 71

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

5. • After importing the XDB file, the PC station has been configured.

Page 72: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.1 Configuration of the SIMATIC S7 stations

72 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

7 Configuration

7.1 Configuration of the SIMATIC S7 stations

All hardware and software components must have been successfully installed and cabled accordingly.

The following configuration steps of the SIMATIC S7 stations exemplify the procedure. Adjust the configuration as required for your hardware.

Note After saving and compiling, all configuration information is overwritten.

The following table shows the configuration of the SIMATIC S7 station.

Table 7-1

No. Action Comment

1. Start STEP 7: Open the SIMATIC Manager and create a new project.

The name “AE-Sample2” was used here.

2. Insert SIMATIC 400 Station and assign name (here: “S7-400”). Insert SIMATIC 300 Station and assign name (here: “S7-300”).

3. Open SIMATIC stations with HW Config and insert CPU, CPs and other components.

Page 73: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.1 Configuration of the SIMATIC S7 stations

Alarm Client with OPC A&E V2.0, ID Number: 26548467 73

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

4. To set the IP address, the Properties dialog box opens.

5. Set the IP address (here: 192.168.0.52) and the associated subnet mask. Create an Ethernet network. A MAC address is entered only if the station is to communicate via ISO transport layer 4.

Page 74: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.1 Configuration of the SIMATIC S7 stations

74 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

6. Repeat the steps for both SIMATIC stations and then download both stations.

Perform this step for the S7-300 and the S7-400 station.

7. Restart the modules. The stations are restarted (warm restart). Confirm respective dialog boxes with “Yes”.

8. Create S7 connections. The connection configuration is described together with the configuration of the PC station (in chapter 7.2).

Page 75: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.2 Configuration of the PC station

Alarm Client with OPC A&E V2.0, ID Number: 26548467 75

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

7.2 Configuration of the PC station

The SIMATIC PC station is configured using STEP 7 and described step by step. Alternatively, the NCM PC software package can also be used for the configuration. The procedure is identical, but unilaterally configured connections are used.

Table 7-2

No. Action Comment

1. Start STEP 7: Open SIMATIC Manager and project.

Open the previously created “AE-Sample” project.

2. Insert SIMATIC PC station and specify name. The name of the PC station must be identical to the “Windows name” of the PC (see My Computer Properties Computer Name).

3. Open PC Station with HW Config and insert CP. The slot must be identical to the index assigned in the configuration console, here index “2” for Ethernet card. The “OPC Server” application was plugged into slot “1”.

Page 76: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.2 Configuration of the PC station

76 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

4. An IP address (here: “192.168.172.1”) is assigned for the Ethernet card and the card is connected to the Ethernet network.

5. On the OPC Server Properties pages (double-click on OPC Server), the use of symbolic addressing is enabled in the “S7” tab.

Page 77: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.2 Configuration of the PC station

Alarm Client with OPC A&E V2.0, ID Number: 26548467 77

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

6. NetPro is used to create two S7 connections from the OPC server to the two controllers. Both connections are created via Ethernet. After the OPC server has been selected, the Properties dialog box is displayed by double-clicking in the list of connections.

7. S7 connection via Ethernet: Once the connection path has been selected, the connection name can be changed (here: “300” for the connection to the S7-300 and “400” for the connection to the S7-400). The connection partners and connection parameters are displayed.

8. In the Properties dialog box of the S7 connection, select the second tab (OPC Connection Parameter). Connection-specific settings are made here. “Retain the connection permanently” is set for the Connection Establishment to ensure that the connection is maintained even if there is no communication. The connection is configured for the transfer of “Block and Symbol-related Messages” and “Diagnostic Messages”.

10

9

Page 78: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.2 Configuration of the PC station

78 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

9. Set the language (for multilingual messages) and the time stamps. Use the “Message text details...” button to go to the used time stamps dialog box. (See step 8)

The signaling concept includes several time stamps. In this dialog box, you configure which time stamp is to be used for the message. Either S7 CPU time (should be synchronized accordingly), S7 CPU time plus fixed offset (e.g., to create a specific time zone) or the PC time of the OPC server in UTC (this setting is used, for example, if not the S7 but only the PC is time-synchronized).

10. It is usually not necessary to set the alarm priority. All alarms are signaled to the OPC clients with default priority “500”. To go to the configured OPC severity list, select the “Alarm Messages...” button (see step 8).

According to a conversion table, all alarms of the SIMATIC station are mapped to the corresponding “OPC severity”. If no priority can be specified at the function block, “500” is used by default. A list of exceptions enables the user to provide individual alarms with a changed severity, this “configured severity” always prevails.

11. Once the connections have been created, the project must be compiled with Save and Compile. Now the stations can be downloaded. As described in chapter 6, the PC station can also be downloaded with the XDB file.

Page 79: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.3 Configuration of the OPC A&E server < V8.0

Alarm Client with OPC A&E V2.0, ID Number: 26548467 79

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

7.3 Configuration of the OPC A&E server < V8.0

It is usually not necessary to configure the SIMATIC NET OPC A&E server. Once an S7 connection for the transfer of events has been configured, the SIMATIC NET OPC A&E server can receive these alarms and forward them to connected clients.

If useful texts are to be sent to the clients in addition to the alarm ID numbers, another configuration step is required. Respective texts are stored in the STEP 7 configuration database for each alarm number. This is possible in different languages. When downloading the PC station, the texts configured in STEP7 are made available to the OPC server. For each alarm sent from the S7, the server checks whether a text was configured and inserts this text into the OPC event in the language, identified by the local ID (lcids), selected on the server. If no text is stored, the alarm is only forwarded with its ID number (default behavior).

Note The configuration of message texts is available for SIMATIC NET version V6.4 + HF2 and higher. Extended configuration of multilingual texts via STEP7 is possible for SIMATIC NET version V8.0 and higher.

The following section describes the message text file (SIMATIC NET version V6.4 + HF2 and higher). Version V8.0 and higher still support this version, however, extended message configuration via STEP7 should be used.

Table 7-3

No. Action Comment

1. Open the scores7.msg file with a text editor, e.g. notepad.exe.

In Windows XP, the file is located in: c:\Program Files\Siemens\Simatic.Net\opc2\binS7\

2. For each S7 connection, insert a section into the file; the section name must correspond to the S7 connection name (here: “[400]” and “[300]”).

In each section, respective texts are then assigned to the event IDs; these texts can be stored in different languages.

Syntax: [<S7 Connection Name>] ALARM<event_id>=<lcids>,<lcid>,”<message text>”

Example: [400] ALARM2=0,1033,“My Message Text Example”

3. Associated values of S7 blocks can also be output within a message text. To do so, a wildcard marked with “@” is inserted into the text and the number of the associated value is entered at the block and a formatting qualifier is entered.

Blocks with associated values are, for example, ALARM, ALARM_8P, NOTIFY, NOTIFY_8P; for S7-300 controllers, only one associated value is possible per block, e.g. ALARM_S, ALARM_SQ, ALARM_D, ALARM_DQ. Syntax: @2X%f@ (second associated value as a floating point) Example: ALARM5,3=0,“Boiler Temperatur of @1X%d@ degrees was exceeded, switch of heater @2X%u@”

4. Diagnostic alarms are signaled by S7 controllers and usually appear in the diagnostic buffer of the relevant CPU.

Syntax: DIAGNOSIS<hex>=<lcids>,<lcid>,”<messagetext>” Example: DIAGNOSIS0x4302=0,1033,"My Text for Diagnosis"

Page 80: 26548467_OPC_AE_DOKU_V20_e

7 Configuration

7.3 Configuration of the OPC A&E server < V8.0

80 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

5. Further information More information is available in the actual scores7.msg file.

Note For SIMATIC NET OPC A&E server < V8.0: The scores7.msg file is read out by the SIMATIC NET OPC A&E server only during startup. Please make sure that the server restarts after changes have been made to this file.

The scores7.msg file is no longer used in SIMATIC NET OPC A&E server version V8.0 or higher. When downloading from STEP 7, a text database is generated, which is then used by the OPC server (scores7.msg.bin).

Page 81: 26548467_OPC_AE_DOKU_V20_e

8 Operation of the Application

Alarm Client with OPC A&E V2.0, ID Number: 26548467 81

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

8 Operation of the Application

You are provided with information on...

how you can operate all functions of this application. The operation described here focuses on the triggering of alarms and the default selection of associated values.

Note To provide a simplified representation of the principle of operation, an ALARM_SQ is called cyclically in OB1 via FB200. The necessary STL code fragment is executable in the S7-300 and the S7-400 and used here as a general example.

Overview

To simulate an alarm, a flag bit was interconnected in addition to the input. An ALARM_SQ is triggered when either the 0.1 input or the DB11.DBX 0.3 data block bit changes to “1” status.

Figure 8-1

The alarm block receives a fixed ID that is unique on a CPU-wide basis and that has been interconnected with an associated value (here an Any pointer that points to a double word in data block 11). The return value of the alarm block is written to flag word 12.

Three items are monitored in OPC Scout (OPC Data Access client):

• S7:\[300]DB11,DWORD0,1 (Begleitwert [associated value])

• S7:\[300]MW12,1 (Status)

• S7:\[300]DB11,X1.0,1 (Trigger)

PC application

Display Acknowl-edgement

Associated value Status Trigger

DataAlarms

Page 82: 26548467_OPC_AE_DOKU_V20_e

8 Operation of the Application

82 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

Triggering alarms

To simulate an alarm, the 10.0 flag bit can now be used in addition to the physical E0.3 input. The flag bit is written with OPC Scout (trigger). An alarm with ID number 5 is triggered when the status changes from “0” “1”, an additional alarm is triggered in the event of a status change from “1” “0”. This corresponds to the “came in” and “went out” principle of status-controlled alarms.

Table 8-1

No. Action Comment

1. Start the OPC A&E client (this example).

2. Select the server. In the drop-down box of the user interface, the OPC A&E server can be selected.

3. Connect. The Connect button is used to establish the connection to the server. Once the connection has been established, two configuration dialog boxes for the subscription are displayed.

4. Configure the subscription settings.

Page 83: 26548467_OPC_AE_DOKU_V20_e

8 Operation of the Application

Alarm Client with OPC A&E V2.0, ID Number: 26548467 83

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

5. Configure the subscription filter settings.

6. Display of active alarms.

Page 84: 26548467_OPC_AE_DOKU_V20_e

8 Operation of the Application

84 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

7. Start the OPC Data Access client (OPC Scout).

8. Browse to the symbolic representation of the address area and insert the items (variables) into the bottom DA view.

Page 85: 26548467_OPC_AE_DOKU_V20_e

8 Operation of the Application

Alarm Client with OPC A&E V2.0, ID Number: 26548467 85

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

No. Action Comment

9. Click in the “New Value” field to display the dialog box for writing values.

10. Default selection of the associated value (for example, “123”). Subsequently, trigger the alarm by writing “1” (true) to the “SignalDQAlarm” item.

11. Display of the alarm in the sample application.

12. To acknowledge the alarm, select the line by right-clicking on it and select the drop-down menu.

Page 86: 26548467_OPC_AE_DOKU_V20_e

9 Related literature

86 Alarm Client with OPC A&E V2.0, ID Number: 26548467

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

9 Related literature

9.1 Bibliography

This list is by no means complete and only presents a selection of related references.

Table 9-1

Topic Title

\1\ STEP7 Automating with STEP7 in STL and SCL Hans Berger Publicis Corporate Publishing ISBN 3-89578-113-4

9.2 Internet link specifications

This list is by no means complete and only presents a selection of appropriate information.

Topic Title

\1\ Reference to the document

http://support.automation.siemens.com/WW/view/en/26548467

\2\ Siemens A&D Customer Support

http://support.automation.siemens.com

\3\ OPC Data Access Custom Interface Version 3.0

\4\ OPC Alarm and Events Custom Interface Version 3.0

Specification on the OPC Foundation website for download for OPC members

http://www.opcfoundation.org

\5\ SIMATIC NET Commissioning PC Stations – Manual and Quick Start for SIMATIC NCM PC / STEP 7 version V5.2 or higher

Description of or information on:

• General information on the PC tools.

• Functions of NCM PC.

Installed by SIMATIC NET, see: Start Simatic Documentation English.

Available in Product Support; ID Number: 13542666

http://support.automation.siemens.com/WW/view/en/13542666

\6\ SIMATIC NET – Industrial Communication with PG/PC

Manual for industrial communication on PG/PC with SIMATIC NET.

Installed by SIMATIC NET, see: Start Simatic Documentation English.

Available in Product Support; ID Number: 2044387

http://support.automation.siemens.com/WW/view/en/2044387

\7\ IPC Configurator http://support.automation.siemens.com/WW/view/en/17128155

\8\ .NET Framework http:\\www.microsoft.com

Page 87: 26548467_OPC_AE_DOKU_V20_e

10 History

Alarm Client with OPC A&E V2.0, ID Number: 26548467 87

Co

pyr

igh

t

Sie

me

ns

AG

20

11

All

righ

ts r

ese

rve

d

10 History Table 10-1 History

Version Date Modification

V1.0 10/30/07 First edition

V2.0 04/29/11 Features from SIMATIC NET CD 2010 added