industrial communication with pg/pc - siemens · pdf file2 simatic net industrial...
TRANSCRIPT
Preface, Contents
General Information1
Industrial Communication2
Basics of the OPC Interface3
OPC Process Variables forSIMATIC NET
4
Properties of the OPC EventServer for SIMATIC NET
5
Using the OPC Server6
Examples7
FAQs8
Related Literature9
Glossary
Industrial Communication withPG/PC
SIMATIC NET
Manual
11/2003C79000-G8976-C172Release 03
This manual is part of thedocumentation packages with the ordernumbers:
6GK1971-1GA00-0AA16GK1971-5DA00-0AA1
2SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Classification of Safety-Related Notices
This manual contains notices which you should observe to ensure your own perso-nal safety, as well as to protect the product and connected equipment. These noti-ces are highlighted in the manual by a warning triangle and are marked as followsaccording to the level of danger:
!Danger
indicates that death or severe personal injury will result if proper precautions arenot taken.
!Warning
indicates that death or severe personal injury can result if proper precautions arenot taken.
!Caution
with warning triangle indicates that minor personal injury can result if proper pre-cautions are not taken.
Caution
without warning triangle indicates that damage to property can result if proper pre-cautions are not taken.
Notice
indicates that an undesirable result or status can result if the relevant notice isignored.
Note
highlights important information on the product, using the product, or part of thedocumentation that is of particular importance and that will be of benefit to theuser.
3SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Trademarks
SIMATIC�, SIMATIC HMI� and SIMATIC NET� are registered trademarks ofSIEMENS AG.
Third parties using for their own purposes any other names in this document whichrefer to trademarks might infringe upon the rights of the trademark owners.
Safety Instructions Regarding your Product:
Before you use the product described here, read the safety instructions below tho-roughly.
Qualified Personnel
Only qualified personnel should be allowed to install and work on this equipment.Qualified persons are defined as persons who are authorized to commission, toground, and to tag circuits, equipment, and systems in accordance with establis-hed safety practices and standards.
Correct Usage of Hardware Products
Note the following:
!Warning
This device and its components may only be used for the applications described inthe catalog or the technical description, and only in connection with devices orcomponents from other manufacturers which have been approved or recommen-ded by Siemens.
This product can only function correctly and safely if it is transported, stored, setup, and installed correctly, and operated and maintained as recommended.
Before you use the supplied sample programs or programs you have written your-self, make certain that no injury to persons nor damage to equipment can result inyour plant or process.
EU Directive: Do not start up until you have established that the machine on whichyou intend to run this component complies with the directive 89/392/EEC.
Correct Usage of Software Products
Note the following:
!Warning
This software may only be used for the applications described in the catalog or thetechnical description, and only in connection with software products, devices, orcomponents from other manufacturers which have been approved or recommen-ded by Siemens.
Before you use the supplied sample programs or programs you have written your-self, make certain that no injury to persons nor damage to equipment can result inyour plant or process.
4SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Prior to Startup
Prior to startup, note the following:
Caution
Prior to startup, note the information and follow the instructions in the latest docu-mentation. You will find the ordering data for this documentation in the relevantcatalogs or contact your local Siemens office.
We have checked the contents of this manual for agreement with the hardwa-re and software described. Since deviations cannot be precluded entirely, wecannot guarantee full agreement. However, the data in this manual are revie-wed regularly and any necessary corrections included in subsequent edi-tions. Suggestions for improvement are welcomed.
DisclaimerCopyright � Siemens AG 2003 All rights reserved
The reproduction, transmission or use of this document or its contents is notpermitted without express written authority. Offenders will be liable fordamages. All rights, including rights created by patent grant or registration ofa utility model or design, are reserved.
Siemens AGAutomation and DrivesIndustrial CommunicationPostfach 4848, D-90327 Nuernberg Technical data subject to change.
Siemens Aktiengesellschaft C79000-G8976-C172-03
5SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Welcome to SIMATIC NET
SIMATIC NET - The Right Decision
You know the advantages of distributed automation systems and want to makeoptimum use of industrial communication. You expect a strong partner andinnovative, reliable products. With SIMATIC NET, you’ve made the right choice.
SIMATIC NET - Pioneering successful solutions in black and white
Now that you have made your decision, we’ll be at your side. This documentationwill be your companion on your way to successful application of SIMATIC NET. Itwill provide you with a gradual and clear introduction to the topics and will showyou how to install components, how to configure your project and the individualcomponents, and how to create your own programs based on OPC. You will seethe opportunities that industrial communication with SIMATIC NET can open up foryou, for your automation solutions, and, above all, for the success of yourcompany.
SIMATIC NET - Professional solutions not only for professionals
To use SIMATIC NET successfully, you don’t need to be an expert. Thisdocumentation will build up your knowledge and let you profit from the know-howand expertise of the specialists.
Are you a beginner? Then you can familiarize yourself systematically. Start withthe introduction to industrial communication. Here, you will learn everything youneed to know about the principles of communication, the range of functions ofSIMATIC NET, the technical possibilities, and suitable functions for implementingyour automation tasks. When you have digested this information, you should turnyour attention to installation and commissioning. Here, of course, everythingrevolves around the OPC interface: Read the basic introduction to the OPCinterface, familiarize yourself with the OPC variables, and learn how to put theOPC Server from SIMATIC NET to the best possible use.
Are you a professional? Then you can get going straight away. Step-by-stepdescriptions, and comprehensive references will guide you over the shortestpossible way to installation, configuration, and operation of SIMATIC NET.
You find examples useful? The supplied sample programs will provide you with aflexible basis with which you can put your own ideas into practice.
6SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Contents1 General Information 21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1 Finding your Way through the Documentation 21. . . . . . . . . . . . . . . . . . . . 1.1.1 Where to Find Descriptions of the Various Products 21. . . . . . . . . . . . . . . 1.1.2 What’s New in the Product Documentation? 22. . . . . . . . . . . . . . . . . . . . . . 1.1.3 What’s the Latest Version of the Documentation? 23. . . . . . . . . . . . . . . . . 1.1.4 How to Work with the Documentation 23. . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Contacts and Training 24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Regulations 25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 Legal Regulations 25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.2 Safety -related Regulations 26. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Industrial Communication 27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1 Introduction to Industrial Communication 27. . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Special Requirements of Industrial Communications Systems 28. . . . . . 2.1.2 Types and Categories of Networks 28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 Communications Functions in Automation Engineering 29. . . . . . . . . . . . 2.1.4 Terms Used in Industrial Communications Engineering 29. . . . . . . . . . . .
2.2 SIMATIC NET in Industrial Communications Engineering 32. . . . . . . . . . 2.2.1 SIMATIC NET for Industrial Communication 32. . . . . . . . . . . . . . . . . . . . . . 2.2.2 SIMATIC NET Communications Systems 33. . . . . . . . . . . . . . . . . . . . . . . .
2.3 Industrial Communication with PROFIBUS 35. . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Description of PROFIBUS 35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.2 Protocols and Devices for SIMATIC NET PROFIBUS 35. . . . . . . . . . . . . 2.3.3 Bus Access Mechanism of PROFIBUS 38. . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.4 PROFIBUS in the ISO/OSI Reference Model 39. . . . . . . . . . . . . . . . . . . . .
2.4 S5-compatible Communication over FDL (SEND/RECEIVE protocol) 412.4.1 Typical System Configuration for S5-compatible Communication 41. . . . 2.4.2 Principle of SEND/RECEIVE Communication 42. . . . . . . . . . . . . . . . . . . . 2.4.3 SEND/RECEIVE Configuration 42. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.4 SEND/RECEIVE Services 43. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 DP Protocol 45. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.1 The DP Protocol and its Expansions 45. . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.2 Typical DP System Configuration 48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.3 Principle of DP Communication 48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.4 DP Configuration 50. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.5 Class 1 DP Master - Principle of Communication and Services 51. . . . . 2.5.6 DP Slaves - Principle of Communication and Services 53. . . . . . . . . . . . 2.5.7 Class 2 DP Master - Principle of Communication and Services 53. . . . . 2.5.8 DPC1 - Principle of Communication and Services 55. . . . . . . . . . . . . . . . 2.5.9 DPC2 - Principle of Communication and Services 57. . . . . . . . . . . . . . . .
2.6 PROFIDrive Bus Server Drives 58. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7 FMS Protocol 59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.1 Typical FMS System Configuration 59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.2 Principle of FMS Communication 60. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.3 FMS Configuration 61. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.4 FMS Services 63. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.7.5 FMS Variable Services with a PC as FMS Client 64. . . . . . . . . . . . . . . . . . 2.7.6 FMS Variable Services with a PC as FMS Server 65. . . . . . . . . . . . . . . . .
2.8 S7 Protocol for PROFIBUS 66. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.1 Typical S7 System Configuration 67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.2 Principle of S7 Communication 67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.3 S7 Configuration 69. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.4 S7 Variable Services 71. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.5 S7 Buffer Send/Receive Services 72. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.6 S7 Block Management Services 73. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.7 S7 Event Services: Alarms 76. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.8 How to Program Alarms 77. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.9 S7 Security Services 79. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.10 S7 Information Services 79. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9 Industrial Communication with Industrial Ethernet 80. . . . . . . . . . . . . . . . . 2.9.1 Description of Industrial Ethernet 80. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.2 Protocols and Devices for SIMATIC NET Industrial Ethernet 81. . . . . . . 2.9.3 Bus Access Methods of Industrial Ethernet 82. . . . . . . . . . . . . . . . . . . . . . 2.9.4 Fast Ethernet 83. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.5 Industrial Ethernet in the ISO/OSI Reference Model 84. . . . . . . . . . . . . . . 2.9.6 Transport Protocols for Industrial Ethernet 86. . . . . . . . . . . . . . . . . . . . . . .
2.10 S5-compatible Communication (SEND/RECEIVE) 87. . . . . . . . . . . . . . . . 2.10.1 Typical SEND/RECEIVE System Configuration 87. . . . . . . . . . . . . . . . . . . 2.10.2 Principle of SEND/RECEIVE Communication 88. . . . . . . . . . . . . . . . . . . . 2.10.3 SEND/RECEIVE Configuration 90. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.4 Buffer SEND/RECEIVE Services 90. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.5 SEND/RECEIVE Variable Services 91. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.11 S7 Protocol for Industrial Ethernet 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.11.1 Typical S7 System Configuration 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.11.2 Principle of S7 Communication 94. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.12 Fault-Tolerant S7 Connections 96. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.1 Properties of Fault-Tolerant S7 Connections 96. . . . . . . . . . . . . . . . . . . . . 2.12.2 Fault-Tolerant S7 Connections on two Paths 98. . . . . . . . . . . . . . . . . . . . . 2.12.3 Fault-Tolerant S7 Connections on Four Paths 99. . . . . . . . . . . . . . . . . . . . 2.12.4 Points to Note when Configuring Fault-Tolerant Connections 100. . . . . . .
2.13 SNMP Protocol 101. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.1 Typical System Configuration for the SNMP Protocol 101. . . . . . . . . . . . . . 2.13.2 Principle of Communication with the SNMP Protocol 102. . . . . . . . . . . . . . 2.13.3 Configuring 103. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.4 SNMP Traps 106. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.14 Buffer-Oriented Services with the OPC Interface 107. . . . . . . . . . . . . . . . . . 2.14.1 Properties of Buffer-Oriented Communication 107. . . . . . . . . . . . . . . . . . . . 2.14.2 Mapping Data Buffers on OPC Variables 108. . . . . . . . . . . . . . . . . . . . . . . . 2.14.3 Using Buffer-Oriented Services 109. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.14.4 Points to Note When Using Buffer-Oriented Services with
TCP/IP native 110. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 Basics of the OPC Interface 111. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1 Basic Terminology 111. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 What are COM Objects? 111. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.1.2 How do COM Objects Appear? 113. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.3 What do COM Interfaces Provide? 113. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.4 What Types of Interface Exist? 114. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.5 How can a .NET client access the OPC COM Interface? 115. . . . . . . . . . . 3.1.6 What Does Object Control through Automation Mean? 116. . . . . . . . . . . .
3.2 Introduction to XML and SOAP 116. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Web Services 118. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Introduction to OPC DX 119. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4 Introduction to OPC 120. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 What Does the OPC Interface Provide? 121. . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 What is an OPC Server? 123. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.3 What is an OPC Client? 124. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.4 How do the Server and Client Work Together? 124. . . . . . . . . . . . . . . . . . .
3.5 OPC Data Access 125. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.1 What Does the Class Model of OPC Data Access Provide? 126. . . . . . . . 3.5.2 OPC Server Class 126. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.3 OPC Group Class 127. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.4 OPC Item Class 127. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.5 Using the “Percent Deadband” Parameter 128. . . . . . . . . . . . . . . . . . . . . . . 3.5.6 Which interfaces are specified for OPC Data Access? 129. . . . . . . . . . . . .
3.6 OPC DX Interface 130. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.1 DX Server 130. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.2 DX Database 131. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.7 OPC Alarms & Events 133. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.1 What are Events and Event Messages? 133. . . . . . . . . . . . . . . . . . . . . . . . . 3.7.2 What Does the Class Model of OPC Alarms & Events Provide? 134. . . . 3.7.3 OPC Event Server Class 135. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.4 OPC Event Subscription Class 135. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.5 OPC Event Area Browser Class 137. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.6 How are Messages Received? 137. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.7 Alarms and SIMATIC S7 137. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.8 Examples of Handling Alarms 139. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7.9 Which Interfaces are Specified for Alarms & Events? 140. . . . . . . . . . . . . .
3.8 OPC XML Interface 140. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.8.1 Web Service OPC XML 142. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.8.2 Simple Read / Write Services 142. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.9 OPC in SIMATIC NET 144. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.1 What Does the OPC Server of SIMATIC NET Provide? 144. . . . . . . . . . . . 3.9.2 How is the OPC Server of SIMATIC NET Used in the World of
Automation? 146. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.3 What are the Advantages of the OPC Server for SIMATIC NET? 147. . . 3.9.4 What is the Best Way to Access Process Data? 148. . . . . . . . . . . . . . . . . . 3.9.5 Using Group Operations 148. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.6 Examples of Group Operations 149. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.7 Accessing the OPC Cache 149. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.8 Examples of Services that Can Use the Cache 149. . . . . . . . . . . . . . . . . . . 3.9.9 Structuring Items 150. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.10 Example of Structuring Items 151. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.9.11 Using Buffer Send/Receive Services 151. . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.12 Example of Using Buffer Send/Receive Services 152. . . . . . . . . . . . . . . . . 3.9.13 Using Suitable OPC Methods 152. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 OPC Process Variables for SIMATIC NET 157. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1 Which Communication Functions Exist? 157. . . . . . . . . . . . . . . . . . . . . . . . .
4.2 What Are Process Variables? 158. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 How Are the ItemIDs of the Process Variables Formed? 158. . . . . . . . . . .
4.4 PROFIBUS-DP 159. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Protocol ID 160. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.2 Connection Names 160. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.3 High-Performance SIMATIC NET Inproc-Server for the
PROFIBUS-DP Protocol 161. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.4 Powerful SIMATIC NET OPC Server for the PROFIBUS-DP Protocol 1624.4.5 DPC1 and DPC2 Services 164. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.6 Process Variables for Services of a Class 1 Master 165. . . . . . . . . . . . . . . 4.4.7 Syntax of Process Variables for a Class 1 Master 166. . . . . . . . . . . . . . . . . 4.4.8 Examples of Process Variables for a Class 1 Master 168. . . . . . . . . . . . . . 4.4.9 DPC1 Services 169. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.10 Syntax of the Process Variables for DPC1 Services 169. . . . . . . . . . . . . . . 4.4.11 Examples of Process Variables for DPC1 Services 172. . . . . . . . . . . . . . . . 4.4.12 Fast Logic for the CP 5613 and CP 5614 (Master Only) 172. . . . . . . . . . . 4.4.13 Syntax of the control variables for Fast Logic 173. . . . . . . . . . . . . . . . . . . . . 4.4.14 DP-Specific Information Variables 175. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.15 Syntax of the DP-specific Information Variables 176. . . . . . . . . . . . . . . . . . 4.4.16 PROFIDrive 181. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.17 Protocol ID 181. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.18 Device Name 181. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.19 Addressing the Bus Node (Slave) 182. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.20 Syntax of the System-Specific Information Variables 189. . . . . . . . . . . . . . 4.4.21 DP Class 2 Master Services 189. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.22 Syntax of the DP Class 2 Master Services 190. . . . . . . . . . . . . . . . . . . . . . . 4.4.23 Name of the CP 190. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.24 Addressing a Bus Node (DP Class 1 Master) 191. . . . . . . . . . . . . . . . . . . . . 4.4.25 Addressing the Bus Node (Slave) 194. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.26 Items for the CP 201. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.27 Examples of DP-Specific Information Variables 201. . . . . . . . . . . . . . . . . . 4.4.28 Variable Services for Access to Local Slave Data 202. . . . . . . . . . . . . . . . . 4.4.29 Syntax of the process variables for the DP slave 203. . . . . . . . . . . . . . . . . . 4.4.30 Examples of Process Variables for the DP Slave 205. . . . . . . . . . . . . . . . . 4.4.31 DP Slave-Specific Information Variables 206. . . . . . . . . . . . . . . . . . . . . . . . . 4.4.32 Syntax of the DP Slave-Specific Information Variables 206. . . . . . . . . . . . .
4.5 S7 Communication 207. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.1 Powerful SIMATIC NET OPC Server for the S7 Protocol 208. . . . . . . . . . . 4.5.2 Protocol ID 209. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.3 Connection Names 209. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.4 Variable Services 209. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.5 Syntax of the Process Variables for S7 Variable Services 210. . . . . . . . . . 4.5.6 Examples of Process Variables for S7 Variable Services 213. . . . . . . . . . . 4.5.7 Buffer-oriented Services 214. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.5.8 Syntax of the Process Variables for Buffer-Oriented Services 214. . . . . . . 4.5.9 Examples of Process Variables for Buffer-oriented Services 216. . . . . . . . 4.5.10 S7-specific Information Variables 217. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.11 Syntax of the S7-specific Information Variables 218. . . . . . . . . . . . . . . . . . . 4.5.12 Examples of S7-specific Information Variables and Return Values 220. . . 4.5.13 Block Management Services 222. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.14 Syntax of the Control Variables for Block Management Services 222. . . . 4.5.15 Examples of Using the Block Management Services 226. . . . . . . . . . . . . . 4.5.16 Passwords 228. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.17 Syntax of the Control Variables for Passwords 229. . . . . . . . . . . . . . . . . . . 4.5.18 Example of Using Passwords 230. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.19 Unconfigured S7 Connection 231. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6 PROFIBUS FMS 236. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.1 Protocol ID (FMS) 236. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.2 Connection Names 236. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.3 Data Types 237. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.4 Variable Services 239. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.5 Syntax of the Process Variables for FMS Variable Services 239. . . . . . . . 4.6.6 Examples of Process Variables for FMS Variable Services 240. . . . . . . . . 4.6.7 FMS-Specific Information Variables 241. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.8 Syntax of the FMS-specific Information Variables 241. . . . . . . . . . . . . . . . . 4.6.9 Examples of FMS-Specific Information Variables and Return Values 245. 4.6.10 FMS Server Variables 246. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.11 FMS Server Variables: ItemID 246. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7 S5-compatible Communication 247. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.1 S5-compatible Communication over Industrial Ethernet 247. . . . . . . . . . . . 4.7.2 Powerful SIMATIC NET OPC Server for the SR Protocol 248. . . . . . . . . . 4.7.3 Protocol ID 249. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.4 Connection Names 250. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.5 Variable Services 250. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.6 Buffer-oriented Services 253. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.7 SEND/RECEIVE-Specific Information Variables 257. . . . . . . . . . . . . . . . . . 4.7.8 S5-compatible Communication over PROFIBUS 259. . . . . . . . . . . . . . . . . . 4.7.9 Protocol ID 259. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.10 Connection Names 260. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.11 Buffer-oriented Services 260. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.12 FDL-specific Information Variables 266. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.8 SNMP Communication over Industrial Ethernet 269. . . . . . . . . . . . . . . . . . . 4.8.1 Protocol ID 270. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.8.2 Data Types of the SNMP Protocol 270. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.8.3 Process Variables for SNMP Variable Services 271. . . . . . . . . . . . . . . . . . . 4.8.4 SNMP-specific Information Variables 272. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.8.5 SNMP-specific Traps 275. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9 Restricting Access Rights of the OPC Variables 276. . . . . . . . . . . . . . . . . .
5 Properties of the OPC Event Server from SIMATIC NET 279. . . . . . . . . . . . . . . . .
5.1 Event Server for S7 Communication 279. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.1 Functions and Alarm Categories 279. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.2 Parameters for Events 281. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.3 Event Attributes 284. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
5.1.4 Event Attributes for SIMOTION-specific Alarms 288. . . . . . . . . . . . . . . . . . 5.1.5 Attributes for Entries in the Diagnostic Buffer of the Module 290. . . . . . . . 5.1.6 Attributes or Alarms Indicating an Interrupted Connection 291. . . . . . . . . .
5.2 Simple Event Server for SNMP Communication 292. . . . . . . . . . . . . . . . . .
6 Using the OPC Server 295. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1 SIMATIC Computing 295. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.1 What Are ActiveX Controls? 296. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2 How Do Controls Access Process Data? 298. . . . . . . . . . . . . . . . . . . . . . . . 6.1.3 How Does Access with DCOM Work? 299. . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.4 How Are SIMATIC NET Controls Used in a Development
Environment? 300. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.5 Configuring the SIMATIC NET OPC Data Control 301. . . . . . . . . . . . . . . . . 6.1.6 Opening the Properties Window for SIMATIC NET OPC Data
Control 302. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.7 Selecting the OPC Server 302. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.8 Connecting Display Controls and Process Variables 303. . . . . . . . . . . . . . . 6.1.9 Assigning an Event to a Process Variable 305. . . . . . . . . . . . . . . . . . . . . . . . 6.1.10 Optional Tasks 306. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.11 Configuring a Button Control 308. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.12 Properties of the Button Control 309. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.13 Opening the Properties Window for the Button Control 310. . . . . . . . . . . . 6.1.14 Specifying the Label 310. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.15 Specifying the Font of the Label 310. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.16 Specifying the Color of the Button Control 311. . . . . . . . . . . . . . . . . . . . . . . 6.1.17 Activating the Button Control 311. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.18 Connecting the Button Control with the Process Data 312. . . . . . . . . . . . . 6.1.19 Configuring a Number Control 313. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.20 Properties and Methods of the Number Control 313. . . . . . . . . . . . . . . . . . . 6.1.21 Opening the Properties Window for the Number Control 318. . . . . . . . . . . 6.1.22 Defining Data Display 318. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.23 Specifying the Appearance 320. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.24 Specifying the Label 320. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.25 Specifying the Scaling for the Display 322. . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.26 Specifying the Font of the Label 323. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.27 Specifying the Color of the Number Control 323. . . . . . . . . . . . . . . . . . . . . . 6.1.28 Activating the Number Control 324. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.29 Connecting the Number Control with the Process Data 324. . . . . . . . . . . . 6.1.30 Configuring a Slider Control 325. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.31 Properties of the Slider Control 325. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.32 Opening the Properties Window for the Slider Control 327. . . . . . . . . . . . . 6.1.33 Defining Data Display 327. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.34 Activating a Slider Control 328. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.35 Connecting the Slider Control with the Process Data 329. . . . . . . . . . . . . . 6.1.36 Using Other ActiveX Controls 329. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.37 What Are the Guidelines for Container Applications? 330. . . . . . . . . . . . . . 6.1.38 What Are the Guidelines for ActiveX Controls? 330. . . . . . . . . . . . . . . . . . . 6.1.39 How Does the Data Control Read Data? 331. . . . . . . . . . . . . . . . . . . . . . . . . 6.1.40 How Is Data Written to the Data Control? 331. . . . . . . . . . . . . . . . . . . . . . . . 6.1.41 Properties and Methods of the SIMATIC Controls 332. . . . . . . . . . . . . . . . . 6.1.42 Activated 335. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.43 Alignment 336. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.44 Appearance 337. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.45 AutoConnect 337. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.46 AutoConnectTimeout 338. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.47 BackColor 339. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.48 BorderStyle 339. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.49 Captionn 340. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.50 CaptionnAlignment 340. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.51 CaptionnBackColor 341. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.52 CaptionnFont 342. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.53 CaptionnForeColor 342. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.54 CaptionnSize 343. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.55 ConvertedValue 344. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.56 DataType 345. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.57 DefaultDeadband 346. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.58 DefaultUpdateRate 347. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.59 Direction 348. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.60 Enabled 348. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.61 Factor 349. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.62 FalseCaption 350. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.63 FalseColor 350. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.64 Font 351. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.65 ForeColor 351. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.66 LargeChange 352. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.67 LayoutType 353. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.68 LimitCheck 353. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.69 Locked 354. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.70 LowerLimit 355. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.71 Max 355. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.72 Min 356. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.73 NodeName 356. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.74 Offset 357. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.75 Precision 358. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.76 Radix 358. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.77 RangeRawMax 359. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.78 RangeRawMin 360. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.79 RangeScaledMax 362. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.80 RangeScaledMin 363. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.81 ScaleMode 364. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.82 ServerName 365. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.83 ShowButtons 366. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.84 ShowErrorBoxes 367. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.85 SmallChange 368. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.86 Ticks 368. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.87 TrueCaption 369. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.88 TrueColor 369. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.89 UpperLimit 370. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.90 Value 370. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.91 WriteMode 371. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.92 ZeroPad 372. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.93 AddNotification 372. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.94 Connect 373. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.95 Disconnect 374. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.96 GetItemProperties 374. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.97 QueryAvailableItemProperties 375. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.98 ReadMultiVariables 376. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.99 ReadVariable 377. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.100 Write 378. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.101 WriteMultiVariables 378. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.102 WriteVariable 379. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.103 Events of the SIMATIC Controls 379. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.104 Events of the Data Control 380. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.105 Events of the Button Control 380. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.106 Events of the Number Control 380. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.107 Events of the Slider Control 381. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.108 Error Messages of the SIMATIC Controls 381. . . . . . . . . . . . . . . . . . . . . . . . 6.1.109 Error Messages of the Data Control 382. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.110 Error Messages of the Number Control 382. . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Programming the Automation Interface 384. . . . . . . . . . . . . . . . . . . . . . . . . . 6.2.1 Programming the Automation Interface for Data Access 384. . . . . . . . . . . 6.2.2 What Does the Object Model of OPC Data Access Provide? 384. . . . . . . 6.2.3 Points to Remember When Programming 385. . . . . . . . . . . . . . . . . . . . . . . . 6.2.4 Objects of the Automation Interface for Data Access 386. . . . . . . . . . . . . . 6.2.5 Programming the Automation Interface for Alarms & Events 397. . . . . . . . 6.2.6 What Does the Object Model of OPC Alarms & Events Provide? 397. . . . 6.2.7 Points to Remember When Programming 399. . . . . . . . . . . . . . . . . . . . . . . . 6.2.8 Objects of the Automation Interface for Alarms & Events 399. . . . . . . . . .
6.3 Programming the Custom Interface 410. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.1 Creating COM Objects and Querying the Status of the OPC Server 412. 6.3.2 Objects of the Custom Interface for Data Access 412. . . . . . . . . . . . . . . . . 6.3.3 OPCServer Object 412. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.4 OPCGroup Object 417. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.5 Objects of the Custom Interface for Alarms & Events 424. . . . . . . . . . . . . . 6.3.6 OPCEventServer Object 424. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.7 OPCEventSubscription Object 428. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.8 OPCEventAreaBrowser Object 430. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.9 Interfaces of the Client for Alarms and Events 430. . . . . . . . . . . . . . . . . . . . 6.3.10 IOPCEventSink Interface 431. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.11 IOPCShutdown Interface 433. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3.12 Error Messages for OPC DA Process Variables 433. . . . . . . . . . . . . . . . . .
6.4 Programming the DX Interface 437. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4.1 Structure of the DX Database 437. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4.2 DX Configuration Services 441. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5 Programming the XML Interface 444. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.1 Description of the Elements 444. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.2 Basic Schemas 445. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.3 ItemProperty 446. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.4 ItemValue 447. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.5 OPCError 448. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.6 ReplyBase 449. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.7 RequestOptions 450. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.8 Read 451. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.9 ReadResponse 454. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.5.10 Write 456. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.11 WriteResponse 458. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.12 Using Subscriptions 460. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.13 Subscribe 462. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.14 SubscribeResponse 464. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.15 SubscriptionPolledRefresh 466. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.16 SubscriptionPolledRefreshResponse 467. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.17 SubscriptionCancel 469. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.18 SubscriptionCancelResponse 469. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.19 Browse 470. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.20 BrowseResponse 472. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.21 GetProperties 474. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.22 GetPropertiesResponse 476. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.23 GetStatus 477. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.5.24 GetStatusResponse 479. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7 Sample Programs 481. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1 Sample Program - Programming with ActiveX Controls 482. . . . . . . . . . . . 7.1.1 Running the Program 482. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.2 Description of the Program 483. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.3 Principle of Assigning Control Properties to OPC Process Variables 483. 7.1.4 Configuring the SIMATIC S7 Number Control 484. . . . . . . . . . . . . . . . . . . . 7.1.5 Configuration of the SIMATIC NET OPC Data Control 486. . . . . . . . . . . . . 7.1.6 Implementing the Event Procedures 488. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.7 Notes on Writing your own Programs 491. . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Sample Program for the OPC Automation Interface (Synchronous Communication) 492. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2.1 Activating the Simulation Connection 492. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.2 Working with the Sample Program 493. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.3 How the Program Runs 495. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.4 Description of the Program 496. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.5 Command_Start_Click 496. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.6 Command_Read_Click 498. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.7 Command_Write_Click 499. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.8 Command_Exit_Click 500. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.9 GetQualityText 501. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.10 Notes on Writing your own Programs 501. . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.11 Using the OPC Automation Interface with the .NET-Framework 502. . . .
7.3 Sample Program for the OPC Automation Interface (Asynchronous Communication) 505. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3.1 Activating the Simulation Connection 505. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.2 Working with the Sample Program 506. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.3 Start Program 506. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.4 Read and Write Values 507. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.5 Activate Group 508. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.6 Stop the Program 508. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.7 How the Program Runs 509. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.8 Description of the Program 510. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.9 Command_Start_Click 511. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.10 The “Group Active” Check Box 514. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.11 Command_Read_Click 514. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.3.12 Command_Write_Click 515. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.13 Command_Exit_Click 517. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.14 GroupObj_AsyncReadComplete 517. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.15 GroupObj_AsyncWriteComplete 519. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.16 ObjGroup_DataChange 520. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.17 GetQualityText 521. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.18 GetErrorString 522. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.19 Notes on Writing your own Programs 522. . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4 Sample Program for the OPC Custom Interface(Synchronous Communication) 523. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4.1 Activating the Simulation Connection 523. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.2 Working with the Sample Program 524. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.3 How the Program Runs 525. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.4 Description of the OPCDA_SyncDlg.cpp Program 529. . . . . . . . . . . . . . . . 7.4.5 OnInitDialog 530. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.6 OnStart 531. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.7 OnRead 540. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.8 OnWrite 543. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.9 OnStop 544. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.10 DestroyWindow 547. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.11 GetQualityText 547. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.12 Notes on Writing your own Programs 548. . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5 Sample Program for the OPC Custom Interface(Asynchronous Communication) 549. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.5.1 Activating the Simulation Connection 549. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.2 Working with the Sample Program 550. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.3 Start Program 550. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.4 Read and Write Values 551. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.5 Activate Group 552. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.6 Stop the Program 553. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.7 How the Program Runs 553. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.8 Description of the Program Structure 560. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.9 The OPCDA_AsyncDlg.cpp File 560. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.10 Callback.cpp and Callback.h 584. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5.11 Notes on Writing your own Programs 591. . . . . . . . . . . . . . . . . . . . . . . . . . .
7.6 Sample Program for the OPC Custom Interface (AsynchronousCommunication) with .NET-Framework 591. . . . . . . . . . . . . . . . . . . . . . . . .
7.6.1 Working with the Sample Program 592. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.6.2 Description of the Program 593. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.7 Sample Program for the OPC XML Interface 599. . . . . . . . . . . . . . . . . . . . . 7.7.1 Working with the Sample Program 599. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.2 Adding a Web Service to the Project 601. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.3 The MainForm Class 602. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.4 The Constructor of MainForm and the Dispose Method 603. . . . . . . . . . . . 7.7.5 Creating the Dialog Box Elements 604. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.6 The Main Method 610. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.7 The Button_Start_Sample_Click Method 610. . . . . . . . . . . . . . . . . . . . . . . . 7.7.8 The Button_Stop_Sample_Click Method 613. . . . . . . . . . . . . . . . . . . . . . . . . 7.7.9 The Button_Read_Value_Click Method 613. . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.10 The Button_Write_Value_Click Method 615. . . . . . . . . . . . . . . . . . . . . . . . . .
17SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.8 Sample Program Custom Interface for Alarms & Events 617. . . . . . . . . . .
8 FAQs 621. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1 FAQs in General 621. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1.1 Administrator Privileges 621. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1.2 Licenses 622. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1.3 Windows Versions 623. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.1.4 Miscellaneous 623. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 FAQs on the SIMATIC NET OPC Server 626. . . . . . . . . . . . . . . . . . . . . . . . 8.2.1 Product Characteristics 626. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.2 Operating and Programming the OPC Server 629. . . . . . . . . . . . . . . . . . . . 8.2.3 Creating the Configuration 633. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.4 The Symbol File Configurator 635. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.5 Special Features of the FMS OPC Server 635. . . . . . . . . . . . . . . . . . . . . . . 8.2.6 Special Features of the DP OPC Server 637. . . . . . . . . . . . . . . . . . . . . . . . . 8.2.7 Special Features of the S7 OPC Server 638. . . . . . . . . . . . . . . . . . . . . . . . . 8.2.8 Special Features of the SR OPC Server 640. . . . . . . . . . . . . . . . . . . . . . . . . 8.2.9 Special Features of the FDL OPC Server 640. . . . . . . . . . . . . . . . . . . . . . . . 8.2.10 OPC Scout 641. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.11 DCOM Configuration 644. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.12 PROFInet OPC Server 644. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.13 SIMATIC NET OPC DataOCX 646. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.14 OPC XML-DA 646. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3 FAQs on the CP 1613 648. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3.1 General Information on Installation 648. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3.2 , Installation along with Other Modules 649. . . . . . . . . . . . . . . . . . . . . . . . . . 8.3.3 Miscellaneous 650. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4 FAQs on SOFTNET Industrial Ethernet 653. . . . . . . . . . . . . . . . . . . . . . . . .
8.5 FAQs on SEND/RECEIVE for Industrial Ethernet 656. . . . . . . . . . . . . . . . .
8.6 FAQs on the CP 5613/CP 5614 658. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.7 FAQs on Converting from the CP 5412 to the CP 5613/CP 5614 and CP 5...11 659. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.8 FAQs on SOFTNET PROFIBUS 660. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.9 FAQs on the CP 5511 661. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.1 Installing the CP 5511 661. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9.2 Parallel Operation of the CP 5511 with other PCMCIA Cards 664. . . . . . .
8.10 FAQs on the CP 5611 665. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.11 FAQs on PROFIBUS SOFTNET S7 666. . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.12 FAQs on PROFIBUS SOFTNET DP 669. . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.12.1 DP Slave 669. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.12.2 DP Master 669. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.13 FAQs on the FDL Protocol in SOFTNET PROFIBUS 672. . . . . . . . . . . . . .
9 Related Literature 679. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1 Other Available Literature 679. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 OPC Specifications 680. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Glossary 683. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
20SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
21SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
General Information
This chapter tells you about the contents, changes, and versions of thedocumentation and explains how you should use it. With the information here, youwill find the topics you want both quickly and easily.
The chapter also explains how to get support if you have technical questions.
At the end of the chapter, you will find the legal and safety regulations that apply toSIMATIC NET Products.
1.1 Finding your Way through the Documentation
1.1.1 Where to Find Descriptions of the Various Products
These products are described in this documentation:
� DP-5613/Windows V 6.0 and higher
� S7-5613/Windows V 6.0 and higher
� FMS-5613/Windows V 6.0 and higher
� SOFTNET -DP/Windows V 6.0 and higher
� SOFTNET -S7/Windows V 6.0 and higher
� SOFTNET -DP-Slave/Windows V 6.0 and higher
� CP 5613/CP 5614 Software V 6.0 and higher
� S7-1613/Windows V 6.0 and higher
� SOFTNET -S7/Windows V 6.0 and higher
� S7-REDCONNECT/Windows V 6.0 and higher
� PN OPC Server/Windows V 6.0 and higher
� SNMP OPC Server/Windows V 6.0 and higher
� DX OPC Server/Windows V6.2 and higher
1
General Information
22SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
1.1.2 What’s New in the Product Documentation?
The SIMATIC NET documentation previously took the form of separate manuals.To provide you with the information you require in a compact and user- friendlyform, we have integrated several manuals into this document. The table belowshows you where to find the topics covered by the previous manuals in thisdocumentation:
Topics in Previous Manuals Where to Find Them Now
S7 Programming Interface OPC Process Variables for SIMATICNET - “S7 Communication”
SEND/RECEIVE Programming In-terface
OPC Process Variables for SIMATICNET - “S5-compatible Communica-tion over Industrial Ethernet”
Introduction to SOFTNET for Industrial Ethernet
“Industrial Communication with Indu-strial Ethernet”
DP Programming Interface OPC Process Variables for SIMATICNET - “PROFIBUS -DP”
DPC1 Programming Interface OPC Process Variables for SIMATICNET - “DPC1 Services”
DP slave “Variable Services for Access to LocalSlave Data”
FDL Programming Interface OPC Process Variables for SIMATICNET - “S5-compatible Communica-tion over PROFIBUS”
FMS Programming Interface OPC Process Variables for SIMATICNET - “PROFIBUS -FMS”
COM PROFIBUS “NCM S7 for PROFIBUS” Manual
COML S7 COML S7 is no longer required and isnow replaced by the following docu-mentation:
“NCM S7 for PROFIBUS” or “NCM S7for Industrial Ethernet” Manual
Introduction to the OPC Server Many parts of this document
General Information
23SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
1.1.3 What’s the Latest Version of the Documentation?
The table below shows the history and versions of this documentation:
Version Corresponding Soft-ware Versions
Content/Changes
December 2003 SIMATIC NET V6.2OPC DX V1.0OPC XML V1.0OPC A&E V1.1
SIMATIC NET Softwarefor Industrial Communi-cation with OPC
1.1.4 How to Work with the Documentation
To help you to work with the documentation, various conventions and symbolshave been used. These are intended to highlight different types of information andto speed up access to the information you require.
Conventions
The documentation uses a variety of conventions to highlight different types ofinformation and to allow you to locate specific types of information at a glance. Thetable below shows the conventions used.
Convention indicates:
“Typewriter font” This is program code.
Italics These are variable terms that must bereplaced by the currently relevantterm.
Bold In syntax descriptions: These are fi-xed syntactical elements.
In normal text: Words are highlighted to allow fastorientation.
{} Braces indicate optional information insyntax descriptions.
This indicates a warning.
General Information
24SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
1.2 Contacts and Training
Contacts
If you have further questions about SIMATIC NET products, contact your localSiemens representative.
You will find the addresses:
� In our catalog IK PIavailable on the SIMATIC NET Documentation CD in “Catalog IK PI IndustrialCommunication and Field Devices“ (double-click on the file START.HTM in themain folder of the SIMATIC NET Documentation CD -> English -> selectionbox below “Industrial Communication SIMATIC NET“ Catalogs -> Catalog IKPI Industrial Communication and Field Devices).
� On the Internet http://www.ad.siemens.de
� In the interactive catalog CA01 http://www.siemens.de/automation/ca01
� On the Quick Start CD
Training Center
Courses are available to help you become familiar with the SIMATIC S7automation system and programmable controllers. Please contact your regionaltraining center or the central training center in D 90327 Nuremberg.
Course office information line:
Tel. 01805 / 23 56 11 (0.12 per minute in Germany)Fax. +49 / (0)1805 / 23 5612
Internet: http://www.siemens.de/sitrain
E-mail: [email protected]
A&D Technical Support
You will find information on A&D Technical Support at the end of this manual.
General Information
25SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
1.3 Regulations
You must observe the following regulations relating to SIMATIC NET products:
1.3.1 Legal Regulations
We would point out that the contents of this document shall not become a part ofor modify any prior or existing agreement, commitment or legal relationship. ThePurchase Agreement contains the complete and exclusive obligations of Siemens.Any statements contained in this document do not create new warranties or restrictthe existing warranty.
We would further point out that, for reasons of clarity, this document cannot dealwith every possible problem arising from the use of the OPC Server. Should yourequire further information or if any special problems arise which are not sufficientlydealt with here, please contact your local Siemens representative.
Disclaimer
We have checked the contents of this document for agreement with the hardwareand software described. Since deviations cannot be precluded entirely, we cannotguarantee full agreement. However, the data in this document are reviewedregularly and any necessary corrections included in subsequent editions.Suggestions for improvement are welcomed.
Technical data subject to change.
The reproduction, transmission or use of this document or its contents is notpermitted without express written authority. Offenders will be liable for damages.All rights, including rights created by patent grant or registration of a utility ordesign, are reserved.
Siemens AG
Bereich Automatisierungs- und Antriebstechnik
Geschäftsgebiet Industrie-Automatisierung
Postfach 4848, D- 90327 Nürnberg
Siemens AG 2003
General Information
26SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
1.3.2 Safety-related Regulations
Qualified Personnel
Only qualified personnel should be allowed to install and work with this product.Qualified persons are defined as persons who are authorized to commission, toground, and to tag circuits, equipment, and systems in accordance withestablished safety practices and standards.
Correct Usage
!Warning
This device and its components may only be used for the applications described inthe relevant catalog or the technical description, and only in connection with devi-ces or components from other manufacturers which have been approved or re-commended by Siemens.
This product can only function correctly and safely if it is transported, stored, setup, and installed correctly, and operated and maintained as recommended.
With the products described in this document, it is easy to access process dataand to modify process data. Modifying process data can lead to unforeseeablereactions in the process that can lead to death, serious injury to persons and/ordamage to equipment.
Proceed cautiously and make sure that you do not access data that could causeunexpected reactions from the controlled devices and equipment.
27SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Industrial Communication
You want to get to know the principles of communication and the range of functionsof the individual protocols in industrial communication with SIMATIC NET. You areinterested in the technical options and when you have read through this sectionyou will be in a position to select the most suitable functions for solving yourautomation tasks.
Your Area of Interest Described in
You want to know what industrialcommunication actually involves.
Introduction to IndustrialCommunication
You want an overview of how SIMA-TIC NET fits into the overall conceptof Siemens industrial communica-tion.
SIMATIC NET for IndustrialCommunication
You want to familiarize yourself withthe range of functions of the variousprotocols for industrial communicationon PROFIBUS.
Industrial Communication onPROFIBUS
You want to familiarize yourself withthe range of functions of the variousprotocols for industrial communica-tion on Industrial Ethernet.
Industrial Communication with Indu-strial Ethernet
You want information on the use ofthe buffer-oriented services with theOPC interface.
Buffer-oriented Services with theOPC Interface
2.1 Introduction to Industrial Communication
Introduction
Communications networks are the backbone of modern automation solutions. Theyallow the interconnection and exchange of information between individualautomation components and devices.
This chapter contains general information about industrial communicationstechnology and engineering.
2
Industrial Communication
28SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.1.1 Special Requirements of Industrial Communications Systems
Industrial Networks
Industrial networks must meet special requirements over and above those ofnormal networks. In the final analysis, the success or failure of a production plantdepends on the functionality and efficiency of the automation system.
� An industrial communications system must allow the connection of the simplestsensors and actuators to controllers and the connection of controllers to eachother and to computers.
� To ensure problem-free operation of processes and plants, availability must beguaranteed: The right information must be there where it is needed at the righttime.
� Certain factors common to an industrial environment such as electromagneticinterference, high levels of contamination, dampness or mechanical strain placehigh demands on the network structure and network components.
� A particularly important aspect is the integrity of the data. Problems affectingthe data transmitter or the transmission medium must be detected and signaledso that the user can rely on the information being correct.
� One automation solution is seldom the same as another. An industrialcommunications system must be flexible and capable of adaptation to theparticular situation on the shop-floor.
2.1.2 Types and Categories of Networks
Distinguishing Between Networks
To be able to categorize industrial communications networks, it is helpful to groupthem roughly according to the network span. Networks can be grouped as follows:
� Global Area Network (GAN): Networks spanning the entire world such as theInternet.
� Wide Area Network (WAN): Networks, for example spanning regions andcountries such as the Datex-P network of the German Post Office or theIntranets of large enterprises.
� Local Area Network (LAN): Communication within a restricted area, for examplein an office building. In a LAN, there is normally a homogeneous datatransmission structure.
Industrial Communication
29SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Where do industrial networks fit in?
Industrial communications networks belong to the LAN group, although byinternetworking LANs, for example with the Internet, worldwide transmission ofselected information from the production area is nevertheless possible.
2.1.3 Communications Functions in Automation Engineering
Industrial communications systems can perform various functions:
� Process or field communication: Direct connection of actuators and sensors toprogrammable logic controllers. Data exchange can be either cyclic using theprocess image or acyclic using control commands.
� Data communication: Data exchange between programmable controllers orbetween a programmable controller and intelligent partner (for example a PC)using protocols and interfaces from the industrial environment.
� IT communication: Programmable controllers can be linked to moderninformation technologies allowing worldwide data exchange using standardtools such as E-mail or Web browsers.
2.1.4 Terms Used in Industrial Communications Engineering
Introduction
This section explains some of the terms commonly used in communicationsengineering. You can skip this section and refer to the explanations later when youmeet them in a concrete context.
Terms and explanations
Protocol
A protocol is a convention for controlled transfer of data. Protocols specify, forexample, the data structure, the structure of data packets, and the coding.
Protocols can also specify control mechanisms as well as hardware and softwarerequirements.
Connection
Industrial Communication
30SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
A connection is a virtual channel between two communications partners.Communication using a connection-oriented protocol involves the following:
� Connection establishment
� Data exchange
� Connection termination
Connection-oriented communication can be compared with a phone call in whichthe connection is established after dialing the subscriber number, data isexchanged by the parties talking and the connection is then terminated by thesubscribers hanging up.
Client/server architecture
Using the client/server architecture, resources of several users can be shared. Theserver provides services to the clients. The clients use the services provided by theserver by sending a job to the server. The server processes the job and sends theresult back to the client. A server can normally service several clients at the sametime. The OPC interface is based on a client/server architecture.
Master/slave principle
If communication is based on the master/slave principle, there is a station knownas the master that can trigger communication with a slave on its own initiative. Theslave then responds to the master. The slave can transfer data in its response. Incontrast to the master, a slave never becomes active on its own initiative. ThePROFIBUS-DP protocol is an example of master/slave communication.
Synchronous/asynchronous
The terms synchronous/asynchronous are used to describe how a service isexecuted. If a service is executed synchronously, program control returns to thecaller only when the result of the service is returned.
If, on the other hand, a service is executed asynchronously, program controlreturns to the caller immediately after a service has been requested. The result ofthe service is returned to the caller at an unspecified time; in other words,asynchronously.
ISO/OSI reference model
The “Open Systems Interconnection” (OSI) layer model is a reference model fordata transmission in networks named after a working group of the InternationalStandardization Organization ISO. The model consists of seven layers: Twohardware-oriented layers (layers 1 and 2), two transmission-oriented layers (layers3 and 4) and three application-oriented layers (layers 5, 6, and 7).
As a reference model, OSI is not a recognized standard. Many products intelecommunications and in networking use the ISO/OSI model as a foundation.
The 7 layers are as follows:
Physical layer (layer 1): The physical layer defines the bit transmission of data viathe network at the cable and connector level.
Industrial Communication
31SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Data-link layer (layer 2): The data-link layer groups data into frames and addsinformation required for passing on the frames. Layer 2 is responsible fortransporting data frames from node to node and for error correction.
Network layer (layer 3): The network layer controls the routing of the frames inconjunction with layer 2. It handles the addressing of the frames and how they arerouted in the network. An example of this layer is the Internet protocol.
Transport layer (layer 4): Coordinates the transmission of data packets. It checkswhether all packets have been received completely. A typical example of layer 4is the Transmission Control Protocol (TCP).
Session layer (layer 5): The session layer establishes a connection between theprocesses running on different hosts. It is responsible for opening a “Session” andfor a continuous dialog of requests and responses between the individualapplications.
Presentation layer (layer 6): The presentation layer is responsible for convertingdata into the format required for the specific application. This layer alsocompresses texts and converts various codes used by the partners.
Application layer (layer 7): The application layer is responsible for applicationsdirectly available to the user, such as file transfer or mail programs. The userrecognizes data transmission in the form of requests or responses.
Service Access Point (SAP)
The service access point is a point at which a layer of the ISO/OSI reference modelprovides its services to the next higher layer.
The entire exchange of information between two neighboring layers takes placevia the service access points. This is the interface between the higher and lowerlayer. If the SAP is between layer 3 (network layer) and layer 4 (transport layer),the service access point is known as the NSAP, Network Service Access Point, andif the SAP is between layer 4 and layer 5 (session layer), it is known as the TSAPor Transport Service Access Point.
Normally, certain resources and communications partners are assigned to aservice access point and the SAPs required for communication are thereforeidentified with unique names and numbers.
Industrial Communication
32SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.2 SIMATIC NET in Industrial Communications Engineering
Introduction
This section describes the possible applications of SIMATIC NET products.
2.2.1 SIMATIC NET for Industrial Communication
Properties of SIMATIC NET products
SIMATIC NET is the name of an entire family of communications networks andproducts from Siemens. The various networks meet the widest possible range ofperformance and application requirements in automation engineering:
� SIMATIC NET provides solutions meeting all the demands of industrialcommunication
� It is of central importance to the entire SIMATIC automation system
� It allows uniform interfacing between systems and to other automationcomponents
� Communication is comprehensive and fully integrated within the system
The communications networks from SIMATIC NET are a component of TotallyIntegrated Automation (TIA) from Siemens.
Industrial Communication
33SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.2.2 SIMATIC NET Communications Systems
Introduction
The bus systems of SIMATIC NET and their functions fit into the automationpyramid model. This section describes the layers of this model:
Field level
At the field level, a higher-level, controlling node communicates with the fielddevices connected to its network. The field devices measure, signal, and pass onthe commands of the cell level to the higher level of the plant or process. At thislevel, the volume of data transferred is relatively small. A hierarchicalcommunication structure is typical here; in other words, several field devicescommunicate with one master.
At the field level, the signals acquired from the process by input and output devicesare sent to the programmable controller via a communications system. For processand field communication at this level, Siemens offers PROFIBUS-DP and theAS-Interface.
Industrial Communication
34SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Cell level
This is the layer at which signals from the process acquired by the input and outputdevices are passed on to the programmable controller via a communicationssystem. At the cell level, programmable controllers, PCs, and devices for operatorcontrol and monitoring are interconnected.
At the cell level, programmable controllers exchange information allowing them toperform a common task or local operator control and monitoring systems areconnected to the programmable controllers. Data communication at the cell levelcan be implemented with components from Siemens both for Industrial Ethernetand PROFIBUS.
Management level
At this level, wider-ranging tasks are executed and processed that affect the entireproduction or process operation (management functions). These tasks includestorage of process values, running optimization and analysis functions, and loggingoperations. The required data can be collected, for example, from several processcells or factories and processed centrally. The number of nodes can run into thethousands.
At the management level, supervisory tasks involving the entire operation can behandled. Here, information about the entire plant comes together and commands(for example, recipes) can be transferred to underlying process cells. Forcommunication and data transmission at the management level, Industrial Ethernetfrom Siemens is the ideal communications system.
Note
Industrial Communication with the PC
As a component in an industrial automation system, the PC can handle bothcontrol tasks at the field level as well as operator control and monitoring functionsat the cell and management level. This documentation is restricted to industrialcommunication with a PC on PROFIBUS and Industrial Ethernet.
Industrial Communication
35SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.3 Industrial Communication with PROFIBUS
Introduction
This section provides you with a general outline of the PROFIBUS bus system.
2.3.1 Description of PROFIBUS
Introduction
PROFIBUS is the open and internationally standardized bus system for processand field communication with field devices and for data communication within anautomation cell. Data transmission in PROFIBUS is either on cost-effectivetwisted-pair cables or on fiber-optic cables that are immune to electromagneticinterference.
This section describes the devices that can be used for communication with thePROFIBUS system. The section also describes the bus access mechanisms andexplains where PROFIBUS fits into the ISO/OSI reference model.
2.3.2 Protocols and Devices for SIMATIC NET PROFIBUS
Process and Data Communication
SIMATIC NET provides the following PROFIBUS protocols and device types:
Industrial Communication
36SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
For process and field communication:
Protocol TypicalPC Module
Description Typical Sie-mens PartnerDevices
DP class 1master
CP 5613
CP 5614
CP 5511
CP 5611
Central device for rea-ding the input and settingthe output data of DPslaves. With the optionalDPV1 extension, the ma-ster can also access datarecords of the DPV1 sla-ves asynchronously.
ET 200B
ET 200X
ET 200L
ET 200LS
CP 5614
DP class 2master
CP 5611
CP 5511
CP 5613
Device for diagnosticsand commissioning a DPsystem. With the optionalDPV1 extension, the ma-ster can also access datarecords of the DPV1 sla-ves.
CP 5613
CP 342-5
CP 343-5
CP 443-5
and the slaveslisted above
DP slave CP 5611
CP 5511
CP 5614
Distributed I/O unit, forexample for acquiringand converting processsignals and transmittingoutput signals.
CP 5613
CP 5614
CP 5511
CP 5611
CP 342-5
CP 443-5
Industrial Communication
37SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
For data communication:
Protocol Typical PC
Module
Description Typical Sie-mens PartnerDevices
FMS CP 5613
CP 5614
Open protocol for net-working programmablecontrollers from differentvendors at the cell levelwith few nodes
CP 5613
CP 343-5
CP 443-5
CP 5431FMS/DP
S7 Proto-col
CP 5613
CP 5614
CP 5511
CP 5611
Integrated and optimizedcommunications functio-nality of the SIMATICS7/C7 systems for a wi-de range of applications
CP 5611
CP 5613
CP 342-5,343-5
CP 443-5
S5-com-patiblecommuni-cation
CP 5613
CP 5614
CP 5511
CP 5611
Simple communicationservices based on PRO-FIBUS FDL for exchan-ging data with S5 and S7devices.
CP 5431
CP 5434
CP 342-4,343-5
CP 443-5
Industrial Communication
38SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.3.3 Bus Access Mechanism of PROFIBUS
Introduction
The PROFIBUS specification is flexible enough to allow the implementation ofvarious protocols optimized for specific tasks in different areas of application. TheFDL data-link layer (layer 2 of the OSI/ISO reference model) ensures uniformcontrol of access to the bus.
Token Passing
In PROFIBUS, access to the bus is controlled by a token-passing technique; inother words, only the station in possession of the token is allowed to transmit onthe network. After a fixed time, the token is passed to the next station. At the endof a cycle, the first station receives the token again.
Active and Passive Nodes
In a PROFIBUS network, there are two basic types of node:
� Active nodes control communication on the bus. Each active node receives thetoken once per cycle and can then exchange data with active and passivenodes. Once the token holding time has elapsed, the node passes the token onto the next master. DP masters and S7 servers, for example, are activestations.
� Passive nodes cannot initiate communication themselves. They do not receivethe token and respond only to polls from another station. A typical example of apassive station is a DP slave.
Industrial Communication
39SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.3.4 PROFIBUS in the ISO/OSI Reference Model
Introduction
PROFIBUS is based on the ISO/OSI reference model but does not implement alllayers:
Layer 1
The physical layer (layer 1) of PROFIBUS uses the electrical and mechanicalcharacteristics of the widespread RS-485 interface. The PROFIBUS standarddefines a selection of bus parameters that can be adapted to meet the specialrequirements of a bus system.
Electrical Characteristics:
Maximum number of nodes 126
Standard transmission rates 9.6 / 19.2 / 45.45 / 93.75 / 187.5 / 500/ 1500 / 3000 / 6000 / 12000 Kbps
Cable length Depending on the transmission rateand medium, between 200 m and 90km
Topology BusStarRing (optical networks only)
LAN cable Shielded twisted pairFiber-optic cable
Termination Both ends of an electrical bus seg-ment must be terminated with a termi-nating resistor.
Mechanical Properties (Electrical Network):
Industrial Communication
40SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Attachment 9-pin D-sub female connector on in-terfacing device with defined pin as-signment
Layer 2
The data-link layer (layer 2) defines the bus access method already mentioned andthe basic services for data transmission. This layer is known as the fieldbus datalink (FDL). It ensures a uniform bus access protocol that specifies the basiccommunication properties for all specific implementations.
The FDL services can be divided into management services and productiveservices. The management services allow local settings to be made that arerequired to use the productive services. The productive services are responsiblefor the data transfer between the various PROFIBUS nodes.
The services for data transmission are as follows:
� SDN (Send Data with no Acknowledge)
� SDA (Send Data with Acknowledge)
� SRD (Send and Request Data with Reply)
Layers 3 to 7
Layers 3 to 6 are not explicitly implemented in the FMS and DP protocols specifiedin the PROFIBUS standard. In DP, layers 3 to 6 are omitted completely. Theadaptation is handled by the lower layer interface (LLI) assigned to layer 7 thatimplements subfunctions such as connection establishment, termination, andmonitoring.
S7 communication is the homogeneous extension of PROFIBUS in the SIMATICenvironment and also implements elements of the network layer (layer 3) and thetransport layer (layer 4).
Industrial Communication
41SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.4 S5-compatible Communication over FDL(SEND/RECEIVE protocol)
Introduction
S5-compatible communication on PROFIBUS allows simple data exchange onPROFIBUS between SIMATIC S5 controllers, SIMATIC S7 controllers, and PCsand workstations.
This section describes the principle of communication and the services of theSEND/RECEIVE protocol. The section also describes the structure andconfiguration.
2.4.1 Typical System Configuration for S5-compatibleCommunication
Introduction
For data exchange using S5-compatible communication, communications modulesare available for controllers of the SIMATIC S5, SIMATIC 505 and SIMATIC S7families as well as for PCs and workstations.
Example of a Configuration
Industrial Communication
42SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.4.2 Principle of SEND/RECEIVE Communication
General Description of the Principles
S5-compatible communication is based on the simple transmission of data in anFDL frame. During data transfer, the receiver provides a receive buffer to which thesender sends a data buffer. S5-compatible communication uses the services of thedata-link layer of PROFIBUS, the fieldbus data link (FDL) directly.
Note
The OPC items used with the PC in S5-compatible communication on PROFIBUSare identified by the “FDL” prefix.
S5-compatible communication is possible only between active PROFIBUS nodes.Due to the length of FDL frames, the length of the user data is restricted to amaximum of 246 bytes per frame. Data is exchanged with the SDA (Send Datawith Acknowledge) and SDN (Send Data with No Acknowledge) services.
No connection establishment is necessary for communication. The sender andreceiver are assigned to each other by specifying the partner address and theservice access point (SAP). By selecting certain SAPs, it is also possible to send aframe to several nodes at the same time (broadcast/multicast).
2.4.3 SEND/RECEIVE Configuration
Address and Service Access Point
Before S5-compatible communication can be used on PROFIBUS, thecommunication relations must first be configured. A communication relation iscreated in the configuration by specifying a name, partner address and serviceaccess point.
Industrial Communication
43SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Example
2.4.4 SEND/RECEIVE Services
Introduction
This section provides you with an overview of the communication services that canbe used with S5-compatible communication.
Functions
S5-compatible communication on PROFIBUS provides the following function:
� Services for transferring data buffers (SEND / RECEIVE)
The following information services are also available on a PC:
� Obtaining the bus parameters and the local station address
� Obtaining the list of stations on the bus
� Identification of the local station and partner station
Note
In contrast to S5-compatible communication on Industrial Ethernet, the bufferservices on PROFIBUS do not provide the “Fetch” and “Write” variable services.
Industrial Communication
44SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Description of the Services
S5-compatible communication provides services for transferring blocks of datausing the SDN and SDA FDL services. The transfer of a packet from the sender tothe receiver must be triggered explicitly by the sender. If the sender is, forexample, a SIMATIC S7 controller, this is done by calling the “AG_SEND” block,and if the sender is a PC with OPC, by calling a method for writing a “SEND”variable.
The receiver cannot initiate data transfer from the sender.
The size of the data buffer transferred is limited by the PROFIBUS frame lengthsof 244 bytes (or 246 bytes when using the default SAPs).
By using the broadcast SAP (63) and the broadcast address (127), it is possible tosend a frame to more than one station at the same time.
Since there is no connection and therefore no connection monitoring for thisprotocol, the receiver cannot detect the failure of a partner device. It is, however,possible to program cyclic send jobs on the controllers and PLCs and to have thereception of these jobs monitored by the partner and so achieve a form ofmonitoring.
Note
When using the OPC server, receive buffers are created by initializing a“RECEIVE” variable and send buffers by initializing a “SEND” variable.
When using the OPC server, it is possible to map the block of data or parts of it onindividual OPC variables and to assign these parts to data types. This structuringmakes the use of the buffer-oriented services much simpler for the OPC user.
Advantages / Disadvantages
S5-compatible communication on FDL has the following advantages anddisadvantages:
Advantages
� Larger blocks of data up to a size of 244 or 246 bytes.
� No network load when data is not being transferred.
� “Broadcast” frames to several nodes is possible.
� Structured access to blocks of data on the PC is possible with OPC.
� Communication with SIMATIC S5 and SIMATIC S7 devices is possible.
� Communication between two PCs/PGs is possible.
Industrial Communication
45SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Disadvantages
� The receiver cannot initiate data transfer. It must wait until the data istransferred by the sender.
� No monitoring of the failure of a partner or break on the network provided forthe receiver by the protocol.
� No routing (forwarding a job to other networks).
2.5 DP Protocol
Introduction
This section describes the principle of communication and the services of the DPprotocol. The section also describes the structure and configuration.
2.5.1 The DP Protocol and its Expansions
Description of the DP Protocol
The distributed peripheral I/O ( or simply DP) allows a large number of analog anddigital input and output modules to be used in a distributed structure in theimmediate vicinity of the process.
There can be large distances between the individual I/O devices bridged byPROFIBUS. Distributed I/O stations collect the input signals locally and these arethen fetched cyclically by the central controller. In the opposite direction, thecentral controller sends output data to the distributed I/O stations cyclically.
The DP protocol is intended for time-critical applications. The simple, optimizedtransmission protocol, the high transmission rates, and the use of a master-slavestructure achieve short cycle times.
As an open protocol, DP is based on the communications standard for the fieldarea (IEC 61158).
Industrial Communication
46SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Example of a Configuration
Characteristics of the DP Protocol
The essential characteristics of the distributed I/O system are as follows:
� Central control by a master
� High data throughput with a simple transmission protocol
� Cyclic transmission of the process image in the input and output direction
� Detection of errors with online diagnostics
� Based on PROFIBUS FDL allowing operation along with other devices (mastersand slaves) on one bus.
DPV1
The DPV1 standard represents an expansion of DP communication. Slavessupporting DPV1 have an additional memory area in which special, slave-specificdata records are stored. Using DPV1 functions, the data records can be read orwritten providing expanded functionality.
Characteristics of the DP Protocol and Expansions
Several expansions are available for the DP protocol with which specific propertiescan be implemented. The following table provides an overview of the various DPmasters and their expansions.
Industrial Communication
47SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Description of the Protocols
Protocols Description
DP Class 1Master
Provides services for setting slave parameters and for cyclicdata exchange.
DP Class 2Master
Additional diagnostic options. A class 2 master can query thestatus of a class 1 master or a slave without interfering in theoperation of the network.
DPC1 DPV1 expansion for class 1 masters. This allows a C1 ma-ster and the additional data areas of a DPV1 slave to be writ-ten to and read acyclically.
DPC2 DPV1 expansion for class 2 masters. Allows a C2 masterand the additional data areas of a DPV1 slave to be writtenand read acyclically.
Class 1 DP Master and DPC1:
Class 2 DP Master and DPC2:
Industrial Communication
48SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.5.2 Typical DP System Configuration
Example
The following graphic shows an example of a typical system configuration:
2.5.3 Principle of DP Communication
Communication Partners
In the distributed I/O system, there are three types of communication partner:
Properties of DP Communication Partners
DP CommunicationPartners
Description
DP slaves Passive bus nodes, normally the I/O devices.
DP class 1 master Active node, central component for controlling theDP slaves.
DP class 2 master Active node that can be used for commissioning anddiagnostics parallel to a class 1 master.
Industrial Communication
49SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Polling
Normal communication between the DP master and the distributed I/O stationstakes the form of polling. Polling means that the DP master sends cyclic pollingframes to the DP slaves assigned to it. A separate polling frame is sent for eachDP slave.
The polling frame contains the current output data that the DP slave will apply to itsoutput ports. If a DP slave does not have output ports, an “empty frame” is sentinstead.
The addressed DP slave must acknowledge that it has received a polling frame byreturning an acknowledgment frame. The acknowledgment frame contains thecurrent input data available at the input ports of the DP slave. If the DP slave doesnot have input ports, an “empty frame” is returned instead.
All the operational DP slaves are addressed in one polling cycle. The next pollingcycle starts immediately after the last slave has been addressed. This methodensures that the data is up-to-date. In every polling cycle, the DP master attemptsto include non-operational slaves in the cycle.
Note
The OPC items used with the PC during DP communication on PROFIBUS areidentified by the prefix “DP”.
Industrial Communication
50SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
No Flow Control in DP
The DP protocol is optimized for fast data throughput between the master andslave and does not include flow control between the master and slave. Input andoutput data is exchanged cyclically between the master and slave. When writing aDP application, you should therefore bear the following points in mind:
� If the output data of the master changes more than once during the cycle time,some values will not be transferred to the slaves.
� If the input data of the master is not read within the cycle time, some valuechanges occurring on the slaves will be lost.
2.5.4 DP Configuration
Introduction
The DP master can only take part in productive data exchange with the DP slaveswhen it has previously set parameters for these slaves and configured them.
The master configures slaves and sets the parameters in the following situations:
� During the startup phase of the DP master.
� Following the temporary failure of a DP slave during the productive phase.
You specify and save the required configuration and parameter assignment dataduring configuration of the network.
Parameter Assignment Frame
The parameter assignment frame sets global operating parameters on the DPslave (for example the watchdog time).
Configuration Frame
The configuration frame is sent after the parameters of the DP slave have been setsuccessfully. This contains the current configuration of the DP slave. Theconfiguration includes the number and type of input/output ports.
The DP slave compares the received configuration frame with the values itobtained itself during the startup phase. If the values match, the DP slave confirmsthe configuration and changes to the productive phase.
Industrial Communication
51SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.5.5 Class 1 DP Master - Principle of Communication and Services
The Modes of the DP Master
The DP master controls the status of the DP system. Each mode of the DP masteris characterized by defined actions between the DP master and the DP slaves:
Mode Meaning
OFFLINE There is no DP communication whatsoever between the DPmaster and DP slaves. This is the initial status of the DP ma-ster.
STOP In this mode, there is also no DP communication between theDP master and DP slaves. In contrast to the OFFLINE mode,a DP diagnostic station (DP class 2 master) can read diagno-stic information from the DP master.
CLEAR All DP slaves entered in the database and activated are assi-gned parameters and are configured. Following this, the va-lue 0h is sent to all slaves with process output in the CLEARmode; in other words, process output is deactivated. The in-put data of the slaves is known and can be read.
OPERATE In this mode, there is cyclic data exchange with the DP sla-ves. This is known as the productive phase. In this mode, theDP slaves are polled one after the other by the DP master.
Note
Starting from the current mode, the modes must be run through in the selectedorder (ascending or descending) OFFLINE - - STOP - - CLEAR - - OPERATE!
With the standard settings, the OPC server of SIMATIC NET controls the modesof the DP master automatically.
Industrial Communication
52SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Description of the Services
Access to process variables by a user application of a class 1 master, is not directbut via a process image on the communications module. The process imagecontains the input data read in from all slaves in the last cycle and the output datato be written in the next cycle.
The process image includes three data areas for each DP slave:
� Input data from the DP slave
� Output data to the DP slave
� Diagnostic data from the DP slave
An application on a PC can use the following services via a class 1 DP master:
Variable services for the process image of the DP master
The following information services are also available:
� Mode of the DP master and the DP slaves
� Event messages from the DP master
� Activity monitoring by the DP module
� The type of a DP slave
Advantages / Disadvantages
Using a class 1 master has the following advantages and disadvantages:
Advantages
� Fast access to cyclic data
� Jobs from the applications can be processed extremely quickly because thedata can be obtained directly from the process image and do not lead explicitlyto communication.
� There are simple (and therefore cost-effective) communications modules.
Disadvantages
� High bus load due to the cyclic exchange of input and output data.
� Synchronization of access to process variables using OPC with the DP cycle isnot possible.
Industrial Communication
53SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.5.6 DP Slaves - Principle of Communication and Services
Principle of Communication
A DP slave makes data communication available. It can set input data so that thiscan be fetched by the DP master in the next polling cycle and it can read and useoutput data sent by the DP master. The DP slave can also set diagnostic data thatis also fetched by the DP master in the next cycle.
Within DP communication, DP slaves are considered to be modular. Each slavecan be made up of several submodules each with their own input and outputareas.
A slave suitable for the DPV1 expansion, can contain additional data records foreach module. These data records contain slave-specific data that can be read andwritten by a DPV1 master. Up to 240 bytes of payload data are available per datarecord.
Configuring a DP Slave with STEP 7
2.5.7 Class 2 DP Master - Principle of Communication and Services
Principle of Communication
Along side devices belonging to the DP class 1 master, a DP system can alsoinclude devices belonging to DP class 2 master. Devices of this class are usedduring commissioning, configuration, and for diagnostics. They are normally usedin programming, configuration, or operator controlled devices.
Industrial Communication
54SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
It is, for example, possible to connect a class 2 master to PROFIBUS fordiagnostic purposes. This can then query the status of slaves and class 1 mastersat any time without interfering with network operation. A class 2 master can alsochange the slave address if the slave permits this.
The inputs and outputs and diagnostic data of a slave can only be read; it is notpossible to write the outputs.
The essential functions of a class 2 master are as follows:
� Reading the slave data
� Reading the class 1 master data
Since these services are processed in addition to the cyclic services, a class 2master increases the network load.
Description of the Services
In much the same way as a class 1 master, the class 2 master can also access thecyclic input and output data and map information to variables. The data can,however, only be read and not written.
Other variables allow access to diagnostic data of the class 1 master and theslaves. By writing a special variable, the class 2 master can also set the address ofa slave.
Advantages / Disadvantages
Using a PC as a class 2 master has the following advantages and disadvantages:
Advantages
� Operation within the network is affected to only a very limited extent.
� The configuration of a slave can be modified (set slave address).
Industrial Communication
55SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Disadvantages
� Inputs, outputs and diagnostic data of a slave can only be read.
� Synchronization of access to process variables using OPC with the DP cycle isnot possible.
2.5.8 DPC1 - Principle of Communication and Services
Principle of Communication
The DPV1 specification represents an expansion of DP communication both forclass 1 and class 2 masters. The functions specially for masters belonging to class1 are known as DPC1 services in SIMATIC NET.
With the DPC1 services, it is possible to poll data from the slaves acyclically inaddition to the cyclic polling by the DP master. Each DPV1 slave has an additionaldata area that can be read and written by the DPV1 master. This data areadepends on the specific slave and can contain, for example, parameter assignmentdata or alarm messages. The individual data records of the additional data areaare addressed by specifying the slot and index.
Industrial Communication
56SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Description of the Services
The DPC1 services include the following:
� Acyclic reading and writing of data records
� Alarm servicing
Since the DPV1 services are handled with lower priority than the cyclic dataservices, the data throughput of DPV1 communication is lower. The round-trip timeis also generally increased since the network is under additional load.
No communication connections to the slaves are necessary to use the DPC1functions since the polling cycle of the master is already initiated as an implicitconnection. As soon as a slave with DPC1 functionality has had parameters setand has been configured, it can be addressed by DPC1 functions.
It is only possible to access the data of a DPV1 slot in complete blocks. A read jobreturns the entire contents of a data record identified by the slot and index, a writejob overwrites the entire data record.
Note
When using the OPC server, it is possible to structure a data record. Parts of adata record can be separated, identified by a data type and used as a variable.Nevertheless, from a network point of view, the entire data record is always reador written.
Advantages / Disadvantages
Using the DPC1 services has the following advantages and disadvantages:
Advantages
� Asynchronous access to slaves is possible.
� Larger blocks of data can be transferred.
� Structured access to data fields is possible with OPC.
� Parallel use with variable services of the class 1 master is possible.
Disadvantages
� Additional load on the network.
� Lower data throughput compared with cyclic data transfer.
Industrial Communication
57SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.5.9 DPC2 - Principle of Communication and Services
Principle of Communication
The DPV1 specification represents an expansion of DP communication both forclass 1 and class 2 masters.
The functions specially for masters belonging to class 2 are known as DPC2services in SIMATIC NET. With the DPC2 services, it is possible to poll data fromthe slaves acyclically from a class 2 master in addition to the cyclic polling by theDP master. Each DPV1 slave has an additional data area that can be read andwritten by the DPV1 master. This data area depends on the specific slave and cancontain, for example, parameter assignment data or alarm messages. Theindividual data records of the additional data area are addressed by specifying theslot and index.
The essential difference between this and the normal master-slave communicationis that a connection must first be established and then maintained until it isinterrupted by external influences or terminated by the master. As long as thisconnection is established, the master can communicate with the slave.
The most important DPC2 functions are as follows:
� Establishment and termination of a communication relation
� Reading the slave data
Description of the Services
Using DPC2 provides the user with the following services:
Buffer services via DPC2
Since the DPV1 services are handled with lower priority than the cyclic dataservices, the data throughput of DPV1 communication is lower. The round-trip timeis also generally increased since the network is under additional load.
In the same way as a class 1 DP master (DPC1), a class 2 master can onlyaccess the data of a DPV1 slot as an entire block. A read job returns the entirecontents of a data record identified by the slot and index, a write job overwrites theentire data record.
Note
When using the OPC server, it is possible to structure a data record. Parts of adata record can be separated, identified by a data type and used as a variable.Nevertheless, from a network point of view, the entire data record is always reador written.
Industrial Communication
58SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Advantages / Disadvantages
Using the DPC2 services has the following advantages and disadvantages:
Advantages
� Asynchronous access to slaves is possible.
� Larger blocks of data can be transferred.
� Structured access to data fields is possible.
� Parallel use with a class 1 master is possible.
Disadvantages
� Additional load on the network.
� Lower data throughput.
2.6 PROFIDrive Bus Server Drives
Function of the Bus Server
The SIMATIC NET OPC PROFIDrive bus server maps the parameter items of ageneral OPC profile server on the SIMATIC NET DPC2 services; in other words,the communication between the PROFIDrive bus server and the drives is handledusing the DPC2 protocol.
Communication between a PROFIDrive bus server and profile server and betweena profile server and client is over OPC interfaces, whereby an OPC PROFIDriveclient accesses the OPC profile server only. The OPC Profile Server is notincluded on the SIMATIC NET CD.
Industrial Communication
59SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.7 FMS Protocol
Introduction
This section describes the principle of communication and the services of the FMSprotocol. The section also describes the structure and configuration.
2.7.1 Typical FMS System Configuration
Introduction
The Fieldbus Message Specification (FMS) specifies a communications protocolstipulated in the EN 50170 standard at layer 7 of the ISO/OSI reference model.
FMS is therefore ideally suited for communication between heterogeneousautomation systems of different manufacturers. Due to the limited processingspeed resulting from the complex functionality, it is only useful in the cell area innetworks with few nodes.
Example of a Configuration
Industrial Communication
60SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.7.2 Principle of FMS Communication
Communication Objects
The aim of the FMS communication model is to link distributed applicationprocesses to form an entire process. FMS uses an object-oriented representation:Real process objects, such as the temperature value of a thermal sensor aremapped on communication objects. The FMS specification describes the structureof the communication objects and the services that can be used with them.
Communication objects can be accessed in different ways:
� Object index: The most effective access makes use of an object index. Theindex is the address of an object in the form of a 16-bit counter.
� Symbolic access: The object is addressed using a unique symbolic name. Thisis a more convenient solution for the user since an object can be referenced, forexample, using a brief description of the data content.
A communication object is described by the following attributes:
� index
� Symbolic name
� Data type
� length
� Access rights/password
FMS devices contain an object dictionary (OD) that lists the objects provided bythe device. FMS allows an object dictionary to be read from a partner device toobtain information about the objects available. Depending on the configuration,object dictionaries can be very large. If an object dictionary is loaded each time aclient starts up, this can delay connection establishment considerably. To getround this problem, an FMS client can load the object dictionary of a partner atsome other time and store it locally, for example in a file. This functionality issupported by the SIMATIC NET OPC Server.
Note
The OPC items used with the PC during FMS communication on PROFIBUS areidentified by the prefix “FMS”.
Industrial Communication
61SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Communication Relations
With few exceptions (broadcast/multicast), information is always exchangedbetween two communication partners. One partner adopts the client role and theother partner adopts the server role.
There is therefore a communication relation between the client and server. Theterm “communication relation” used in the FMS protocol corresponds to aconnection. Each node can maintain several communication relations with thesame and with different partners at the same time.
A communication relation is defined by a number of parameters in thecommunication reference. The parameters of a communication relation include theaddress of the partner station, the service access point, the type of connection andservices supported on the connection, and the size of the receive and sendbuffers.
Connection Type
The connection type describes the type of node involved in communication (masteror slave) and the type of transmission at layer 2 (cyclic or acyclic). The typicalconfiguration in the cell area is acyclic master-master communication.
Virtual Field Devices
A virtual field device (VFD) is an abstract object used to describe the data andbehavior of a device from the point of view of a communication partner. A VFDincludes all communication objects (for example communication relations) and theirproperties and statuses. Several VFDs can be assigned to a physical device and aVFD can include communication relations to several physical devices.
2.7.3 FMS Configuration
Introduction
For communication using the FMS protocol on PROFIBUS, the communicationobjects and communication connections must be specified in advance during theconfiguration phase.
The data specified in the communication are used by the communicationcomponents during run time and no longer need to be specified by a user program.If the system is physically reconfigured, the changes only need to be made in theconfiguration without needing to adapt the programs.
Industrial Communication
62SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Objects and Connections
During configuration of FMS communication, the following elements are specified:
Virtual Field Devices (VFDs)
� Number and name of the virtual field device
� Vendor information
� Version
FMS Connections
� Name of the connection
� Addresses of the partner stations
� Service access points of the FDL layer (LSAPs)
� Communication type/connection type
� Services on this connection
� Access protection
Communication Objects
An object dictionary on an FMS server defines the objects that can be accessed byan OPC client. A communication object has the following properties:
� index
� Symbolic name (optional)
� Data type
� length
� Access rights
If the FMS server is an S7 device, the communication objects are specified in thesymbol table by defining additional properties.
If a PC with an OPC server is used as the FMS server, the communication objectsmust be defined within the definition of a VFD.
Industrial Communication
63SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Example
2.7.4 FMS Services
Productive and Management Services
Due to the wide range of demands made of an FMS system, the FMS specificationdefines numerous services of which only a small part belong to the mandatoryservices.
A distinction is made between productive and management services:
Productive Services
� READ (read communication object)
� WRITE (write communication object)
Management Services
� INITIATE (start connection establishment)
� ABORT (terminate connection)
� STATUS (get the status of the partner)
� IDENTIFY (identify the communication partner)
� GET-OD (read out the object dictionary of the partner)
FMS Services for SIMATIC NET
� Variable services with the PC as FMS client
� Variable services with the PC as FMS server
� Identification and query of the attributes of a partner device
� Querying the status of a partner device
� Obtaining an overview of the nodes communicating on PROFIBUS
Industrial Communication
64SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.7.5 FMS Variable Services with a PC as FMS Client
Description of the Services
A client (in this case a PC) can access the objects made available by an FMSserver as a variable. The client has two ways of addressing an object:
� The index of the communication object
� The symbolic name of the communication object
The client can obtain a list of the objects provided by a server and the properties ofa variable such as access rights and data type from the object dictionary of theserver.
When communication starts, the client (PC) can load this object dictionary toobtain all the information about the objects available for communication. Thevariables do not need to be configured at the client end. On the server, however,the object dictionary must be configured.
Once the object dictionary is available to the client, it can write or read variablesdepending on the access rights permitted by the server.
To enter into communication with the server, the connection between the twonodes must first be established. This is normally instigated by the client. Theconnection is established according to the characteristics specified in the list ofcommunication relations and confirmed by the server. From this point on, the otherFMS services can also be used. Either partner can terminate the connection at anytime.
Advantages / Disadvantages
Communication using FMS objects accessed by the PC has the followingadvantages and disadvantages:
Advantages
� As an open protocol, FMS can be used to access the widest range of FMSdevices.
� The server provides only the data configured by the user, unauthorized accessis not possible.
� A data type is defined for an object or variable on the server.
� The client can read the list of variables from the server so that variables do notneed to be configured on the client.
� Variables can be given a symbolic name and the client then reads the symbolicname from the object dictionary of the server.
Industrial Communication
65SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Disadvantages
� The data throughput with this protocol is lower than with DP due to theuser-friendly characteristics listed above.
� To monitor a variable, this must be polled by the OPC server over thecommunication system. As a result, this leads to permanent network load.
2.7.6 FMS Variable Services with a PC as FMS Server
Description of the Services
On an FMS connection, the PC can also be used as the FMS server and providevariables. Other partner devices, for example programmable controllers, can readand write the variables available on the PC. An application running on the PC alsouses these variables in basically the same way as variables on a partner device:Write access sets the locally maintained variable. When the partner reads thevariable, the previously set value is read.
Variables are accessed
� using the index of a communication object or
� using the symbolic name of the communication object.
Which data is made available to which client is decided by the user duringconfiguration. An object dictionary must be created containing information aboutthe variables (type, initial value, access rights). This information is adopted in theobject dictionary of the FMS server (here, the PC).
Advantages / Disadvantages
The provision of variables by the PC acting as FMS server has the followingadvantages and disadvantages:
Advantages
� As an open protocol, FMS can be used to access the widest range of FMSdevices.
� No communication load when the partner is not reading or writing data.
� If variables on the server are written by a partner device, the changed valuesare reported on the OPC interface (if the variable is being monitored).
Industrial Communication
66SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Disadvantages
� A program is required on the controller for reading or writing variables andplaces demands on the CPU of the controller.
� An object dictionary must be configured on the PC.
� The data throughput with this protocol is lower than with DP.
2.8 S7 Protocol for PROFIBUS
Introduction
This section describes the principle of communication and the services of the S7protocol. The section also describes the structure and configuration.
Communication Services
The S7 protocol supports the following communication services:
Service Description
Information services Information on the connection status.Display of the device/user status ofthe communication partner.
Variable services Functions for reading and writing oneor more variables.
Buffer send/receive services Program-controlled transfer of largeblocks of data.
Block management services These services allow the downloa-ding, uploading, deleting, and linkingof blocks in the program sequence ofa PLC during operation. This allowsdynamic modification of program se-quences and parameters.
Event services These services are used to receiveand process messages from SIMATICS7 programmable controllers, for ex-ample ALARMs.
Security services Setting passwords for access to SI-MATIC S7 data objects.
Industrial Communication
67SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.8.1 Typical S7 System Configuration
Introduction
The S7 protocol is used for communication with SIMATIC S7/M7 programmablecontrollers (PLCs). Its main features are as follows:
� Optimization for SIMATIC communication
� Adaptation of protocol elements to SIMATIC requirements
� Greater speed compared with other automation protocols for datacommunication.
� Availability for bus systems of the management and cell level such as IndustrialEthernet and the field level with PROFIBUS.
Example of a Configuration
2.8.2 Principle of S7 Communication
PC as Client or Server
The S7 protocol provides simple and powerful communication services on thebasis of a client-server model. Data is transmitted between an automationapplication on a SIMATIC PC station (client) and another automation application(server). Data is provided by the programmable controller and these stations aretherefore servers. The data is requested by an application running on a PC and thePC is therefore the client. During the connection establishment and in buffersend/receive services, the PC can also be the server.
Industrial Communication
68SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
S7 Protocol with PROFIBUS
The implementation of the S7 protocol on PROFIBUS is based on the FDLservices (layer 2) and expands the protocol with the addition of Siemens-specificelements. Communication therefore provides the advantages of aconnection-oriented protocol, such as checking for the existence of a station withconnection monitoring.
S7 Connections
A connection for the S7 protocol is specified by the PROFIBUS addresses of thepartners and address details (for example service access points). These propertiesare specified for the S7 protocol in the configuration.
The S7 connection is identified on the PC by specifying the connection name, forexample, “S7_connection_1”.
S7 connections that are defined at both the client and server ends are known as“two-ended” connections. Connections defined only at the client end, for examplefrom a PC to an S7-300 station are known as “one-ended”.
On the programmable controller, a two-ended connection is identified by a local ID,in the example, the value “1”. By specifying the local ID, S7 programs can use acommunication connection with the aid of function blocks such as BRCV/BSEND.
Note
The OPC items used with the PC during S7 communication on PROFIBUS areidentified by the prefix “S7”.
Connection Establishment
During the connection establishment, the communication partners automaticallynegotiate the most important characteristics of the communication path. Thesettings used are those that can be achieved by both communication partners.
The following details are agreed upon:
� Size of the data packets at the transport level (PDU size)
� The number of send credits (number of send and receive resources used at thesame time)
Industrial Communication
69SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.8.3 S7 Configuration
Introduction
For communication using the S7 protocol on PROFIBUS, the communicationconnections must be specified in advance during the configuration phase.
The data specified in the communication are used by the communicationcomponents during run time and no longer need to be specified by a user program.If the system is physically reconfigured, the changes only need to be made in theconfiguration without needing to adapt the programs.
Address and Service Access Point
The following is defined in the configuration for an S7 communication connection:
� Name of the connection
� Partner address
� Service access point of the transport layer (TSAP) for the local station
� Service access point of the transport layer (TSAP) for the remote station
� The way the connection is established
Example
Structure of the Service Access Point
The service access point for S7 communication (TSAP) is made up of 2 bytes:
Industrial Communication
70SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Byte 1
Number of the communication resource reserved for this connection. The numberof the connection resource for the local and remote station is assigned by theconfiguration system (STEP 7). The configuration system makes sure that thereare not more resources assigned on the programmable controller than actuallyexist.
Some numbers are reserved for specific connection types and are not included inthe resource monitoring:
� 01: PG connection (reserved for the use of a programming device)
� 02: OS connection for operator control and monitoring devices that require nopermanent connection.
� 03: Other connections
Byte 2
Specifies the position of the CPU in the programmable controller:
� Bits 7 through 5: Rack
� Bits 4 through 0: Slot
(Special case: If the device attached to the network is addressed directly, the valueof byte 2 is zero)
Note
When using the OPC Server, further connection properties can be defined in theconfiguration:
- Time of connection establishment and termination by the OPC Server. - Use and configuration of alarm services on the connection. - Other detailed parameters.
Industrial Communication
71SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.8.4 S7 Variable Services
Description of the Services
The S7 protocol allows simple access to S7 variables of a programmablecontroller.
S7 variables are normally parts of an S7 object starting at a specific memoryaddress of the object that are assigned a data type. For example, the variable withthe notation “DB 5,W10” accesses bytes 10 and 11 of data block 5 and representsthe content as a word. It is also possible to form array variables (several elementsof the same type in one variable).
The following are available as S7 objects on most S7 devices:
� Data blocks
� Instance data blocks
� Inputs/outputs
� Peripheral inputs/outputs
� Memory bits
� Timers
� Counters
Advantages / Disadvantages
Using the variable services has the following advantages and disadvantages:
Advantages
� Very simple access to the partner device without programming the partner.
� Reading and writing several variables and long arrays of variables is optimized.
� When using the OPC server, access rights can be assigned to protectsafety-related variables.
� With OPC, it is possible to use symbols from STEP 7.
� When using OPC, there is no limitation of the size of variables (particularlyarrays) to the size of a PDU.
� Data consistency over the entire length of the PDU when using the newerCPUs.
Industrial Communication
72SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Disadvantages
� To monitor variable changes, the partner device must be accessed cyclically.
� Access at short intervals means a high network load.
� No guaranteed consistency of the data (data originate from several programcycles of the PLC) if the size of the variable exceeds the size of the PDU.
2.8.5 S7 Buffer Send/Receive Services
Description of the Services
Buffer-oriented services allow program-controlled transfer of larger blocks of data.Up to 65534 bytes of payload data can be transferred regardless of the size of thePDU.
For data exchange between a SIMATIC S7 PLC and a SIMATIC PC, theconnection must be configured at both ends. In contrast to the variable services,the connection configuration must be downloaded to the PLC.
To receive blocks of data, receive resources must be made available. The programof a programmable controller includes the “BRCV” function block for this purpose.
Note
When the OPC Server is used, the resources are made available by creating a“RECEIVE” variable.
When using the OPC server, it is possible to map the block of data or parts of it onindividual OPC variables and to assign these parts to data types. This structuringmakes the use of the buffer-oriented services much simpler for the OPC user.
Industrial Communication
73SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Advantages / Disadvantages
Using the buffer-oriented services has the following advantages anddisadvantages:
Advantages
� Large (max. 64 Kbytes) blocks of data can also be transferred.
� A SIMATIC PC can be both client and server, in other words, with buffersend/receive services, data can also be transferred from PC to PC using the S7protocol.
� It is possible to structure the blocks of data in OPC items.
� All OPC variables defined within a receive buffer receive a change messagewhen a block of data arrives.
� Consistent data within a block of data (all data originate from one program cycleof the programmable controller)
� No network load from polling if no data are sent.
Disadvantages
� Send and receive blocks must be programmed on the PLC.
� The receiver cannot request data but must wait until data is sent.
� Buffer send/receive services are not available for all S7 programmablecontrollers.
2.8.6 S7 Block Management Services
Available Block Management Services
A block represents a loadable area on a programmable controller.
With the S7 protocol and using the OPC Server, the following block managementservices are possible and are started by the SIMATIC PG or PC:
� Downloading data from the PG/PC to the SIMATIC CPU.
� Uploading data from the SIMATIC CPU to the PG/PC.
� Linking of blocks in the program sequence of the SIMATIC CPU.
� Deleting blocks.
� Compressing the memory of the programmable controller.
Industrial Communication
74SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Block Types
The block management services can be used with the following block types:
� Organization blocks (OB)
� Function blocks (FB)
� Functions (FC)
� Data blocks (DB)
Block Management
A block can be uploaded from a SIMATIC CPU to a PC by an S7-OPC applicationand vice versa. On the PC, the blocks are saved in files.
The block name must be unique on the S7-CPU. The maximum amount of data islimited depending on the specific CPU. The blocks are therefore divided intoseparate segments that are transferred sequentially.
Linking Blocks.
A block transferred to a programmable controller is stored in a buffer. This meansthat the block is not yet available for an S7 program. Although the block is visible inthe list of data blocks that can be viewed using the online functions of STEP 7, theblock cannot be opened. This is first possible after the block has linked into the listof active blocks.
Industrial Communication
75SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Application of the Block Management Services Based on an Example
Blocks programmed or created with STEP 7 are transferred to a programmablecontroller from a programming device during commissioning. These blocks, in theexample DB_red_car.dbf, DB_green_car.dbf,... are stored as DB1, DB2, ... in theprogram memory. An S7-OPC application can upload these blocks duringoperation and save them locally as files DB_red_car.dbf, DB_green_car.dbf,.... APC controller can therefore download and delete blocks and influence theexecution of the program, for example by replacing DB1 (DB_red_car.dbf) withanother data block (DB_blue_car.dbf) that then becomes DB1.
Note
The block management services are mapped on OPC special variables. Writingthese variables triggers execution of a service. The values written are used as theparameters for the service.
Industrial Communication
76SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.8.7 S7 Event Services: Alarms
Description of the Services
Events can be signaled by alarms. Alarms must be programmed because they aretriggered by S7 blocks and not by a change in a process state.
Up to 10 associated values can be sent with an alarm. Alarms are exceptionalevents triggered by the partner device. Alarms are buffered and cannot be lost.
For the programmed messages, the user must include an ALARM, ALARM_8,ALARM_8P or NOTIFY S7 block in the S7 program. The block checks up to 8signals for changes and then sends a frame with the time and additional values.
Note
S7 alarms can be processed only by the OPC Server for Alarms & Events.Mapping of alarms on variables (OPC Data Access) is not planned.
Programming Alarms
Before you can use alarms as described here, you must first program them. Usingthe configured message number, you can access received alarms with OPCEvents.
Advantages / Disadvantages
Advantages
� Alarms are buffered and cannot be lost.
� Up to 10 associated values can be sent with an alarm. The size of theassociated values is restricted only by the PDU size.
Disadvantages
� To generate alarms, a program must be created on the controller.
� Only limited data types supported for associated values.
� Can only be used with OPC Alarms & Events.
Industrial Communication
77SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.8.8 How to Program Alarms
Introduction
The S7-OPC Server can receive the alarms sent by an S7 program. Alarms aretriggered by an S7 block. The following section describes how to program suchalarms. For more detailed information, refer to the STEP 7 user manual.
Industrial Communication
78SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Procedure
Step Steps
1 Select the suitable message block.
2 Select the function block to which the message will be assignedand open it.
3 Complete the variable declaration table.
4 Program the message block call in the statement section of thefunction block.
5 Create the message type with texts, attributes, and display devi-ces in the FB.
6 Assign instance data blocks to the FB and modify them to meetyour requirements.
Industrial Communication
79SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.8.9 S7 Security Services
Description of the Services
Write and read access to the CPU of a PLC can be made dependent on theknowledge of a password. The priority of the password is higher than that of thekeyswitch of the CPU.
Using the security services, the password for a connection can be sent tolegitimize access and cancel the level of protection. For an S7 programmablecontroller, three levels of protection can be activated for the block managementservices using the configuration tool STEP 7:
� Protection due to the setting of the keyswitch
� Write protection
� Write and read protection
By transferring the correct password, all the protection levels listed above arecanceled for the connection on which the password was sent.
Note
On connections configured at both ends, all services can be executed even in theRUN key position.
2.8.10 S7 Information Services
Description of the Services
The S7 protocol provides services with which
� attributes of a virtual field device (VFD) can be queried.
� the status of a virtual field device can be read.
Note
The OPC server provides not only information variables for these services, butalso variables for specifying the connection status and for registering for eventservices.
Industrial Communication
80SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.9 Industrial Communication with Industrial Ethernet
Introduction
This section provides you with general information on the Industrial Ethernetcommunications system.
2.9.1 Description of Industrial Ethernet
Introduction
Industrial Ethernet is a powerful communication network complying with theinternational standard IEEE 802.3 (Ethernet) and was designed for therequirements in an industrial environment.
Its main features are as follows:
� Networking of different areas of application such as office and plant floor.
� Robust design and electromagnetic immunity.
� High transmission performance even with large numbers of nodes thanks to thegeneral availability of network components capable of 100 Mbps complying withFast Ethernet.
� Various transmission media (for example, Industrial Twisted Pair, fiber-opticcables).
� Scalable performance with switching technology.
� High availability with redundant network topologies.
Industrial Communication
81SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.9.2 Protocols and Devices for SIMATIC NET Industrial Ethernet
Data Communication:
The area of application of Industrial Ethernet is limited to data communication. Anumber of devices and protocols are available:
Protocol Description Typical SiemensPartner Device
S7 communication Integrated and optimi-zed communicationsfunctionality of the SI-MATIC S7/M7 systemsfor a wide range of ap-plications (TCP/IP withRFC 1006 or ISO).
Any PC EthernetadapterCP 1512, CP 1612CP 1613CP 343-1CP 443-1CP 443-1 IT
S5-compatible Com-munication (SEND/RECEIVE)
Communication ser-vices based on thetransport protocol (TCP/IP with RFC 1006 orISO) for data exchangewith S5 and S7 devices.
Any PC EthernetadapterCP 1512, CP 1612CP 1613CP 343-1 (TCP)CP 443-1CP 443-1 IT
TCP/IP native Simple communicationservices based on TCP/IP for data exchangewith any device thatsupports the TCP/IPprotocol.
Any PC EthernetadapterCP 1512, CP 1612CP 1613CP 443-1
Industrial Communication
82SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.9.3 Bus Access Methods of Industrial Ethernet
Collision Detection with CSMA/CD
Ethernet uses the CSMA/CD bus access mechanism. This acronym stands forCarrier Sense Multiple Access with Collision Detection. With this mechanism, astation wanting to send listens to the common bus cable (carrier sense) andtransmits if the cable is free. If the cable is currently being used by another station,the node withdraws its send request and attempts to send again later (multipleaccess).
If an attempt to access the bus fails, the sender listens constantly to the line andsends immediately after the current communication is completed. It is possible thattwo senders start transmission at the same time. As a result, the two framescollide and destroy each other. To detect such a collision, the nodes receive thesignals while they are sending. If the data sent differs from the data received therehas been a collision, the station backs off and waits a random time beforebeginning to transmit again. Using switching technology and full duplex throughouteliminates collisions.
This medium access control method functions correctly only when the timerequired to send a data packet is greater than twice the signal propagation time.For a specific transmission rate and packet size, the span of a network is thereforerestricted.
To implement networks with a larger span, switches with the Full Duplex functioncan be used.
Using this bus access method, it is clear that the effective data rate depends onthe bus load. If the bus load is too high, collisions will occur often. As a result, theproportion of data correctly transferred is reduced.
Modes
Two modes are possible:
Half Duplex: A node can either send or receive but not both at the same time.
Full Duplex: A node can send and receive at the same time. The basic requirementfor Full Duplex is a transmission medium with separate send and receive channels(for example fiber-optic cable or ITP).
Industrial Communication
83SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.9.4 Fast Ethernet
Properties of Fast Ethernet
Fast Ethernet is the further development of the Ethernet technology. The FastEthernet standard IEEE 802.3u is based essentially on the classical Ethernetstandard with a transmission rate increased by a factor of 10 to 100 Mbps.
Ethernet and Fast Ethernet have the following common features:
� The data format
� CSMA/CD medium access control
They differ from each other in the following respects:
� The network span
� The rules for network design
� The automatic detection of the transmission rate
� Support of the duplex mode.
Industrial Communication
84SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.9.5 Industrial Ethernet in the ISO/OSI Reference Model
Introduction
Based on the various layers of the reference model, Industrial Ethernet providesseveral user interfaces:
Symbol Protocol Description
A, E S7 communication Uniform user interfacefor TCP/IP (A) and ISO(E) using S7 functions
B, D S5-compatible Commu-nication (SEND/RECEIVE)
Communication ser-vices based on the ISOtransport interface fordata exchange with S5and S7 devices. WithTCP/IP, an adapter(RFC 1006) is required.This makes the SEND/RECEIVE user interfa-ce for TCP/IP (B) andISO (D) uniform.
C TCP/IP native Simple communicationservices based on TCP/IP (C) for data ex-change with any devicethat supports the TCP/IP protocol.
Industrial Communication
85SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
All the user interfaces listed are mapped on the uniform OPC interface by the OPCserver on the PC.
Layer 1
Electrical Characteristics
Maximum number of nodes Unlimited, maximum of 1024 per net-work segment.
Transmission rate 10 Mbps or 100 Mbps
Network size Electrical network: 1.5 km Optical network at 10 Mbps: 4.5 km Switched Network: In principle unlimi-ted
Topology Bus Tree Redundant ring Star
Transmission medium (Industrial) Twisted Pair Triaxial cable FO cable
Mechanical Characteristics
Attachment 15-pin D-sub female connector for at-tachment to AUI or Industrial TwistedPair RJ-45 attachment for 10BaseT,100BaseTX (twisted pair)
Industrial Communication
86SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.9.6 Transport Protocols for Industrial Ethernet
ISO Transport Protocol
The international standard (ISO 8073 class 4) defines services for transmittingdata over connections. The ISO transport service corresponds to layer 4 of theISO reference model.
Due to the possibility of “data blocking” (user data can be segmented into severalframes at the ISO transport level), the ISO transport service can transfer largeamounts of data. The ISO transport service allows communication with anycommunication partner (for example SIMATIC S5 PLC or PC) that supportssending and receiving data in compliance with ISO transport.
Reliability, for example if cable problems occur
With the automatic repetition in ISO transport and additional block checkmechanisms (for example CRC check at layer 2), a high degree of reliability isachieved. Reception of the data is confirmed by the ISO transport service of thecommunication partner with a confirmation.
ISO on TCP (RFC1006)
The ISO-on-TCP service corresponds to the standard TCP/IP (TransmissionControl Protocol/Internet Protocol) with the RFC 1006 expansion according to layer4 of the ISO reference model. RFC 1006 is required since TCP provides datastream communication without blocking of the data in messages. This problem isavoided in the ISO protocol of layer 4 with an EOM code (End Of Message). EOMallows messages to be sent as blocks of data. TCP/IP does not recognize this.Protocol expansions are necessary to be able to send messages. RFC 1006describes how the services of ISO layer 4 can be mapped on TCP. RFC 1006 is anofficial standard and is used by many manufacturers.
The ISO-on-TCP service allows communication with any communication partner(for example PC or systems from other vendors) that supports the sending andreceiving of data complying with ISO-on-TCP.
Reliability, for example if cable problems occur
With automatic repetition and additional block check mechanisms (CRC check atlayer 2), a high degree of reliability is achieved. Reception of the data is confirmedby the communication partner with a confirmation.
Industrial Communication
87SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
TCP/IP native (without RFC 1006)
The TCP/IP standard (Transmission Control Protocol/Internet Protocol) without theRFC 1006 expansion, allows access from any communication partner that usesTCP/IP to a SIMATIC S7 controller. Since the transport layer of TCP/IP providesan unstructured data stream, the task of blocking is left up to the user. Bothpartners on a communication connection must be informed of the size of thepacket to be transferred so that the correct packet can be picked out of the datastream.
Reliability, for example if cable problems occur
Using block check mechanisms (CRC check at layer 2), a high degree of reliabilityis achieved. Reception of the data is confirmed by the communication partner witha confirmation. Reliable communication is possible only if the buffer sizes arenegotiated between the communication partners.
Note
The OPC server provides communication functions based on RFC 1006, ISO andTCP uniformly as “SEND/RECEIVE” functions.
2.10 S5-compatible Communication (SEND/RECEIVE)
Introduction
S5-compatible communication on Industrial Ethernet allows data exchange onEthernet between SIMATIC S5 controllers, SIMATIC S7 controllers, and PCs andworkstations.
This section describes the principle of communication and the services of theSEND/RECEIVE protocol. The structure and configuration are also discussed.
2.10.1 Typical SEND/RECEIVE System Configuration
Introduction
For data exchange using S5-compatible communication, communications modulesare available for controllers of the SIMATIC S5, SIMATIC 505 and SIMATIC S7families as well as for PCs and workstations.
Industrial Communication
88SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Example of a Configuration
2.10.2 Principle of SEND/RECEIVE Communication
Transport Protocols
In contrast to S5-compatible communication on PROFIBUS, S5-compatiblecommunication on Industrial Ethernet is based on the transport layer of theISO/OSI reference model. This provides the user with the functionality of thetransport layer in the form of connections, flow control, and data segmentation.
S5-compatible communication can be used on Industrial Ethernet with the followingtransport protocols:
� ISO
� TCP/IP with RFC 1006
� TCP/IP without RFC 1006
S5-compatible communication is connection-oriented. Data can only be transferredafter a transport connection is established to the partner device. Severalconnections to a partner device can be used at the same time.
Connection establishment is triggered by one of the communication partners. Ifconnection establishment is active from the perspective of partner A, this partnersends a request to establish the connection to the other device B. If connectionestablishment is passive, partner A waits for the arrival of a connectionestablishment request from device B. Which end is responsible for establishing theconnection is specified in the connection configuration.
Industrial Communication
89SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Block Types/Job Types
S5-compatible communication via Industrial Ethernet makes use of handling orfunction blocks on the programmable controller. The following block types or jobtypes are available:
Name of the Block Type / Job Ty-pe
Description
SEND (without WRITE function) Transfer of a data buffer to the part-ner
RECEIVE Reception of a data buffer from thepartner
SEND (with WRITE function) Writing to an object/variable on thepartner
FETCH Reading an object/variable on thepartner
Note
During communication with S5 devices, only one job type can be used on aconnection. Simultaneous use of a connection for SEND and RECEIVE or FETCHcauses the SIMATIC S5 controller to terminate the connection.
Apart from the services for transferring data buffers (SEND/RECEIVE),S5-compatible communication also provides the “Fetch” and “Write” services overIndustrial Ethernet with which direct access to objects on the partner is possible.
With SEND and RECEIVE, the data exchange is between the SEND block and theRECEIVE block. The SEND block always initiates communication. Forbi-directional communication, both a SEND and a RECEIVE block must be calledat both ends.
If FETCH is selected as the job type (corresponds to the READ function in S5),source parameters can be provided with a send job that are used by the S5communications processor to read data directly from the CPU and send it back.With this type of job, direct access to objects such as inputs, outputs, data blocks,memory bits (flags) and counters is possible.
Industrial Communication
90SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.10.3 SEND/RECEIVE Configuration
Connection Parameters
Before S5-compatible communication can be used on Industrial Ethernet, thecommunication connections must first be configured. The following parameters areset for each connection:
� Connection name
� Connection type (job type)
� Addresses of the partner stations
� Identifier of the service access points at the transport layer (TSAPs)
� Control of connection establishment (active/passive)
2.10.4 Buffer SEND/RECEIVE Services
Description of the Services
S5-compatible communication provides services for transferring data buffers. Thetransfer of a packet from the sender to the receiver must be triggered explicitly bythe sender. On a SIMATIC S7 PLC, for example, this is achieved by calling the“AG_SEND” block.
The maximum size of the data buffer is 4 Kbytes.
The receiver cannot initiate data transfer from the sender. The recipient mustnevertheless be prepared to receive packets by making receive resourcesavailable.
Note
The sending of a packet by a PC is triggered by writing a “SEND” variable. Toreceive blocks of data, a “RECEIVE” variable must be set up on the relevantconnection.
When using the OPC server, it is possible to structure a block of data. Parts of theblock of data can be separated, identified by a data type, and used as a variable.Nevertheless, from a network point of view, the entire block of data is always reador written.
Industrial Communication
91SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Advantages / Disadvantages
Communication with the buffer services of the SEND/RECEIVE protocol have thefollowing advantages and disadvantages:
Advantages
� With the OPC server, larger blocks of data up to 64 Kbytes can be transferred.
� No network load since there is no data transmission unless this is triggered bythe user program (no polling)
� Using the OPC server allows structured access to blocks of data.
� Communication with S5 and S7 devices as well as with PCs is possible.
Disadvantages
� The receiver cannot initiate data transfer. It must wait until the data istransferred by the sender.
� The data must be located in a buffer or copied to a buffer by a user program onthe partner device.
2.10.5 SEND/RECEIVE Variable Services
Description of the Services
Using S5-compatible communication on Industrial Ethernet, allows simple accessto symbolic variables of an S5 or S7 programmable controller. In this case, the“FETCH” and “WRITE with SEND function” services are used.
When the “FETCH” service is executed, a job is transferred to the partner devicethat contains the information on the requested variables as a source parameters.The recipient of the job evaluates the source parameter and returns the currentcontent of the requested variable with the confirmation of the job.
With a job for the “WRITE with SEND function” service, not only the sourceparameter but also the value to be written to the variable on the target device istransferred. The recipient evaluates the source parameter and sets the specifiedvariable. A job confirmation is then returned.
Industrial Communication
92SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Variables are normally parts of an S7 or S6 object starting at a specific memoryaddress of the object that are assigned a specific data type. For example, thevariable with the notation “DB 5,B10” accesses byte 10 of data block 5 andrepresents the content as a word. It is also possible to form array variables(several elements of the same type in one variable).
The following are available as objects on most S5 and S7 devices:
� Data blocks
� Inputs/outputs
� Peripheral inputs/outputs
� Memory bits
� Timers
� Counters
� System area
� Extended I/O
Advantages / Disadvantages
Communication with the variable services of the SEND/RECEIVE protocol havethe following advantages and disadvantages:
Advantages
� Flexible access
� Automatic optimization by the OPC server is possible
Disadvantages
� Lower data throughput compared with the buffer services with SEND/RECEIVE.
� To monitor variable changes, the partner device must be accessed cyclically.
Industrial Communication
93SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.11 S7 Protocol for Industrial Ethernet
Introduction
The S7 protocol is used for communication with SIMATIC S7/M7 programmablecontrollers (PLCs).
This section describes the principle of communication and the services of the S7protocol. The section also describes the structure and configuration.
2.11.1 Typical S7 System Configuration
Introduction
The S7 protocol is used for communication with SIMATIC S7/M7 programmablecontrollers (PLCs). Its main features are as follows:
� Optimization for SIMATIC communication
� Adaptation of protocol elements to SIMATIC requirements
� Greater speed compared with other automation protocols for datacommunication.
� Availability for bus systems of the management and cell level such as IndustrialEthernet and the field level with PROFIBUS.
Example
Industrial Communication
94SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.11.2 Principle of S7 Communication
Characteristics of the S7 Protocol
The S7 protocol is used for communication with SIMATIC S7/M7 programmablecontrollers (PLCs). Its major features are as follows:
� Optimization for SIMATIC communication
� Adaptation of protocol elements to SIMATIC requirements
� Greater speed compared with other automation protocols for datacommunication.
� Availability for bus systems of the management and cell level such as IndustrialEthernet and the field level with MPI/PROFIBUS.
The S7 protocol provides simple and powerful communication services on thebasis of a client-server model. Data is transmitted between an automationapplication on a SIMATIC PC station (client) and on SIMATIC programmablecontrollers (server). Data is provided by the programmable controller and thesestations are therefore servers. The data is requested by an application running ona PC and the PC is therefore the client. During the connection establishment andin buffer send/receive services, the PC can also be the server.
S7 Protocol with Industrial Ethernet
The implementation of the S7 protocol on Industrial Ethernet is based on anISO-compliant interface of layer 4 (transport layer) of the ISO/OSI reference modeland adds Siemens-specific protocol elements to layers 5 through 7. When usingTCP/IP as the transport protocol, an adapter is therefore necessary (RFC 1006).
Communication provides the advantages of a connection-oriented protocol, suchas checking for the existence of a station with connection monitoring.
Industrial Communication
95SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
S7 Connections
A connection for the S7 protocol is specified by the Ethernet MAC address or theTCP/IP addresses of the partners and address details (for example service accesspoints). These properties are specified for the S7 protocol in the configuration.
In the same way as the FMS protocol, the S7 protocol defines “Virtual FieldDevices” (VFDs). Only PC stations have this view of VFDs. Within a VFD,connections are grouped together that can be used by only one application. In theS7 protocol, a VFD is effectively an application. To be able to operate severalapplications with S7 communication on one PC station, several VFDs arenecessary.
The S7 connection is identified on the PC by specifying the connection name, forexample, “S7_connection_1”.
Note
Remember that the OPC server is an S7 application. If several OPC clientsaccess the OPC server, only one VFD is required!
S7 connections that are defined at both the client and server ends are known as“two-ended” connections. Connections defined only at the client end, for examplefrom a PC to an S7-300 station are known as “one-ended”.
On the programmable controller, an S7 connection is identified by a local ID, in theexample, the value “1”. By specifying the local ID, S7 programs can use acommunication connection with the aid of function blocks such as BRCV/BSEND.
During the connection establishment, the communication partners automaticallynegotiate the most important characteristics of the communication path. Thesettings used are those that can be achieved by both communication partners.
The following details are agreed upon:
� Size of the data packets at the transport level (PDU size)
� The number of send and receive credits (number of send and receive resourcesused at the same time)
Industrial Communication
96SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.12 Fault-Tolerant S7 Connections
Introduction
The availability of communication can be increased by medium redundancy,doubling up components (for example CPU, CP or network) or by doubling up allnetwork components.
This section describes the types of fault-tolerant connection and what to rememberwhen configuring such connections.
2.12.1 Properties of Fault-Tolerant S7 Connections
How It Works
Standard S7 Connections
A standard S7 connection is established over a non-redundant connection path(CP-network-CP).
Fault-Tolerant Connections
A fault-tolerant connection, on the other hand, consists of at least two redundantconnection paths.
Monitoring and synchronization mechanisms ensure that if the active redundantconnection path fails, the passive (redundant) connection path takes over thecommunication automatically. The connection itself remains established.
Wire Break Detection
The time within which a wire break is detected is less than one second with activedata traffic on this connection path.
After a wire break is recognized, the sections of the protocol specifically designedfor fault-tolerant communication are executed. Depending on the number ofproductive connections established and used on the PC, this sequence can takelonger than one second.
Industrial Communication
97SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Scalable Redundancy
The redundancy of the fault-tolerant connection can be increased by increasing thenumber of CPs and the number of networks used.
The following redundant S7-REDCONNECT connections can be configured:
� Fault-tolerant connections on 2 paths
� Fault-tolerant connections on 4 paths (“Enable max. CP redundancy (with 4connection paths)”)
Industrial Communication
98SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.12.2 Fault-Tolerant S7 Connections on two Paths
Properties
A fault-tolerant S7 connection has two communication paths. The failure of onecomponent leads to an automatic failover to the other redundant communicationpath.
Example
Two-path communication can, for example, be structured with the followingcomponents:
� SIMATIC H station, two racks each with a CP
� Two networks
� PC station with two CPs
Figure 2-1 Example of Two-Path Redundancy between a SIMATIC S7 Station and PC Station
Industrial Communication
99SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.12.3 Fault-Tolerant S7 Connections on Four Paths
Properties
A fault-tolerant S7 connection has four communication paths. Now, for example,rack 0 can fail and network 2 can be down. Since four paths are available, rack 1and network 1 continue to operate automatically, refer to the example below.
Example
Fault-tolerant communication on four paths with increased redundancy can bestructured, for example, with the following components:
� SIMATIC H station, two racks each with two CPs
� Two networks
� PC station with two CPs
Figure 2-2 Example of Four-Path Redundancy between a SIMATIC S7 Station and PC Station
Industrial Communication
100SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.12.4 Points to Note when Configuring Fault-Tolerant Connections
Requirements
Before your PC can use a connection to a fault-tolerant SIMATIC S7 system, itrequires specific information, for example, the addresses of the bus nodesinvolved, the network adapters used etc.
This information is generated automatically if the following three requirements aremet:
� You configured your S7 project with STEP 7 (version 5 or higher).
� You included your PC in the project as a “SIMATIC PC Station”.
� You connected the communication partners over the same subnets.
Configuring a Four-Path Connection
If you configure a network with STEP 7 and require the increased redundancy offour-path operation, you must select the check box “Enable max. CP redundancy(with 4 connection paths)” in “NetPro” (Properties - Fault-Tolerant S7 Connection).
Configuring a CP 443-1
When you configure a CP 443-1 with STEP 7, please remember the following:
!Caution
If you insert a CP 443-1 in a SIMATIC S7 station, the check box “Activate fastswitchover of the connections” must have a check mark entered (Properties CP443-1 dialog > Options > Ethernet Profile for Fault-Tolerant Connections > Activatefast switchover of the connections).
Industrial Communication
101SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.13 SNMP Protocol
Introduction
SNMP (Simple Network Management Protocol) is a UDP-based, open protocol formanaging networks. With SNMP, you can collect data centrally from the entirenetwork and then evaluate it. With this protocol, you can also make parametersettings for the devices. The OPC SNMP Server of SIMATIC NET supportsSNMPv1 (SNMP Version 1.0).
Information on the properties of SNMP-compliant devices is stored in MIB files(MIB = Managed Information Base). The OPC Server cannot process this datadirectly and you require an MIB Compiler that is supplied with NCM. The MIBCompiler processes only MIBs complying with SMIv1 (SMI Version 1.0; SMI =Structure of Management Information).
For more detailed information on the topics of MIB and SMI, refer to the followingbook:
Internetworking with TCP/IP Douglas E. Comer Prentice Hall
2.13.1 Typical System Configuration for the SNMP Protocol
Example
The following graphic shows an example of a typical system configuration:
Industrial Communication
102SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.13.2 Principle of Communication with the SNMP Protocol
Protocol
SNMP is based on the connectionless UDP protocol (User Datagram Protocol).
Reading out and Modifying Variables
With the variable services, the OPC Server sends requests to the partner devicesand the partner devices respond to them.
Traps
There are also messages that the device transfers event-triggered and withoutbeing requested by the SNMP OPC Server. These are known as traps and areused to allow a device to send status changes to the SNMP OPC Server.
Industrial Communication
103SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.13.3 Configuring
Introduction
If you want to use the SNMP protocol over Industrial Ethernet, you must create adefined configuration of the system. The section below describes the parametersyou will need to set.
To configure the SNMP protocol, the following dialog is available in the NCMprogram:
Parameters for the SNMP Protocol
Name
Enter a name for the device or subscriber that identifies it according to itstechnological function. The name can be a maximum of 255 characters long.
IP address
Enter the IP address of the subscriber here. The IP address consists of 4 decimalnumbers in the range from 0 to 255 separated from each other by a dot (forexample, 141.80.0.16).
Device profile:
The device profile describes the structure of the device information available overSNMP. You can either select an existing profile or, if necessary, create a new SNMPprofile.
For devices without SNMP capability, select “No SNMP”.
Industrial Communication
104SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The device profiles contain the MIB objects selected by the MIB compiler withinformation on the OPC items corresponding to these MIB objects. Device profilesare text files. In the STEP 7 project, the profile files are managed in a special folder(s7data/Snmp/Profile).
Device profiles are available for the following modules on the SIMATIC NETSoftware CD:
CP 1613 - -> MIBII_V10.txt (supports only MIBII objects)
OSM - -> Profil_OSM_V10.txt
ELS - -> Profil_ELS_TP40_V10.txt
These files are stored in the following folder:
<installationdrive>\SIEMENS\SIMATIC.NCM\S7data\SNMP\Profile
“Create Profile” Button
Clicking this button starts the MIB compiler. For more detailed information onworking with this program, refer to the online help of the MIB Compiler.
Community
With this parameter, you specify the access rights. The normal (default) entries arePublic (read-only) or Private (read and write). During configuration, you specifycharacter strings that function in much the same way as passwords. Here, youmust specify a string that matches the community string stored on the SNMPagent.
There are two community strings, one for the read community and one for the Writecommunity. The OPC Server reads the string stored on the SNMP device andallows access only if the strings match.
If you enter the string for the read community here, you can send read requestsfor the specified device. If you enter the string for the write community, you cansend both read and write requests for the specified device.
Timeout
With this parameter, you specify the maximum reaction time within which theSNMP OPC Server responds to a request from the OPC client.
- The entry is in milliseconds (ms)
- Range of values: 50 to 60000 ms
- Default: 9000 ms (9 s)
“Optimization of SNMP access” option
Here, you can see whether (read) access to the SNMP agent will be optimized. Tominimize the load on the network and to optimize the transmission time, accesscan be optimized so that as many values as possible are transferred.
Industrial Communication
105SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
This type of access is possible only if the SNMP agent supports this type oftransmission. This is the case with most SNMP-compliant devices and this istherefore the default setting.
sysContact
For this parameter, you can enter the name of a person to contact who isresponsible for managing the device. This entry should also include information onhow the person can be contacted. With SNMP-compliant devices, you cannotenter this parameter because it is specified with tools specifically for the device andis stored on the device itself.
The contact person entry can be up to 255 characters long.
sysLocation
This is intended for information identifying the location of the managed device, forexample a room number. With SNMP-compliant devices, you cannot enter thisparameter because it is specified with tools specifically for the device and is storedon the device itself.
The location entry can be up to 255 characters long.
sysName
This parameter contains the description of the device in text form. The entry shouldinclude the full name and version of the hardware, the operating system, orfirmware and the network software. With SNMP-compliant devices, you cannotenter this parameter because it is specified with tools specifically for the device andis stored on the device itself.
The description entry can be up to 255 characters long.
Comment
Here you can enter additional information on the device.
The comment can be up to 255 characters long.
Industrial Communication
106SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.13.4 SNMP Traps
Introduction
Traps are messages that can be sent to the OPC Server without it requestingthem. There are seven generic traps available on every SNMP-compliant device.There are also device-specific traps that are described in the MIB file.
Generic Traps
warmStart
This is sent after a warm restart on the device.
coldStart
This is sent after a cold restart on the device.
linkDown
This is sent when a connection from the device disconnects.
linkUp
This is sent when a connection from the device is established.
authenticationFailure
This is sent when there was unauthorized access to the device.
egpNeighborLoss
The EGP neighbor (EGP = Exterior Gateway Protocol) of the device is notoperational.
The Exterior Gateway Protocol is used to exchange routing information betweentwo neighboring gateway hosts.
enterpriseSpecific
This is sent when a device-specific trap was sent.
Industrial Communication
107SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.14 Buffer-Oriented Services with the OPC Interface
Introduction
This section describes the use of buffer-oriented services with OPC. You will learnhow data buffers are mapped on OPC variables. The section also describes thespecial points to note when using TCP/IP native in conjunction with thebuffer-oriented services.
2.14.1 Properties of Buffer-Oriented Communication
Supported Services
In the buffer-oriented services, data buffers are transferred by the sender to areceiver using the communications system.
The following protocols support buffer-oriented services:
� S7 communication (BSEND/BRECEIVE)
� S5-compatible communication on Ethernet (SEND/RECEIVE)
� S5-compatible communication on PROFIBUS (SDA, SDN/Indication)
The distinguishing feature of the buffer-oriented services is that data is transferredonly when the sender initiates the transfer. The receiver cannot initiate datatransfer.
Activities of the sender and recipient when exchanging data buffers
Sender
� Puts together the send buffer and its content
� Sends the buffer on a connection to a communication partner
� Receives a confirmation of the result of the data transfer
Recipient
� Prepares a receive buffer for a connection
� Is informed when a partner sends a data buffer to it
� Evaluates the received data
Industrial Communication
108SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.14.2 Mapping Data Buffers on OPC Variables
Differences between Send and Receive Items
The OPC Data Access Interface recognizes only process variables. To allow theadvantages of buffer-oriented services to be used with OPC, the buffers must bemapped on OPC items:
Send item (S7 communication: “BSEND”, S5-compatible communication:“Send”)
� An OPC item represents a send buffer or part of a send buffer.
� When the OPC item is written (synchronous / asynchronous), a write job isinitiated on the network.
� If several items representing part of a buffer are written at once in a groupoperation, the entire send buffer made up of all parts is put together first andthen sent.
� The read returns the last data sent from the send buffer. If nothing was sent,the item may possibly be readable, however is has the quality “BAD”.
Receive item (S7 communication: “BRCV”, S5-compatible communication:“RECEIVE”)
� An OPC item represents a receive buffer
� If the OPC item is read from the device (synchronous/asynchronous), themodule is ready to receive. This state exists until a data packet is received orthe timeout for the specific connection elapses. If no data packet is receivedbefore the timeout, the quality of the OPC item is “BAD”.
� If the OPC item is monitored (active receive item in an active group), a receivebuffer is set up permanently on the communication module. When a datapacket is received, the OnDataChange callback signals this to the application ifthe data differ from the previous data received.
� Receive items cannot be written.
Industrial Communication
109SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
2.14.3 Using Buffer-Oriented Services
Handling Send and Receive Items
Send items should only be written; reading or monitoring send items returns onlythe previously written data.
Receive items should be monitored; in other words, the receive item should existas an active item in an active group. Regardless of the implementation of acallback function, the cache of the OPC server is then updated on the arrival ofevery data packet.
Reading from the cache and directly from the device
Read jobs both synchronous or asynchronous should read the cache. The cachecontains the last block of data received if the receive item is monitored. Using thecache also ensures that several clients reading the item at the same time obtainthe same value.
Reads to device (directly to the device) are not useful since there is only a receivebuffer available during the timeout interval of the connection (normally severalseconds). A sender must send within this time or the data buffer will not beaccepted by the receiver.
Update Rate
Make sure that the OPC Server fetches the receive buffer faster than the sendersends it. The rate at which the receive buffers are fetched is specified by the“Update Rate”, a group-specific OPC parameter.
Depending on the protocol, received blocks of data will otherwise be overwrittenwithout the OPC client being informed (S7, SEND/RECEIVE with ISO and RFC1006) or a backlog or packets will form and the receiver will only receive obsoletedata (SEND/RECEIVE with TCP/IP native).
Industrial Communication
110SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
2.14.4 Points to Note When Using Buffer-Oriented Services withTCP/IP native
Meaning of the Socket Interface
The SEND/RECEIVE protocol with TCP/IP native is based on the Windows Socketservices. No explicit buffers are transferred, but rather a continuous data stream istransmitted on the Socket interface. The protocol uses an interim buffer both at thesend and receive end and incoming and outgoing data is managed as in a FIFObuffer (First-In First-Out).
TCP/IP native and OPC Variables
This feature of the protocol also affects the application with OPC variables:
� Even if the partner does not accept any data, send jobs are acknowledgedpositively until the buffer at the sending end overflows.
� The interim buffer for receiving data is always available regardless of whetheror not a variable is monitored or a read job is sent.
� If the data is not fetched quickly enough at the receiver end, there will be a databacklog in the receive buffer. As a result, the receiver does not obtain the dataread last but data that is no longer up to date.
111SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Basics of the OPC Interface
This chapter will familiarize you with some of the basic terminology you will requireto understand OPC.
You will also learn the fundamental background to OPC and get to know the DataAccess and Alarms & Events OPC interfaces.
To complete the section, you will see how the OPC server of SIMATIC NET isimplemented.
3.1 Basic Terminology
Before you read the introduction to OPC or start to work with OPC, you may find ituseful to familiarize yourself with some of the basic terminology. You can also skipthis section for the meantime and refer to the explanations later as you requirethem.
3.1.1 What are COM Objects?
What is COM?
The basis of OPC mechanisms is COM, the Component Object Model fromMicrosoft.
COM defines a standard that allows objects to be defined as separate units inWindows and to access these units beyond the boundaries of a process.
Objects can be understood as extensions of the operating system. They are notdependent on programming languages and are available in principle to allapplications.
COM objects are components that are executable under Windows and that providea defined functionality for other components via their interfaces. A COM object canbe used simultaneously by several applications.
The data and code of the object are not transparent for the user of the COMobject.
3
Basics of the OPC Interface
112SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
The term object in the context of COM does not correspond to the object definitionin object-oriented programming languages. A COM object must be seen as aself-contained software unit. Typical properties of object-oriented programminglanguages, such as inheriting, are not provided by COM.
Structure of COM Objects
The schematic below illustrates the structure of a COM object with 4 interfaces.The object is accessed only via the interfaces. Access is governed by variousmethods. It is not possible to access the actual object as a whole, nor the data orcode it contains.
Figure 3-1 Structure of a COM Object
Basics of the OPC Interface
113SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.1.2 How do COM Objects Appear?
In documentation, COM objects are usually illustrated graphically. Theobject-specific interfaces are shown to the side of the object and the IUnknowninterface supplied with all objects is shown at the top edge of the object.
The methods underlying the interfaces are disguised by the interfaces.
Figure 3-2 Representation of a COM Object
3.1.3 What do COM Interfaces Provide?
A COM interface is a defined collection of methods for invoking the functionality ofthe COM object. It consists of a table of pointers that reference the methods. ACOM interface encapsulates the functionality of the COM object and ensures thatthe object can only be accessed in a defined way. COM interfaces are assigned aunique identifier so that an application that wants to access the COM object cancheck whether the object supports the interface prior to the access.
Interface Structure
The schematic shows the basic structure of an interface.
Figure 3-3 Structure of an Interface
Basics of the OPC Interface
114SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.1.4 What Types of Interface Exist?
COM distinguishes the following types of interface:
� Automation Interface
� Custom Interface
The interfaces differ in the internal method call. For each interface, there areseparate interface specifications. They are nevertheless suitable for the widestpossible range of applications, such as access to variables or receiving messages.
OPC client applications based on a script language such as Visual Basic or VBAmust use the automation interface.
OPC client applications based on C or C++, can also use the automation interface.To achieve maximum performance, it is, however, advisable to use the custominterface.
Figure 3-4 Example of the Assignment between the Interface and the Application
Basics of the OPC Interface
115SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.1.5 How can a .NET client access the OPC COM Interface?
Sequence when using the OPC custom interface
From within managed code, a .NET client can access a general COM object of theOPC custom interface. Due to the differing properties of COM and the .NETprogramming model (in .NET, for example, there is no access using pointers) nodirect call is possible.
To allow a transition from managed code to unmanaged code, an RCW (runtimecallable wrapper) must be used. RCWs marshal calls between managed .NETobjects and unmanaged COM objects.
Sequence when using the OPC automation interface
With the aid of a .NET framework import application, an interop assembly, a .NETcomponent, is created. .NET clients can use this to create instances of COMobjects and call methods of COM objects as if a .NET instance were involved.Unmanaged code, the OPC automation interface, is therefore converted into a.NET component.
Basics of the OPC Interface
116SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.1.6 What Does Object Control through Automation Mean?
Object control is used to control COM objects with the aid of script languages.
The custom interfaces are not suitable for the range of functions of developmenttools based on script languages. By extending the COM objects with theAutomation Interface distributor interface, the methods of the objects areaccessible for even simple script languages. The Automation Interface makes thecommands understood by the object visible to the outside.
Programmable access to COM automation servers is defined by properties andmethods. This allows the simple embedding of a COM object, for example indevelopment environments such as Visual Basic for Applications.
3.2 Introduction to XML and SOAP
XML and OPC-XML
XML (eXtensible Markup Language) is a new standard for the Internet that has inthe meantime also become widespread in standard software in many areas. Justlike HTML, XML allows metainformation to be added to data. The difference beingwith XML, that you can define your own data structures and attributes.
Based on XML, a new specification was also defined for OPC known asOPC-XML, that describes the process data interface with XML data records.
Access to OPC over the Internet
Communication via the DCOM interfaces of OPC is usually limited to local areanetworks. COM interfaces are also normally defined on Windows-based systems.To ensure security, firewalls allow only restricted access from the Internet and tothe Internet. With OPC-XML, a standard is made available that allowscommunication using the cross-platform protocol SOAP (Simple Object AccessProtocol). Data access using OPC-XML has a range of functions based on OPCData Access.
Interface Description with XML
The data interfaces and methods are described by XML. The exact description ofthe methods is specified in a WSDL specification (WSDL = WebService DefinitionLanguage) supplied by the OPC Foundation along with the OPC-XML DAspecification. The methods are described using SOAP (XML protocol) and sentusing the HTTP protocol. In simple terms, we can say the following:
SOAP = HTTP + XML
The graphic below illustrates the relationships:
Basics of the OPC Interface
117SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Data Transfer with the HTTP Protocol
Access to methods directly from the Internet represents a considerable securityrisk. SOAP therefore only uses the Internet HTTP channel (HTTP = HyperTextTransfer Protocol) for data transfer that is simple to administrate through a firewall:
Basics of the OPC Interface
118SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.2.1 Web Services
Function Calls over the Internet
A Web service allows function calls to be sent to a server over the Internet. Thedescription of the methods and parameters made available by a Web service isstored in WSDL files in XML format. These can be requested from the Web serverby the client. To use Web services, effectively only the Internet address or URL ofthe Web service is required. Data is transferred over SOAP with HTTP frames.
Basics of the OPC Interface
119SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.3 Introduction to OPC DX
Data exchange between OPC Servers
OPC DX allows communication between OPC-DA and OPC-DX servers inEthernet networks. In contrast, with OPC-DA, only pure client servercommunication is possible. This is illustrated in the graphic below.
Since in OPC, the interface is multiple-vendor, data can also be exchangedbetween DX servers or between DX and DA servers of different vendors.
A DX server provides access to the data of other OPC servers, by queryingrelevant items from these servers. In terms of this data query, a DX serverbehaves like a DA client.
DX Connections
How the data is transferred between the OPC servers is stipulated in DXconnections. Among other things, a DX connection defines a source item (on a DAor DX server) and a target item (on the DX server), between which data istransferred. A DX connection is displayed as a read-only OPC-DA item.
Basics of the OPC Interface
120SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
DX Database
All the DX connections are collected in the DX database. The content of the DXdatabase is mapped to part of the name space of the DA server. OPC-DA clientscan access the DX database over the OPC DA interface.
The DX database also contains a list of source servers. Source servers areOPC-DA and DX servers containing the source items.
Configuring a Source Server and the DX Connection
The DX server sends data according to the configuration created by a DX client.OPC DX provides methods with which a DX client can add, modify, and deletesource servers or DX connections. These methods can be implemented in a Webservice or as a DCOM interface.
Controlling and Monitoring the Data Transfer at Runtime
For each DX connection, there are a number of attributes (items in the addressspace of the DA server) that describe how the data is transferred. A DA client caninfluence the data transfer at runtime by writing certain values for such items.
The client can, for example, change the following parameters:
� Establish / terminate connection to a source item
� Establish / terminate connection to a target item
The client can, for example, read or monitor the following items:
� Substitute values if a source item is not accessible
� Runtime parameters of the items (such as value, quality, time stamp)
3.4 Introduction to OPC
What is OPC?
OPC is the acronym for OLE for Process Control.
With the introduction of OPC, the term OLE was used for the entire componentarchitecture of Microsoft. This has changed in the meantime. In its original form,OLE represented the mechanisms for embedding objects in compound documents.
From today’s perspective, OPC should be called COM for Process Control sinceOPC is based on the Component Object Model (COM). COM is the centralcomponent of Windows operating systems and controls the interplay betweenmultiple software components.
Basics of the OPC Interface
121SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
By using COM, the OPC server becomes similar to part of the Windows operatingsystem and is therefore independent of file names, storage locations, and versions.
As a further development of COM, DCOM supports distributed applications andallows cooperation between software components on different computers within anetwork.
Before OPC, a lot of effort was necessary to control the hardware of differentvendors using software applications. There were numerous different systems andprotocols; for each vendor and each protocol, a user had to order special softwareto access the specific interfaces and drivers. User programs were thereforedependent on the vendor, protocol, or system. OPC on the basis of COM orDCOM has a uniform and non-proprietary software interface that hasrevolutionized data exchange in automation engineering.
Figure 3-5 Areas of Application of OPC
3.4.1 What Does the OPC Interface Provide?
As an industrial standard, OPC defines the exchange of information for a variety ofapplications in an industrial environment. Working at your PC, you can monitor,call, and process system data and events of the automation systems.
The OPC interface is part of the software running on a PC as the platform foroperator control and monitoring systems or other applications. It is thereforelocated below the application program.
Basics of the OPC Interface
122SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Scope of the OPC Interface
The OPC Foundation has been creating specifications for the OPC interface since1996. The following specifications are currently available for automationengineering:
� For data exchange based on process variables: Data Access
� For servicing alarms and events: Alarms & Events
� For access to archived data: Historical Data Access
� For working with recipes: Batch
As the interface to the industrial communications systems, the OPC serverprovides the functionality of Data Access and Alarms & Events. Only thesespecifications are described in this documentation.
Applications of the OPC Interface
The applications of the OPC interface are based on the client-server model. Onecomponent provides its services to other components via interfaces. Anothercomponent makes use of these services. With OPC, another application canrecognize which OPC servers exist in a system. It can then address one or moreof these servers and query the services they provide. Since several different OPCclients can access the same OPC server at the same time, the same data sourcecan be used for any OPC-compliant application.
Manufacturers of modules that supply process data (communications systems,measuring devices etc.) provide an OPC server for their module that then handlesthe interfacing to the relevant data source.
Basics of the OPC Interface
123SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.4.2 What is an OPC Server?
OPC components that deliver data are called OPC servers. They implement theinterfacing to existing communications systems. Apart from services, they provideinformation for the OPC client from any data source; this might be ahardware-driven data source or software component. The data is acquired, forexample, from interfaces, fieldbus cards, measuring devices, or controllers.
Server Names
Each OPC server is assigned a unique name by the vendor to identify it. Accordingto the COM standard, these names are known as ProgIDs. By specifying theProgID, you can address specific OPC servers.
Server Types
There are three types of OPC server. The type depends on how they are includedin the communications system:
� In-Process Server
� Local Server
� Remote Server
The vendor of an OPC server specifies whether the server is an in-process serveror a local server. Operation as a remote server is configured by the user.
In terms of the application, it is irrelevant which server is used, the syntax of themethod calls is the same for all.
The schematic below shows which components of the OPC server are accessedby various types of clients:
Figure 3-6 OPC Servers
Basics of the OPC Interface
124SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.4.3 What is an OPC Client?
OPC components that use an OPC server as a data source are known as OPCclients. OPC clients can be obtained on the market as standard software. Softwaremodules are also available that you can put together to create your own clientfunctionality. To meet the individual requirements of your system and to achievethe best possible performance, you can write your own OPC clients in variousprogramming languages (for example, Visual Basic, C and C++).
Some properties of OPC servers (for example variable names) are not defined bythe OPC standard but depend, for example, on the properties of the automationsystem or the plant and are specified, for example by the vendor. To ensure thatOPC clients can work problem-free with various OPC servers, you should plan theconfiguration of the variables when programming. An application is then flexibleand can be reused.
3.4.4 How do the Server and Client Work Together?
The server and client communicate on the basis of COM or DCOM. The clientdoes not access a server directly but uses the COM library. By specifying theProgID, the OPC client can address every OPC server it requires.
For the client, the access path (using COM or DCOM) is not transparent. Theschematics illustrate the possible access paths: Both local and between twodifferent machines.
Figure 3-7 COM on the Local Computer
Figure 3-8 COM on Another Computer
Basics of the OPC Interface
125SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Properties and Methods
The functionality of OPC servers is determined by their interfaces. The OPC clienttherefore knows the server functionality to be expected and can use the availableservices specifically. From an object-oriented point of view, the services of theOPC server are represented by properties and methods. All OPC servers have abasic set of the same properties and methods. Certain interfaces are designatedas optional in the OPC specifications. If a server does not provide such optionalfunctionality, a client can recognize this and react accordingly. As a result,components of different vendors can work together without problems.
A client can create, use, and delete objects on the server via the OPC interfaces.The OPC client references server functions and uses the methods of the server forreading and writing data. Each server function corresponds with a call on the client.
3.5 OPC Data Access
What is OPC Data Access?
Data Access is an OPC specification for accessing process data using variables.An OPC server for Data Access manages the process variables and the variousways in which the variables can be accessed. The server can do the following:
� Read the value of one or more process variables
� Modify the value of one or more process variables by writing a new value
� Monitor the value of one or more process variables.
The server checks whether the value of the process variable has changed. If thereis a new value, the server signals the new value to the client. The messages to theclient are, however, not faster than the “Update Rate” set for the client. If a valuechanges faster than specified in the “Update Rate”, the client is not informed oninterim values.
Process variables are placeholders for values that must be acquired in runtime.
Process Values
The source of the process values is not stipulated in the OPC specification and isvendor-specific. This means that any information can be provided by Data Access.
Basics of the OPC Interface
126SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.5.1 What Does the Class Model of OPC Data Access Provide?
The hierarchical class model of Data Access helps to adapt the time taken and theobtained result to the current requirements of an application when the clientaccesses data. Data Access can be divided into three classes, as follows:
� OPC Server
� OPC Group
� OPC Item
Figure 3-9 Class Model of the Data Access Interface
The client application uses COM calls of the operating system only to create anobject of the OPC server class. The other objects are created by appropriate OPCmethods of the OPC server class or underlying classes.
The class model applies both to the automation interface as well as to the custominterface (with certain restrictions).
3.5.2 OPC Server Class
The highest class is the OPC server class. Each OPC server belongs to this class.This class represents the point of access for all further services of the OPC DataAccess server.
With the aid of class-specific attributes and methods, you can obtain informationabout the status, version, and as an option the name space of the availableprocess variables. An object of the OPC server class manages the instances of thenext lower class; in other words, the OPC group.
Basics of the OPC Interface
127SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.5.3 OPC Group Class
The OPC group class is directly below the OPC server class and structures theprocess variables used by the OPC server. An OPC client can use several objectsof this class at the same time. Using the objects of an OPC group, a client canform meaningful units of process variables and execute operations with them. Asan example, it might be useful to put all the process variables of one screen pageof an operator control and monitoring system into one group.
The OPC group class defines methods with which the values of the processvariables can be read and written.
With some methods, several variables can be put together in one job andtransferred at the same time. In particular when using an OPC server over thenetwork, these group operations allow fast execution.
3.5.4 OPC Item Class
Objects of this class represent the actual process variables and allow specific datato be queried. Each variable is an element (item) in the name space of the OPCserver and is identified by an Item ID. The Item ID is specified by the vendor of theserver and must be unique within the name space of the server. The followingproperties are associated with each item:
� Value
Last acquired value of the variable.
� Quality
Reliability of the value. If the quality is good, the value was acquired withcertainty.
� Time stamp
The time at which the current value of the variable was first acquired. Each timea value change is signaled to the client, the time stamp is updated. If the valueof a variable does not change, the time stamp remains the same.
The Role of Variables
Variables must be specified in the OPC interface calls to obtain process values. Byspecifying variables, the client can request the required values from the server.The client must register each required variable with the server to specify whichvalues will be read and when. Variables can be read and written synchronously andasynchronously.
The client can delegate the monitoring of variables to the server. When the valueof a variable changes, the server sends a message to the client.
Basics of the OPC Interface
128SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The variables provided by the OPC server can be grouped as follows:
� Process variables
Represent measured and controlled variables in a process such as provided byinput and output devices or
� Control variables
Using these variables triggers certain additional services, for example thetransfer of passwords.
� Information variables
These variables are provided by the communications system and provideinformation about the status of connections, devices etc.
A few examples of variables of an OPC Data Access server are shown below:
� Control variables of a programmable controller
� Data of a measured data acquisition system
� Status variables of the communications system
3.5.5 Using the “Percent Deadband” Parameter
This parameter is specified as a percentage and defines a range in which changesare not signaled for all items of a group. The absolute value of the range is thespecified percentage of the total value range of the process variable.
In the following example: Percent Deadband = 10% = 1 unit (where lower limit = 0and upper limit = 10).
Basics of the OPC Interface
129SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Following each value change, a band is placed around the last changed value. Achange message is generated and sent to the client only when the value leavesthis band when it is read, following which a new band is set.
Note
Violating the upper or lower limits does not generate any special alarms accordingto the OPC Specification !
3.5.6 Which interfaces are specified for OPC Data Access?
Automation and Custom interface are specified for Data Access:
� Data Access Automation Interface, Standard, February 4, 1999, Version 2.02
� Data Access Custom Interface, Standard, October 14, 1998, Version 2.0
Basics of the OPC Interface
130SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.6 OPC DX Interface
3.6.1 DX Server
The DX Server as an Expansion of a DA Server
A DX server is based on a DA server that meets one of the specifications for OPCinterfaces. A DX server also includes functions required for server-servercommunication. A DX server is a DA server expanded by the followingfunctionality:
� the DX interface
� a configurable OPC-DA client
The following graphic illustrates the structure of a DX server:
Basics of the OPC Interface
131SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
DX-specific functionality
A DX server differs from a DA server due to the following expansions:
� The DX server maintains a DX database. This database contains all theinformation about the server itself and about the source server and DXconnections.
� The configuration interface provides methods for adding, modifying, anddeleting source servers or DX connections.
� The DX server contains a mechanism corresponding to a DA client with which itcan log on at data sources to obtain cyclic updates of the source data.
� At runtime, the DX server copies data from the source to the target. Clients cancancel the connection from the DX server to source or target items and specifythe rules for updating the data. The client can, for example, disable theupdating or set fixed values in the target item.
� DA items and the methods of the DX interface to control the runtime responsedescribed in the previous section.
3.6.2 DX Database
Structuring of Information in the Name Space
The DX server uses part of the name space of the DA server for the DX database.The OPC DA items contained in this database can be accessed using the methodsof the .
The DX item is the root node of this data structure. Branching from this, there areitems for the browse path and for the DX connections. The items located below aDX connection contain all the information required by the DX server to handle thedata transfer on this DX connection. These include, for example, informationidentifying the source and target item and the source server.
Basics of the OPC Interface
132SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The following graphic illustrates the arrangement of these items in the DA namespace of OPC:
General Items for the DX Connection
Each DX connection contains several attributes that specify the properties of thisconnection.
Status Items
The Status item contains two types of attribute. One group contains items formonitoring the data transfer. These items are read-only and are updated by theDX server during runtime. The other group of items controls the runtime behaviorof the server. If, for example, the item SourceItemConnected has the value FALSE,the DX server requests no more data from the corresponding source.
Basics of the OPC Interface
133SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.7 OPC Alarms & Events
What Is Meant by Alarms & Events?
Alarms & Events is a specification for the transfer of process alarms and events. Itis structured flexibly and can therefore be used with a wide variety of eventsources. The spectrum ranges from simple events to complex events and evenincludes events that must be acknowledged.
The OPC specification defines the possible status changes for conditional eventsin a state diagram.
Access to the events is based on a class model.
3.7.1 What are Events and Event Messages?
Selection Using Filter Criteria
Events are particular states in the process that need to be signaled to a receiver.Which events are signaled to which programs is decided by the OPC client usingfilters.
All events that correspond to the criteria set with the filter must be passed from theoriginator of the event to the user. This is a distinction between Alarms & Eventsand Data Access. When monitoring variables, only the value changes that fallwithin the specified time interval are signaled.
Message Content
The message contains the parameters defined in the OPC specification andpossibly also associated values specified by the vendor.
There are simple event messages and more complex status-linked messages.With the complex status-linked messages, the sender of the event can demand anacknowledgment by the user.
Event Types
The OPC specification defines three types of event:
� Condition-related events
These signal the status changes defined in the OPC status model and arerelated to defined conditions.
� Tracking events
These signal changes in the process if, for example, a user changes thesetpoint of a controller.
Basics of the OPC Interface
134SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� Simple events
These signal all other events that do not involve a status, for example, thefailure of a system component.
The OPC specification defines the syntax of the interface for receiving messages.Which types of event a server provides is specified by the vendor of the OPCserver.
3.7.2 What Does the Class Model of OPC Alarms & Events Provide?
The class model of Alarms & Events allows the adaptation of the OPC client to therequirements of an automation solution. Alarms & Events distinguishes betweenthree classes:
� OPC Event Server
� OPC Event Subscription
� OPC Event Area Browser
Figure 3-10 Class Model of the Alarms & Events Interface
Note
The OPC Event Area Browser class is optional and is not supported by the OPCAlarms & Event server of SIMATIC NET.
Basics of the OPC Interface
135SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.7.3 OPC Event Server Class
Functionality of the OPCEventServer
The highest class is the OPC Event Server class. Each OPC Alarms & Eventsserver belongs to this class. This class represents the access point for all furtherservices of the OPC Alarms & Events server.
The objects in the OPC Event server class mainly manage the registration of theclients for receiving events. They also provide information about the supportedevent categories and the attributes that can be delivered with an event.
A client application addresses the objects of the OPC Event server class usingCOM mechanisms and can receive the events provided by the event server.
Acknowledging Events
Using the AckCondition method of the OPCEventServer class, the clientacknowledges condition-related events in this is specified in the AckRequiredparameter of the event. As soon as the acknowledgments arrives, this causes achange in the NewState parameter of the condition-related event and therefore anew event:
Figure 3-11 Sequence of Events and Acknowledgment with Condition-Related Events
3.7.4 OPC Event Subscription Class
Functionality of OPCEventSubscription
Using objects of the OPC Event Server class, a client creates one or more objectsof the OPCEventSubscription class. An object of this class represents asubscription to a set of events. Objects of this class manage the filters and
Basics of the OPC Interface
136SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
attributes required for a specific client. The SelectReturnedAttributes methodallows the user to specify which event attributes are transferred with each eventmessage. Using the objects of the OPC Event Subscription class, the client canform useful groups and execute group operations.
Filtering Events
By filtering, a client can specify the events it wants to receive. A filter is nothingmore than the definition of an event based on its properties. The following criterionare used:
� EventType
� Category
� Priority
� Event source
An event is only forwarded to the client when it matches the filter values in allcriteria.
Buffering Events
If each event is transferred individually to the client, more resources are requiredthan when several events can be transferred together. With the BufferTimeparameter, the client can specify that events are sent only after a certain intervalhas elapsed. Events occurring during the interval are buffered until the intervalelapses and all the buffered events are sent together.
Figure 3-12 Meaning of the Parameters BufferTime and MaxLength
The maximum number of buffered events can be set with the MaxSize parameter.Once the specified number as been reached, all events are sent to the clientregardless of the selected BufferTime interval.
BufferTime and MaxSize are used as parameters in the CreateEventSubscriptionmethod of the OPCEventServer class and in the GetState and SetState methodsof the OPCEventSubscription class.
Basics of the OPC Interface
137SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.7.5 OPC Event Area Browser Class
With Alarms & Events, you can divide extensive plants into areas. Areas can beused to filter events. The use of objects of the OPC Event Area Browser classallows the plant areas to be investigated.
Note
Objects of the OPC Event Area Browser class are optional and are not supportedby the OPC Alarms & Event server of SIMATIC NET.
3.7.6 How are Messages Received?
An application registers itself for receiving messages in four steps:
1. The client registers with the server for receipt of messages.
2. The client creates one or more objects of the OPCEventSubscription class.
3. The client sets up a callback over the IConnectionPointContainer interface.
4. The client makes an OnEvent method available that is called by the server whenan event occurs.
Figure 3-13 Connection between Server and Client for Receiving Messages
3.7.7 Alarms and SIMATIC S7
An alarm is characterized by the following properties:
� An alarm is indicated by a change to a binary signal (edge).
� The signal change leads to a new binary signal state that lasts for a time of t > 0.
Basics of the OPC Interface
138SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� Each signal change can be (but does not need to be) acknowledged by therecipient of the signal.
� The acknowledgment state can be (but does not need to be) monitored by thetriggerer of the alarm.
� The signal can change again without the last signal change having beenacknowledged.
A SIMATIC S7 can trigger alarms with various blocks:
Block Name Numberof
signals
Acknowledgment
Associated
values
Severity
SFB36 NOTIFY 1 No 1-10 0-127
SFB33 ALARM 1 Yes (withSFB33)
1-10 0-127
SFB34 ALARM_8 8 Yes (withSFB34)
No 0-127
SFB35 ALARM_8P 8 Yes (withSFB35)
1-10 0-127
SFC17 ALARM_SQ 1 Yes (withSFC19)
1 No
SFC18 ALARM_S 1 Acknowledgedimplicitly
1 No
The S7 user program specifies whether or not an acknowledgment is required fromthe recipient of the alarm. The S7 program distinguishes betweenacknowledgments for the occurrence of an alarm state (alarm entered state”) andacknowledgments for the end of an alarm state (alarm exited state). The OPCinterface does not provide mechanisms for such a distinction and onlyacknowledgment of the occurrence of an alarm is supported. The acknowledgmentof the end of an alarm state is made implicitly by the Alarms & Events server.
Basics of the OPC Interface
139SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.7.8 Examples of Handling Alarms
Alarm without acknowledgment
Figure 3-14 Signal States of an Alarm without Acknowledgment
An S7 block monitors the level of a container that is filled during a productionprocess. When the container is full, the S7 block triggers an alarm (t1) andproduction is stopped. The alarm does not need to be acknowledged, production isinterrupted without any further measures being taken by the controller. Once thecontroller detects that the container has been emptied again, it terminates thealarm (t2) and production is continued.
Alarm with acknowledgment
Figure 3-15 Signal States of an Alarm with Acknowledgment
An S7 block monitors tank pressure. If the limit value is exceeded, the S7 blocktriggers an alarm (t3), at the same time, a warning lamp on the overpressure valveand an acoustic signal are activated.
When the operator acknowledges (t3Ack), the acoustic signal is turned off, thealarm state, however, remains because the tank pressure is still above the limitvalue. The warning lamp is not turned off by the acknowledgment. Receiving theoperator acknowledgment on the S7 controller triggers a further alarm.
Basics of the OPC Interface
140SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Once pressure has been reduced, the S7 block recognizes that the value is belowthe limit pressure and terminates the alarm (t4). The end of the alarm state alsotriggers an alarm.
An operator acknowledgment of the end of the alarm state turns off the warninglamp (t4Ack). This acknowledgment is not visible on the OPC interface becauseOPC only supports acknowledgments of the occurrence of alarm states.
3.7.9 Which Interfaces are Specified for Alarms & Events?
The Automation and Custom Interfaces are specified for Alarms & Events:
� Alarm & Events Automation Interface, Standard, December 15, 1999,Version 1.01
Description of the OPC Alarms & Events Server as well as the specification of the custom interface of this server.
� OPC Alarms & Events Custom Interface, October 2, 2002, Version 1.10
Specification of the automation interface of the OPC Alarms & Events Server.
3.8 OPC XML Interface
Note
The OPC XML interface is available in the SIMATIC NET Software from Version6.1 onwards.
Internet Access for OPC
OPC-XML is a standard that allows communication with cross-platform protocolsover the Internet. A client is no longer restricted to a Windows environment (COM).Other operating systems such as LINUX can monitor and exchange OPC data withthe HTTP protocol and the SOAP interface.
Data access with OPC XML has a range of functions based on OPC Data Access,however there are only simple write and read services available. Change-drivenmessages about data changes such as in DCOM OPC DA interfaces are notintended for OPC XML due to the loose Internet connection.
One possible disadvantage of this interface is that it requires an Internet server.Only low performance over the Internet can be expected.
Basics of the OPC Interface
141SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Interfaces of the SIMATIC NET OPC Server
The following graphic shows the internal structure of the SIMATIC NET OPCServer and the available interfaces:
Basics of the OPC Interface
142SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.8.1 Web Service OPC XML
Web Service of the Internet Information Server
The OPC XML specification is implemented in SIMATIC NET by a Web service ofthe Microsoft Internet Information Server (IIS). Remember that the InternetInformation Server is a component of the operating system that must be installedand configured separately.
The OPC XML component is largely transparent to the user. It is startedautomatically by the IIS when a Web client requests the relevant OPC-XMLservices. The graphic below illustrates the relationships:
3.8.2 Simple Read / Write Services
Available Methods
The following methods are implemented on the SIMATIC NET OPC XML server:
GetStatus
With GetStatus, the general status and vendor-specific information (version,product name) can be queried.
Read
With the Read service, the value of one (ore more) variables can be read.
Write
The Write service writes one (or more) variables. As an option, the OPC-XMLserver must then execute the Read method and integrate the values obtained inthe write job.
Basics of the OPC Interface
143SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Subscription, SubscriptionPolledRefresh, SubscriptionCancel
With subscriptions, the variables are registered and any changes read (cyclically)with the SubscriptionPolledRefresh. A subscription can be canceled withSubscriptionCancel.
One special feature of SubscriptionPolledRefresh is the time window that isspecified with WaitTime and HoldTime. The call on the server is held until theWaitTime. The response to the call is then returned as soon as a value change isdetected or at the latest when HoldTime is reached.
Browse
The Browse service allows navigation through the hierarchical address space. Incontrast to the COM interface, a request can be used to read both branches andleaves.
It is also possible to specify which properties of an element the server shouldreturn.
GetProperties
As an alternative to Browse, properties of elements can also be read with theGetProperties service.
Synchronous / Asynchronous Use of the Methods
According to the OPC-XML DA specification, these methods are asynchronous.The request and response are separate parts of the protocol. The use of thesemethods by higher programming languages such as C# or Visual Basic etc. allowsthe request and response to be put together to form a synchronous method.
When creating a proxy class for the client program, a synchronous and anasynchronous variant are generated for each method. Both variants use the sameOPC-XML DA methods. The use of the asynchronous variant does, however, havebeneficial effects on the runtime response of the client program.
For more detailed information, refer to the following book, Chapter 9,Asynchronous Programming:
Professional ASP.NET Web ServicesWROX Press LtdISBN 1-861005-45-8
Basics of the OPC Interface
144SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.9 OPC in SIMATIC NET
The open OPC interface is the central interface of the products on the PG/PC ofSIMATIC NET. The OPC Server of SIMATIC NET supports all communicationprotocols and services provided by the communication modules.
The OPC Server of SIMATIC NET supports the OPC Data Access interfacespecification for all protocols. For protocols with mechanisms for signaling events(S7 communication), OPC Alarms & Events is also supported.
In the following sections, you will see how the OPC Server of SIMATIC NET isused, the advantages of using the server, and its characteristics. You will also learnways of optimizing access to process data with the OPC server.
3.9.1 What Does the OPC Server of SIMATIC NET Provide?
The OPC Server of SIMATIC NET allows access to the industrial communicationsnetworks PROFIBUS and Industrial Ethernet of SIMATIC NET. It provides OPCclients with the values of process variables or signals events from the partnerdevice. It accesses the partner devices using the protocol software and thecommunications processor of SIMATIC NET over the communications network(see figure).
Figure 3-16 OPC Server for SIMATIC NET with OPC Client
Special Features
Since the OPC server is capable of distributing jobs to various communicationssystems, the OPC client can use several different protocols at the same time via asingle OPC server. If only one protocol is used in the configuration of the OPCserver, no distribution is necessary. This optimizes the data throughput.
Basics of the OPC Interface
145SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Restrictions
The OPC Server of SIMATIC NET supports all the interfaces required by thespecification for OPC Data Access and OPC Alarms & Events. It also provides themost important optional interfaces such as the Browsing Interface for OPC DataAccess.
The following restrictions apply to the optional interfaces:
� The OPC Server for Data Access does not support “OPC Public Groups”.
� OPC Server for Alarms & Events
- No signaling of condition-related events
- Acknowledgment of events is not necessary
- Division of plants into areas is not possible
- Browsing areas is not possible.
The type of message and the content of messages is not specified by the OPCSpecification. The SIMATIC NET OPC Alarms & Events Server does not have anyconfiguration information for alarm or event handling in an operator control andmonitoring system. In this version, the OPC server only delivers simple events.
Basics of the OPC Interface
146SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.9.2 How is the OPC Server of SIMATIC NET Used in the World ofAutomation?
The schematic shows how the OPC Server of SIMATIC NET is used. At the top,you can see a selection of possible clients that can access the OPC server.
The bottom half shows the communications networks with possiblecommunications partners.
Figure 3-17 The Role of the OPC Server in the World of Automation
Basics of the OPC Interface
147SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.9.3 What are the Advantages of the OPC Server for SIMATIC NET?
With the numerous benefits of OPC, SIMATIC NET offers a series of generaladvantages and advantages in the programming and development of individualclients. Commissioning personnel has, however, not been left out.
Advantages for Commissioning
� You use an interface that is not protocol-specific; in other words, only oneinterface needs to be installed for several applications.
� You have simple access to the communications networks of SIMATIC NET.
� You can use your programmable controllers with numerous applications fromautomation engineering over the communications network of SIMATIC NET.
� You can integrate Microsoft Office products.
� Using DCOM, applications installed on other computers can access theservices of the OPC server over global or local area networks.
� The OPC client application “OPC Scout” of SIMATIC NET provides you with apowerful tool for simple access to process variables.
� With the aid of SIMATIC Computing, you can, for example, create simpleutilities in Visual Basic.
Advantages for Program Development
� You operate with a multi-vendor interface. This means the future of yourinvestment is safe. You can service a wider market and can reuse yourdevelopments.
� The applications you develop are not dependent on the communications systemof one vendor and can communicate unchanged with OPC servers from othervendors.
� The OPC interfaces provide applications with efficient access to OPC serversand the underlying communications networks.
� OPC has high-performance interfaces for the C and C++ programminglanguages.
� Convenient and simple access to process data is possible with developmentenvironments such as Visual Basic via the Data Control.
� You do not need to familiarize yourself with protocol- and vendor-specificinterfaces.
� The option of a trace output simplifies debugging and troubleshooting.
� Since a partner device can be simulated, a program can be developed withoutinstalling additional devices.
Basics of the OPC Interface
148SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
3.9.4 What is the Best Way to Access Process Data?
With OPC Data Access, you can access various types of process data. Byselecting suitable methods, you can influence the data throughput of yourapplication.
With some protocols, you can also influence the performance of the OPC server byselecting a service and by structuring the variables in the name space.
Tips for Optimum Data Throughput
The following tips will help you to achieve the highest possible data throughput:
� Use group operations
� Access the OPC cache
� Structure items
� Use buffer send/receive services
Use Suitable Methods
There are various ways of accessing variables. Since they have differentproperties, you should note the advantages and disadvantages described belowand select the most suitable type of access for your situation.
� Use suitable OPC methods
3.9.5 Using Group Operations
With many methods, you can transfer multiple process variables as parameters inone array using one function call. The use of group operations improves the datathroughput since there are fewer function calls and process changes between theOPC client and OPC server. The OPC server can then optimize communicationover the network itself, for example by putting single jobs together.
If you work with a remote server using DCOM, the use of group operations isparticularly effective since in this case, a function call is transported over thenetwork.
Note
The OPC server also uses group operations when transferring change messagesto the client.
Basics of the OPC Interface
149SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.9.6 Examples of Group Operations
Here, you can see examples of group operations on the OPC Custom interface:
IOPCItemMgt::AddItems (NumItems, pItems, ppResults, ppError)
Items defined in the pItemArray array are included in a group.
Note
Calling AddItems is faster if the group is not active. Activate the group only afteryou have added all the OPC items.
IOPCSyncIO::Read (Source, NumItems, pServerhandle, ppResults, ppError)
The value, time stamp, and quality of several OPC items defined by an array withserver handles are read synchronously.
IOPCSyncIO::Write (NumItems, pServerhandle, pItemValues, ppError)
Values are written synchronously to several OPC items defined by an array withserver handles. The values are transferred in an array.
3.9.7 Accessing the OPC Cache
The OPC cache is an internal interim buffer of the OPC server in which the lastvalues of the OPC items to be acquired are entered. The OPC server updates allactive items inserted in active groups. The values in the cache are valid assumingthat the item was read successfully.
Reading a variable from the cache is significantly faster than access over thenetwork. If the values in the cache are updated at an interval that is short enoughfor the particular application, it is advisable to access the cache.
The update rate in the cache is specified by the UpdateRate parameter.
Note
Remember that a very high update rate (short interval) puts more load on theprocessor of the computer and the communications system.
3.9.8 Examples of Services that Can Use the Cache
Here, you can see examples of services that can make use of the cache:
Basics of the OPC Interface
150SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
IOPCSyncIO::Read(...,OPC_DS_CACHE,...)
The value, time stamp , and quality of several OPC items are read synchronouslyfrom the cache.
IOPCAsyncIO2::Refresh(...,OPC_DS_CACHE,...)
Regardless of the value, a callback is generated for all active OPC items. The valuecurrently stored in the cache is sent to the client.
3.9.9 Structuring Items
The OPC Server for SIMATIC NET provides an optimization algorithm for thevariable services of the following protocols:
� S7 Protocol
� S5-compatible communication over Industrial Ethernet
Several simultaneous jobs to access individual variables are converted internally toa single access to an array on the partner device. This reduces the number of datapackets transported over the network, improves the utilization of the packets, andincreases the payload of a packet.
This optimization is used for both read and write access and is activated as thedefault setting. For the OPC client this optimization algorithm is invisible.
Rules for Arranging the OPC Items in the Name Space
The optimization is only possible if you keep to the following rules for thearrangement of the OPC items in the name space:
� OPC items that are read or monitored simultaneously should be arrangedconsecutively in the name space of the partner device.Small gaps between the relevant sections are processed but make for a poorerdata throughput.
� OPC items that are written simultaneously must be arranged consecutively inthe name space.For optimum write access, there must be no gaps. The array formed during theoptimization is always transferred in its entirety to the partner device. Theaddress area of any gaps would be overwritten by undefined values. To avoidthis, the OPC server then sends individual access jobs without anyoptimization.
Note
If your OPC client does not need to use individual OPC items for processvariables, you can use arrays directly for accessing the relevant data and assignthe elements of the arrays read to individual process variables.
Basics of the OPC Interface
151SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
3.9.10 Example of Structuring Items
Organization of a Data Block for Read Access
DB10,W10
DB10,B12
DB10,B13
DB10,DW14
DB10,W20
This is executed as a read access to DB10,B10,12 via the communicationssystem.
Despite the gap at byte 18 and byte 19, this is converted to a read job. The dataread unnecessarily is discarded. Instead of five single variable requests, only onerequest is transported over the network.
Organization of a Data Block for Write Access
DB10,W10
DB10,B12
DB10,B13
DB10,DW14
DB10,W20
This is executed via the communication system as two writes to the DB10,B10,8array and the individual variable DB10,W20.
3.9.11 Using Buffer Send/Receive Services
For the transfer of large data packets, S7 communication and S5-compatiblecommunication over Industrial Ethernet provide buffer send/receive services. Datapackets are sent between communications partners. The transfer of the data putsload on the network only when a partner explicitly initiates a send job.
Using the OPC Server for SIMATIC NET, you can structure blocks of data. Thisallows individual parts of a data packet to be assigned to OPC items.
Basics of the OPC Interface
152SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
The S7 buffer send/receive services are currently available only for devices of theS7-400 and M7 series and PC stations. The S5 buffer send/receive services areavailable for practically all devices of the S5 and S7 series and PC stations. Notethe information on the communication partner relating to future support of thebuffer-oriented services in the readme file in the main folder of the SIMATIC NETSoftware Product CD.
3.9.12 Example of Using Buffer Send/Receive Services
The following schematic illustrates how an S7-400 sends a data packet to a PCstation with the S7 OPC Server.
Figure 3-18 Sending a Data Packet
To allow the OPC server to receive data, one or more OPC items of the typeRECEIVE or BRCV are added to an active group on the PC.
On the S7-400, a user program starts the BSEND function block. BSEND startsthe transfer of the entire data area as a buffer to the PC.
On the PC, the received data is transferred to the OPC server. The OPC servernow maps the subareas of the block of data to the corresponding OPC items. Ifthese OPC items are monitored, the OPC server sends a callback to the OPCclient if the values change.
3.9.13 Using Suitable OPC Methods
For OPC Data Access, there are three ways of accessing data:
Basics of the OPC Interface
153SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Synchronous Read or Write
Both reads and writes can be synchronous.
A program sends a synchronous function call to access process data. When thefunction is executed, the OPC server handles all the communication over thenetwork. The read values are transferred to the user program with the returnparameters of the function and the application can now continue to execute thenext instructions.
Applications of Synchronous Access
You should always use synchronous access when a longer interruption in the userprogram is acceptable, for example when using worker threads. Synchronousaccess is the fastest possible access to data on the partner device.
Note
The data throughput with synchronous jobs does not depend on the UpdateRateparameter and the cycle time specified in the configuration.
Advantages and Disadvantages of Synchronous Access
Advantages
� Simple programming
� High data throughput, since there is only one process change per job betweenthe OPC client and OPC server.
Disadvantage:
� The application is interrupted until the synchronous job has been completed.The application can only continue when all the data has been read. If thefunction is not called in a separate thread, the user interface, for example, of aninteractive application is blocked during the function call.
Basics of the OPC Interface
154SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Asynchronous Read or Write
It is possible to read or write asynchronously.
A program sends an asynchronous function call to access process data. Thefunction returns to the program immediately indicating whether the job was sentsuccessfully to the OPC server. The program can then continue to run.
The OPC server assigns a TransactionID to the job with which the client can lateridentify the response to the job.
At a later, undefined point in time, the OPC server calls the AsyncReadCompleteor AsyncWriteComplete function of the OPC client. The results of the previousfunction call (read or write) and the TransactionID are sent to the client as callparameters.
The program execution of the OPC client in no way influences the time at whichthe data are sent over the network.
Applications for Asynchronous Access
Asynchronous access is useful when large amounts of data need to be read andwhen the application needs to be capable of reacting while the job is executed.
Asynchronous access to the cache of the OPC server serves no practicalpurpose.There is high processor utilization simply as a result of processchangeovers between the OPC client and OPC server.
Note
The data throughput with asynchronous jobs does not depend on the UpdateRateparameter and the cycle time specified in the configuration.
Advantages and Disadvantages of Asynchronous Access
Advantages
The local application is interrupted only for a short time since the actualcommunication runs parallel to the application.
Disadvantages
� Writing the application is somewhat more complicated. A callback mechanismmust be implemented in the application that can receive the result of theprocessed job at any time.Standard Windows programs have asynchronous mechanisms to allow them toreact to user input.
� When transferring only a few variables in a job, there is a large load caused bythe process changes with the call and callback. There are twice as many as insynchronous access.
Basics of the OPC Interface
155SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Monitoring Variables
When monitoring variables, the OPC server checks continuously whether the valueor the quality of variables has changed.
The OPC client therefore adds active OPC items to a group and activates thegroup. All the active OPC items in all active groups are then monitored.
The OPC client provides the DataChange function. The OPC server calls thisfunction when the values have changed. As the parameters of DataChange, theOPC server transfers the changed values, qualities, and time stamp of the OPCitems.
The OPC client is put under no extra load by monitoring variables. The program ofthe client is executed only when a change is detected.
To make sure that the OPC client is not completely overloaded with messages ifprocess variables change very quickly, you can use the group-specific parameterUpdateRate to specify the minimum interval at which the client is called.
Analog values affected by noise would lead to flurries of change messages sincethe value changes slightly all the time. Noise can also be filtered out by using thegroup-specific parameter PercentDeadBand. Using this parameter, only signalchanges greater than a specific percentage of the value range of the variable aresignaled.
This is only possible when the range of values of the variables is defined in theSymbol File Configurator.
Applications of Variable Monitoring
Monitoring variables is an ideal solution when a program constantly requires thelatest data of the process or part of the process.
Note
The data throughput is decided by the UpdateRate parameter of the group and thecycle time specified in the configuration. The cycle time determines the smallestpossible update interval. The update rate should be specified in multiples of thecycle time.
Basics of the OPC Interface
156SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Advantages and Disadvantages of Monitoring Variables
Advantages
� The application is only notified when the process data has changed.
� High data throughput since there are few process changes. Depending on theway in which the items are structured, good optimization is possible.
� Monitoring of variables can be activated and deactivated item-oriented andgroup-oriented by the client.
Disadvantages
� The reaction time from the change in a value in the process to the transfer ofthe new value to the client is greater than the update rate of the group.
� Writing the application is somewhat more complicated. The application requiresan asynchronous section for receiving changed values.
Standard Windows programs have asynchronous mechanisms to allow them toreact to user input.
Relationship between Cycle Time and Update Rate
The “UpdateRate” parameter that can be set in the user program specifies theshortest possible interval for checking the values of the OPC items of an activeOPC group. When this interval elapses, the server checks whether or not thevalues of the active OPC items have changed.
The update rates used by the OPC Server for SIMATIC NET are multiples of thecycle time specified here during configuration. The maximum update rate (shortestinterval) is the same as the cycle time.
Relationship between the Set Protocol-specific Cycle Times
Since the SIMATIC NET OPC Server can use variables of different protocols at thesame time, the maximum update rate of the OPC server is the highest value setfor the scan cycle time for the active protocols (those for which connections areconfigured).
157SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
OPC Process Variables for SIMATIC NET
This chapter explains the syntax of the names of the process variables. The syntaxof the names of the process variables on the OPC interface specifies whichprocess variables are addressed. You specify the variable names when youprogram or configure an OPC client.
4.1 Which Communication Functions Exist?
The OPC server provides standardized access to the SIMATIC NET industrialcommunications networks via Data Access.
The SIMATIC NET OPC Server supports the interfacing of applications with anyautomation components networked over PROFIBUS or Industrial Ethernet. Itprovides the following communication functions:
� S7 communication
� S5-compatible communication
� PROFIBUS-DP
� PROFIBUS-FMS
Further communication functions are in development.
The communication functions are specially optimized for the various requirements.Several communication functions can be supported at the same time by the OPCserver.
4
OPC Process Variables for SIMATIC NET
158SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.2 What Are Process Variables?
A process variable is a writable and/or readable data item of the process I/O suchas the temperature of a tank used as the input value of a programmable controller.
Process variables are represented in the OPC class model by the class OPC item.Only elements of this class represent a real value from the process in OPC.
ItemIDs
The ItemID is a string that identifies the process variable uniquely. It tells theserver which process variable is assigned to the OPC item. The process variablecan then be accessed via the OPC item.
The OPC Server of SIMATIC NET maps the various communication services ofthe protocols using OPC items by using parts of the ItemID as parameters forcalling the communication function.
4.3 How Are the ItemIDs of the Process Variables Formed?
Process variables are identified on the OPC interface by a unique name, theItemID. The ItemID is made up as follows:
Syntax
<protocolID>:[<connectionname>]<variablename>
Explanations
<protocolID>
Specifies the protocol for access to the process variable.
The following protocol IDs exist:
DP DP protocol including DP master, DP slave, and DPC1S7 S7 functions over PROFIBUS and EthernetFMS FMS protocol over PROFIBUSSEND/RECEIVE S5-compatible communication over Industrial EthernetFDL S5-compatible communication over PROFIBUS
<connectionname>
The connection name identifies the connection or communication module viawhich the partner (for example PLC, other PC station or DP slave) can beaccessed. This is specified in STEP 7 / SIMATIC NCM PC when configuring thehardware.
OPC Process Variables for SIMATIC NET
159SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The connection name specified depends on the protocol being used. Theconnection name must be unique within a protocol.
<variablename>
Variable to be addressed.
The variable name must be unique for the connection specified in the connectionname. The structure of the variable name depends on the selected protocol.
Note
As of version 6.0 of the OPC server, the syntax of the ItemIDs has been simplified.The previous syntax is, however, still supported. Programs and configurations withthe older ItemIDs can continue to be used unchanged.
The older syntax is, however, no longer displayed in OPC Browsing of the OPCserver. In future applications, use the new simplified syntax.
4.4 PROFIBUS-DP
Process Variables for the DP Master
The OPC Server of SIMATIC NET for the DP master mode provides processvariables for the following services:
� Services for a Class 1 Master
Access and monitoring of DP inputs and outputs
� DPC1 Services
Acyclic transmission of blocks of data
� Fast Logic for the CP 5613 and CP 5614 (DP Master Only)
Automatic monitoring of slave data
� Diagnostic Variables
Evaluation of static diagnostic information
OPC Process Variables for SIMATIC NET
160SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Process Variables for the DP Slave
The OPC Server of SIMATIC NET for the DP slave mode provides processvariables for the following services:
� Variable Services for Access to the Local Slave Data
Access to the inputs and outputs of the slave
� Diagnostic Variables
Evaluation of static diagnostic information of the slave
Note
Parallel operation of the DP master and DP slave with the CP 5614 module ispossible only when the DP Base mode was set during configuration with SIMATICNCM PC or STEP 7.
4.4.1 Protocol ID
The protocol ID for the DP protocol is DP.
4.4.2 Connection Names
The connection name specifies the communication access by specifying thecommunications processor attached to the PROFIBUS network.
In the DP protocol, the connection name is the configured name of thecommunications module.
Examples of Connection Names
Typical connection names are:
CP 5613
CP 5614
CP 5611
OPC Process Variables for SIMATIC NET
161SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.4.3 High-Performance SIMATIC NET Inproc-Server for thePROFIBUS-DP Protocol
Since the PROFIBUS DP protocol maintains an image of the input and output datain the communications processor of the computer, access to process data takesplace only within the local computer. Particularly when using the SIMATIC NET CP5613 over the “DP-Base” interface, this makes access extremely fast.
In some situations, for example, when using PC-based controllers, extremely fastaccess to process data is necessary.
Using OPC as COM-based client-server architecture does involve certain internalexecution times depending on the implementation of the OPC server. These resultin the main when using a local server (also known as an “out-process server”; anEXE file with its own process space) due to process changeovers and transferringthe function parameters from the client to the server (marshaling).
If the OPC server is implemented as an in-process server, the overheads forchanging processes and marshaling are avoided since the OPC server takes theform of a dynamic-link library (DLL) and runs in the process of the client.
Using an in-process server does, however, have disadvantages that cannot beignored when selecting the server:
� Only one client can use the server at any one time.
The simultaneous use of the in-process OPC server by several clients wouldmean generating the server more than once in different process spaces andwould result in simultaneous but uncoordinated access to the same hardware.As a result, only the client that starts first has access to the process data whileaccess by other clients would be denied.
� The stability of the OPC server depends on the client.
If the OPC client behaves in an uncontrolled manner and, for example causesaccess violations, the OPC server will also be affected. As a result, thecommunications module cannot be reset by the OPC server as may sometimesbe necessary. Explicit closing of the OPC server using the configurationprograms would also not be possible.
For the extremely fast DP protocol, SIMATIC NET offers an in-process server thatprovides practically the full the performance of the DP protocol for OPC clients.
When using the other connection-oriented protocols, the access time dependsprimarily on the propagation times in the network required by the communicationservices so that an in-process server is provided only for DP.
Calling the In-process Server for DP
The in-process server for DP is addressed using a separate ProgID. The ProgIDis:
OPC.SimaticNET.DP
The ProgID is specified in function calls or in the OPC clients to select a server.
OPC Process Variables for SIMATIC NET
162SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Examples of Function Calls
Visual Basic:
ServerObj.Connect (“OPC.SimaticNET.DP”)
Visual C++:
r1 = CLSIDFromProgID(L“OPC.SimaticNET.DP”, &clsid);
r1 = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER,IID_IOPCServer, (void**)&m_pIOPCServer);
4.4.4 Powerful SIMATIC NET OPC Server for the PROFIBUS-DPProtocol
Improved performance even with several clients
As described in the section above, the high-performance inproc server forPROFIBUS -DP can be used by only one client. To allow the same utilization bytwo or more clients with the same performance requirements, a secondconfiguration variant is available.
To use this variant, all underlying DP protocol libraries and the COM server asinproc server are loaded on the outproc OPC server. The protocol is handled in theprocess of the OPC server, additional execution times for changing betweenprocesses and multiprotocol mode are avoided. The process change between theOPC client and OPC server is, however, still necessary.
Configuration
This high-performance variant is activated implicitly simply by selecting the DPprotocol in the ”Configuration Console”.
OPC Process Variables for SIMATIC NET
163SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Configured OPC data exchange DX and symbols can also be selected.
Advantages / Disadvantages
Using the high-performance DP OPC server does, however, have thedisadvantage that only the DP single protocol mode is possible. On the other hand,it does have the following advantages:
� Higher performance than with multiprotocol mode.
� Simple configuration.
� Access via the ProgID OPC.SimaticNET.
� Several clients can use the server at the same time.
� The stability of the OPC server does not depend on the clients.
OPC Process Variables for SIMATIC NET
164SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.4.5 DPC1 and DPC2 Services
DP class 1 master
The DP class 1 master communicates cyclically with the DP slaves. With DPC1, a master operating cyclically can handle additional acyclic data trafficand react to interrupts from slaves.
Communication includes central functions such as:
� Configuring and assigning parameter values to the slaves
� Cyclic data transfer with the DP slaves
� Monitoring the DP slaves
� Providing diagnostic information
DP class 2 master
With DPC2, a DP class 2 master can establish additional communication relationswith the DP slaves. The DP slaves must support the DP-V1 additional functions.The most important DPC2 additional functions are as follows:
� Connection establishment
� Connection termination
� Reading data records
� Writing data records
� Transferring data
Slaves with DP-V1 Additional Functions
Slaves with DP-V1 additional functions can communicate with class 1 and class 2DP masters.
OPC Process Variables for SIMATIC NET
165SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Overview of the DP Protocol
The following figure illustrates the parts of the DP or DP-V1 protocol.
4.4.6 Process Variables for Services of a Class 1 Master
With the services for accessing cyclic data, you can access and monitor the inputsand outputs of the slaves.
Access is via:
� Slave number.This number corresponds the PROFIBUS address.
� Submodule number.DP slaves can include several submodules with different input/output areas.
� Input/output area.
OPC Process Variables for SIMATIC NET
166SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.4.7 Syntax of Process Variables for a Class 1 Master
Syntax
Inputs:
DP:[<connectionname>]slave<address>{M<number>}_I{<format><offset>{.<bit>}{,<quantity>}}
Outputs:
DP:[<connectionname>]slave<address>{M<Nummer>}_Q{<format><offset>{.<bit>}{,<quantity>}}
Explanations
DP
DP protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
slave
Indicates that a DP slave is addressed.
<address>
PROFIBUS address of the slave.
Range 0 through 126
M
Identifier for the number of the submodule that contains the input or output area.
<number>
Number of the submodule containing the input or output area.
_I
Identifier for the input. Inputs are read only.
_Q
Identifier for the output. Outputs can be read and written.
<format>
Format of the delivered data.
OPC Process Variables for SIMATIC NET
167SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Specifying the format specifies the data type.
In principle, all listed OLE data types can be read via the Automation and Custominterface of OPC. However, certain development tools such as Visual Basic onlyoffer a restricted number of data types.
The following table therefore lists the corresponding Visual Basic type in which thevariable value can be represented.
Format Identifier
Description OLE Data Type Visual Ba-sic Type
X Bit VT_BOOL Boolean
BYTE or B Byte (unsigned 8)
VT_UI1 Byte
CHAR Character (signed 8)
VT_I1 Integer
WORD or W Word (unsigned16)
VT_UI2 Long
INT Integer(signed 16)
VT_I2 Integer
DWORD or D Double word (unsigned 32)
VT_UI4 Double
DINT Double integer (unsigned 32)
VT_I4 Long
REAL Floating-pointnumber(IEEE 4 bytes)
VT_R4 Single
<Offset>
Byte offset in the address space of the slave at which the element to be addressedis located. If a submodule is specified, the offset applies within the submodule. Ifno submodule is specified, the offset relates to the entire input/output area of theslave.
<Bit>
Bit number in the addressed byte.
Specifying a bit is permitted only with the X format identifier, the range is between0 and 7.
<quantity>
Number of elements.
The data type (VT_ARRAY) of the variable is an array with elements of thespecified format. If quantity is omitted, the quantity 1 is assumed and the data typeof the variable is not an array.
Do not use the quantity parameter with the X format identifier.
OPC Process Variables for SIMATIC NET
168SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
If no submodule is specified, the variable returns the entire input or output areaover all submodules. Structured access by specifying the format and quantity isalso possible.
4.4.8 Examples of Process Variables for a Class 1 Master
Here you will find examples illustrating the syntax of variable names for DPvariables.
Inputs
DP:[CP 5613]Slave005M003_IB0
Slave005M003_IB0
Input byte 0 of submodule 3 of slave 5.
DP:[CP 5613]Slave005M003_IB1,3
Slave005M003_IB1,3
Array with 3 bytes from input byte 1 of submodule 3 of slave 5.
DP:[CP 5613]Slave005M003_ID2
Slave005M003_ID2
Double word from input byte 2 of submodule 3 of slave 5
DP:[CP 5613]Slave004M003_IReal0
Slave004M003_IReal0
Floating point number in the input area of slave 4, submodule 3.
DP:[CP 5613]Slave004_IB0,8
Slave004_IB0,8
The first 8 bytes of the entire input area of slave 4 over all submodules.
Outputs
DP:[CP 5613]Slave005M007_QB1
Slave005M007_QB1
Output byte 1 of submodule 7
OPC Process Variables for SIMATIC NET
169SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
DP:[CP 5613]Slave005M007_QX2.5
Slave005M007_QX2.5
Bit 5 in output byte 2 of slave 5, submodule 7
DP:[CP 5613]Slave004_QW0,8
Slave004_QW0,8
Array with 8 words from the output area of slave 4 over all submodules.
4.4.9 DPC1 Services
Using DPC1 services, you can access the data records of the DPC1 slaves. Thedata records are transferred acyclically.
The meaning of the data records is specified by the vendor of the slave. Theycould, for example, be used for the configuration data of a drive.
When a DPC1 variable is registered, the OPC server can only check that thesyntax is correct and not whether the variable is valid on the partner device and thesize of the data record is adequate based on the configuration of the DPC1 slave.
4.4.10 Syntax of the Process Variables for DPC1 Services
Syntax
DP:[<connectionname>]slave<address>S<slot>data<index>,<length>{,<subarea>}
Explanations
DP
DP protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
slave
Identifier for access to a slave over the DP protocol.
OPC Process Variables for SIMATIC NET
170SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
address
PROFIBUS address of the slave.
Range 0 through 126
S
Identifier for the slot of the slave, typically a submodule.
<slot>
Slot in the extended memory area of a slave for acyclic services. The slot and indexidentify a data record.
data
Identifier for access to a data record.
<Index>
Index within a slot in the extended memory area of a slave for acyclic services. Theslot and index identify a data record.
<length>
Length of the record. Range between 1 and 244.
<subarea>
The subarea is made up as follows:
formatoffset{.bit}{,quantity}
format
Format in which the data is delivered.
If no format is specified, the byte format is used.
Format Identifier
Description OLE Data Ty-pe
Visual BasicType
X Bit VT_BOOL Boolean
BYTE or B Byte (unsigned 8)
VT_UI1 Byte
CHAR Character (signed 8)
VT_I1 Integer
WORD or W Word (unsigned16)
VT_UI2 Long
INT Integer(signed 16)
VT_I2 Integer
DWORD or D Double word(unsigned 32)
VT_UI4 Double
OPC Process Variables for SIMATIC NET
171SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Format Identifier
Visual BasicType
OLE Data Ty-pe
Description
DINT Double integer (unsigned 32)
VT_I4 Long
REAL Floating pointnumber
VT_R4 Single
offset
Byte address in the data record for the element to be addressed.
bit
Bit number in the addressed byte.
A bit can only be specified with the format identifier X .
quantity
Number of elements (not permitted with X format)
The data type VT_ARRAY of the variable is an array with elements of the specifiedformat. If this part of the name is omitted, the quantity 1 is assumed and the datatype of the variable is not an array.
Note
The data length resulting from the parameters quantity and format must notexceed the size of the data record on the slave. The size of a data record dependson the particular slave and cannot be checked by the OPC server.
Note
If you define subareas, remember the following point: If you read a data record,the partner device initially always reads the entire data record. The subarea is onlyevaluated afterwards.
When writing, the entire data record is also sent to the partner device. If severalsubareas are written using a group call, all the subareas are first entered in thedata record before the data record is sent.
You should therefore group together all OPC items with alternate access to onedata record and write the entire group. Avoid overlaps and gaps since it is nototherwise possible to predict which value is written in this case.
OPC Process Variables for SIMATIC NET
172SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.4.11 Examples of Process Variables for DPC1 Services
Here you will find examples illustrating the syntax of variable names for DPC1services.
Variable Names for DPC1DP:[CP 5613]Slave005S003Data2,120,DWORD7
Slave005S003Data2,120,DWORD7
Access to the double word from offset 7 in a data record with a length of 120 bytesin slot 3, index 2 of slave 5.
DP:[CP 5613]Slave005S003Data2,120,B8,4
Slave005S003Data2,120,B8,4
Access to an array with 4 bytes from offset 8 in a data record with a length of 120bytes in slot 3, index 2 of slave 5.
4.4.12 Fast Logic for the CP 5613 and CP 5614 (Master Only)
The CP 5613 and DP master section of the CP 5614 have the Fast Logic property.This means that you can set the CP parameters so that it writes values to otherslaves as a reaction to the data change of a slave. The user application is alsoinformed of the data change.
The CP 5613/5614 provides four Fast Logic triggers that can be configured andevaluated using the OPC control variables.
Advantages of Fast Logic
Using Fast Logic has the following advantages:
� There is less load on the OPC server and OPC client.
� The data transmission is faster because it is not dependent on the softwarerunning on the CP and takes place in the hardware of the CP.
� Since the data transmission is not dependent on the PC software, a fastreaction to a change in an input signal is guaranteed.
Note
The Fast Logic property can only be used when the DP Base mode was set for theCP 5613 or CP 5614 during configuration.
OPC Process Variables for SIMATIC NET
173SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
After a fast logic trigger has been triggered, it is automatically deactivated againafterwards. You must then activate the trigger again using the FLActivate variable.
Fast logic functions correctly only when the DP master is in the OPERATE modeand the slaves involved are in the READY state. A fast logic trigger shouldtherefore only be activated by the DP application when the user program hasbrought the DP master to the OPERATE mode.
As long as fast logic triggers are active, no DP user program may write to theoutput bytes linked to input bytes with fast logic .
4.4.13 Syntax of the control variables for Fast Logic
Syntax
DP:[<connectionname>]FL<parameter><N>
Explanations
DP
DP protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
FL
Identifier for Fast Logic.
OPC Process Variables for SIMATIC NET
174SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
<parameter>
Possible values are as follows:
� State
Returns the Fast Logic status.
Return values:
� CLEARED
Trigger N is not activated.
� ACTIVATED
Trigger N is activated.
� TRIGGERED
Trigger N has executed monitoring.
OLE Data Type Visual Basic Type
VT_BSTR String
Activate
Activate can only be written.
Writing a parameter field specifies the Fast Logic property for the trigger specifiedin the ItemID.
The parameter field that is written is an array with 8 bytes and has the followingstructure:
slave_addr_in_byte
Address of the slave whose inputs are selected for the trigger
index_in_byte
Offset of the input byte of the trigger
cmp_value_in_byte
Comparison value for the input byte
mask_in_byte
You can mask individual bits in the input byte so that they are ignored in thecomparison. A bit is masked by setting the value 1; this means that ifmask_in_byte==0x00 is set, all bits of cmp_value_in_byte are used for thecomparison. The trigger is triggered when all unmasked bits in the selectedinput byte match the bits in cmp_value_in_byte.
OPC Process Variables for SIMATIC NET
175SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
slave_addr_out_byte
Selects the slave whose output byte will be changed when the trigger conditionoccurs
index_out_byte
Offset of the output byte
value_out_byte
Value of the output byte that will be written
mask_out_byte
Bits in the output byte can be masked individually so that they are not modifiedwhen the trigger condition arrives. A bit is masked by setting the value 1 ; thismeans that if mask_out_byte==0x00 is set, all bits of value_out_byte are writtento the selected output byte.
OLE Data Type Visual Basic Type
VT_ARRAY of VT_UI1 Byte()
Clear
Clear can only be written.
If the Boolean value TRUE is written, the Fast Logic trigger specified in the ItemIDis deactivated.
OLE Data Type Visual Basic Type
VT_BOOL Boolean
<N>
Number of the Fast Logic trigger being used. Value between 1 and 4.
4.4.14 DP-Specific Information Variables
The DP-specific information variables for the class 1 master are used to queryinformation on the DP master and the attached DP slaves.
You can query the following information:
� Mode of the DP master
� Event messages of the DP master
� Sign of life monitoring of the CP
� Mode of a DP slave
� The type of a DP slave
� Other information for more detailed diagnostics
OPC Process Variables for SIMATIC NET
176SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.4.15 Syntax of the DP-specific Information Variables
Syntax
DP:[<connectionname>]<informationparameter>
Explanations
DP
DP protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<informationparameter>
Possible values are as follows:
� Masterstate
� EvAutoclear
� EvWatchdog
� EvClass2Master
� WatchdogTimeout
� SlavenSlvState
� SlavenSlvDiag
� SlavenMiscSlvType
� Other slave information
Masterstate
Current mode of the DP master.
The current mode can be both written and read. Setting the mode by writing one ofthe values shown below is only possible within the context of the DP applicationenvironment.
Input and return values::
OFFLINE
No communication between master and slave.
STOP
No communication between master and slave except for diagnostic data
CLEAR
OPC Process Variables for SIMATIC NET
177SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Parameter assignment and configuration phase
AUTOCLEAR
Autoclear phase, the DP master can no longer access all slaves
OPERATE
Productive phase
OLE Data Type Visual Basic Type
VT_BSTR String
EvAutoclear
Signals an error during communication with DP slaves. The DP systemautomatically closes down and changes to the CLEAR mode.
Return values:
True
An error has occurred in communication with DP slaves and the system has closeddown and changed to the CLEAR mode
False
No error occurred
OLE Data Type Visual Basic Type
VT_BOOL Boolean
Note
You can only use EvAutoclear if AUTOCLEAR was set during configuration.
Note
If this information parameter is output, no reaction is necessary.
EvWatchdog
Signals that job monitoring timed out on the module. The OPC server has notmade a DP function call during the monitoring time. The OPC client or OPC servermay no longer be available.
You set this monitoring time in the configuration.
OPC Process Variables for SIMATIC NET
178SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Return values:
� True
Monitoring timed out on the module
� False
Monitoring did not time out on the module
OLE Data Type Visual Basic Type
VT_BOOL Boolean
EvClass2Master
Signals access by a class 2 DP master.
Return values:
True
A class 2 DP master is participating in data traffic and accessing internal diagnosticlists of the class 1 DP master
False
No class 2 DP master is involved
OLE Data Type Visual Basic Type
VT_BOOL Boolean
Note
No reaction to the event by the user program is required.
WatchdogTimeout
Watchdog on the CP. If a value is written, the watchdog can be set. The defaultvalue is set in the configuration.
Return values:
� 0
Monitoring off
� 400 - 102000
Any value in ms. The value is rounded to a multiple of 400
� 6000
Default
OPC Process Variables for SIMATIC NET
179SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
OLE Data Type Visual Basic Type
VT_UI4 Double
SlavenSlvState
Current status of the DP slaves with address n.
Return values:
� OFFLINE
No communication between master and slave
� NOT_ACTIVE
DP slave is not activated
� READY
DP slave is in the data transfer phase
� READY_DIAG
DP slave is in the data transfer phase; diagnostic data also exist
� NOT_READY
DP slave is not in the data transfer phase
� NOT_READY_DIAG
DP slave is not in the data transfer phase; diagnostic data also exist
OLE Data Type Visual Basic Type
VT_BSTR String
SlavenSlvDiag
Last diagnostic data of the DP slave with address n. The structure of the diagnosticdata is slave-specific and can be found in the documentation of the slave.
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte()
SlavenMiscSlvType
Type of the DP slave with address n.
Return values:
� NO_SLV
No DP slave
� NORM
Standard DP slave
� ET200_U
OPC Process Variables for SIMATIC NET
180SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Non-standard slave: ET 200 U
� ET200K_B
Non-standard slave: ET 200 K/B
� ET200_SPM
Non-standard slave: General SPM station
� UNDEFINED
Unknown DP slave
OLE Data Type Visual Basic Type
VT_BSTR String
Other slave information
The following slave-specific information parameters are not intended for productivecommunication. If problems occur, it may, nevertheless, be useful to evaluate thevariables listed below.
All variables are generally assigned directly to low level DP services. Thesevariables are read in the same way as other information variables. The result of thecall is the byte dump of the particular low level DP service.
SlavenMiscReadSlvParCfgData
Configuration data of the slave at address n for describing the input and outputdata areas and the data consistency
SlavenMiscReadSlvParUserData
Application data of slave n (part of the parameter file)
SlavenMiscReadSlvParPrmData
Parameter assignment data of slave n
SlavenMiscReadSlvParType
SI flag and type of slave n (slave-related flags, slave type and other reserveddata)
SlavenMiscSlvDiag
Diagnostic data of slave n
OPC Process Variables for SIMATIC NET
181SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.4.16 PROFIDrive
Introduction
The following section describes the variables of the SIMATIC NET PROFIDrivebus server. This server is used to link devices using the DP protocol.
4.4.17 Protocol ID
To comply with the profile server specification, all items begin with the prefix DP2://
Note
In contrast to the other protocols, no square brackets are used with PROFIDrive.
The item ID for PROFIDrive is made up as follows:
DP2://<Devicename>/<Variablename>
4.4.18 Device Name
The board number specifies the slot of the board in the in the Station ConfigurationEditor of the PC station (virtual slot). The board number is configured withSIMATIC NCM.
SyntaxDP2://brd<n>.seg<s>/&lifelist()
Explanation
brd
Identifier indicating that a board will be addressed.
n
Number of the configured board. The board number is configured with SIMATICNCM. The configured board number is made available by the Configuration Serverusing the CP name. Range: 1-32
OPC Process Variables for SIMATIC NET
182SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
seg
Identifier indicating that a segment will be addressed.
s
PROFIBUS segment number of the board. Currently always 0.
&lifelist()
Returns a list with all the connected bus nodes.
Data type: VT_ARRAY
Description: 127 array elements (0-126)
Access right: Read-only
OLE data type: VT_UI1
Each array element stands for a PROFIBUS station address and the array indexcorresponds to the PROFIBUS address. The values of the array elements have the following meaning:
Va-lue
Meaning
0x00 STATION_PASSIVE
0x10 STATION_NON_EXISTENT
0x20 STATION_ACTIVE_READY (ready to enter the logical ring)
0x30 STATION_ACTIVE (already in the logical ring)
This item is used for information and diagnostic purposes and is not used by theprofile server.
4.4.19 Addressing the Bus Node (Slave)
Introduction
The following section describes the various forms of syntax with which you canaccess the data of a PROFIDrive device:
OPC Process Variables for SIMATIC NET
183SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SyntaxDP2://brd<n>.seg<s>.dev<address>/
Explanation
dev
Identifier for the bus node (device).
address
Specifies the PROFIBUS station address of the bus node. The bus node does not necessarily need to be attached to PROFIBUS for the itemto be created and used (possibly with an access error). Range: 1-32
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_Vendor-Name
Explanation
DS_Vendor-Name
Item of the bus node. Service for recognition of a bus node by the profile server.
Data type: VT_BSTR
Access right: Read-only
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/Timeout
Explanation
DS_MSAC2_Parameter/Timeout
Items of the bus node (access control). DS_MSAC2_Parameter/Timeout monitoring in ms read or write access to MSAC2items.
Data type: VT_I4
Access right: Read-write
OPC Process Variables for SIMATIC NET
184SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/ConnectionStatus
Explanation
DS_MSAC2_Parameter/Connection Status
Items of the bus node (access control). DS_MSAC2_Parameter/Timeout connection status MSAC2.
Data type: VT_I2
Access right: Read-only
Va-lue
Meaning
1 CONNECTED Connection is open
0 NO_CONNECTION Connection not yet established. The SIMATIC NET OPC Serverhas not yet made an unsuccessful attempt. The connection sta-tus NO_CONNECTION is only achieved again when the clienthas released all items with which there is productive communica-tion, for example, items for MSAC2_Read/Write, MSAC2_Data-Transport or drives.
-1 SLAVE_NOT_PRESENT Connection could not be established or is interrupted. Slave doesnot respond. Without read/write jobs for the slave, a problem (forexample, disconnecting from the cable) cannot be detected andinitially has no effect on the item, in other words, the connectionstatus may remain “CONNECTED”.
-2 NO_RESOURCES Slave allows no more new connections (for example, no newSAPs are available).
-3 TIMEOUT Timeout accessing the slave.
OPC Process Variables for SIMATIC NET
185SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SendTimeout
Explanation
DS_MSAC2_Parameter/SendTimeout
Items of the bus node (Initiate parameter of the master). These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here. Time monitoring in ms for connection establishment to the slave. Evaluated insteps of 10 ms.
Data type: VT_I4
Access right: Read-write
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/MA_Features_Supported_1
Explanation
DS_MSAC2_Parameter/MA_Features_Supported_1
Items of the bus node (Initiate parameter of the master). These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here. Function parameter of the master in MSAC2_Initiate.
Data type: VT_UI1
Access right: Read-write
Default 1
OPC Process Variables for SIMATIC NET
186SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/MA_Features_Supported_2
DP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/MA_Profile_Features_Supported_1
DP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/MA_Profile_Features_Supported_2
Explanation
DS_MSAC2_Parameter/MA_Features_Supported_2DS_MSAC2_Parameter/MA_Profile_Features_Supported_1DS_MSAC2_Parameter/MA_Profile_Features_Supported_2
Items of the bus node (Initiate parameter of the master).These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here.Function parameter of the master in MSAC2_Initiate.
Data type: VT_UI1
Access right: Read-write
Default 0
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/MA_ProfileIdentNumber
Explanation
DS_MSAC2_Parameter/MA_ProfileIdentNumber
Items of the bus node (Initiate parameter of the master).These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here.Function parameter of the master in MSAC2_Initiate.
Data type: VT_UI2
Access right: Read-write
Default 0
OPC Process Variables for SIMATIC NET
187SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SL_Features_Supported_1
DP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SL_Features_Supported_2
DP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SL_Profile_Features_Supported_1
DP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SL_Profile_Features_Supported_2
Explanation
DS_MSAC2_Parameter/SL_Features_Supported_1 DS_MSAC2_Parameter/SL_Features_Supported_2 DS_MSAC2_Parameter/SL_Profile_Features_Supported_1 DS_MSAC2_Parameter/SL_Profile_Features_Supported_2
Items of the bus node (Initiate parameter of the slave).These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here. These items have thequality OPC_QUALITY_GOOD only as long as the MSAC2 connection exists.Function parameter of the slave in MSAC2_Initiate.
Data type: VT_UI1
Access right: Read-only
SyntaxDP2://brd<n>.seg<s>.dev<address>/DS_MSAC2_Parameter/SL_ProfileIdentNumber
Explanation
DS_MSAC2_Parameter/SL_ProfileIdentNumber
Items of the bus node (Initiate parameter of the slave).These items are managed separately for each server object; in other words,different clients can have different values for these parameters and have their ownMSAC2 connection to the addressed slaves. If a client creates several serverobjects, these items are also managed separately here. These items have thequality OPC_QUALITY_GOOD only as long as the MSAC2 connection exists.Function parameter of the slave in MSAC2_Initiate.
Data type: VT_UI2
OPC Process Variables for SIMATIC NET
188SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Access right: Read-only
SyntaxDP2://brd<n>.seg<s>.dev<address>/SlotI<slot>S<index>{D8209}
Explanation
Items for addressing MSAC2_Read/Write.
Data type: VT_ARRAY
OLE data type: VT_UI1
Specifying the format with D8209 is optional.
SlotI
Identifier for the slot of the slave, typically a submodule.
slot
Slot in the extended memory area of a slave. Slot and index identify a data record.To access PROFIDrive parameters, slot 0 is normally used. Range: 0 through 254
S
Identifier for the slot of the slave, typically a submodule.
index
Index of the data in the slave slot. To access PROFIDrive parameters, index 47 isnormally used. Range: 0 through 254
SyntaxDP2://brd<n>.seg<s>.dev<address>/SlotI<slot>S<index>{D8209}xDT
Explanation
Items for addressing MSAC2_DataTransport.The DPC2 items have read/write access. New data is transferred and result datais received in the protocol acknowledgment. Read access of these items is localand returns the data record obtained with last write access.
The quality of the item only has the value “good” when valid data have beenreceived following a write.
Data type: VT_ARRAY
OLE data type: VT_UI1
OPC Process Variables for SIMATIC NET
189SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Specifying the format with D8209 is optional.
4.4.20 Syntax of the System-Specific Information Variables
SyntaxDP2://&version()
Explanation
Returns a version ID for the PROFIDrive OPC Server, here, for example, the string
SIMATIC NET Core Server PD V 6.xxxx.yyyy.zzzz Copyright 2002
Data type: VT_BSTR
Access right: Read-only
4.4.21 DP Class 2 Master Services
DP class 1 master
The DP class 1 master communicates cyclically with the DP slaves.Communication includes central functions such as:
� Configuring and assigning parameter values to the slaves
� Cyclic data transfer with the DP slaves
� Monitoring the DP slaves
� Providing diagnostic information
OPC Process Variables for SIMATIC NET
190SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
DP class 2 master
A DP class 2 master can handle configuration tasks and online diagnostics. Theessential DP class 2 master functions are:
� Reading the input and output data of a slave
� Reading the diagnostic data of a slave
� Reading the slave configuration
� Writing data records for a slave
� Reading the class 1 master diagnostic data
With the services for accessing cyclic data, you can read and monitor the inputsand outputs of the slaves and their diagnostic data. The DP slaves must supportthe DP-V1 additional functions. You can also access the data of a class 1 master.
Variables are accessed
� via the PROFIBUS address of the slave. Slave devices cannot initiatecommunication themselves. They do not receive the token and respond only topolls from the master. Slaves are therefore known as passive nodes. Thisnumber corresponds the PROFIBUS address.
� via the PROFIBUS address of the master Access to the data of a class 1master from a class 2 master.
to the required data of the slave or class 1 master.
4.4.22 Syntax of the DP Class 2 Master Services
Protocol ID
All items begin with the prefix: DP2:
4.4.23 Name of the CP
The configured CP name specifies the communications processor used (CP).
OPC Process Variables for SIMATIC NET
191SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SyntaxDP2:[<configuredCPname>]
Explanation
configuredCPname
The configured CP name is configured with SIMATIC NCM.
Example
DP:[CP5613]
4.4.24 Addressing a Bus Node (DP Class 1 Master)
Introduction
The following section describes the various forms of syntax with which you canaccess the data of a DP class 1 master:
DP2 Items of the Bus Node
master
Identifier for access to a master using the DP protocol.
masteraddress
PROFIBUS station address of the bus node.Range: 0 through 126
SyntaxDP2:[<configuredCPname>]master<masteraddress>MstDiag
ExplanationDP2 items of the bus node - Item for master diagnostics
MstDiag
Last system diagnostic data of the DP master
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_BOOL
OPC Process Variables for SIMATIC NET
192SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Description: 126 elements
Each element in the array signals whether the assigned slave has sent diagnosticdata; the array index corresponds to the PROFIBUS address.
Value Meaning
FALSE The slave has not sent diagnostic data
TRUE The slave has sent diagnostic data
SyntaxDP2:[<configuredCPname>]master<masteraddress>MstState
ExplanationDP2 items of the bus node - Master diagnostic items
MstState
Status of the DP master. Contains the current status and some version information.
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_UI1
Description: 16 elements
Byte Description
1 Operating status 0x40 – STOP 0x80 – CLEAR 0xC0 – OPERATE
2 and 3 Ident number
4 Version of the hardware (DDLM/user interface)
5 Version of the software (DDLM/user interface)
6 Version of the hardware
7 Version of the software
8 to 16 Reserved
OPC Process Variables for SIMATIC NET
193SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SyntaxDP2:[<configuredCPname>]master<masteraddress>DataTransferList
Explanation DP2 items of the bus node - Master diagnostic items
DataTransferList
Data transfer list of the DP master.
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_BOOL
Description: 126 elements
Each element in the array signals whether the assigned slave is in the productivephase and has sent data; the array index corresponds to the PROFIBUS address.
Value Description
FALSE Slave is not in the data transfer phase
TRUE Slave is in the data transfer phase
SyntaxDP2:[<configuredCPname>]master<masteraddress>Slave<address>SlvDiag
ExplanationDP2 items of the bus node - Master diagnostic items
address
PROFIBUS station address of the bus node. The bus node does not necessarilyneed to be attached to PROFIBUS for the item to be created and used (possiblywith an access error).
Range: 0 through 126
The SIMATIC NET OPC Server can only recognize whether the addressed busnode is actually DP-compliant after a slave service has executed successfully.With critical bus nodes that may react incorrectly to such services, the creation ofthe corresponding items is responsibility of the user.
SlvDiag
Last diagnostic data of the DP slave stored on the DP master.
Data type: VT_ARRAY
OPC Process Variables for SIMATIC NET
194SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Access right: Read-only
OLE data type: VT_UI1
4.4.25 Addressing the Bus Node (Slave)
Introduction
The following section describes the various forms of syntax with which you canaccess the data of a master:
DP2 Items of the Bus Node
slave
Identifier for access to a slave over the DP protocol.
address
PROFIBUS station address of the bus node. The bus node does not necessarilyneed to be attached to PROFIBUS for the item to be created and used (possiblywith an access error).
Range: 0 through 126
The SIMATIC NET OPC Server can only recognize whether the addressed busnode is actually DP-compliant after a slave service has executed successfully.With critical bus nodes that may react incorrectly to such services, the creation ofthe corresponding items is responsibility of the user.
SyntaxDP2:[<configuredCPname>]slave<address>S<slot>data<index>,<length>{,subarea}
Where subarea = <format><offset{.bit}>{,quantity}
Explanation DPC2 items of the bus node - DPC2 Read/Write
S
Identifier for the slot of the slave, typically a submodule.
slot
Slot in the extended memory area of a slave. Slot and index identify a data record.
Range: 0 through 254
OPC Process Variables for SIMATIC NET
195SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
data
Identifier for a data record.
index
Index of the data in the slave slot.
Range: 0 through 254
length
Length of the record.
Range: 1 through 240
subarea
Identifier for a subarea.
format
The “format“ element specifies the format in which the data will be delivered.Specifying the format also specifies the data type.
Format iden-tifier
Description OLE DataType
Visual Basicdata type
X Bit VT_BOOL VT_BOOL
BYTE or B Byte (unsigned 8) VT_UI1 VT_UI1
CHAR Character (signed 8)
VT_I1 VT_I2
WORD or W Word (unsigned 16) VT_UI2 VT_I4
INT Integer (signed 16) VT_I2 VT_I2
DWORD or D Double word (unsigned 32)
VT_UI4 VT_CY
DINT Double integer (signed 32)
VT_I4 VT_I4
REAL Floating point num-ber
VT_R4 VT_R4
offset{.bit}
Offset in bytes of the element to be accessed. A bit can only be specified with thetype X .
Example: X2.3 returns the 3rd bit of the 2nd byte.
quantity
Number of elements. The data type of the variable is an array with elements (datatype VT_ARRAY) of the specified format. If this part of the name is omitted or
OPC Process Variables for SIMATIC NET
196SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
specified as quantity 1, the quantity 1 is assumed and the data type of the variableis not an array.
When a subarea of the data record is read, the partner device first reads the entiredata record and then evaluates the relevant subarea.
When a subarea is written, the entire data record is also transferred to the partnerdevice. If several subareas of the data record are written in a write job, the datarecord is only written to the partner device after all the subareas of the data recordhave been updated.
When using the OPC server, it makes sense to put all the items with partial accessto a particular data record together in one group and to write the entire group.Overlaps or gaps resulting from subareas when writing should be avoided, thevalues actually written to the areas involved cannot be foreseen deterministically.
SyntaxDP2:[<configuredCPname>]slave<address>DTS<slot>data<index>,<length>{,subarea}
Where subarea = <format><offset{.bit}>{,quantity}
Explanation DPC2 items of the bus node - DPC2 data transport
The DPC2 data transport items have read/write access. If no subarea is specified,the data type is as follows:
Data type: VT_ARRAY
OLE data type: VT_UI1
This item implements a data exchange in the protocol. Read access of these itemsis local and returns the data record obtained with last write access.
DTS
Identifier for data transport.
slot
Slot in the extended memory area of a slave. Slot and index identify a data record.
Range: 0 through 254
offset{.bit}
Offset in bytes of the element to be accessed. A bit can only be specified with thetype X .
Example: X2.3 returns the 3rd bit of the 2nd byte.
OPC Process Variables for SIMATIC NET
197SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
quantity
Number of elements. The data type of the variable is an array with elements (datatype VT_ARRAY) of the specified format. If this part of the name is omitted, or thenumber 1 is specified, the number 1 is assumed and the data type of the variableis not an array.
When a subarea of the data record is read, the subarea of the last data recordreceived from the partner device is evaluated.
When a subarea is written, the entire data record is also transferred to the partnerdevice. If several subareas of the data record are written in a write job, the datarecord is only written to the partner device after all the subareas of the data recordhave been updated.
When using the OPC server, it makes sense to put all the items with partial accessto a particular data record together in one group and to write the entire group.Overlaps or gaps resulting from subareas when writing should be avoided, thevalues actually written to the areas involved cannot be foreseen deterministically.
SyntaxDP2:[<configuredCPname>]slave<address>SlvDiag
Explanation DPMCL2 items of the bus node - Slave diagnostic items
SlvDiag
Last diagnostic data of the DP slave
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_UI1
SyntaxDP2:[<configuredCPname>]slave<address>SlvCFGData
Explanation DPMCL2 items of the bus node - Slave diagnostic items
SlvCFGData
Configuration data of the DP slave stored on the DP master
Data type: VT_ARRAY
OPC Process Variables for SIMATIC NET
198SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Access right: Read-only
OLE data type: VT_U I1
SyntaxDP2:[<configuredCPname>]slave<address>SetSlaveAddress
Explanation DPMCL2 items of the bus node - Slave diagnostic items
SetSlaveAddress
Sets a new PROFIBUS address for the slave
Data type: VT_ARRAY
Access right: Write-only
OLE data type: VT_VARIANT
When writing the item, the corresponding DPMCL2 service is executed. The valueto be written also contains an array with the parameters necessary for executingthe service.
Arrayele-ment
Data type Meaning
1 VT_UI1 New slave address to be assigned
2 VT_BOOL Flag indicating whether or not the DP slaveaddress can be changed again at a laterpoint in time.
3 VT_I4 Device type (PROFIBUS Ident number) ofthe node
4 VT_ARRAY |VT_UI1
User-specific data. An empty array can betransferred.
After writing the new slave address successfully, it may be necessary to create newitems for the slave. The items with the old slave address (for exampleDPMCL2_I/O Items) continue to access the slave at the old address and cantherefore no longer be read successfully.
SyntaxDP2:[<configuredCPname>]slave<address>_E{<format><offset{.bit}>{,quantity}}
or (English)DP2:[<configuredCPname>]slave<address>_I{<format><offset{.bit}>{,quantity}}
OPC Process Variables for SIMATIC NET
199SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanation DPMCL2 items of the bus node - Slave I/O items
<address>_E <address>_I
The inputs and the outputs can only be read by the OPC client of the SIMATIC NETOPC server.
The submodules and the data size (byte or word) as assigned in the definedconfiguration and the consistency are ignored by the DP class 2 master. Thisdistinguishes it from a DP class 1 master. Although the DP class 2 master canquery the configuration of the slave during runtime, the slave and correspondingDP class 1 master can nevertheless change its configuration during runtimewithout informing the DP class 2 master. The result of this is inconsistentconfiguration data even if time-consuming polling of the configuration data isimplemented (not forgetting the considerable load on the network).
An I/O area is accessed by specifying the slave number <address> and the I/Oarea, where “_I” identifies the input area. If the optional format information isomitted, the data will be returned as an array of bytes with the entire length of theinputs.
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_UI1
format
The “format“ element specifies the format in which the data will be delivered. If noformat is specified, the “byte” format is used. Specifying the format also specifiesthe data type.
Format identi-fier
Description OLE datatype
Visual Basicdata type
X Bit VT_BOOL VT_BOOL
BYTE or B Byte (unsigned 8) VT_UI1 VT_UI1
CHAR Character (signed8)
VT_I1 VT_I2
WORD or W Word (unsigned16)
VT_UI2 VT_I4
INT Integer (signed 16) VT_I2 VT_I2
DWORD or D Double word (unsigned 32)
VT_UI4 VT_CY
DINT Double integer (si-gned 32)
VT_I4 VT_I4
REAL Floating pointnumber
VT_R4 VT_R4
OPC Process Variables for SIMATIC NET
200SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
offset{.bit}
Offset in bytes of the element to be accessed (offset addressing). A bit can onlybe specified with the type X . The offset is specified in bytes.
Example: X2.3 returns the 3rd bit of the 2nd byte.
quantity
Number of elements. The data type of the variable is an array with elements (datatype VT_ARRAY) of the specified format. It is not possible to specify the numberfor the format X.
If this part of the name is omitted, or the number 1 is specified, the number 1 isassumed and the data type of the variable is not an array.
Syntax
When accessing the outputs in the I/O area of a slave, the slave variable musthave the following syntax:
DP2:[<configuredCPname>]slave<address>_A{<format><offset{.bit}>{,quantity}}
or (English)DP2:[<configuredCPname>]slave<address>_Q{<format><offset{.bit}>{,quantity}
Explanation DPMCL2 items of the bus node - Slave I/O items
An I/O area is accessed by specifying the slave number <address> and the I/Oarea, where “_Q” identifies the output area. If the optional format information isomitted, the data will be returned as an array of bytes with the entire length of theinputs.
Data type: VT_ARRAY
Access right: Read-only
OLE data type: VT_UI1
OPC Process Variables for SIMATIC NET
201SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.4.26 Items for the CP
SyntaxDP2:[<configuredCPname>]&lifelist()
Explanation
&lifelist()
General Items
Returns a list with all the connected bus nodes.
Data type: VT_ARRAY
Description: 127 array elements (0-126)
Access right: Read-only
OLE data type: VT_UI1
Each array element stands for a PROFIBUS station address. The values of thearray elements have the following meaning:
Element Meaning
0x00 STATION_PASSIVE
0x10 STATION_NON_EXISTENT
0x20 STATION_ACTIVE_READY (ready to enter the logical ring)
0x30 STATION_ACTIVE (already in the logical ring)
4.4.27 Examples of DP-Specific Information Variables
Here, you will find several examples of return values of DP-specific informationvariables.
DP Master ModeDP:[CP 5613]MasterState
MasterState
can, for example, return the following value:
OPERATE The DP master is in the productive phase.
OPC Process Variables for SIMATIC NET
202SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Current Status of a SlaveDP:[CP 5613]Slave3SlvState
Slave3SlvState
can, for example, return the following value:
READY The DP slave with address 3 is in the data transfer phase.
Slave TypeDP:[CP 5613]Slave3MiscSlvType
Slave3MiscSlvType
can, for example, return the following value:
ET200_U Slave 3 is an ET 200 U.
4.4.28 Variable Services for Access to Local Slave Data
The OPC Server for SIMATIC NET can operate in a PROFIBUS DP network notonly as a DP master but also in the role of DP slave. The OPC server managesmemory areas for the inputs and outputs of the DP slave and maps them to OPCvariables. An OPC client can read the outputs set by the master and set values inthe inputs that will be fetched by the master in the next cycle.
DP slaves have a modular structure. A DP slave can include several submoduleswith different input/output areas. The submodules are assigned duringconfiguration.
The variable name identifies an input or output area in the submodule of a slave.The inputs and outputs of the slave are accessed by specifying the submodulenumber and the input or output area.
Status information of the slaves and the DP master can also be queried usingvariable names.
Note
Parallel operation of the DP master and DP slave with the CP 5614 module ispossible only when the DP Base mode was set during configuration.
OPC Process Variables for SIMATIC NET
203SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.4.29 Syntax of the process variables for the DP slave
Syntax
Inputs
DP:[<connectionname>]slave{M<number>}_I{<format><offset>{.<bit>}{,<quantity>}}
Outputs
DP:[<connectionname>]slave{M<number>}_Q<format><offset>{.<bit>}{,<quantity>}
Explanations
DP
Protocol for access to the process variables.
<connectionname>
Name of the communications module specified in the configuration.
slave
Identifier for access to a slave over the DP protocol.
M
Identifier for the number of the submodule.
<number>
Number of the submodule containing the input or output area.
_I
Identifier for the input.
_Q
Identifier for the output.
<format>
Format in which the data is delivered.
Specifying the format also specifies the data type.
All specified OLE data types can be read via the automation interface of OPC.However, certain development tools (for example Visual Basic) only offer arestricted number of data types. The following table therefore lists thecorresponding Visual Basic type in which the variable value can be represented.
OPC Process Variables for SIMATIC NET
204SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
FormatIdentifier
Description OLE data type Visual BasicType
X Bit VT_BOOL Boolean
BYTE or B Byte (unsigned8)
VT_UI1 Byte
CHAR Character (signed 8)
VT_I1 Integer
WORD or W Word (unsigned16)
VT_UI2 Long
INT Integer (signed16)
VT_I2 Integer
DWORD or D Double word(unsigned 32)
VT_UI4 Double
DINT Double integer (unsigned 32)
VT_I4 Long
REAL Floating pointnumber
VT_R4 Single
<offset>
Byte address in the address space of the slave at which the element to beaddressed is located.
<bit>
Bit number in the addressed byte. The range is between 0 and 7.
A bit can only be specified with the format identifier X.
<quantity>
Number of elements.
The data type (VT_ARRAY) of the variable is an array with elements of thespecified format.
If quantity is omitted, the quantity 1 is assumed and the data type of the variableis not an array.
Do not use the quantity parameter with the X format identifier.
OPC Process Variables for SIMATIC NET
205SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.4.30 Examples of Process Variables for the DP Slave
Here you will find examples illustrating the syntax of variable names for DPSvariables.
Inputs
DP:[CP 5611]SlaveM003_IB0
SlaveM003_IB0
Input byte 0 (offset 0) in submodule 3 of the DP slave.
DP:[CP 5611]SlaveM003_IB1,3
SlaveM003_IB1,3
An array with 3 bytes starting at input byte 1 (offset 1) in submodule 3 of the DPslave.
DP:[CP 5614]SlaveM003_IX0.0
SlaveM003_IX0.0
Input bit 0 in byte 0 in submodule 3 of the DP slave.
DP:[CP 5614]SlaveM003_IB3,8
SlaveM003_IB3,8
An array with 8 input bytes starting at offset 3 in submodule 3 of the DP slave.
Outputs
DP:[CP 5611]SlaveM003_QW3
SlaveM004_QW3
An output word at address 3 in submodule 4 of the DP slave.
DP:[CP 5611]SlaveM003_QDWORD2
SlaveM003_QDWORD2
An output double word at address 2 in submodule 3 of the DP slave.
DP:[CP 5614]SlaveM003_QX3.7
Slave_QX3.7
An output bit 7 in byte 3 of the DP slave.
OPC Process Variables for SIMATIC NET
206SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
DP:[CP 5614]SlaveM001_QW0,4
SlaveM001_QW0,4
An array with 4 output words in submodule 1 of the DP slave.
4.4.31 DP Slave-Specific Information Variables
For DP slave diagnostics, there are several predefined information variables.
4.4.32 Syntax of the DP Slave-Specific Information Variables
Syntax
You have two options:
DP:[<connectionname>]&<diagnosticitem>
DP:[<connectionname>]<parameteritem>
Explanations
DP
Protocol for access to the process variables.
<connectionname>
Name specified in the configuration of the communications module.
<diagnosticitem>
Predefined item.
You have the following option:
devicestate
State of the module on which the DP slave is located.
The following states are possible:
� ONLINE
� OFFLINE
OPC Process Variables for SIMATIC NET
207SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
parameteritem
Predefined parameter items.
The available options are as follows:
SlaveMiscReadSlvParCfgData
Configuration data of the slave.
SlaveSlvState
State of the slave
The following states are possible:
� DATA_EXCHANGE
� NO_DATA_EXCHANGE
4.5 S7 Communication
The S7 protocol for PROFIBUS and Industrial Ethernet is used for communicationbetween system components within the SIMATIC S7 programmable controller andfor communication between SIMATIC S7 system components and programmingdevices or PCs.
Properties of S7 Communication with OPC
The OPC server from SIMATIC NET has the following characteristics:
� Variable services
Access to and monitoring of S7 variables.
� Buffer-oriented services
Program-controlled transfer of larger blocks of data.
� Server functionality
In buffer-oriented services, the PC can also be used as server.
� Block management services
Transfer of a loadable data area from and to S7.
� S7 password functions
Setting a password to access protected blocks.
� Events
Processing S7 messages (S7 alarms) as OPC Alarms & Events.
OPC Process Variables for SIMATIC NET
208SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.5.1 Powerful SIMATIC NET OPC Server for the S7 Protocol
Introduction
The section below describes a configuration variant for the S7 protocol that meetsrequirements for higher performance. To use this variant, all underlying S7 protocollibraries and the COM server as inproc server are loaded on the outproc OPCserver. The protocol is handled in the process of the OPC server, additionalexecution times for changing between processes and multiprotocol mode areavoided. The process change between the OPC client and OPC server is,however, still necessary.
configuration
This high-performance variant is activated implicitly simply by selecting the S7protocol in the ”Configuration Console”.
Configured OPC data exchange DX and symbols can also be selected.
Advantages / Disadvantages
Using the high-performance S7 OPC server does, however, have thedisadvantage that only the S7 single protocol mode is possible. On the other hand,it does have the following advantages:
� Higher performance than with multiprotocol mode.
� Simple configuration.
� Access via the ProgID OPC.SimaticNET.
� Several clients can use the server at the same time.
OPC Process Variables for SIMATIC NET
209SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
� The stability of the OPC server does not depend on the clients.
4.5.2 Protocol ID
The protocol ID for the S7 protocol is S7.
4.5.3 Connection Names
The connection name is the name configured in STEP 7 to identify the connection.In STEP 7, this name is known as the local ID. The local ID is unique within theOPC server.
The OPC server supports the following connection types:
� S7 connection
� Fault-tolerant S7 connection
Note
Compatibility with version 2.2 and earlier - please note the following:
In older versions, the connection information was made up of the information forthe S7 connection, the VFDs, and the communications processor. These elementscontinue to be accepted in the ItemID of the variables but are no longer displayedin OPC Browsing. If several VFDs were used by the OPC server in aconfiguration, these can be configured in STEP 7 solely for reasons ofcompatibility.
Examples of Connection Names
Typical examples are:
S7-connection-1
S7-OPC-connection
my_connection
4.5.4 Variable Services
Variable services allow access to and monitoring of S7 variables on theprogrammable controller. S7 variables are addressed symbolically. The type ofaccess is oriented on the notation of the S7 tools.
OPC Process Variables for SIMATIC NET
210SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Objects on the Programmable Controller
The OPC server supports the following objects:
� Data blocks
� Instance data blocks
� Inputs
� Outputs
� Peripheral inputs
� Peripheral outputs
� Memory bits
� Timers
� Counters
Some S7 programmable controllers do not support all object types.
4.5.5 Syntax of the Process Variables for S7 Variable Services
Syntax
You have three options:
S7:[<connectionname>]DB<no>,{<type>}<address>{,<quantity>}
S7:[<connectionname>]DI<no>,{<type>}<address>{,<quantity>}
S7:[<connectionname>]<object>{<type>}<address>{,<quantity>}
Explanations
S7
S7 protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
DB
Data block Identifier for an S7 variable from a data block.
DI
Instance data block Identifier for an S7 variable from an instance data block.
OPC Process Variables for SIMATIC NET
211SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<Nr>
Number of the data block or instance data block.
<object>
Specifies the block/area type on the S7 PLC.
Possible values are as follows:
I Input
Q Output
PI |Peripheral input
PQ Peripheral output
M Memory bits
T Timers
C Counters
Time Base and Range of Values for S7 Timer Variables (Type T):
The range of values of OPC process variables for S7 of the type timer (T) is decimalcoded in ms. Multiples of 10,000 ms, 1,000 ms, 100 ms, and 10 ms determine thetime base in this order. The ranges of values are obtained from this time base anda factor of 1 through 999:
Possible Values TimeBase
Comment
10,000 through 9,990,000ms
10,000 ms The values must be a multipleof 10,000 ms.
1,000 ms through 999,000 ms 1,000 ms The values must be a multipleof 1,000 ms.
100 ms through 99,900 ms 100 ms The values must be a multipleof 100 ms.
10 ms through 9,990 ms 10 ms The values must be a multipleof 10 ms. A smaller time baseis not possible. 0 ms is per-mitted but has no function.
Range of Values of S7 Counter Variables (Type C):
The range of values of OPC process variables for S7 of the type counter (C) is 0through 999 decimal coded.
<type>
S7 Data Type
An S7 data type is converted to the corresponding OLE data type in the OPCserver.
All specified OLE data types can be read via the automation interface of
OPC Process Variables for SIMATIC NET
212SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OPC.However, certain development tools (for example Visual Basic) only offer arestricted number of data types. The following table therefore lists thecorresponding Visual Basic type in which the variable value can be represented.
For objects of the types T and C, no type can be specified.
Format Identifier
Description OLE Data Type VisualBasic Ty-pe
X Bit (bool).
You must speci-fy the bit number(0 through 7).
VT_BOOL Boolean
B Byte (unsigned) VT_UI1 Byte
W Word (unsigned) VT_UI2 Long
D Double word(unsigned)
VT_UI4 Double
CHAR Byte (signed) VT_I1 Integer
INT Word (signed) VT_I2 Integer
DINT Double word (si-gned)
VT_I4 Long
REAL Floating pointnumber
VT_R4 Single
STRING String.You must speci-fy the stringlength.
VT_BSTR String
DT Date and time, 8bytes BCD for-mat
VT_DATE Date
TIME Time value (si-gned), IEC for-mat, in ms
VT_I4 Long
TOD Time of day (un-signed),0 ... 86399999ms
VT_UI4 Double
The data types CHAR, INT, DINT, and REAL can be used only in a data block (DB)or in an instance data block (DI).
OPC Process Variables for SIMATIC NET
213SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<address>
Address of the first variable to be addressed. Possible values are as follows:
� Byte offset
� Byte offset. Bit (only for data type X)
� Byte offset. String length (only for data type string, string length 1 bytethrough 254 bytes)
<quantityl>
Quantity of variables of a type to be addressed starting at the offset specified inthe address parameter.
For the objects T and C, no quantity can be entered.
For data type X, the quantity can only be entered in multiples of 8. The bit addressmust then be zero.
Example: S7:[S7-OPC-1]DB1,X10.0,64
4.5.6 Examples of Process Variables for S7 Variable Services
Here you will find examples illustrating the syntax of variable names for variableservices.
Data Block Parameter
S7:[S7-connection-1]DB5,B12
DB5,B12
identifies data byte 12 in data block 5.
Instance Data Block Parameter
S7:[S7-connection-1]DI5,W10,9
DI5,W10,9
identifies 9 data words starting at byte address 10 in instance data block 5.
Objects Parameter
S7:[S7-connection-1]IB0
IB0
identifies input byte 0.
OPC Process Variables for SIMATIC NET
214SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.5.7 Buffer-oriented Services
Buffer-oriented services allow program-controlled transfer of larger blocks of data.Data transfer is implemented with variables:
� Variables that send blocks of data
� Variables that receive blocks of data
Up to 65534 bytes of payload data can be transferred regardless of the size of thePDU. The segmentation of the data is handled by the functions themselves.
Note
Buffer-oriented services can only be used on two-ended connections. Theconnection configuration must be downloaded to the S7 programmable controller.
4.5.8 Syntax of the Process Variables for Buffer-Oriented Services
Syntax
You have two options:
S7:[<connectionname>]BRCV,<RID>{,{<type>}<address>{,<quantity>}}
S7:[<connectionname>]BSEND<length>,<RID>{{<type>}<address>{,<quantity>}}
Explanations
S7
S7 protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
BRCV
BRCV contains the last block of data received from the partner.
The content and length of the received data are specified by the sending partner.
The variable is read-only.
OPC Process Variables for SIMATIC NET
215SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Use these variables for monitoring. The reception of a block of data by the OPCserver is then signaled to an OPC client application.
An explicit job to read these variables returns when the connection times out (timespecified in the configuration for the specific connection) or a block of data isreceived.
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte()
BSEND
BSEND contains the block of data to be sent to a partner device.
The block of data is sent to the partner only when the variable is written. A readgets the content of the last successfully transferred block of data.
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte()
<length>
Length in bytes of the block of data to be sent.
<RID>
ID of the addressing parameter. This set is for a block pair (BSEND/ BRCV) anduniquely defined within a connection.
You can send several BSEND blocks over a connection or receive several BRCVblocks but each must have a different ID. The same IDs can be used on otherconnections.
<type>
S7 Data Type
An S7 data type is converted to the corresponding OLE data type in the OPCserver.
All specified OLE data types can be read via the automation interface of OPC.However, certain development tools (for example Visual Basic) only offer arestricted number of data types. The following table therefore lists thecorresponding Visual Basic type in which the variable value can be represented.
OPC Process Variables for SIMATIC NET
216SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Format Identifier
Description OLE Data Ty-pe
Visual BasicType
X Bit (bool).You must speci-fy the bit num-ber.
VT_BOOL Boolean
B Byte (unsigned) VT_UI1 Byte
W Word (unsigned) VT_UI2 Long
D Double word(unsigned)
VT_UI4 Double
CHAR Byte (signed) VT_I1 Integer
INT Word (signed) VT_I2 Integer
DINT Double word (si-gned)
VT_I4 Long
REAL Floating pointnumber
VT_R4 Single
<address>
Address of the first variable to be addressed.
Possible values are as follows:
byte number
byte number.bit (only for X format)
<quantity>
Number of variables of a type to be addressed starting at the address specified inthe address parameter.
For data type X, the quantity can only be entered in multiples of 8. The bit addressmust then be 0.
Example: S7:[S7-OPC-1]BRCV,1,X10.0,64
Note
By specifying the optional information type, address and quantity, you can definestructured access to subareas of blocks of data.
4.5.9 Examples of Process Variables for Buffer-oriented Services
Here you will find examples illustrating the syntax of variable names forbuffer-oriented services.
OPC Process Variables for SIMATIC NET
217SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Block of data received in the entire bufferS7:[S7-OPC-1]BRCV,1
BRCV,1
A block of data is received in the receive buffer with RID 1. The complete buffer ismapped on an array of bytes.
Alternate access to received block of dataS7:[S7-OPC-1]BRCV,1,W2,4
BRCV,1,W2,4
From the received block of data, the content is mapped starting at offset 2 on anarray of 4 words. In total, 8 bytes of the block of data are relevant.
Double word transferredS7:[S7-OPC-1]BSEND16,1,D2
BSEND16,1,D2
A double word is addressed in a block of data with a length of 16 with RID 1starting at offset 2. If a write command is applied to the variable, the written valueis entered at the specified position in the block and the block of data is sent.
Floating-point numbers transferredS7:[S7-OPC-1]BSEND32,1,REAL20,2
BSEND32,1,REAL20,2
An array with floating-point numbers is addressed in a block of data with a lengthof 32 with RID 1 starting at offset 20. If a write command is applied to the variable,the written value is entered at the specified position in the block and the block ofdata is sent.
4.5.10 S7-specific Information Variables
There are S7-specific variables with which you can obtain information about the S7communication and the established connections.
The following information can be obtained:
� Attribute of virtual field device (VFD).
� Status of an S7 connection
� Status of a virtual device
� Status of the logon the messages.
OPC Process Variables for SIMATIC NET
218SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.5.11 Syntax of the S7-specific Information Variables
Syntax
S7:[<connectionname>]<informationparameter>
Explanations
S7
S7 protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<informationparameter>
Possible values are as follows:
&identify()
Vendor attributes of a communication partner.
Return values (as elements of a string field):
� Vendor
� Model
� Revision
OLE Data Type Visual Basic Type
VT_ARRAY of VT_BSTR String()
&vfdstate()
State of a virtual field device
Data type: VT_ARRAY of VT_VARIANT with the following components:
Logical status
Supported services
Return Value:
S7_STATE_CHANGES_ALLOWED all services are permitted
OLE Data Type Visual Basic Type
VT_BSTR String
Physical status
OPC Process Variables for SIMATIC NET
219SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Operability of the real device
Return values:
S7_OPERATIONAL the real device is operational.
S7 NEEDS COMMISSIONING the real device is only operational af-ter local settings have been made.
OLE Data Type Visual Basic Type
VT_BSTR String
Detailed Information on the local VFD state
The state is returned as an octet string. For more detailed information on themeaning of the return value, refer to the documentation of the partner device.
OLE Data Type Visual Basic Type
VT_ARRAY of VT_BSTR String()
&statepath()
State of a communication connection to a partner device.
Return values:
� DOWN
Connection is not established
� UP
Connection is established
� RECOVERY
Connection being established
� ESTABLISH
(Reserved for future expansions)
OLE Data Type Visual Basic TypeVT_BSTR String
OPC Process Variables for SIMATIC NET
220SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
Changes in the variables &statepath() and &statepathval() between UP andRECOVERY
If you have set the “S5Access” parameter to 1 in the configuration file for the SRprotocol and use the TIMEOUT parameter, the variables &statepath() and&statepathval() change between UP and RECOVERY, or 2 and 3 when no data isreceived.
Remedy: Set the value for the S5Access parameter to 0 and this response nolonger occurs.
&statepathval()
State of a communication connection to a partner device.
Return values:
� 1
Connection is not established
� 2
Connection is established
� 3
Connection being established
� 4
(Reserved for future expansions)
OLE Data Type Visual Basic Type
VT_UI1 Byte
4.5.12 Examples of S7-specific Information Variables and ReturnValues
Here you will find examples illustrating the syntax of variable names forbuffer-oriented services.
Information on the Vendor Attributes of a Virtual Field Device
S7:[S7-OPC-1]&identify()
OPC Process Variables for SIMATIC NET
221SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
&identify()
can, for example, return the following values:
� Vendor: “SIEMENS AG”
� Model of the virtual device: “GES7413-1AE0-0AB0”
� Revision: “V1.0”
State of a Device
S7:[S7-OPC-1]&vfdstate()
&vfdstate()
can, for example, return the following values:
� Logical status: “S7_STATE_CHANGES_ALLOWED”
� All services are allowed.
� Physical status: “S7_OPERATIONAL”
� The real device is operational.
� Detailed information: “02.00.00”
� Detailed Information on the Local VFD state
Status of a communication connection as string
S7:[S7-OPC-1]&statepath()
&statepath()
can, for example, return the following value:
� Connection status: “RECOVERY”
� The connection is currently being established.
Status of a communication connection as value
S7:[S7-OPC-1]&statepathval()
&statepathval()
can, for example, return the following value:
� Connection status: “2”
� The connection is established
OPC Process Variables for SIMATIC NET
222SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.5.13 Block Management Services
Block management services control the transfer and return of data and programelements between the PC and the programmable controller. On the PC, data andprogram elements are stored in files. Block management services can be protectedby a password.
Blocks
Data and program elements are stored on S7 programmable controllers in blocks.These blocks are compiled using STEP 7 and transferred to the S7 device. Thefollowing blocks can exist on S7 devices:
� Organization blocks
� Function blocks
� Data blocks (DB / DI)
Block Management Functions
You can execute the following functions via the SIMATIC NET OPC Server:
� Transfer blocks between PCs and programmable controllers
� Delete blocks
� Link blocks
� Compress the memory of the programmable controller
Note
It is not possible to create blocks with the OPC server, you must use STEP 7.
4.5.14 Syntax of the Control Variables for Block Management Services
Syntax
S7:[<connectionname>]<serviceparameter>
Explanations
S7
S7 protocol for access to the process variable.
OPC Process Variables for SIMATIC NET
223SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<serviceparameter>
These variables can only be written. The service is triggered by writing a value.
Possible values are as follows:
&blockread()
A block from a programmable controller is transferred to the PC and stored in a file.
The written value contains the parameter setting for the service. It is representedas an array of variants with the following elements:
Flags
The following hexadecimal numbers are possible:
0x0001 An unlinked block is read. If a target file exists, it is not over-written, an error message is displayed.
0x0040 A linked block is read. If a target file exists, it is not overwrit-ten, an error message is displayed.
0x1001 An unlinked block is read. An existing target file is overwrit-ten.
0x1040 A linked block is read. An existing target file is overwritten.
OLE Data Type Visual Basic Type
VT-BSTR String
Block
Block type and number
OB Organization block
FB Function block
FC Function
DB Data block
OLE Data Type Visual Basic Type
VT-BSTR String
File
Full path of the file in which the block will be stored
OPC Process Variables for SIMATIC NET
224SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OLE Data Type Visual Basic Type
VT-BSTR String
&blockwrite()
Transfer a block from a PC to a programmable controller.
The written value contains the parameter setting for this service. It is representedas an array of variants with the following elements:
Flags
The following hexadecimal numbers are possible:
0x1000 An unlinked block of the same name on the automationsystem is to be overwritten
0x0000 An unlinked block of the same name on the automationsystem is not to be overwritten
OLE Data Type Visual Basic Type
VT-BSTR String
File
Full path of the file in which the block is stored
OLE Data Type Visual Basic Type
VT-BSTR String
Note
The domain services “blockread()” and “blockwrite()” do not allow accessto source and target files of the blocks on a network drive.
Overwriting (0x1000) a block is possible only after the part relevant toexecution has been linked.
&blocklinkin()
Link a block with the passive status into the program sequence of theprogrammable controller. The executable part of the block is copied to the workmemory of the programmable controller.
The block is then accessible to the program. By linking a block, an existing, activeblock is overwritten without an error message.
The written value contains the specification of the block to be linked as theparameter setting for the service.
OPC Process Variables for SIMATIC NET
225SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Block
Block type and number
The following types are possible:
OB Organization block
FB Function block
FC Function
DB Data block
OLE Data Type Visual Basic Type
VT-BSTR String
&blockdelete()
Delete a block on the programmable controller. Both the passive blocks and thoselinked into the program sequence can be removed.
The written value contains the parameter setting for this service. It is representedas an array of variants with the following elements:
Flags
The following hexadecimal numbers are possible:
0x0001 An unlinked block is deleted
0x0040 A linked block is deleted
0x0041 The linked and the unlinked block are deleted
OLE Data Type Visual Basic Type
VT-BSTR String
Block
Block type and number
The following types are possible:
OB Organization block
FB Function block
FC Function
DB Data block
OLE Data Type Visual Basic Type
VT-BSTR String
&blockcompress()
OPC Process Variables for SIMATIC NET
226SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Compress the memory of the programmable controller.
Fragmented memory areas are moved together to create space for new blocks tobe transferred.
This variable can only be written. The service is triggered by writing an emptystring.
Note
The parameters of some of the block management services are set bythe written value. Here, arrays are used as the data type. From theuser’s point of view, it may be advantageous to transfer the valueparameters as a value of the data type VT_BSTR. The OPC serverconverts the values into the required data type automatically. Therepresentation of an array in a string is, for example:“{firstelement|secondelement|thirdelement}”. You should also refer to the examples.
4.5.15 Examples of Using the Block Management Services
Here you will find examples illustrating the syntax of variable names for blockmanagement services.
Reading a Block
S7:[S7-OPC-1]&blockread()&blockread()
For example, to read the block OB1 in a file c:\temp\ob1.blk , the item must bewritten with the following value:
{0x0040|OB1|c:\temp\ob1.blk}
OPC Process Variables for SIMATIC NET
227SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
To specify the value as in this example, string must be requested as the data type.The value can then be specified in the converted representation for arrays.
Writing a Block
S7:[S7-OPC-1]&blockwrite()&blockwrite()
For example, to send the block in the file c:\temp\ob1.blk to the programmablecontroller, the item must be written with the following value:
{0x1000|c:\temp\ob1.blk}
Note
To specify the value as in this example, string must be requested as the data type.The value can then be specified in the converted representation for arrays.
Example of Linking a Block
S7:[S7-OPC-1]&blocklinkin()
&blocklinkin()
For example, to link the block DB1 into program execution on the programmablecontroller, the item must be written with the following value:
DB1
Example of Deleting a Block
S7:[S7-OPC-1]&blockdelete()&blockdelete()
To delete a linked block DB1, the item must be written with the following value:
{0x0040|DB1}
OPC Process Variables for SIMATIC NET
228SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Example of Compressing the Memory of the Programmable Controller
S7:[S7-OPC-1]&blockcompress()&blockcompress()
To compress memory, the item must be written with an empty string.
4.5.16 Passwords
Write and read access by block management services to the CPU can beprotected by a password during configuration. The password has higher prioritythan the keyswitch of the CPU.
Protection Levels
There are three protection levels for S7 programmable controllers. These areactivated with the aid of STEP 7.
� Protection due to the setting of the keyswitch
� Write protection
� Write and read protection
When the correct password is transferred, all the protection levels for thisconnection are revoked. When an empty string is transferred as the password, theconnection protection is reactivated.
A default protection level can be sent during configuration for two-endedconnections. If the protection for two-ended connections is not activated by theconfiguration, all services are possible on these connections even when thekeyswitch is set to “RUN”.
The following table shows the relationship between password transfer and theprotection level on connections configured at one end.
One-endedConfiguredConnections
Resulting Active Protection Level
Configured pro-tection level
Password was nottransferred
Correct password wastransferred
Keyswitch setting Keyswitch setting
RUN RUN-P
STOP
RUN RUN-P
STOP
Keyswitch set-ting RUN - canbe canceled bypassword
Read
All
All
All
OPC Process Variables for SIMATIC NET
229SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
One-endedConfiguredConnections
Resulting Active Protection Level
Keyswitch RUN- cannot be can-celed by pass-word
Read
All
Read
All
Write protectionwith password
Read
Read
All
All
Write/read pro-tection
None
None
All
All
Figure 4-1 Relationship between Password Transfer and Protection Level
Key:“All” = all services possible; “Read” = only read block; “None” = no block services allowed
4.5.17 Syntax of the Control Variables for Passwords
Syntax
S7:[<connectionname>]&password()
Explanations
S7
S7 protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
OPC Process Variables for SIMATIC NET
230SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
&password()
Identifier for the password service.
The transfer of the password is triggered by writing a value.
The password can be transferred in the following representations:
� Octet string
String with the hexadecimal codes of the individual characters of thepassword separated by a period (maximum of 8 characters)
� String
Any alphanumeric string starting with the & character (maximum 8characters)
Writing the password returns the following values:
� OPC_E_BADRIGHTS
The password is invalid
� S_OK
The password is valid
OLE Data Type Visual Basic Type
String String
4.5.18 Example of Using Passwords
Here, you will find an example illustrating the transfer of passwords.
Example of Transferring a Password
S7:[S7-OPC-1]&password()&password()
To transfer the password SetMeFre to the programmable controller, the variablemust be written with the following value:
&SetMeFre
OPC Process Variables for SIMATIC NET
231SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.5.19 Unconfigured S7 Connection
Access to a Partner without Configuration
Normally, connections to partner devices are defined in a configuration. This isdone in the STEP 7 or NCM PC / NCM S7 programs. There are, however,situations in which, for example, data must be read from a partner device orvariables written or monitored. It is possible to implement these tasks withoutconfiguration.
Requirements
For device access without configuration, all the data of the partner device relevantfor communication must be known. These include the connection name, theaccess point and the station address. The required parameters are listed in thefollowing section. When selecting the connection name, make sure that it is uniqueand does not already exist among the names already configured.
Parameters for an Unconfigured Connection
An unconfigured connection has the following syntax:
S7:[<connectionname>|<VFD>|<access>| <address_specification>]<dataelement>
The individual components have the following significance:
� <connectionname>The connection name must not exist already. If the selected connection namehas already been configured and is used for another freely specified S7connection, the additional information for freely specified connections will beignored and the item will be assigned to the existing connection.
� <VFD>Any VFD name. All connections can be created on the same VFD. The VFDname can be a maximum of 32 characters long. The selected name must notalready exist.
� <accesspoint>The access point of the communication module must be configured in advancewith the “Configuration Console” program.
OPC Process Variables for SIMATIC NET
232SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� <address_specification> = <local TSAP>,<stationaddresse>,<remote TSAP>,<mode>
The address specification contains the following information with the individualvalues separated by commas:
- Local TSAP (local Transport Service Access Point)For the S7 protocol, the local TSAP consists of exactly two numbersseparated by blanks or the period with the following significance:
First byte: This can contain a device ID.02 OS (Operating Station, operator control and
monitoring)03 Other
Second byte: Always 0.Recommended setting: 01.00
- stationaddressThere are three possible representations for the station address:
Transmissiontechnique
Representation of thestation address
Example
PROFIBUS PROFIBUS address, de-cimal representation
65
TCP/IP TCP/IP address 192.168.0.7
ISO MAC address 08-00-06-01-3a-00
- Remote TSAP (Remote Transport Service Access Point)The representation is the same as for the local TSAP, however the 2nd bytehas a different meaning:
First byte: Contains a device ID:02 OS (Operating Station, operator control and
monitoring)03 OtherRecommended setting: 02
Second byte: Contains the addressing of the SIMATIC S7 CPU,divided into:bits 7 through 5
Rack (subsystem) of the S7 CPUbits 4 through 0
Slot of the S7 CPU
OPC Process Variables for SIMATIC NET
233SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
- modeS7 connections are actively established either by the OPC server or by theconnection partner. On such connections, it is also possible to use optimizedwrite or read access. The following values are possible for mode:1 Active connection establishment with optimization3 Active connection establishment without optimization
� <dataelement>Here, for example, a data block with its number and the type (byte, word etc.)and the address (for example byte offset) can be specified. Which dataelements are possible for S7 is explained in the chapter “OPC ProcessVariables for SIMATIC NET”, section “S7 Communication”.
Examples
S7:[S7 connection 1|VFD1|S7ONLINE|01.00,192.168.0.7,02.02,1]DB10,B0
S7:[S7 connection 2|VFD2|S7ONLINE|01.00,65,02.02,1]DB10,B0
S7:[S7 connection 3|VFD3|S7ONLINE|01.00,08.06.05.e4.3a.00,02.02,1]MB0
OPC Process Variables for SIMATIC NET
234SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Defining the Access Point
Start the “Configuration Console” program to define an access point and to assignan interface parameter assignment:
OPC Process Variables for SIMATIC NET
235SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Entries in the Client Program
Open the client program and create an item using the syntax shown above. In theOPC Scout program, open the input boxes for inserting items by selecting ”AddItem” in the context menu on the right-hand side of the program window. Browsingfor the unconfigured connection is not yet possible at this time.
Add Item
Enter the item with the previously described parameters in the ”Add Item” dialogand click on the ”Add Item” button. If the syntax is correct, the item appears in thename space under the “S7” branch.
After adding the item and as long as the item is active, the connection can be usedlike a configured connection. This means that you can browse in the name spaceand also add further items without using the syntax of the unconfigured connection.All you need to do is specify the connection name, for exampleS7:[S7-Verb_1]MB1.
OPC Process Variables for SIMATIC NET
236SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.6 PROFIBUS FMS
Introduction
The FMS protocol for PROFIBUS is an open communications protocol belongingto layer 7 of the ISO/OSI reference model.
Using FMS, communication is possible with all programmable controllers that meetthe FMS standard. This applies in particular to the S5 and S7 programmablecontrollers from Siemens.
Properties of PROFIBUS-FMS
The OPC server from SIMATIC NET has the following characteristics:
Reading and Writing FMS Variables
� FMS server functionality
� Support of arrays and structures, including alternate access
� Support of connections over which no object dictionary (OD), a short OD, orlong OD can be downloaded
� Support of the FMS services Identify and VfdState
� Support of the PROFIBUS service Lifelist
� Display and monitoring of the connection state
4.6.1 Protocol ID (FMS)
The protocol ID for the FMS protocol is FMS.
4.6.2 Connection Names
The connection name is the name configured in STEP 7 to identify the connection.During configuration, STEP 7 makes sure that the FMS connection name for theOPC server is unique.
Examples of Connection Names
Typical examples are:
Simocode
S5_5431
connection1
OPC Process Variables for SIMATIC NET
237SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.6.3 Data Types
The FMS protocol uses its own data types in the declaration of the FMS variables.The FMS data types must be mapped on the data types available on the OPCinterface.
* Default setting VT_BSTR
FMS Data Ty-pe
Canonical OLE DataType
VisualBasic Ty-pe
Meaning
unsigned8 VT_UI1 Byte unsigned char (1 Byte)
unsigned16 VT_UI2 Long unsigned short (2 bytes)
unsigned32 VT_UI4 Double unsigned long (4 Byte)
integer8 VT_I1 Integer signed char (1 Byte)
integer16 VT_I2 Integer signed short (2 Byte)
integer32 VT_I4 Long signed long (4 Byte)
float VT_R4 Single real (4 bytes)
boolean VT_BOOL Boolean signed short (True = -1;False = 0)
vstringX VT_BSTR String Visible String X: Number of charac-ters
bstringX VT_BSTR String Bit string X: Number of bits structure: b.b.b.b.b.bwhere b=0 or 1
ostringX VT_BSTR String Octet string X: number of octets structure:hh.hh.hh.hh.hh whereh=0..f
OPC Process Variables for SIMATIC NET
238SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
FMS Data Ty-pe
MeaningVisualBasic Ty-pe
Canonical OLE DataType
time_of_day VT_DATE Date Time of dayTimeOfDay4 (4 bytes)0 ... 86399999 ms(alternative VT_UI4)
The OPC date is al-ways 01.01.1984 and isignored when writing.
TimeOfDay6 (6 bytes)01.01.198400:00:00.000through31.12.208323:59:59.999
date VT_DATE Date Date7 bytes01.01.198400:00:00.000through31.12.208323:59:59.999
time_differen-ce
VT_DATE Date Time DifferenceTimeDifference4 (4 by-tes)0 ... 86399999 ms(alternative VT_UI4)
The OPC date is al-ways 30.12.1899 and isignored when writing.
TimeDifference6 (6 by-tes)00:00:00.000 0 daysthrough 23:59:59.999 65535days(alternative VT_UI8)The OPC date beginson 30.12.1899.
OPC Process Variables for SIMATIC NET
239SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
FMS Data Ty-pe
MeaningVisualBasic Ty-pe
Canonical OLE DataType
array
( Data type[N])
VT_ARRAYof element ty-pe
Array ofthe VBelementa-ry type
FMS array as safearraywith N elements of typeelement type.
struct
( {Type1|Ty-pe2|Type3|Ty-pe4} )
VT_ARRAYof VT_VA-RIANT
Array withelementsof the re-spectiveelementa-ry types
FMS structure with 4different data types Ty-pe1...Type4.
4.6.4 Variable Services
FMS variables are the variables on the partner device. You access the variablesusing the object dictionary of the partner.
There are two types of object dictionaries on the partner device:
� Short object dictionary
You can only access variables using indexes.
� Long object dictionary
You can use both the symbolic name stored in the object dictionary andindexes.
You specify which object dictionary will be used for the variable access duringconfiguration.
4.6.5 Syntax of the Process Variables for FMS Variable Services
Syntax
You have two options:
FMS:[<connectionname>]<index>{:<subindex>}
FMS:[<connectionname>]<objectname>{:<subindex>}
OPC Process Variables for SIMATIC NET
240SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
FMS
FMS protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<index>
Index for the variable in the short object dictionary of the partner device.
<objectname>
Symbolic name of the variable in the long object dictionary of the partner device.
<subindex>
Alternate access to a structure element.
4.6.6 Examples of Process Variables for FMS Variable Services
Here you will find examples illustrating the syntax of variable names for FMSvariables.
Addressing Symbolic Names on a Demonstration Connection
FMS:[DEMO]Valve_In
Valve_In
Variable with the name Valve_In of the demo connection.
Addressing an Index on a normal Connection
FMS:[CR1]200
200
Variable with Index 200 of the CR1 connection
OPC Process Variables for SIMATIC NET
241SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Addressing Symbolic Names on a normal Connection
FMS:[CR1]Count
Count
Count variable of the CR1 connection
Addressing a Structure Element on a normal Connection
FMS:[CR1]200:2
200:2
Access to the second structure element of the variable with index 200
4.6.7 FMS-Specific Information Variables
The OPC server provides variables with which information about the FMScommunication system and the connection states can be queried.
You can query the following information:
� Attributes of a virtual field device (VFD).
� Status of a virtual device
� Status of an FMS connection
� Station addresses of the obtainable nodes (lifeless)
4.6.8 Syntax of the FMS-specific Information Variables
Syntax
FMS:[<connectionname>]&<informationparameter>()
Explanations
FMS
FMS protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
OPC Process Variables for SIMATIC NET
242SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
<informationparameter>
Possible values are as follows:
identify
Vendor attributes of a virtual device
A virtual field device is a model of a real device, also known as VFD.
Return values:
� Vendor
� Model
� Revision
OLE Data Type Visual Basic Type
VT_ARRAY of VT_BSTR String() with 3 elements
vfdstate
State of a virtual field device
Data type: VT_ARRAY of VT_VARIANT with the following components:
Logical status
Supported services
Return values:
FMS_STATE_CHANGES_ALLO-WED
all services are permitted
FMS_LIMITED_SERVICES_PER-MITTED
only the services Status virtual de-vice and Identify virtual device arepermitted
FMS_OD_LOADING_NON_INTER-ACTING
Loading an object dictionary is notpermitted.
FMS_OD_LOADING_INTERAC-TING
An object dictionary is currentlybeing loaded on the interface modu-le.
OLE Data Type Visual Basic Type
VT_BSTR Array with three string elements
OPC Process Variables for SIMATIC NET
243SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Physical status
Operability of the real device
Return values:
FMS_OPERATIONAL the real device is operational.
FMS_PARTIALLY_OPERATIONAL the real device is partially operational.
FMS NEEDS COMMISSIONING the real device is only operational af-ter local settings have been made.
FMS_INOPERABLE the real device is not operational.
OLE Data Type Visual Basic Type
VT_BSTR Array with three string elements
Detailed Information on the Local VFD State
Detailed local state as octet string with the structure hh.hh.hh where h = 0..f . Tointerpret this value, the description of the local VFD is required.
OLE Data Type Visual Basic Type
VT_BSTR Array with three string elements
statepath
State of a communication connection to a partner device.
Return values:
� DOWN
Connection is not established
� UP
Connection is established
� RECOVERY
Connection being established
� ESTABLISH
The object dictionary of the partner is read.
OLE Data Type Visual Basic Type
VT_BSTR String
OPC Process Variables for SIMATIC NET
244SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
statepathval
State of a communication connection to a partner device.
Return values:
� 1
Connection is not established
� 2
Connection is established
� 3
Connection being established
� 4
The object dictionary of the partner device is read.
� Other
Connection is unknown
OLE Data Type Visual Basic Type
VT_UI1 Byte
livelist
Corresponds to the PROFIBUS FMS service Lifelist. Information on accessiblenodes on the bus
The array with its 127 elements includes information about every possible stationaddress. Each station address is assigned an index of the array.
Return values of the array entries:
� FMS_STATION_NONEXISTENT
No node exists (value 0)
� FMS_STATION_PASSIVE
Passive node (value 1)
� FMS_STATION_READY_FOR_RING
Node ready for entry in the token ring of PROFIBUS (value 2).
� FMS_STATION_ACTIVE
Active node (value 3)
OLE Data Type Visual Basic Type
VT_ARRAY of VT_UI1 Array with 127 elements of the typebyte()
OPC Process Variables for SIMATIC NET
245SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
4.6.9 Examples of FMS-Specific Information Variables and ReturnValues
Here, you will find examples of return values of FMS-specific information variables.
Information on the Vendor Attributes of a Virtual Field Device
FMS:[connection1]&identify()&identify
can, for example, return the following values:
SIEMENS AG Vendor
ET 200U-DP/FMS Model of the Virtual Device
V1.0 Revision
State of a Device
FMS:[connection1]&vfdstate()&vfdstate()
can, for example, return the following values:
FMS_STATE_CHANGES_ALLOWED all service are permitted.
FMS_OPERATIONAL the real device is operational.
00.00.00 local VFD status.
’State of a Communication Connection
FMS:[connection1]&statepath()&statepath()
can, for example, return the following value:
UP connection is established.
OPC Process Variables for SIMATIC NET
246SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Information on Accessible Nodes on the Bus
FMS:[connection1]&livelist()&livelist()
can, for example, return the following value (shown with string data type):
{0|1|0|0|1|0|0|1|0|2|1|0|1|0|1|0|3|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|2|0|1|2|0|0|0|0|0|0|0|1|1|1|0|1|1|0|1|0|1|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|3|0|0|0|0|0|0|0|0|0|1|0|1|0|1|0|1|0|1|0|0|1|0|0|1|0|0|1|0|0|1|0|1|3|0|3|0|1|0|3|1|0|0|3|0|3|0|3|0|0|0|0|0|0|0|0|0}
In this context, &livelist() corresponds to the PROFIBUS FMS Lifelist service.
4.6.10 FMS Server Variables
The FMS-OPC server can itself be a server in the sense of the FMS protocol. Asan FMS server, it provides variables and an object dictionary that other FMSpartner devices can access. This allows FMS communication between PCs to beestablished.
The FMS server variables are created during configuration and managed by theOPC server.
Note
To make the PC acting as FMS server available for other devices, the OPC servermust be started by an OPC client.
4.6.11 FMS Server Variables: ItemID
Syntax
You have two options:
FMS:[<connectionname>]<index>{:<subindex>}
FMS:[<connectionname>]<symbolicname>{:<subindex>}
Explanations
FMS
FMS protocol for access to the process variable.
OPC Process Variables for SIMATIC NET
247SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<index>
Index for the variable in the local short object dictionary.
<symbolicname>
Symbolic name of the variable in the local long object dictionary.
<subindex>
Alternate access to a structure element.
Note
From the perspective of an OPC client, these variables are local elementsmanaged by the OPC server. The data is transported over PROFIBUS only whenan FMS partner device accesses these variables.
4.7 S5-compatible Communication
Depending on the communications network, there are two versions ofS5-compatible communication:
� S5-compatible Communication over Industrial EthernetProtocol ID: SR
� S5-compatible Communication over PROFIBUSProtocol ID: FDL
4.7.1 S5-compatible Communication over Industrial Ethernet
S5-compatible communication over Industrial Ethernet is also known asSEND/RECEIVE protocol. Communication with S5 and S7 devices is possible.
OPC Process Variables for SIMATIC NET
248SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Properties of S5-compatible Communication over Industrial Ethernet
� Communication using SIMATIC S5 handling blocks and S7 function blocks
� Link between two PC stations possible.
� Support of the WRITE and FETCH function for access to objects of the partnerdevice.
� Fast access to large data packets with the modes SEND and RECEIVE.
� Alternate access within a data packet.
� Display and monitoring of the connection state
4.7.2 Powerful SIMATIC NET OPC Server for the SR Protocol
Introduction
The section below describes a configuration variant for the SR protocol that meetsrequirements for higher performance. To use this variant, all underlying SRprotocol libraries and the COM server as inproc server are loaded on the outprocOPC server. The protocol is handled in the process of the OPC server, additionalexecution times for changing between processes and multiprotocol mode areavoided. The process change between the OPC client and OPC server is,however, still necessary.
OPC Process Variables for SIMATIC NET
249SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
configuration
This high-performance variant is activated implicitly simply by selecting the SRprotocol in the ”Configuration Console”.
Configured OPC data exchange DX and symbols can also be selected.
Advantages / Disadvantages
Using the high-performance SR OPC server does, however, have thedisadvantage that only the SR single protocol mode is possible. On the other hand,it does have the following advantages:
� Higher performance than with multiprotocol mode.
� Simple configuration.
� Access via the ProgID OPC.SimaticNET.
� Several clients can use the server at the same time.
� The stability of the OPC server does not depend on the clients.
4.7.3 Protocol ID
The protocol ID for the SEND/RECEIVE protocol is SR.
OPC Process Variables for SIMATIC NET
250SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.7.4 Connection Names
The connection name is the name configured in STEP 7 to identify the connection.
The following connection types are supported by the OPC server:
� ISO transport connection
� ISO-on-TCP connection
� TCP connection
Examples of Connection Names
Typical examples are:
MyConnection
SR_Connection
4.7.5 Variable Services
Variable services allow direct access to and monitoring of variables on theprogrammable controller. The variables are addressed symbolically, the notation ofthe variable names is oriented on the programming tools. For direct read access,the OPC server transfers the required address information to the receiver and thissends the requested data back. During write access, the OPC server transfers theaddress information along with the value to be written.
Note
The requested variable must be consistent with the configuration of the partnerdevice. Otherwise, the access to certain areas leads to communication errors. TheOPC server can only check the syntax when a variable registers. Based on theconfiguration of the partner, it is not possible to determine whether the variable isvalid on the partner device.
Syntax of the Process Variables for SEND/RECEIVE Variable Services
Syntax
SR:[<connectionname>]<area>{,}<type><address>{,<quantity>}
OPC Process Variables for SIMATIC NET
251SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
SR
SEND/RECEIVE protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<area>
Object to be addressed.
� DBnn,
Data block no. nn
� Q
Output
� I
Input
� M
Memory bits
� P
I/O (for S5 CPUs)
� PII
I/O (for S7 CPUs)
� C
Counters
� T
Timers
� RS
System area
� IA
Absolute start address
� DXnn,
Extended data block
� DEnn,
Data block in the external memory
� OY
Extended I/O
OPC Process Variables for SIMATIC NET
252SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
<type>
Data type.
The data type is converted to the corresponding OLE data type in the OPC server.
Data type Description OLE Data Ty-pe
Visual Ba-sic Type
X Bit (Boolean)
Only with theobjects I, Q, F,P, PII, and OY(read access on-ly)
VT_BOOL Boolean
B or BYTEOnly availablefor the objects I,Q, F, P, PII, andOY
Byte (unsi-gned8)
VT_UI1 Byte
CHAROnly availablefor the objects I,Q, F, P, PII, andOY
Byte (signed8) VT_I1 Integer
W or WORD Word (unsi-gned16)
VT_UI2 Long
INT Word (signed16) VT_I2 Integer
D or DWORD Double word(unsigned 32)
VT_UI4 Double
DINT Double word (si-gned 32)
VT_I4 Long
REAL Floating-point,IEEE represen-tation
VT_R4 Single
S5REAL Floating-point,S5 representa-tion
VT_R4 Single
OPC Process Variables for SIMATIC NET
253SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<address>
Address of the variables in the area:
Depending on the area, the address specified must be a byte or a word address.When accessing the following areas, the specified address is interpreted as a wordaddress: DBnn
� RS
� IA
� DXnn,
� DEnn,
� C
� T
<quantity>
Number of variables of a type to be addressed starting at the address specified inthe address parameter.
4.7.6 Buffer-oriented Services
Buffer-oriented services allow program-controlled transfer of larger blocks of data.These services are also known as SEND/RECEIVE services. Data transfer withthe OPC server is implemented with variables:
� Variables that send blocks of data
� Variables that receive blocks of data
A default size for the blocks of data is specified in the configuration, when sendingvariables, the length can be restricted. Alternate access within the blocks of data ispossible.
Fixed Variable Names
The following fixed variable names are specified for each connection:
� RECEIVE
� SEND
Syntax of the Process Variables for Buffer-Oriented Services
The available options are as follows:
SR:[<connectionname>]receive{,<type><address>{,<quantity>}}
SR:[<connectionname>]send{<n>}{,<type><address>{,<quantity>}}
OPC Process Variables for SIMATIC NET
254SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
SR
SEND/RECEIVE protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
receive
Last data buffer received from partner.
The structure of the data buffer is not fixed. For this reason, the buffer is alwaysdelivered as an array of bytes.
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte
Note
The RECEIVE variable corresponds to a receive buffer. The variable can thereforeonly be read. With read access to the DEVICE, a receive buffer is preparedexplicitly in the communications system. If no data field is received for this bufferwithin a specified time, a timeout is reported. You should therefore only monitorthese variables or read them from the cache.
send
A send buffer that can be transferred to the connection partner.
A default value for the size of the send buffer is specified during configuration. Thebuffer is always delivered as an array of bytes.
Write access to these variables causes the send buffer to be transferred to thepartner.
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte
OPC Process Variables for SIMATIC NET
255SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
This variable and variables derived from it must not be read and not activated.Read access to these variables may well result in the partner terminating theconnection.
<n>
Size of the send buffer
You can use n if send buffers of different sizes are used on a connection. If you omitn , the buffer size entered in the configuration is used.
If the miniprotocol is deactivated in TCP/IP native, (see SIMATIC STEP 7 orSIMATIC NCM PC configuration tool), it is not possible to specify the size of thesend buffer. In this case, the buffer size entered in the defined configuration is used.
Note
Variables for send buffers of different sizes have independent memory areas!
<type>
Data type.
The data type is converted to the corresponding OLE data type in the OPC server.
Data type Description OLE DataType
Visual BasicType
X Bit (Boolean) VT_BOOL Boolean
B or BYTE Byte (unsi-gned8)
VT_UI1 Byte
CHAR Byte (signed8) VT_I1 Integer
W or WORD Word (unsi-gned16)
VT_UI2 Long
INT Word (signed16) VT_I2 Integer
D or DWORD Double word(unsigned 32)
VT_UI4 Double
DINT Double word (si-gned 32)
VT_I4 Long
OPC Process Variables for SIMATIC NET
256SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Data type Visual BasicType
OLE DataType
Description
REAL Floating-point,IEEE represen-tation
VT_R4 Single
S5REAL Floating-point,S5 representa-tion
VT_R4 Single
<address>
Byte address of the variables in the area byte number.
For the bit data type, the requested bit is addressed by
Byte number.bit number addressed.
<quantityl>
Number of variables of a type to be addressed starting at the address specified inthe address parameter.
Bit arrays are not supported. For the data type X (Boolean) the specification of anumber is therefore omitted or must be 1.
Note
When using the SEND/RECEIVE variable services for an S7 automation system,remember that no array access (size of the requested area greater than 1) ispossible to counters and timers.
Examples of Process Variables for Buffer-Oriented Services
Here you will find examples illustrating the syntax of variable names forbuffer-oriented services.
Receive Variables
SR:[MyConnection]receive,w4,6
receive,w4,6
6 data words starting at offset 4 in the receive buffer
SR:[MyConnection]receive,dword7
receive,dword7
A double word starting at offset 7 in the receive buffer
OPC Process Variables for SIMATIC NET
257SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SR:[MyConnection]receive,REAL0,2
receive,REAL0,2
An array with 2 floating point values starting at offset 0 in the receive buffer.
Send Variables
SR:[MyConnection]send30,dword7
send30,dword7
A double word starting at byte 7 in a 30-byte long send buffer. If the default for thesize of the send buffer is not 30, the variable accesses a separate buffer.
SR:[MyConnection]send,B20,6
send,B20,6
An array with 20 bytes starting at offset 6 in a send buffer with default size. Thedefault size of the send buffer is specified in the configuration.
SR:[MyConnection]send8,DINT0
send8,DINT0
A signed double word starting at address 0 in a send buffer with the size 8.
4.7.7 SEND/RECEIVE-Specific Information Variables
With the SEND/RECEIVE-specific information variables, you can query informationabout the connection state.
The following information can be obtained:
Status of a connection
Syntax of Information Variables for S5-compatible Communication(SEND/RECEIVE)
SR:[<connectionname>]&<informationparameter>()
Explanations
SR
SEND/RECEIVE protocol for access to the process variable.
OPC Process Variables for SIMATIC NET
258SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
<connectionsname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
<informationparameter>
The available options are as follows:
statepath
State of a communication connection to a partner device.
The result is represented as a string.
Return values:
� DOWN
Connection is not established
� UP
Connection is established
� RECOVERY
Connection being established
� ESTABLISH
Reserved for future expansions
OLE Data Type Visual Basic Type
VT_BSTR String
statepathval
State of a communication connection to a partner device.
The result is represented as a number.
Return values:
� 1
Connection is not established
� 2
Connection is established
� 3
Connection being established
� 4
Reserved for future expansions
OLE Data Type Visual Basic Type
VT_UI1 Byte
OPC Process Variables for SIMATIC NET
259SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Examples of SEND/RECEIVE-specific Information Variables
Here, you will find several examples of return values of information variables forS5-compatible communication (SEND/RECEIVE):
SR:[SR_CONNECTION]&statepath()
&statepath()
can, for example, return the following value:
UP The connection is established
SR:[SR_CONNECTION]&statepathval()
&statepathval()
can, for example, return the following value:
2 The connection is established
4.7.8 S5-compatible Communication over PROFIBUS
The ISO/OSI Reference Model
S5-compatible communication over PROFIBUS is a simple, frame-orientedprotocol for SIMATIC devices. It uses the services of the Fieldbus Data Link (FDL)of layer 2 of the ISO/OSI reference model in PROFIBUS.
Properties of S5-compatible Communication over PROFIBUS
The OPC server of SIMATIC NET has the following characteristics:
� Communication using SIMATIC S5 and SIMATIC S7 handling blocks on aprogrammable controller
� Link between two PC stations possible
� Fast transfer of data packets
� Structured access within a data packet
� Display and monitoring of the connection state
4.7.9 Protocol ID
The protocol ID for the FDL protocol is FDL.
OPC Process Variables for SIMATIC NET
260SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.7.10 Connection Names
The connection name is the name configured in STEP 7 to identify the connection.Select a unique FDL connection name for the OPC server.
Examples of Connection Names
A typical name might be:
FDL_Connection
4.7.11 Buffer-oriented Services
Buffer-oriented services allow program-controlled transfer of blocks of data. Thereceived data buffers and the data buffers to be sent are mapped on OPCvariables.
Fixed Variable Names
The following fixed variable names are specified for each connection:
� RECEIVE
� SEND
� SendSDA
� SendSDN
Syntax of the Process Variables for Buffer-Oriented Services (FDL)
You have two options:
FDL:[<connectionname>]receive{,}<type><address>{,<quantity>}
FDL:[<connectionname>]send{<n>}{,}<type><address>{,<quantity>}
Explanations:
FDL
FDL protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
OPC Process Variables for SIMATIC NET
261SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
receive
Last data buffer received from partner.
The structure of the data buffer is not fixed. For this reason, the buffer is alwaysdelivered as an array of bytes.
Note
The RECEIVE variable corresponds to a receive buffer. The variable can thereforeonly be read. With read access to the DEVICE, a receive buffer is preparedexplicitly in the communications system. If no data field is received for this bufferwithin a specified time, a timeout is reported. You should therefore only monitorthese variables or read them from the cache.
OLE Data Type Visual Basic Type
T_ARRAY|VT_UI1 Array with elements of the type byte
send
A send buffer that exists permanently and can be transferred to the connectionpartner.
A default value for the size of the send buffer is specified during configuration. Thebuffer is always delivered as an array of bytes.
Write access to these and derived variables causes the send buffer to betransferred to the partner.
This variable and variables derived from it must not be read and not activated.
Depending on the combination of the station address and the SAPs specified in theconnection configuration, a special FDL service is used when writing a send item:
OPC Process Variables for SIMATIC NET
262SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Local SAP RemoteStation
RemoteSAP
Meaning / Ser-vice Used withSend
0..62, 255 0..126 0..62, 255 Sending and Re-ceiving / SDA
0..62, 255 0..126 63 Send only / SDA
63 0..126 0..62, 255 Receive only (nosend)
0..62, 255 127 63 Broadcast: Onlysend to all /SDN
Local SAP RemoteStation
RemoteSAP
Meaning / Ser-vice Used withSend
63 127 0..62, 255 Broadcast Re-ceive
(no send)
0..62, 255 127 0..62, 255 Multicast: Onlysend to all thosethat activatedthe remote SAP/ SDN
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Array with elements of the type by-te
<n>
Size of the send buffer
With buffer-oriented services, you can send and receive data buffers. The receiveddata buffers and the data buffers to be sent are mapped on OPC variables. Asuitably large array can, for example, contain the entire receive buffer. It is alsopossible to assign subsections of the buffers to individual variables.
OPC Process Variables for SIMATIC NET
263SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
Variables for send buffers of different sizes have independent memory areas!
<type>
Data type.
The data type is converted to the corresponding OLE data type in the OPC server.
Data Types Description OLE Data Ty-pe
Visual BasicType
X Bit (Boolean) VT_BOOL Boolean
B or BYTE Byte (unsi-gned8)
VT_UI1 Byte
CHAR Byte (signed8) VT_I1 Integer
W or WORD Word (unsi-gned16)
VT_UI2 Long
INT Word (signed16) VT_I2 Integer
D or DWORD Double word(unsigned 32)
VT_UI4 Double
DINT Double word (si-gned 32)
VT_I4 Long
REAL Floating-point,IEEE represen-tation
VT_R4 Single
S5REAL Floating-point,S5 representa-tion
VT_R4 Single
<address>
Byte address of the variables in the area byte number.
For the bit data type, the requested bit is addressed by
Byte number.bit number addressed.
<quantity>
Number of variables of a type to be addressed starting at the address specified inthe address parameter.
Bit arrays are not supported. For the data type X (Boolean) the specification of anumber is therefore omitted or must be 1.
OPC Process Variables for SIMATIC NET
264SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Syntax of the Process Variables for Buffer-oriented Services using SDA and SDN(FDL)
It can be an advantage when the service used is not dependent on thecombination of the address of the partner station and the SAPs.
By using the names SendSDA and SendSDN you can specify that only therelevant services SDA or SDN are used for sending. These special names are notdisplayed in the OPC Browser.
Syntax:
You have two options:
FDL:[<connectionname>]SendSDA{<n>}{,}<type><address>{,<quantity>}
FDL:[<connectionname>]SendSDN{<n>}{,}<type><address>{,<quantity>}
Explanations
FDL
FDL protocol for access to the process variable.
<connectionname>
Protocol-specific connection name. The connection name is specified in theconfiguration.
SendSDA
SendSDN
Only the services SDA or SDN are used to send.
<n>
Size of the send buffer
With buffer-oriented services, you can send and receive data buffers. The receiveddata buffers and the data buffers to be sent are mapped on OPC variables. Asuitably large array can, for example, contain the entire receive buffer. It is alsopossible to assign subsections of the buffers to individual variables.
<type>
Data type.
The data type is converted to the corresponding OLE data type in the OPC server.
OPC Process Variables for SIMATIC NET
265SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Data Types Description OLE DataType
Visual BasicType
X Bit (Boolean) VT_BOOL Boolean
B or BYTE Byte (unsi-gned8)
VT_UI1 Byte
CHAR Byte (signed8) VT_I1 Integer
W or WORD Word (unsi-gned16)
VT_UI2 Long
INT Word (signed16) VT_I2 Integer
D or DWORD Double word(unsigned 32)
VT_UI4 Double
DINT Double word (si-gned 32)
VT_I4 Long
REAL Floating-point,IEEE represen-tation
VT_R4 Single
S5REAL Floating-point,S5 representa-tion
VT_R4 Single
<address>
Byte address of the variables in the area byte number.
For the bit data type, the requested bit is addressed by
Byte number.bit number addressed.
<quantity>
Number of variables of a type to be addressed starting at the address specified inthe address parameter.
Bit arrays are not supported. For the data type X (Boolean) the specification of anumber is therefore omitted or must be 1.
Examples of Process Variables for Buffer-Oriented Services (FDL)
Here you will find examples illustrating the syntax of variable names for FDLvariables.
Read Variable
FDL:[MyConnection]receive,w0,6
6 data words starting at byte 0 in the receive buffer
OPC Process Variables for SIMATIC NET
266SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
FDL:[MyConnection]receive,dword7
A double word starting at byte 7
FDL:[MyConnection]Receive,REAL0,2
Two real values starting at byte 0 in the receive buffer
Write Variable
FDL:[MyConnection]send30,dword7
A double word starting at byte 7 in a 30-byte long send buffer.
FDL:[MyConnection]SendSDN,B5,20
An array with 20 bytes starting at offset 5 in a send buffer with default size. Thedefault size is set during configuration. Regardless of which SAP is specified in theconfiguration, the PROFIBUS-FDL SDN service is used.FDL:[MyConnection]Send8,DINT0
A signed double word from starting at address 0 in a send buffer with the size 8bytes.
4.7.12 FDL-specific Information Variables
The OPC server for SEND/RECEIVE over PROFIBUS (FDL) provides variableswith which information can be queried about the status and extent of thecommunication network.
Syntax of FDL-specific Information Variables
FDL:[||<CPname>]&<informationparameter>()
Explanations
FDLFDL protocol for access to the process variable.
CPnameThe CP name is specified during configuration. Only those CP names aresupported over which an FDL connection is configured.
Information parametersThere are five options:
� busparameter
� defaultsap
� identify
OPC Process Variables for SIMATIC NET
267SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
� ts
� lifelist
These five options are described below.
Busparameter
Gets the bus parameters of the PROFIBUS network operated on the specifiedconnection. The values are returned as a byte array and correspond to the resultsreturned by the FDL service FDL_READ_VALUE. For more detailed information,refer to the manual on the FDL programming interface.
Content Description Data type Length(bytes)
HSA Highest PROFIBUS address onthe bus, 2...126
BYTE 1
TS PROFIBUS address of the localstation, 0...hsa or 126.
BYTE 1
Station_Type Type of local station INTEGER 2
Baudrate Transmission rate INTEGER 2
Medium_red Redundancy INTEGER 2
Retry_Ctr Number of repeated calls tonon-responding station (remo-te), 0...7.
UWORD 2
Default_SAP Number of the default SAP ofthe station (local), 0...63
BYTE 1
network_con_SAP
reserved BYTE 1
TSL SLOT time UWORD 2
TQUI Quiet time for modulator / re-peater switchover time
UWORD 2
TSET Setup time UWORD 2
MIN_TSDR Minimum station delay respon-der
UWORD 2
MAX TSDR Maximum station delay respon-der
UWORD 2
TTR Target rotation time DWORD 4
GAP GAP update factor BYTE 1
in_Ring_desired
Request to enter ring BOO-LEAN
1
physical_layer Selectable physical bus charac-teristics
INTEGER 2
ident Vendor name, controller type,hardware and software versions
STRING 211
OPC Process Variables for SIMATIC NET
268SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OLE Data Type Visual Basic Type
VT_ARRAY | VT_UI1 Byte()
defaultsap
Returns the value for the default SAP (SAP = Service Access Point). Whenever anSAP is not explicitly specified, the default SAP is used for addressing.
OLE Data Type Visual Basic Type
VT_UI1 Byte
identify
Gets the station identifier of the specified connection as an array with four strings:
Elements of the return value:
� Vendor
� Controller
� Hardware version
� Software version
OLE Data Type Visual Basic Type
VT_ARRAY | VT_BSTR String()
ts
Returns the local station address of the specified module.
OLE Data Type Visual Basic Type
VT_UI1 Byte
OPC Process Variables for SIMATIC NET
269SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
lifelist
Information on accessible nodes on the bus
The array with its 127 elements includes information about every possible stationaddress. Each station address is assigned an index of the array.
Return values of the array entries:
� FDL_STATION_NON_EXISTENTNo node exists (value 0x10)
� FDL_STATION_PASSIVEPassive node (value 0x00)
� FDL_STATION_READY_FOR_RINGNode ready for entry in the token ring of PROFIBUS (value 0x30).
� FDL_STATION_ACTIVEActive node (value 0x20)
OLE Data Type Visual Basic Type
VT_ARRAY of VT_UI1 Array with 127 elements of the type by-te()
Note
This information is obtained using the FDL service“FDL_LIFE_LIST_CREATE_REMOTE”. This service creates a significant load onthe bus so that whenever possible this variable should not be monitored actively.
4.8 SNMP Communication over Industrial Ethernet
Process Variables for SNMP
The SNMP OPC Server of SIMATIC NET provides the following variables:
� Process variables
� Information variables
� Trap variables
OPC Process Variables for SIMATIC NET
270SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
4.8.1 Protocol ID
Protocol ID
The protocol ID for the SNMP protocol is SNMP.
4.8.2 Data Types of the SNMP Protocol
Mapping on Available Data Types
In the declaration of the MIB objects, the SNMP protocol uses its own data types. TheSNMP OPC Server maps the data types of the SNMP protocol to the available data typeson the OPC interface as follows:
SNMP Data Type
Code
CanonicalOLE DataType
Visual BasicType
Meaning
ASN_INTEGER
02h
VT_I4 Long signed long (4 bytes)
ASN_INTEGER32<
02h
VT_I4 Long signed long (4 bytes)
ASN_UNSIGNED32
47h
VT_UI4 Double unsigned long (4 bytes)
ASN_OCTET-STRING
04h
VT_BSTR String If not a printablecharacter, notation: “os-tring:xx.xx.xx.xx”
ASN_OBJECTIDEN-TIFIER
06h
VT_BSTR String In MIB notation: .a.b.c.d.e.
ASN_IPADDRESS
40h
VT_BSTR String In decimal notation: 129.168.0.4
ASN_COUNTER32
41h
VT_UI4 Double unsigned long (4 bytes)
ASN_GAUGE32
42h
VT_UI4 Double unsigned long (4 bytes)
OPC Process Variables for SIMATIC NET
271SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SNMP Data Type
Code
MeaningVisual BasicType
CanonicalOLE DataType
ASN_TIMETICKS
43h
VT_UI4 Double unsigned long (4 bytes)
ASN_OPAQUE
44h
VT_ARRAYof VT_UI1
VT_ARRAY ofVT_UI1
unsigned byte
4.8.3 Process Variables for SNMP Variable Services
Variables and Device Profiles
SNMP variables are the variables on the partner device. These variables are made knownto the OPC server based on device profiles. These device profiles can be created withthe MIB compiler and the MIB files of the device. The defined configuration is thendownloaded to the PC with the OPC server so that the variables are available to the OPCserver.
Syntax
Note
In contrast to the syntax of the other protocols, the following syntax is used with SNMP.
SNMP:[<devicename>]<objectname>
Explanations
SNMP
SNMP protocol for access to the process variables (MIB objects) and trapvariables.
<Teilnehmername>
The device name is specified during configuration of the system and is unique.
<Objektname>
Symbolic name for the MIB object of the partner device.
OPC Process Variables for SIMATIC NET
272SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Example
SNMP:[OSM]sysName
Queries the MIB object sysName. The device name was configured in the systemconfiguration in this example as OSM.
4.8.4 SNMP-specific Information Variables
Introduction
The following sections describe the variables provided by the SNMP OPC Server:
� Variables for the communications system and connection statuses
� Variables for the SNMP OPC Server
Information on the Communications System
The OPC server provides variables with which information you can get information on theSNMP communication system and the connection statuses.
You can query the following information:
� The comment entered during configuration
� The IP address of the partner device
� The status of the connection to the partner device
� Additional information for non SNMP-compliant devices
Syntax
SNMP:[<devicename>]<informationparameter>
Explanations
SNMP
SNMP protocol for access to the process variables (MIB objects) and trapvariables.
<devicename>
The device name is specified during configuration of the system.
<nformationparameter>
The following information parameters are defined:
OPC Process Variables for SIMATIC NET
273SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
&description() The text entered in the comment field during configu-ration. VT_BSTR, Read-only
&ipaddress() The IP address of the partner device. VT_BSTR, Re-ad-only.
&statepath() Status of the connection to the partner device. Valuein text form (VT_BSTR, read-only):
DOWNThe device cannot be reached with a ping or there areno active read or write jobs.
UPJobs could be executed successfully with this device.
RECOVERYThe device cannot be reached with a ping or the lastjob was terminated with an error that suggests a com-munication abort and there are still active jobs for thedevice.
&statepathval() Status of the connection to the partner device. Valuesas integers: VT_UI1, read-only.
1The device cannot be reached with a ping or there areno active read or write jobs.
2Jobs could be executed successfully with this device.
3The device cannot be reached with a ping or the lastjob was terminated with an error that suggests a com-munication abort and there are still active jobs for thedevice.
OPC Process Variables for SIMATIC NET
274SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The following information parameters are visible only when you select “No SNMP” duringconfiguration because the device does not support SNMP but only the ping:
sysContact The text entered in the sysContact field during configuration;VT_BSTR, read-only.
sysLocation The text entered in the sysLocation field during configuration;VT_BSTR, read-only.
sysName The text entered in the sysName field during configuration;VT_BSTR, read-only.
Example
SNMP:[OSM]&ipaddress()
The configured IP address of the node name with the name OSM is returned.
Information on the SNMP OPC Server
The OPC server provides variables with which information about the SIMATIC NETSNMP OPC Server can be queried.
You can query the following information:
� Version of the SIMATIC NET SNMP OPC Server
� Version of the Winsocket
� Information on trap reception
Syntax
SNMP:[SYSTEM]&<informationparameter>()
Explanations
SNMP
SNMP protocol for access to the information variables for the local system.
SYSTEM
Identifier of the local system; the same is fixed.
OPC Process Variables for SIMATIC NET
275SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<informationparameter>
The following information parameters are defined:
version Version identifier of the SIMATIC NET SNMP OPCServer. VT_BSTR, Read-only.
&winsockversion() Version identifier of the Winsocket. VT_BSTR, Re-ad-only.
&traplists() Indicates whether the SIMATIC NET SNMP OPCServer was able to log on to receive traps.VT_BOOL; Read-only.
FALSEThe SNMP OPC Server could not log on to receivetraps.
TRUEThe SNMP OPC Server logged on successfully toreceive traps.
Example
SNMP:[SYSTEM]&version()
The version of the SIMATIC NET SNMP OPC Server is returned, for example “SIMATICNET Core Server SNMP V6.1.1000.2815 Copyright SIEMENS AG”
4.8.5 SNMP-specific Traps
How the OPC Server Handles Traps
Traps are events sent spontaneously by the device to the OPC SNMP Server. The OPCserver processes these events as described below:
� The trap is mapped as a simple event on the Alarms & Events interface.
� For each configured trap, two variables are created on the Data Accessinterface: One variable is incremented each time the relevant trap occurs, theother variable stores a description of the trap.
Syntax
First variable for the number of the occurrences of the event:
SNMP:[<devicename]<trapname>
OPC Process Variables for SIMATIC NET
276SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Second variable for describing the trap:
SNMP:[<devicename>]<trapname>_description
Explanations
SNMP
SNMP protocol for access to the process variables (MIB objects) and trapvariables.
<Teilnehmername>
The device name is specified during configuration of the system.
<trapname>
Name of the trap.
Example
The first variable returns the number of cold start traps triggered by the partner device:
SNMP:[OSM]coldStart
The second variable returns a description of the trap:
SNMP:[OSM]coldStart_description
4.9 Restricting Access Rights of the OPC Variables
Specifying Access Rights in STEP 7 or NCM
In STEP 7 or NCM, you can activate the access rights in the properties dialog ofthe OPC server. As default, the access rights of the variables are set toRead/Write (RW) by activating the relevant check box but this can be changedwhen necessary to Read (R), Write (W) or None.
In the “Item-specific Access Rights” dialog box, you can define access rights thatdiffer from the settings for all items. The rights entered in this dialog box thenoverwrite the default access rights.
Assign OPC Item-specific Access Rights
Here, enter the access rights for one or more OPC items. The default rightsdefined for the other OPC items are not affected. The syntax is defined as follows:
<OPCItem>=<rights>
OPC Process Variables for SIMATIC NET
277SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
<OPCItem>
Specification of one or more OPC items according to the syntax defined in the OPCdocumentation. The use of alias names is possible. The following placeholders canbe used:
* any number of characters
? exactly one character
<rights>
RW read and write access
R read access only
W write access only
NONE neither write nor read access
Rules for Evaluation
The specific rights assigned here have priority over the default rights you assignedin the access protection area. The specific rights assigned here are evaluated inthe order in which they are entered here. If there is a multiple assignment for anOPC item, the last assignment is always valid.
Example:
DP:[CP 5611]Slave040_AB*=RWDP:[CP 5611]Slave040_AB1=RDP:[CP 5611]Slave040_AB2=WDP:[CP 5611]Slave040_AB1=WDP:[CP 5611]Slave040_AB1*=R
As a result of the entry, the following access rights, among others, are effective:
DP:[CP 5611]Slave040_AB2=WDP:[CP 5611]Slave040_AB1=R
OPC Process Variables for SIMATIC NET
278SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
279SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Properties of the OPC Event Server fromSIMATIC NET
5.1 Event Server for S7 Communication
5.1.1 Functions and Alarm Categories
Introduction
This section describes the events returned by the OPC server and which additionalinformation is available in the form of attributes.
A&E Server for SIMATIC NET
The OPC server for SIMATIC NET can be used as a simple event server or as aconditional event server. A simple event server has no configuration information foralarm and event handling in an operator control and monitoring system.
Figure 5-1 Principle of Alarms and Events Communication between Client and A&E Server
Condition-related events can include subconditions. It is also possible to defineseveral subconditions for an alarm. Such an event occurs when the subconditionsare satisfied.
5
Properties of the OPC Event Server from SIMATIC NET
280SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Condition-related events also allow evaluation of the conditions to be activated ordeactivated by the server and the option of an acknowledgment.
The Event Server in the System
A Simple Event Server passes on only simple messages to the underlyingcomponents. A higher- level alarm/event management server processes themessages of the lower level simple server taking into account configurationinformation.
Figure 5-2 The Event Server in the System
S7 Protocol
The S7 protocol provides the protocol mechanism “Programmed Messages(ALARM)” for transferring events.
The message type is used by the Simple Event Server.
Properties of the OPC Event Server from SIMATIC NET
281SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Alarm Category
The following Alarms&Events categories are available for S7 communication:
Event categoryvalue
Description
EVENTCATEGORY_S7SIMPLE2
Simple events for the following S7alarms:NOTIFYALARMALARM_8ALARM_8P
EVENTCATEGORY_S7TO11
SIMOTION -specific alarms.
EVENTCATEGORY_DIAGNOSIS12
Contain the entries in the diagnosticbuffer of the module.
EVENTCATEGORY_S7CONDITION13
Condition events for the following S7alarms:NOTIFYALARMALARM_8ALARM_8PALARM_SALARM_SQ
EVENTCATEGORY_STATEPATH14
Alarms for displaying an uninterrup-ted connection to a device.
5.1.2 Parameters for Events
Parameters for all Events
By calling the OnEvent callback function of the client, the client obtains a list ofevents. Which parameters the OPC event server supplies depends on the type ofevent. The following parameters are relevant for all events:
Parameter Meaning
szSource As the source of the message, the OPC Eventserver specifies the connection information of thereporting S7 device. This is made up as follows:
S7:\<connectionname>
Properties of the OPC Event Server from SIMATIC NET
282SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
ftTime The time at which the event occurred.
szMessage The name of a message is made up of themessage mechanism and the configuredmessage number:
ALARM<messagenumber>
Examples: ALARM55
dwEventType The OPC Event server supports the followingevents:
OPC_SIMPLE_EVENTThis constant has the value 0x0001.
OPC_CONDITION_EVENTThis constant has the value 0x0004.
dwEventCategory The following values are possible as event cate-gory:
EVENTCATEGORY_S7SIMPLE (2)EVENTCATEGORY_S7T0 (11)EVENTCATEGORY_DIAGNOSIS (12)EVENTCATEGORY_S7CONDITION (13)EVENTCATEGORY_STATEPATH (14)
dwSeverity A predefined value is returned for the severity ofthe error. This value can be modified for indivi-dual message numbers of a communication part-ner in the configuration database.
dwNumEventAttrs The number of attributes supplied with the mes-sage depends on the number of supplied asso-ciated values.
pEventAttributes This structure contains the attributes suppliedwith the event. The attributes also include theassociated values of the message supplied bythe partner device.
Properties of the OPC Event Server from SIMATIC NET
283SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Parameters for Condition-related Events
For condition-related events, the following additional parameters are transferred:
Parameter Meaning
szConditionName Name of the condition.
szSubconditionName Name of the subcondition. If there is no subcondi-tion, this parameter has the name of the condi-tion.
wChangeMask Indicates which state change caused the messa-ge to be sent. Possible values include for exam-ple OPC_CHANGE_QUALITY or OPC_CHAN-GE_SUBCONDITION.
wNewState The status of the subcondition contained in theszSubconditionName parameter. The followingvalues are possible:OPC_CONDITION_ACTIVEOPC_CONDITION_ENABLEOPC_CONDITION_ACKED
wQuality Contains information on the quality of the value towhich the message relates.
bAckRequired Indicates whether the message requires an ack-nowledgment.
ftActiveTime The time at which the subcondition was activated.If no subcondition exists, this parameter containsthe time from which the condition was satisfied.
dwCookie Cookie assigned by the server for the message.
szActorID Contains application-specific information aboutthe cause of the event.
Properties of the OPC Event Server from SIMATIC NET
284SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
5.1.3 Event Attributes
An S7 station can send up to 10 associated values with a message or an alarm.These associated values are available in the event attributes via the OPC Alarms& Events interface.
Programmed messages (ALARM) provide the following attributes:
� EVENT_ATTR_S7_ACK_STATE
� EVENT_ATTR_S7_DATAn
� EVENT_ATTR_S7_DATAn_DATATYPE
� EVENT_ATTR_S7_DATAn_VALUE_LEN
� EVENT_ATTR_S7_EVENT_STATE
� EVENT_ATTR_S7_NO_DATA
� EVENT_ATTR_S7_PCTIME
� EVENT_ATTR_S7_S7TIME
� EVENT_ATTR_S7_STATE
� EVENT_ATTR_S7_TYPE
EVENT_ATTR_S7_ACK_STATE
Value: 6003
Data type: VT_UI2
Acknowledgment status of the alarm on the S7 programmable controller.
It is not possible to acknowledge messages using the OPC Event Server forSIMATIC NET. Messages can, however, be acknowledged by other user interfacesystems.
ALARM Messages
The bit indicates:
0 Acknowledgment 1 entered state
1 to 6 Acknowledgment 2 to 7 entered state
7 Acknowledgment 8 entered state
8 Acknowledgment 1 left state
9 to 14 Acknowledgment 2 to 7 left state
15 Acknowledgment 8 left state
Properties of the OPC Event Server from SIMATIC NET
285SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
EVENT_ATTR_S7_DATAn
Value: where n = 0
where n = 1
where n = 2
where n = 3
where n = 4
where n = 5
where n = 6
where n = 7
where n = 8
where n = 9
6008
6012
6016
6020
6024
6028
6032
6036
6040
6044
Data type: VT_ARRAY | VT_UI1
The relevant bytes of associated value no. n as array of bytes.
EVENT_ATTR_S7_DATAn_DATATYPE
Value: where n = 0
where n = 1
where n = 2
where n = 3
where n = 4
where n = 5
where n = 6
where n = 7
where n = 8
where n = 9
6006
6010
6014
6018
6022
6026
6030
6034
6038
6042
Data type: VT_UI2
Data type of the associated value no. n.
Properties of the OPC Event Server from SIMATIC NET
286SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter value Description
S7_DATATYPE_ERROR Error (0x0)
S7_DATATYPE_BOOLEAN Boolean (0x03)
S7_DATATYPE_INTEGER Integer (0x05)
S7_DATATYPE_FLOAT Float (0x07)
S7_DATATYPE_OCTET_STRING String (0x09)
S7_DATATYPE_BITSTRING Bit string (0x04)Note:Length information in bytes instead ofbits
S7_DATATYPE_DATE Date (0x30)Note: Days since 01.01.1990
S7_DATATYPE_TIME_OF_DAY Time (0x31)Note: ms since the start of the day
S7_DATATYPE_TIME Time (0x32)Note: ms
S7_DATATYPE_S5TIME Time (0x33)Note: BCD-coded
EVENT_ATTR_S7_DATAn_VALUE_LEN
Value: where n = 0
where n = 1
where n = 2
where n = 3
where n = 4
where n = 5
where n = 6
where n = 7
where n = 8
where n = 9
6007
6011
6015
6019
6023
6027
6031
6035
6039
6043
Data type: VT_UI2
Number of relevant bytes of associated value no. n.
Properties of the OPC Event Server from SIMATIC NET
287SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
EVENT_ATTR_S7_EVENT_STATE
Value: 6004
Data type: VT_UI2
Event state
The bit indicates:
Bit 0 Current status (1 = active)
Remaining bits irrelevant
EVENT_ATTR_S7_NO_DATA
Value: 6005
Data type: VT_UI2
Number of associated values
Range of values: 1 through 10
EVENT_ATTR_S7_PCTIME
Value: 6000
Data type: VT_DATE
Time at which the OPC Event Server received the message.
EVENT_ATTR_S7_S7TIME
Value: 6001
Data type: VT_DATE
Time at which the message was generated on the partner device.
EVENT_ATTR_S7_STATE
Value: 6002
Data type: VT_UI2
General status indicating whether or not a message exists.
Properties of the OPC Event Server from SIMATIC NET
288SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
ALARM Messages
The bit indicates:
0x00H (all bits 0) The message exists
Bit 0 set Initialization
Bit 1 set Overflow signal
Bit 2 set Overflow instance
Bit 3..5 0, reserved
Bit 6 set Additional values cannot be ent-ered (size)
Bit 7 set Additional values not obtainable
EVENT_ATTR_S7_TYPE
Value: -5
Data type: VT_UI4
The following attribute values exist:
Event category Value
EVENTCATEGORY_S7CONDITION EVENT_TYPE_CONDITION
EVENTCATEGORY_S7SIMPLE EVENT_TYPE_SIMPLE
5.1.4 Event Attributes for SIMOTION-specific Alarms
EVENT_ATTR_S7TO_TYPE
Value: -5
Data type: VT_UI4
Attribute value: EVENT_TYPE_CONDITION
Properties of the OPC Event Server from SIMATIC NET
289SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
EVENT_ATTR_S7TO_ALARMID
Value: 5100
Data type: VT_I4
Unique alarm number.
EVENT_ATTR_S7TO_INSTANCEID
Value: 5101
Data type: VT_I4
RT-ID of the object instance.
EVENT_ATTR_S7TO_SEQUENCENO
Value: 5102
Data type: VT_CY
Consecutive number.
EVENT_ATTR_S7TO_GUID
Value: 5103
Data type: VT_ARRAY or VT_UI1
RT-GUID of TO type.
EVENT_ATTR_S7TO_ALARMTYPE
Value: 5104
Data type: VT_UI1
SIMOTION -specific additional value.
EVENT_ATTR_S7TO_ACKTYPE
Value: 5105
Data type: VT_UI1
SIMOTION -specific additional value.
Properties of the OPC Event Server from SIMATIC NET
290SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
EVENT_ATTR_S7TO_TIMESTAMP
Value: 5106
Data type: VT_DATE
Time stamp.
EVENT_ATTR_S7TO_TIMESTAMPPC
Value: 5107
Data type: VT_DATE
Time stamp of the SIMATIC NET core server.
EVENT_ATTR_S7TO_PARAMDATA
Value: 5108
Data type: VT_ARRAY or VT_UI1
SIMOTION -specific additional value.
5.1.5 Attributes for Entries in the Diagnostic Buffer of the Module
EVENT_ATTR_DIAGNOSIS_TYPE
Value: -5
Data type: VT_UI4
Attribute value: EVENT_TYPE_SIMPLE
EVENT_ATTR_DIAGNOSIS_S7_PCTIME
Value: 6000
Data type: VT_DATE
Time stamp of the SIMATIC NET core server.
Properties of the OPC Event Server from SIMATIC NET
291SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
EVENT_ATTR_DIAGNOSIS_S7_S7TIME
Value: 6100
Data type: VT_DATE
Time stamp.
EVENT_ATTR_DIAGNOSIS_S7_DIAGNOSISID
Value: 6048
Data type: VT_I4
Diagnostic event number, analog EventID.
EVENT_ATTR_DIAGNOSIS_S7_DIAGNOSISDATA
Value: 6049
Data type: VT_ARRAY or VT_UI1
Information on the diagnostic event or its effects, data length depending on theevent class.
5.1.6 Attributes or Alarms Indicating an Interrupted Connection
EVENT_ATTR_STATEPATH_TYPE
Value: -5
Data type: VT_UI4
Attribute value: EVENT_TYPE_CONDITION
Properties of the OPC Event Server from SIMATIC NET
292SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
5.2 Simple Event Server for SNMP Communication
Forwarding Traps
Traps are forwarded as so-called simple events via the IEvent interface to the OPCA&E Server. In addition to this, the frequency of the occurrence and the descriptionof a trap are available as an OPC item.
Requirements
� The IP address of the PC with the OPC SNMP server must be entered as atrap recipient on the SNMP-compliant device and the traps must be activated.This is implemented by device-specific configuration tools (refer to theCommissioning PC Stations manual).
� The Windows SNMP service must be installed.
OPC Alarm Server Name: OPC.SimaticNetAlarmsSNMP
Alarms & Events Categories
The following Alarms & Events categories are available and are described ingreater detail below:
CategoryNumber
Name Description
20 EVENTCATEGORY_SNMP_GENERICTRAP
SNMP trap event (generictrap)
21 EVENTCATEGORY_SNMP_SPECIFICTRAP
SNMP trap event (specifictrap)
Generic traps are specified by standards and have the same significance for alldevices. Specific traps are device-specific. The SNMP OPC Server is informedwhether or not a trap is generic or specific by the device profile file.
These categories “generic” or “specific” must be understood in the context of theterm “Category”. Alarms and events of every category can occur on any partnerdevice (“source”). Different alarms and the events of one and the same categoryfrom the same partner device are identified by their different EventIDs.
Traps are triggered by the communication partner and forwarded by the SNMPprotocol to the SIMATIC NET SNMP OPC Server. With high communication loads,traps can be discarded by the SNMP protocol so that the SIMATIC NET SNMPOPC Server does not necessarily receive all traps.
Properties of the OPC Event Server from SIMATIC NET
293SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Traps do not have a status and are not acknowledged and consequently theSIMATIC NET SNMP OPC Server does not manage a state machine for the traps.
By calling the OnEvent callback function of the client, the client obtains a list ofevents. The SNMP Event Server returns the following server-specific parameters:
Parameter Meaning
dwEventCategory The following value is possible as the event category:
EVENTCATEGORY_SNMP_GENERICTRAP = 20
EVENTCATEGORY_SNMP_SPECIFICTRAP = 21
dwEventType The SNMP OPC Event server supports only the follo-wing type:
OPC_SIMPLE_EVENT
This constant has the value 0x0001.
dwNumEven-tAttrs
The number of attributes supplied with the messagedepends on the number of supplied associated values.
dwSeverity A predefined value is returned for the severity of theerror. This value can be modified for individual messagenumbers of a communication partner in the configura-tion database.
pEventAttributes This structure contains the attributes supplied with theevent. The attributes also include the associated valuesof the message supplied by the partner device.
szMessage Trap event name from the device profile file:
<Namenstext>
e.g. TrapPowerDown
szSource As the source of the message, the SNMP OPC EventServer specifies the device information of the reportingSNMP device. This corresponds to the device name ofan SNMP variable for OPC Data Access:
SNMP:\<device>
e.g. SNMP:\Switch33
Properties of the OPC Event Server from SIMATIC NET
294SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Along with this event, additional information in the form of attributes can also besent. SNMP traps provide the following attributes:
Attribute IDvalue
Attributes Meaning
EVENT_ATTR_SNMP_PCTIME6100
VT_DATE Time at which the OPCserver received themessage.
EVENT_ATTR_SNMP_TIMESTAMP6101
AsnTimeticks(VT_UI4)
Time at which the mes-sage was generated onthe partner device.
EVENT_ATTR_SNMP_EVENTID6102
LONG (VT_I4) Unique trap number wit-hin the device
EVENT_ATTR_SNMP_ENTERPRISE6103
AsnObjectIdentifier(VT_BSTR)
Device-specific trap
EVENT_ATTR_SNMP_AGENTADDRESS6104
AsnNetworkAddress(VT_BSTR)
IP address of agent
EVENT_ATTR_SNMP_SOURCEADDRESS6105
AsnNetworkAddress(VT_BSTR)
IP address of trap sour-ce
EVENT_ATTR_SNMP_VARBINDINGS6106
SnmpVarBindList(VT_ARRAY |VT_VARIANT)
Variable bindings of thesent trap
295SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Using the OPC Server
This section explains the various options open to you when you work with the OPCserver.
6.1 SIMATIC Computing
With the SIMATIC Computing software as part of the SIMATIC NET PC software,you can create simple applications with which you can access process datawithout a lot of programming effort. The process data can be read and written overany SIMATIC NET communication system.
SIMATIC Computing provides you with various ActiveX controls. You can configureand interconnect these ActiveX controls to suit your task.
Compatibility with OPC
The ActiveX controls from SIMATIC NET use the OPC interface directly.
Applications created using the ActiveX controls of SIMATIC NET can also beoperated with OPC servers of other vendors. Check the licensing situation first.
Compatibility with Earlier Versions
Older versions of SIMATIC NET and SIMATIC Computing for WinAC and WinLCincluded the data control “S7Data” control. This version also includes the new,more convenient SIMATIC NET OPC Data control.
The functionality of the S7Data control continues to be supported, however, thecontrol will not be developed any further and is not described in thisdocumentation. In future, you should use the new SIMATIC NET OPC Datacontrol.
6
Using the OPC Server
296SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
When you interconnect a process variable via the ActiveX controls, you establishaccess to process data. If you change the values of a process variable in anActiveX control, the values in the process can change as a direct result.
Changing process data can trigger unexpected reactions in the process that canlead to serious injury to persons or damage to equipment.
With this in mind, a degree of caution is necessary. You should, for example,restrict access rights for process variables. Install a physical emergency stopcircuit for the machine or process.
6.1.1 What Are ActiveX Controls?
SIMATIC Computing provides you with various ActiveX controls. You can work withthe SIMATIC display controls or connect other ActiveX controls (other vendors orcontrols you have developed yourself) with the SIMATIC NET OPC Data control.
SIMATIC NET OPC Data Control
The most important control is the SIMATIC NET OPC Data control. Without thiscontrol, no other SIMATIC control can access process data. This Data controlaccesses process data obtained by the OPC server.
Control Appearance Brief Description
SIMATIC NETOPC Data
Establishes the connection to theOPC server.
The data control is invisible while theprogram is running.
Display Controls
The display controls are elements for visualizing process data. They receive theirdata via the SIMATIC NET OPC Data control and not directly by access to OPC oranother interface.
Using the OPC Server
297SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The following SIMATIC display controls are available:
Control Appearance Brief Description
Button Accesses individual bits stored on theOPC server. The button control ac-cesses only in the bit format andworks with two values:
Off = 0
On = 1
If you change the state of the buttoncontrol, the state of the variable assi-gned to the control also changes.
If you set up write protection for thebutton control, it more or less worksas a lamp or LED.
Number Accesses the process data via varia-bles. You can access in the byte,word, or double-word format andchange individual bits within the data.
When you enter a new value in thenumber control, the values change inthe process.
Slider Accesses the process data via varia-bles. You can access in the byte,word, and double-word format.
When you change a value in the slidercontrol, the values change in the pro-cess.
Using the OPC Server
298SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.2 How Do Controls Access Process Data?
Before the SIMATIC Button, Number, and Slider controls or other controls canaccess process data, the following is required:
� The connection between the SIMATIC NET OPC Data control and an OPCserver.
� The interconnection between a property of a process variable of the OPCserver (value, quality, timestamp) with a property of a display control (forexample, value, background color etc.).
The Data control configures the OPC server so that the assigned variables aremonitored permanently. If a value changes, the new value is passed to the Datacontrol and written to the other controls by the Data control.
The graphic illustrates the relationship between the SIMATIC NET OPC Datacontrol and other SIMATIC controls.
Figure 6-1 Connection between the SIMATIC NET OPC Data Control and Module for ProcessInterfacing
Using the OPC Server
299SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.3 How Does Access with DCOM Work?
With the SIMATIC NET OPC Data control, you can connect your program with anOPC server on another computer.
Figure 6-2 Connecting an OPC Server with DCOM
Using the OPC Server
300SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.4 How Are SIMATIC NET Controls Used in a DevelopmentEnvironment?
Before you can use SIMATIC NET Controls in a development environment, theymust be made known in the development environment.
Below, we will describe the procedure for Visual Basic. If you use a differentapplication, you will need to adapt the steps to your application.
1. Start Visual Basic and create a new project.
2. Open the Project menu and select the Components command.
The Components window opens. The Controls tab displays all the ActiveXcontrols available on your computer.
3. Select the SIMATIC NET Controls.
SIMATIC NET Controls
4. Click the OK button.
The Components window closes, the SIMATIC NET Controls have beeninserted in your development environment.
Using the OPC Server
301SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.5 Configuring the SIMATIC NET OPC Data Control
The SIMATIC NET OPC Data Control establishes the connection between ActiveXcontrols and the OPC server.
The Data control has properties that you can set in container applications (forexample Visual Basic).
Figure 6-3 Data Control
How does it work?
You configure the SIMATIC NET OPC Data control in the following steps:
� Open the Properties window for SIMATIC NET OPC Data Control
� Select OPC server
� There are two ways to continue from here:
� Connect the properties of display controls with the properties of the OPCprocess variables
� Assign OPC Process Variables to Events and to the Programmed Handlingof Change Messages
� Optional Tasks
Creating a Program
The SIMATIC NET OPC Data control is visible as an icon in the design phase. TheData control then only communicates with the OPC server to query the OPC namespace when the OPC server is available locally or on the target computer and isoperable.
The SIMATIC NET OPC Data control can be configured in the Property Pageswindow.
Program Execution
When the created program is running, the SIMATIC NET OPC Data control worksin the background. For the user of the application, it is not visible.
Using the OPC Server
302SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.6 Opening the Properties Window for SIMATIC NET OPC DataControl
You configure the SIMATIC NET OPC Data control in the Properties Pageswindow that you open from your container application.
Below, we will describe the procedure for Visual Basic. If you use a differentapplication, you will need to adapt the steps to your application.
1. Click on the Data control with the right mouse button.
The context-sensitive menu is opened.
2. Select the Properties menu.
The Property Pages window opens.
6.1.7 Selecting the OPC Server
The SIMATIC NET OPC Data control as an OPC client for the OPC Data Access2.0 interface can use any OPC server. The OPC server can be local or can beaccessed on a remote computer over the network.
1. Select the OPC server tab in the Property Pages window.
2. Enter the name of the OPC server in the “Server” field, for exampleOPC.SimaticNET.
You can also select the OPC server using the Browse button.
3. If you want to connect to an OPC server over a network using DCOM, enter thename of the target computer in the Computer box.
In this case, all the computers must be configured for DCOM.
4. Click the OK button.
Your settings are saved.
Using the OPC Server
303SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.8 Connecting Display Controls and Process Variables
You can connect the properties of display controls with the properties of the OPCprocess variables.By configuring a connection between the display and the process variable, the dataof the variable is displayed while the program is running.
How does it work?
You connect display controls as shown below:
Select the property of a control for displaying or entering process information
You can also perform the following optional tasks:
� Delete the assignment of a property to a variable
� Filter the properties of an ActiveX control
� Configure general properties
Select the property of a control for displaying or entering process information
To be able to display or enter process data, you must connect the property ofanother ActiveX control with a property of an OPC variable via the SIMATIC NETOPC Data control.The properties of an OPC variable are value, quality, and timestamp.
Examples
� The Text property of a text box of Visual Basic is connected to the value ofmemory word 5.
The text box then displays the content of memory word 5.
� The BackColor property of the SIMATIC Number control is interconnected withthe quality of memory word 5. The color codes green, red, and yellow areassigned to the quality states GOOD, BAD and UNCERTAIN.
The background color of the Number control changes when the quality of theprocess variable changes, for example due to a wire break.
Using the OPC Server
304SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
How to Select a Property of a Display Control
1. Select the Items tab in the Property Pages window.
2. Click the Assign New button.
The Assign Items window opens.
3. In the Controls list box, select the properties of the control you require.
4. Select the property you want to connect to a process variable.
5. From the upper box that displays the name space of the server, select theprocess variable you want to connect with the selected property.
The ItemID of the selected variable appears in the Assigned Item box.
You can also enter an ItemID directly in this box.
6. Specify the property of the OPC items that will be used for visualization.
The available options are as follows:
Property of the Process Va-riable
Meaning
Value The value of the process variable willbe connected to the selected ActiveXcontrol property.
Time stamp The timestamp of the process varia-ble will be connected to the selectedActiveX control property.
The timestamp is transferred as astring. You can specify the format inwhich the timestamp is displayed.
Quality The quality of the process variable willbe connected to the selected ActiveXcontrol property.
You can specify which value is usedfor the quality. You can, for example,select a color code or a meaningfultext.
7. Repeat steps 3 through 6 until you have assigned all the required properties.
8. Click the OK button.
The Assign Items window closes. The values of the selected properties arenow set by the process variables.
Using the OPC Server
305SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.9 Assigning an Event to a Process Variable
You can assign process variables to events. If the variable changes during runtime,the Data control generates an event whose parameter contains the event name.Your program can react to the event and therefore to the change in the variable.
Assigning an Event to a Process Variable
You can configure events generated by the Data control by assigning a processvariable to each event.
1. Select the Events tab in the Property Pages window.
2. Select the Add... button.
The Add Events window opens.
3. Enter a name for the event in the User ID field.
4. From the upper box that displays the name space of the server, select theprocess variable you want to connect with the selected event.
The ItemID of the selected variable appears in the Item ID box.
You can also enter an ItemID directly in this box.
5. Click the Add... button.
The process variable is assigned to the event.
6. Repeat steps 4 through 7 until you have assigned all the required events.
7. Click the OK button.
The Add Events window closes.
Note
To be able to react to events configured as shown above in your program, youmust implement the ValueChanged method of the Data control.
Using the OPC Server
306SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.10 Optional Tasks
As an option, you can also perform the following tasks on the Data control:
Delete the assignment of a property to a variable
You can delete the assignment of a property to a variable in two ways:
� You delete the ActiveX control in the container application.
� You delete the assignment in the Property Pages window.
If you delete the display ActiveX control in the container application, the connectionremains configured in the Data control. The next time you insert a control in theapplication, this new control automatically receives the name of the deleted control.The configured connection properties of the deleted control are also adopted.
In the Property Pages window, you can remove the assignment completely.
1. Select the Items tab in the Property Pages window.
2. Click the Assign New button.
The Assign Items window opens.
3. Display the properties of the ActiveX control for which you want to delete theassignment.
4. Select the property whose assignment you want to delete.
5. Delete the value in Assigned Item.
The assignment of the process variable to the selected property is deleted.
6. Click the OK button.
The Assign Items window closes.
Note
You can only delete the connection when it is not used in the container application.
Using the OPC Server
307SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Filter the properties of an ActiveX control
With a display control, you can edit selected properties only, for example Enabledor Value. To do this, you can filter the properties.
1. Select the Items tab in the Property Pages window.
2. Click the Assign New button.
The Assign Items window opens.
3. Select the Filter... button.
The Property Filter window opens.
4. Select the Add... button.
The Add window opens.
5. Specify the property to be selected.
6. Click the OK button.
The Add window closes.
7. In the Property Filter window, you can modify an entered property with theEdit button.
With the Delete button, you can delete a selected property from the filter.
8. Select the OK button.
The Property Filter window closes.
9. Select the Filter check box in the Assign Items window.
For all ActiveX controls, only the properties specified in the filter will now bedisplayed.
If you deactivate the Filter check box, all the properties will be displayed again.
Configure general properties
You can configure the following properties:
� Autoconnect (automatic connection)
If Autoconnect is activated, the data control is automatically connected to thevariables of the OPC server after configuration.
If Autoconnect is deactivated, the data control is only connected to the variablesas a result of instructions in the program code.
� AutoConnect Timeout
This property decides how many milliseconds the data control will wait afterconnecting to the OPC server before it writes data.
� Default Dead Band
This property decides how large changes must be before the OPC server writesa new value to the data control.
Using the OPC Server
308SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� Default Update Rate
This property specifies the time interval in milliseconds at which the OPC serverchecks the process variables for changes.
� Show Error Boxes
If Show Error Boxes is activated, standard error messages are displayed if usererrors occur.
SIMATIC Computing displays all error messages in English. If you want todisplay the messages in other languages, deactivate the Show Error Boxesoption and write an additional program for error messages.
1. Select the Options tab in the Property Pages window.
2. Enter the required values in the boxes.
3. Click the OK button.
You have now configured the properties.
6.1.11 Configuring a Button Control
With the Button control, you can create a button for working with Boolean processvariables. During runtime, the button control displays the variable state with itscolor and label. If you click this button during runtime, you can change the value ofthe Boolean process variable.
You connect the button with a process variable by assigning an OPC variable tothe Value property of the Button control.
With the Button control, there are two animation states:
� 0 or off
� 1 or on
Figure 6-4 Button Control
Using the OPC Server
309SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
How does it work?
You can configure a Button control in the following steps:
6.1.12 Properties of the Button Control
The Button control has the following properties:
Proper-ty
Tab in theSiemens But-ton ControlPropertiesWindow
Brief Description Described in
Enabled General Specifies whether thecontrol passes onchanges to Value andtriggers events
Activating the But-ton Control
False-Caption
General Specifies the labelingof the control if Valuehas the value false, 0,or off
Specifying the Label
False-Color
Color Specifies the color ofthe control if Valuehas the value false, 0,or off
Specifying the Co-lor of the ButtonControl
Font Font Specifies the font forlabeling the control
Specifying theFont of the Label
True-Caption
General Specifies the labelingof the control if Valuehas the value true, 1or on
Specifying the La-bel
TrueCo-lor
Color Specifies the color ofthe control if Valuehas the value true, 1or on
Specifying the Co-lor of the ButtonControl
Value Value displayed or entered by the Buttoncontrol. This property is connected to aprocess variable via the Data control.
Connecting theButton Control withthe Process Data
Using the OPC Server
310SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.13 Opening the Properties Window for the Button Control
You open the Property Pages window in the container application.
Here, we will show you the procedure in Visual Basic. If you use a differentapplication, you will need to adapt the steps accordingly.
1. Select the Button control you want to configure.
2. Right-click on the control.
The context-sensitive menu is opened.
3. Select the Properties command.
The Property Pages window opens.
6.1.14 Specifying the Label
You can specify two different labels for the Button control:
� Label of the button when the bit has the value true, 1 or on.
� Label of the button when the bit has the value false, 0 or off.
1. Select the General tab in the Property Pages window.
2. Enter the label that the button will display when the bit has the value true, 1 oron in the TrueCaption box.
3. Enter the label that the button will display when the bit has the value false, 0 oroff in the FalseCaption box.
6.1.15 Specifying the Font of the Label
You can make the following settings for the font of the Button control:
� Font
� Font size
� Effects
1. Select the Font tab in the Property Pages window.
2. Select the font for the label in the Font list box.
3. Select the font size in the Size list box. You can also overwrite the displayedvalues.
4. Select the required effects in the Effects list box.
A sample text reflecting the settings you have made it is displayed in the Sample Text box.
Using the OPC Server
311SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.16 Specifying the Color of the Button Control
You can specify colors for the two states of the Button control by selecting a colorfrom the color palette or defining a color yourself.
1. Select the Color tab in the Property Pages window.
2. If you want to define the off state, select FalseColor in the Properties box. Ifyou want to define the on state, select TrueColor.
3. Select the color palette you want to use in the Color Set list box.
The colors of the selected color palette appear in the Color Palette box.
You can define your own colors by clicking the Edit Custom Color... button.
4. Select the required color.
6.1.17 Activating the Button Control
As default, the Button control is activated following configuration. You candeactivate or reactivate the Button control in the Siemens Button ControlProperties window at any time:
1. Select the General tab in the Siemens Button Control Properties window.
The Button control is activated when the Enable check box is selected.
The Button control is deactivated when the check box is not selected.
2. If necessary, change the selection.
Using the OPC Server
312SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.18 Connecting the Button Control with the Process Data
If you want to display or modify the value of a process variable with the Buttoncontrol, you connect the Value property of the Button control with a processvariable in the SIMATIC NET OPC Data control.
The Value property of the Button control can only be assigned to a bit. If variableswith data types other than Boolean are used, the values of the variables will beconverted to a Boolean value when possible by the OPC server.
Figure 6-5 Connecting the Button Control with the Process Data
Note
After you have assigned a variable to the Button control, the control can accessprocess data. If you change the value displayed by the control, you also changethe value in the real process at the same time.
Changing process data can trigger unexpected reactions in the process that canlead to serious injury to persons or damage to equipment. Always install a physicalemergency stop circuit for the machine or process.
Using the OPC Server
313SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.19 Configuring a Number Control
With the number control, you can display and modify process data in numericformat.
Figure 6-6 Number Control
During runtime, the value of the variable is displayed in the display area. Here, youcan enter a new value. Depending on the configuration, newly entered values aremodified immediately or only after clicking the button for input to the OPC server.
How does it work?
You can configure a number control in the following steps:
6.1.20 Properties and Methods of the Number Control
The Number control has the following properties and methods:
Property or Method
Tab in theSiemensNumberControl Pro-perties Win-dow
Brief Descrip-tion
Described in
Alignment General Specifies thealignment of va-lues displayed inthe Number con-trol
Defining DataDisplay
Appearance Style Specifies three-or two-dimensio-nal display ofthe control
Specifying theAppearance
BackColor Color Specifies thebackground co-lor
Specifying theColor of theNumber Control
Using the OPC Server
314SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Property or Method
Described inBrief Descrip-tion
Tab in theSiemensNumberControl Pro-perties Win-dow
BorderStyle Style Specifies the ap-pearance of thecontrol borders
Specifying theAppearance
Captionn Label Specifies thedisplayed text ofthe first (n=1) orsecond (n=2) tit-le
Specifying theLabel
CaptionnAlign-ment
Label Specifies thealignment of thefirst or secondtitle
Specifying theLabel
CaptionnBack-Color
Color Specifies thebackground co-lor of the first orsecond title
Specifying theColor of theNumber Control
CaptionFont Font Specifies thefont of the twotitles
Specifying theFont of the La-bel
CaptionnFore-Color
Color Specifies the fo-reground colorof the first or se-cond title
Specifying theColor of theNumber Control
CaptionnSize Label Specifies thefont size of thefirst or secondtitle
Specifying theLabel
ConvertedValue read-only Specifies the va-lue of the pro-cess variable
Using the OPC Server
315SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property or Method
Described inBrief Descrip-tion
Tab in theSiemensNumberControl Pro-perties Win-dow
DataType General Specifies the da-ta type to beused for theconverted va-lues
Defining DataDisplay
Enabled Style Specifies whe-ther the controlpasses on chan-ges to Valueand triggersevents
Activating aNumber Control
Factor Scaling Specifies thescaling factor tobe used if thescale-by-for-mula option wasenabled
Specifying theScaling for theDisplay
Font Font Specifies thefont of the con-trol
Specifying theFont of the La-bel
ForeColor Color Specifies the fo-reground colorof the control
Specifying theColor of theNumber Control
LayoutType Label Specifies thelayout of the dis-played label
Specifying theLabel
LimitCheck General Specifies whe-ther or not thevalue should bewithin specific li-mits and definesthe range of vali-dity within the li-mit values
Defining DataDisplay
Locked Style Sets the read-only status
Activating aNumber Control
Using the OPC Server
316SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Property or Method
Described inBrief Descrip-tion
Tab in theSiemensNumberControl Pro-perties Win-dow
LowerLimit General Specifies the lo-wer limit valuefor access
Defining DataDisplay
Offset Scaling Specifies theOffset to beused with thescale-by-for-mula option
Specifying theScaling for theDisplay
Precision General Specifies theprecision of realnumbers
Defining DataDisplay
Radix General Specifies the ba-se for the num-ber to be dis-played: binary,octal, decimal,or hexadecimal
Defining DataDisplay
RangeRawMax Scaling Specifies themaximum valueof the sourcerange
Specifying theScaling for theDisplay
RangeRawMin Scaling Specifies the mi-nimum value ofthe source ran-ge
Specifying theScaling for theDisplay
RangeScaled-Max
Scaling Specifies themaximum valueof the target ran-ge
Specifying theScaling for theDisplay
RangeScaled-Min
Scaling Specifies the mi-nimum value ofthe target range
Specifying theScaling for theDisplay
ScaleMode Scaling Specifies thescaling modeused to scalethe values
Specifying theScaling for theDisplay
Using the OPC Server
317SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property or Method
Described inBrief Descrip-tion
Tab in theSiemensNumberControl Pro-perties Win-dow
ShowButtons General Specifies whe-ther or not thebuttons for ente-ring and deletingvalues are dis-played
Defining DataDisplay
ShowErrorBo-xes
General Specifies whe-ther or not thestandard errormessage is dis-played if a usererror occurs
Defining DataDisplay
UpperLimit General Specifies the up-per limit valuefor access
Defining DataDisplay
Value Value displayed by the Numbercontrol. This property is connectedto a process variable via the Datacontrol.
Connecting Dis-play Controlsand Process Va-riables
Write Writes the valueof Converted-Value to Value
WriteMode Style Specifies whe-ther new valuesare written auto-matically moremanually
Specifying theAppearance
ZeroPad General Specifies whetherthe numberdisplayed by thecontrol is paddedfrom the left withleading zeros untilthe maximumsize of the datatype is reached
Defining DataDisplay
Using the OPC Server
318SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.21 Opening the Properties Window for the Number Control
You open the Property Pages window in the container application.
Here, we will show you the procedure in Visual Basic. If you use a differentapplication, you will need to adapt the steps accordingly.
1. Select the Number control you want to configure.
2. Right-click on the control.
The context-sensitive menu is opened.
3. Select the Properties command.
The Property Pages window opens.
6.1.22 Defining Data Display
You can specify how the Number control displays the values of process variables.You can specify the following:
� Size and appearance of the data.
A table shows the size of the data types for the Number control.
Data type Grade Size Description
Boolean 0 1 bit Boolean value
Byte 1 1 byte Unsigned singlebyte value
Word 2 2 bytes Unsigned two-byte value
Integer 3 2 bytes Signed two-byteinteger value
Double word 4 4 bytes Unsigned four-byte value
Double integer 5 4 bytes Signed four-bytevalue
Real 6 4 bytes Signed four-byteinteger value
� Specifies whether the value is displayed in binary, octal, decimal, orhexadecimal.
� Number of decimal places for real data types.
� Values displayed left-aligned, right-aligned, or centered in the Number control.
� Limit values.
Using the OPC Server
319SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
� Display of leading zeros.
� Display of buttons for entering and deleting values.
� Display of error messages.
Procedure
1. Select the General tab in the Property Pages window.
2. Select the data type in the Data type box. Select the data type to match thedata type of the process variable.
3. In the Radix box, select whether the value will be displayed in binary, decimal,octal, or hexadecimal.
4. If you have selected Real in the Data type box, enter the number of decimalplaces in the Precision box.
If you do not make an entry, the value 3 is set.
5. Using the Alignment buttons, decide whether the value will be displayedright-aligned, left-aligned or centered in the Number control.
6. If you want to display leading zeros, select the Zero Pad box.
As default, the box is not selected.
7. If you want to display the buttons for entering and deleting values, select theShow Buttons box.
If you display the buttons, you must confirm every new entry during runtime.
If you click the entry button, the value will be written to the OPC server.
If you click the delete button, the new value is deleted and replaced by theprevious value.
As default, the box is not selected.
If you have defined the buttons, you can use the following keys as alternativesduring runtime:
Button Key
Entry
Return key
Delete
Escape key
8. If you want to display standard error messages during runtime, select the ShowError Boxes box.
As default, the box is selected.
Using the OPC Server
320SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.23 Specifying the Appearance
You can decide how the Number control appears:
� Two- or three-dimensional appearance
� Border of the control
� Whether changes to Value are automatically written to the OPC processvariable or by program code using Write
Procedure
1. Select the Style tab in the Property Pages window.
2. Choose whether the control has a two- or three-dimensional appearance in theAppearance list box.
You can only set a three-dimensional appearance if the value Fixed Single isselected in the Border Style list box.
3. In the Border Style list box, you can select between a rectangular border or noborder for the control.
4. In the Write Mode list box, you decide whether the values of the Numbercontrol are written to the process variable automatically or by the program.
6.1.24 Specifying the Label
You can specify the label for the Number control:
� Horizontal or vertical alignment of the label
� Horizontal Alignment
Using the OPC Server
321SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Vertical Alignment
� Left-aligned, right-aligned, or centered
� Width or height of the label
� Text for the label
� Color of the label
You specify the color in the Color tab.
� Font of the label
You specify the font for the label in the Font tab.
Procedure
1. Select the Label tab in the Property Pages window.
2. In the Layout Type box, you can choose between horizontal and verticalalignment of the label.
3. If necessary, you can specify the width and height of the Number control in theSize 1 and Size 2 boxes.
If you have selected horizontal alignment, you specify the width of the Numbercontrol with the length of the first and second caption. If you have selectedvertical alignment, you specify the height of the Number control with the heightof the first and second caption.
As default, the value 1 is set. In this case, the size of the label is automaticallyadapted to the length of the text and the size of the font for the captions.
If, however, you want to set up several number controls, it is a good idea tospecify the size so that the number controls have a uniform appearance.
In this case, you enter the size of the captions in twips. A twip is approximately0.018 mm or 567 twips are 1 centimeter on the screen.
4. Enter the text for the first and second captions in the Caption 1 and Caption 2text boxes.
5. With the alignment buttons, you can specify whether the first and secondcaptions are left-aligned, right-aligned, or centered.
Using the OPC Server
322SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.25 Specifying the Scaling for the Display
You can specify a scale for displaying the process variables with the numbercontrol. With the scaling function, the range of values of the process variables isconverted to a range for display. The scaling factor is used at runtime both forreading and writing the values.
You can select the following scaling options:
� No scaling
� Scale by formula
� Scale by range
Procedure
1. Select the Scaling tab in the Property Pages window.
2. Select the scaling option in the Scale mode list box.
As default, No scaling is set.
3. If you have selected Scale by formula in the Scale mode box, you must alsoenter the formula.
Enter a scaling factor in the Scale box.
Enter a constant in the Offset box that will be added to the scaled result beforethis is displayed.
The scaled value is then calculated according to the following formula:
(PLC value x Scale) + Offset = Display
PLC value
Value of the process variable
Scale
Scaling factor
Offset
Constant part
Display
Value displayed in the number control
4. If you have selected the value Scale by range transformation in the Scalemode box, you must specify an upper and lower limit for the value of theprocess variable and the value that will be displayed in the Number control.
Using the OPC Server
323SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.26 Specifying the Font of the Label
You can make the following settings for the font of the Number control:
� Font
� Font size
� Effects
Procedure
1. Select the Font tab in the Property Pages window.
2. Select the font for the label in the Font list box.
3. Select the font size in the Size box or overwrite the displayed value.
4. Select the required effects in the Effects list box.
A sample text reflecting the settings you have made it is displayed in the Sample Text box.
6.1.27 Specifying the Color of the Number Control
You can specify the following colors:
� Background and foreground color of the control
� Background and foreground color for the first and second title
Procedure
You can select colors from a color palette or define them yourself:
1. Select the Color tab in the Property Pages window.
2. Select the entry in the list for which you want to define the color.
3. Select the color palette you want to use in the Color Set list box.
The colors of the selected color palette are displayed in the Color Palette box.
If you want to define your own Colors, click the Edit Custom Color... button.
4. Select the required color.
Using the OPC Server
324SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.28 Activating the Number Control
As default, the Number control is activated following configuration and accessesthe process variable. You can deactivate or reactivate the Number control in theProperty Pages at any time:
1. Select the Style tab in the Property Pages window.
The Number control is activated when the Enabled check box is selected.Otherwise it is deactivated.
2. If necessary, change the selection.
3. If you want access to the process variables of the process interfacing module tobe read-only, select the Locked check box.
As default, the option is not activated.
6.1.29 Connecting the Number Control with the Process Data
If you want to display numeric process values or want to enter values, you mustconnect the Value property of the Number control in the SIMATIC NET OPC Datacontrol with a process variable.
You can also connect the BackColor property with the quality of a processvariable. In this case, the background color of the Number control shows thevalidity of the displayed value.
Figure 6-7 Connecting the Number Control with the Process Data
Using the OPC Server
325SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
After you have assigned a variable to the Number control, the control can accessprocess data. If you change the value displayed by the control, you also changethe value in the real process at the same time.
Changing process data can trigger unexpected reactions in the process that canlead to serious injury to persons or damage to equipment. Always install a physicalemergency stop circuit for the machine or process.
6.1.30 Configuring a Slider Control
Using the Slider control, you can display and modify process data using a slider.When you move the slider, the process values change. As soon as thecorresponding variable changes, the slider adjusts its position automatically.
Figure 6-8 Slider Control
How does it work?
You can configure a slider control in the following steps:
6.1.31 Properties of the Slider Control
The Slider control has the following properties:
Property Tab in the Sie-mens SliderControl Proper-ties Window
Brief Descrip-tion
Described in
Direction General Specifies the di-rection: horizon-tal or vertical
Defining DataDisplay
Using the OPC Server
326SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Property Described inBrief Descrip-tion
Tab in the Sie-mens SliderControl Proper-ties Window
Enabled General Specifies whe-ther or not thecontrol reacts tochanges in thevalue properties
Activating a Sli-der Control
LargeChange General Specifies howfar the slidermoves when thecontrol is activa-ted and youpress the pageup or page downkey
Defining DataDisplay
Max General Specifies the va-lue of the hig-hest position ofthe slider
Defining DataDisplay
Min General Specifies the va-lue of the lowestposition of theslider
Defining DataDisplay
SmallChange General Specifies howfar the slidermoves when thecontrol is activa-ted and youpress the up/down or right/leftarrow keys
Defining DataDisplay
Ticks General Specifies thenumber of ticks(scale marks)
Defining DataDisplay
Value Value set or displayed by the Slidercontrol. This property is connected toa process variable via the Data con-trol.
Connecting theSlider Controlwith the ProcessData
Using the OPC Server
327SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.32 Opening the Properties Window for the Slider Control
You open the Property Pages window in the container application.
Here, we will show you the procedure in Visual Basic. If you use a differentapplication, you will need to adapt the steps accordingly.
Procedure
1. Select the Slider control you want to configure.
2. Right-click on the control.
The context-sensitive menu is opened.
3. Select the Properties command.
The Property Pages window opens.
6.1.33 Defining Data Display
You can specify how the Slider control displays the values of process variables.
� xHorizontal or vertical alignment of the control
Horizontal Alignment
Vertical Alignment
� Scale division between the minimum and maximum value
� Minimum and maximum displayed value
� Movement of the slider with the arrow keys
� Whether the minimum and maximum value are displayed
Using the OPC Server
328SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Procedure
1. Open the Property Pages window.
2. In the Direction boxes, specify whether the Slider control should be alignedhorizontally or vertically.
3. If you want the Slider control to display the minimum and maximum value,select the Show Min and Max Value box.
4. In the Ticks box, specify the number of intermediate values between theminimum and maximum value. The intermediate values are shown as shortscale marks at runtime. The slider can only be moved to these marks.
5. Enter the minimum value and maximum value in the Min and Max boxes.
6. Enter how far the slider will move during runtime when the arrow keys or pageup and page down keys are pressed in the SmallChange and LargeChangeboxes.
6.1.34 Activating a Slider Control
As default, the Slider control is activated following configuration. You candeactivate or reactivate the Slider control in the Property Pages window at anytime:
1. Open the Property Pages window.
The slider control is activated when the Enable check box is selected.Otherwise it is deactivated.
2. If necessary, change the selection.
Using the OPC Server
329SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.35 Connecting the Slider Control with the Process Data
If you want to display or modify the value of a process variable with the Slidercontrol, you connect the Value property of the Slider control with a processvariable in the SIMATIC NET OPC Data control.
Figure 6-9 Connecting the Slider Control with the Process Data
Note
After you have assigned a variable to the Slider control, the control can accessprocess data. If you change the value displayed by the control, you also changethe value in the real process at the same time.
Changing process data can trigger unexpected reactions in the process that canlead to serious injury to persons or damage to equipment. Always install a physicalemergency stop circuit for the machine or process.
6.1.36 Using Other ActiveX Controls
The SIMATIC NET OPC Data control can also be used with controls from othervendors or ActiveX controls you have developed yourself.
Your own ActiveX controls and controls from other vendors must provide a numberof methods that can react to the changes of the assigned variables.
As the container application, you can, for example, use Visual Basic. If you use adifferent container application, this must meet the requirements for ExtendedControls. Otherwise, you will need to enter program code that executes thesefunctions.
Using the OPC Server
330SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.37 What Are the Guidelines for Container Applications?
Extended Controls
For the SIMATIC NET OPC Data control to work with a container application, theapplication must support the Data control function Property Browsing. Thecontainer application must also support the functions for extended controls as isthe case with the container applications from Microsoft.
An extended control is a subcontrol that contains another control to supportcontainer-specific properties, methods, and events. For more detailed information,read the Microsoft online help.
Properties and Methods for Extended Controls
To use the functions of the extended controls, the container application mustsupport the following methods:
� IOleClientSize::GetContainer
� IOleContainer::EnumObjects
� IOleControlSite::GetExtendedControl
The application must also recognize the Name property.
Absence of Extended Controls
Visual Basic supports extended controls. Container applications of other vendorsmay not support extended controls (for example, Borland’s Delphi Version 3.0).
If your container application does not support extended controls, you must write aprogram to handle the missing functions. The Siemens Customer Support Centerwill be happy to advise you on your specific container application. The SupportCenter will provide you with sample programs containing the additional functions.
6.1.38 What Are the Guidelines for ActiveX Controls?
You can create your own ActiveX controls and use these with the Data control fromSIMATIC. The created control must provide one property that corresponds to theValue property of the SIMATIC controls.
Using the OPC Server
331SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.39 How Does the Data Control Read Data?
If the container application supports extended controls, the Data control will findyour newly created ActiveX control and its properties automatically.
Otherwise, assign the process variables to the property corresponding to Value (asnormal in the Items tab of the Property Pages) window. If the value of the variablein the module for process interfacing changes, the Data control automaticallyadapts the value of the property of the control used.
The control you develop yourself should have a subroutine for handling the data ofthe Data control.
6.1.40 How Is Data Written to the Data Control?
If you have developed your own ActiveX control, you will need a subroutine forhandling data.
The following example shows a subroutine for reading and writing the change tovalue of a property.
Visual Basic Code
Public Property Get Value() As Long Value = Object1.ValueEnd Property
Public Property Let Value(ByVal New_Value As Long) Object1.Value() = New_Value PropertyChanged “Value”End Property
Private Sub Value_Change() PropertyChanged “Value”End Sub
Using the OPC Server
332SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.41 Properties and Methods of the SIMATIC Controls
Refer to this section if you require more detailed information on the properties andmethods of the SIMATIC Controls.
The following properties and methods exist with the SIMATIC Controls:
This property or method has the following function
Activated Specifies whether or not all intercon-nections are active
AddNotification Adds an event to the event table ofthe OPC Data control. When the va-riable passed with the call changes, afunction is called.
Alignment Specifies the alignment of parameters
Appearance Specifies the appearance of a control
AutoConnect Specifies whether the configured con-nections exist automatically duringruntime
AutoConnectTimeout Specifies the timeout value
BackColor Specifies the background color of anobject
BorderStyle Specifies whether or not an object isdisplayed with a rectangular border
Captionn Specifies the text of the first and se-cond title
CaptionnAlignment Specifies the alignment of the firstand second title
CaptionnBackColor Specifies the background colors of thetitles
CaptionnFont Specifies the font of the titles
CaptionnForeColor Specifies the foreground color of thetitles
CaptionnSize Specifies the width of the titles
Connect Establishes all configured connections
ConvertedValue Specifies the value for the Value pro-perty converted according to the sca-ling formula
DataType Specifies the data type for convertedvalues
DefaultDeadband Specifies the deadband used by theOPC server
Using the OPC Server
333SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
This property or method has the following function
DefaultUpdateRate Specifies the update rate used by theSIMATIC Data control if no update ra-te is defined
Direction Specifies the direction (horizontal orvertical)
Disconnect Disconnects all established connec-tions
Enabled Specifies whether or not the controlreacts to changes to the Value pro-perty
Factor Specifies the scaling factor if the sca-le-by-formula option was selected
FalseCaption Specifies the text displayed in thecontrol if the Value property is set toFalse
FalseColor Specifies the color of the control if theValue property is set to False
Font Specifies the font
ForeColor Specifies the text color
GetItemProperties Returns the values of the propertiesof an OPC items specified at the me-thod call
LargeChange Specifies how far the slider of thecontrol moves when the control hasthe focus and the page up or pagedown key is pressed
LayoutType Specifies the layout of the titles in thedisplay part of the control
LimitCheck Specifies whether or not the valuerange of an entered value is checked
Locked Specifies that the control is permittedread access only
LowerLimit Specifies the lower limit value writtento the OPC server and returned bythe OPC server
Max Specifies the maximum value of theslider
Min Specifies the minimum value of theslider
NodeName Specifies the network identification ofa remote computer (for connectionusing DCOM).
Using the OPC Server
334SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
This property or method has the following function
offset Specifies the offset if the scale-by-formula option was selected.
Precision Specifies the precision of a number
QueryAvailableItemProperties Returns a list of all OPC propertiesincluding the description of the pro-perties of an OPC item.
Radix Specifies the base (binary, octal, deci-mal, or hexadecimal) for the numberto be displayed
RangeRawMax Specifies the maximum value of thesource range
RangeRawMin Specifies the minimum value of thesource range
RangeScaledMax Specifies the maximum value of thetarget range
RangeScaledMin Specifies the minimum value of thetarget range
ReadMultiVariables Reads the values of the specifiedOPC items from the partner device
ReadVariable Reads the value of a variable of theOPC server from the partner device
ScaleMode Specifies the scaling mode used toscale the values
ServerName Specifies the OPC server for processinterfacing
ShowButtons Specifies whether or not the buttonsfor entering and deleting are displayedfor the control
ShowErrorBoxes Specifies whether or not error messa-ges are displayed if a user-specific er-ror occurred
SmallChange Specifies how far the slider of thecontrol moves when the control hasthe focus and the up/down or right/leftarrow keys are pressed
Ticks Specifies the number of ticks or scalemarks of the control
TrueCaption Specifies the text displayed in thecontrol if the Value property is set toTrue
TrueColor Specifies the color of the control if theValue property is set to True
Using the OPC Server
335SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
This property or method has the following function
UpperLimit Specifies the upper limit for value writ-ten to the OPC server
Value Connects the SIMATIC NET OPC Da-ta control with the OPC server
Write Writes the value of the ConvertedVa-lue property to the Value property
WriteMode Specifies how the control respondswhen the user enters a new value
WriteMultiVariables Writes new values to multiple varia-bles on the OPC server
WriteVariable Writes a new value to a specific varia-ble on the OPC server
ZeroPad Specifies whether the number dis-played by the control is padded fromthe left with leading zeros until themaximum size of the data type is re-ached
6.1.42 Activated
SIMATIC NET OPC Data Control
Activates or deactivates all interconnections with process variables. If the SIMATIC NET OPC Data Control is deactivated, the transfer of databetween display controls and SIMATIC OPC Data Control is deactivated.
Syntax
object.Activated [= value]
Using the OPC Server
336SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
Boolean expression that specifies whether the object can react to eventsgenerated by the user.
The available options are as follows:
True All connections are activated (default).
False All connections are deactivated.
If you do not specify Activated all interconnections with process variables areactivated.
Note
The connections to process variables remain established even if they aredeactivated.
6.1.43 Alignment
SIMATIC Number Control
Specifies the alignment of the number displayed in the number control.
Syntax
object.Alignment [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or a constant that specifies the alignment.
The available options are as follows:
Using the OPC Server
337SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
0 or Left The number is aligned left in the box (default).
1 or Right The number is aligned right in the box.
2 or Center The number is centered in the box.
If you do not specify Alignment the number is aligned left in the box.
6.1.44 Appearance
SIMATIC Number Control
Specifies whether or not the number control is displayed with 3D effects.
Syntax
object.Appearance [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value or constant that specifies the appearance of the control.
The available options are as follows:
0 or Flat The control is displayed without 3D effects.
1 or ThreeD The control is displayed with 3D effects (default).
Note
Appearance only has any effect when BorderStyle is set to FixedSingle.
6.1.45 AutoConnect
SIMATIC NET OPC Data Control
Specifies whether or not the configured interconnections to the OPC server areestablished automatically at runtime.
Using the OPC Server
338SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Syntax
object.AutoConnect [= value]
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
Boolean expression that specifies whether the object can react to eventsgenerated by the user.
The available options are as follows:
True All configured interconnections are established automaticallyat runtime (default).
False The interconnections are established only after the Connectmethod call.
If you do not specify AutoConnect, all interconnections are establishedautomatically at runtime.
6.1.46 AutoConnectTimeout
SIMATIC NET OPC Data Control
Specifies a timeout.
If the AutoConnect property is set to True, the SIMATIC NET OPC data controlcalls the Connect method after the specified time.
Syntax
object.AutoConnectTimeout [= value]
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
Value of the type long for the timeout.
Using the OPC Server
339SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.47 BackColor
SIMATIC Number Control
Specifies the background color of the number control.
Syntax
object.BackColor [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value or constant that specifies the background color of an object.
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
6.1.48 BorderStyle
SIMATIC Number Control
Specifies whether or not the number control has a border.
Syntax
object.BorderStyle [= value]
Using the OPC Server
340SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Number control.
value
Value or constant that specifies whether or not a border is used.
The available options are as follows:
0 or None No border.
1 or FixedSingle A border with a single line.
If you do not specify BorderStyle, the object does not have a border.
6.1.49 Captionn
SIMATIC Number Control
Specifies the text for the title.
Syntax
First title:
object.Caption1 [= value]
Second title:
object.Caption2 [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
String with the text of the title.
6.1.50 CaptionnAlignment
SIMATIC Number Control
Specifies the alignment of titles.
Using the OPC Server
341SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Syntax
First title:
object.Caption1Alignment [= value]
Second title:
object.Caption2Alignment [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or a constant that specifies the alignment of the titles.
The available options are as follows:
0 or Left The title is aligned left (default).
1 or Right The title is aligned right (default).
2 or Center The title is centered.
6.1.51 CaptionnBackColor
SIMATIC Number Control
Specifies the color of the background for the titles.
Syntax
First title:
object.Caption1BackColor [= value]
Second title:
object.Caption2BackColor [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or a constant that specifies the background color of the title.
Using the OPC Server
342SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
6.1.52 CaptionnFont
SIMATIC Number Control
Specifies the font for the first or second title.
Syntax
First title:
object.Caption1Font [= value]
Second title:
object.Caption2Font [= value]
Explanation
object
Describes an object in the assignment list and identifies a specific SIMATICcontrol.
value
Value or constant that specifies a font.Remember the options provided by your development environment for defining afont.
6.1.53 CaptionnForeColor
SIMATIC Number Control
Specifies the color of the font for the titles.
Using the OPC Server
343SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Syntax
First title:
object.Caption1ForeColor [= value]
Second title:
object.Caption2ForeColor [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or a constant that specifies the foreground color of the title.
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
6.1.54 CaptionnSize
SIMATIC Number Control
For the horizontal layout this specifies the width and for the vertical layout theheight of titles. The height and width are specified in twips.
Syntax
First title:
object.Caption1Size [= value]
Second title:
object.Caption2Size [= value]
Using the OPC Server
344SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Number control.
value
Value or constant with which you can specify the font size of a caption.
Possible Values:
-1 Automatic (default)
>=1 Values in twips
If you do not specify CaptionnSize, the value -1 is assumed. In this case, the sizeof the box is calculated based on the space required by the text.
6.1.55 ConvertedValue
SIMATIC Number Control
Saves the scaled value of the Value property. ConvertedValue is alreadyconverted to the data type specified by the DataType property.
Syntax
object.ConvertedValue [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value of the type variant that specifies the value of the control.
Note
If Enabled is set to false, the bidirectional connection between Value andConvertedValue is disabled. Changes to ConvertedValue are not applied to theValue property.
Using the OPC Server
345SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.56 DataType
SIMATIC Number Control
Defines the data type for converted values.
If the data type used is too long to display, the value is truncated. The data typespecified in the SIMATIC number control must match the data type in theAssigned Variable box of the SIMATIC NET OPC data controls.
Syntax
object.DataType [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or a constant that specifies the data type.
The available options are as follows:
Data type Value Size Description
Boolean 0 1 bit Single bit value
Byte 1 1 byte Unsigned single-byte value
Word 2 2 bytes Unsigned two-byte value
Integer 3 2 bytes Signed two-byteinteger value
Double word 4 4 bytes Unsigned four-byte value (de-fault)
Double integer 5 4 bytes Signed four-byteinteger value
Real 6 4 bytes Signed four-bytereal (floating-point) value
Using the OPC Server
346SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Data type DescriptionSizeValue
Timers 7 2 bytes Unsigned two-byte value
Counter 8 2 bytes Unsigned two-byte value
If you do not specify DataType, the data type double word is used.
Note
With DataType, you specify whether Precision has any effects.
If the length of the data returned by the data control is greater than the length ofthe data displayed in the corresponding SIMATIC control or the length of the OPCprocess variable is greater than the data range of the data type set in the numbercontrol, the value is shown with three dots (...). If you want to change this value,you must delete the three dots.
6.1.57 DefaultDeadband
SIMATIC NET OPC Data Control
Specifies the percentage deadband used by the SIMATIC NET OPC server.
If DefaultDeadband is defined, the OPC server reports changes to the values ofthe process variables to the OPC data control only when the value change isgreater than the specified percentage of the value range.
Syntax
object.DefaultDeadBand [= value]
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
Value of the type single. The value must not be negative.
Using the OPC Server
347SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
Before you can use DefaultDeadband, a value range must be defined for thevariables involved using the Symbol File Configurator. DefaultDeadband applies toall the variables connected to the SIMATIC NET OPC data control. If you usedifferent DefaultDeadbands in an application for different display controls, youmust use multiple SIMATIC NET OPC data controls with differentDefaultDeadbands and assign the display controls accordingly.
6.1.58 DefaultUpdateRate
SIMATIC NET OPC Data Control
Specifies the interval at which the data is updated by the OPC server.
Syntax
object.DefaultUpdateRate [= value]
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
Value of the type long.
The available options are as follows:
0 The minimum update rate defined by the OPC server is used.
> 0 All changes to the connected variables are passed on at theearliest after this interval.
Note
For SIMATIC NET, the smallest permitted update rate is 50 ms. TheDefaultUpdateRate applies to all the variables connected to the SIMATIC NETOPC data control. If you use different DefaultUpdateRates in an application fordifferent display controls, you must use multiple SIMATIC NET OPC data controlswith different DefaultUpdateRates and assign the display controls accordingly.
Using the OPC Server
348SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.59 Direction
SIMATIC Slider Control
Specifies the direction of the slider control:
� horizontal
� vertical
Syntax
object.Direction [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
A value or a constant that specifies the orientation.
The available options are as follows:
0 Horizontal
1 Vertical
6.1.60 Enabled
SIMATIC Button Control
SIMATIC Number Control
SIMATIC Slider Control
Specifies whether or not the control reacts to changes to the Value property andthen sends events.
Syntax
object.Enabled [= value]
Using the OPC Server
349SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of a SIMATIC display control.
value
Boolean expression specifying whether or not the object responds to eventsgenerated by the user.
The available options are as follows:
True Object reacts to events.
False Object does not react to events. The exception is the errorevent.
If you do not specify Enabled, the object reacts to events.
6.1.61 Factor
SIMATIC Number Control
Specifies the scaling used when the ScaleByFormula option is selected. Forscaling, not only scaling factor but also the Offset must be specified.
You can use a formula to scale the value:
(PLC Value * Scale) + Offset = displayed value
PLC Value is the value of Value when the control is connected to the OPC server.
Scale is the value of Factor.
Offset is the value of Offset.
Displayed value is the content of the Text property.
Syntax
object.Factor [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value of the type Float that specifies the factor for the scaling formula.
If you do not specify Factor, the value 1.0 is assumed.
Using the OPC Server
350SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Note
The ScaleMode property must be set to ScaleByFormula otherwise Factor has noeffect.
6.1.62 FalseCaption
SIMATIC Button Control
Decides the text displayed in the control if Value is set to False.
Syntax
object.FalseCaption [= value]
Explanations
object
An instance of the SIMATIC Button control.
value
String with the text to be displayed.
6.1.63 FalseColor
SIMATIC Button Control
Specifies the color of the control if Value is set to False.
Syntax
object.FalseColor [= value]
Using the OPC Server
351SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Button control.
value
Value or constant that specifies the foreground or background color of an object.
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
6.1.64 Font
SIMATIC Button Control
SIMATIC Number Control
Specifies a font for the control.
Syntax
object.Font
Explanations
object
An instance of the SIMATIC Button control or an instance of the SIMATIC Numbercontrol.
6.1.65 ForeColor
SIMATIC Number Control
Specifies the foreground color for text.
Syntax
object.ForeColor [= value]
Using the OPC Server
352SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Number control.
value
A value or constant that specifies the foreground color of objects.
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
6.1.66 LargeChange
SIMATIC Slider Control
Specifies how far the slider of the slider control moves when the arrows of theslider control are clicked with the cursor.
Syntax
object.LargeChange [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
A value or constant that specifies the size of the change.
Note
Value is increased by the value of LargeChange when the page up key is pressedor when you click on the top right of the slider. Value is reduced by the value ofLargeChange when the page down key is pressed or when you click on the bottomleft of the slider.
Using the OPC Server
353SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.67 LayoutType
SIMATIC Number Control
Specifies how the captions of the control are arranged.
Syntax
object.LayoutType [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or constant that specifies the layout type.
The available options are as follows:
Horizontal (0) Places the first caption to the left and the second caption tothe right of the display part of the control.
Vertical (1) Places the first caption above and the second caption belowthe display part of the control.
If you do not specify LayoutType, the captions are placed to the left and right ofthe display part of the control.
6.1.68 LimitCheck
SIMATIC Number Control
Specifies whether or not the value range of an entered value is checked. The valuerange is specified with UpperLimit and LowerLimit.
The check determines whether or not a value supplied by the control is within thespecified limits. A value passed from the OPC server to the number control is notchecked.
If a value is entered that is outside the value range, the control does not write avalue to the Value property. In this case, a LimitCheckFailed event is sent.
Syntax
object.LimitCheck [= value]
Using the OPC Server
354SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Number control.
value
A value or constant that specifies the type of limit value check.
The available options are as follows:
CheckNone or 0 The entry is not checked.
Lower or 1 Only the lower limit of the entry is checked.
Upper or 2 Only the higher limit of the entry is checked.
Both or 3 Both limits of the entry are checked.
If you do not specify LimitCheck, the entry is not checked.
Note
LimitCheck must be activated otherwise UpperLimit and LowerLimit have noeffect.
6.1.69 Locked
SIMATIC Number Control
Sets the control to the Read-only status. You cannot change any values but onlydisplay the current value.
Syntax
object.Locked [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Boolean expression that specifies whether or not values can be changed.
The available options are as follows:
Using the OPC Server
355SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
True The text in the control can be read and selected but notedited. The program can modify the text by changing Value.These changes are displayed.
False The text in the control can be edited.
If you do not specify Locked, you can enter values.
6.1.70 LowerLimit
SIMATIC Number Control
Specifies the lower limit value for values entered by the user. The value is checkedby LimitCheck.
If a value lower than the limit value is entered, the control does not write this valueto the Value property. In this case, a LimitCheckFailed event is sent.
Syntax
object.LowerLimit [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value of the type Float that specifies the lower limit used for the limit value check.
Note
LimitCheck must be set to Lower or Both otherwise LowerLimit has no effect.
6.1.71 Max
SIMATIC Slider Control
Specifies the highest value of the slider of the SIMATIC control. If Value is greaterthan or equal to Max, the slider is at its extreme right or extreme top position.
Using the OPC Server
356SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Syntax
object.Max [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
A value or constant that specifies the highest displayed number.
6.1.72 Min
SIMATIC Slider Control
Specifies the lowest value of the slider of the SIMATIC control. If Value is less thanor equal to Min, the slider is at its extreme left or extreme bottom position.
Syntax
object.Min [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
A value or constant that specifies the lowest displayed number.
6.1.73 NodeName
SIMATIC NET OPC Data Control
Specifies the name of a remote computer on which the OPC server is running. Byspecifying a node name, a connection can be established over a network usingDCOM.
Syntax
object.Node [= value]
Using the OPC Server
357SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
String that specifies the path or the identifier of a remote computer (PC) for theconnection.
6.1.74 Offset
SIMATIC Number Control
Specifies the offset used when the ScaleByFormula option is selected. Forscaling, not only the offset but also the Factor of the scaling factor must bespecified.
You can use a formula to scale the value:
(PLC Value * Scale) + Offset = displayed value
PLC Value is the value of Value when the control is connected to the OPC server.
Scale is the value of Factor.
Offset is the value of Offset.
Displayed value is the content of the Text property.
Syntax
object.Offset [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value of the type Float that specifies the offset for the scaling formula.
If you do not specify Offset, the value 0.0 is assumed.
Note
ScaleMode must be set to ScaleByFormula (1) otherwise Offset has no effect.
Using the OPC Server
358SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.75 Precision
SIMATIC Number Control
This changes the precision; in other words, the number of decimal places. Thenumber is rounded after the specified decimal place.
Syntax
object.Precision [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value of the type Integer that specifies the precision of the number.
If you do not specify Precision, the value 3 is used.
6.1.76 Radix
SIMATIC Number Control
Defines the base of the number to be displayed:
� binary
� octal
� decimal
� hexadecimal
Each value must be entered in keeping with the specified base.
Syntax
object.Radix [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or constant that specifies the base of the value to be displayed.
Using the OPC Server
359SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The available options are as follows:
Binary or 0 Binary mode.Valid entries: 0 and 1
Octal or 1 Octal mode.Valid entries: 0 through 7
Decimal or 2 Decimal mode:Valid entries: 0 through 9, ’+’, ’ - ’ and ’.’)
Hexadecimal or 3 Hexadecimal mode:Valid entries: 0 through 9, a through fand A through F)
If you do not specify Radix , the value Decimal is used.
6.1.77 RangeRawMax
SIMATIC Number Control
Together with RangeRawMin , this specifies the range for raw values. Raw valuesare the values supplied directly by the OPC server. The range of raw values canbe recalculated into displayed values by the number control. The value range ofthe displayed values is defined by RangeScaledMin and RangeScaledMax.
RangeRawMax specifies the upper value of the raw value range.
The conversion of value ranges by specifying range limits is known as rangetransformation. The following is specified:
� Raw value range
for the values supplied by the OPC server
� Target range
for the values to be displayed by the control and entered in it
The values of one range are automatically converted to the other value range.
Figure 6-10 Range Transformation
Using the OPC Server
360SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Syntax
object.RangeRawMax [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value of the type Float that specifies the range limits for the transformation.
If you do not specify RangeRawMax, the value 255.0 is used.
Note
ScaleMode must be set to ScaleByRange otherwise RangeRawMax has no effect.
6.1.78 RangeRawMin
SIMATIC Number Control
Together with RangeRawMax , this specifies the range for raw values. Raw valuesare the values supplied directly by the OPC server. The range of raw values canbe recalculated into displayed values by the number control. The value range ofthe displayed values is defined by RangeScaledMin and RangeScaledMax.
RangeRawMin specifies the lower value of the raw value range.
The conversion of value ranges by specifying range limits is known as rangetransformation. The following is specified:
� Raw value range
for the values supplied by the OPC server
� Target range
for the values to be displayed by the control and entered in it
The values of one range are automatically converted to the other value range.
Using the OPC Server
361SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Figure 6-11 Range Transformation
Syntax
object.RangeRawMin [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value of the type Float that specifies the range limits for the transformation.
If you do not specify RangeRawMin, the value 0.0 is used.
Note
ScaleMode must be set to ScaleByRange otherwise RangeRawMin has no effect.
Using the OPC Server
362SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.79 RangeScaledMax
SIMATIC Number Control
Together with RangeScaledMin defines the value range of values displayed in thenumber control. The displayed values are calculated from the raw values suppliedby the OPC server.
RangeScaledMax specifies the upper value for the target range.
The conversion of value ranges by specifying range limits is known as rangetransformation. The following is specified:
� Raw value range
for the values supplied by the OPC server
� Target range
for the values to be displayed by the control and entered in it
The values of one range are automatically converted to the other value range.
Figure 6-12 Range Transformation
Syntax
object.RangeScaledMax [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value of the type Float that specifies the range limits for the transformation.
If you do not specify RangeScaledMax, the value 100.0 is used.
Using the OPC Server
363SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
ScaleMode must be set to ScaleByRange otherwise RangeScaledMax has noeffect.
6.1.80 RangeScaledMin
SIMATIC Number Control
Together with RangeScaledMax defines the value range of values displayed inthe number control. The displayed values are calculated from the raw valuessupplied by the OPC server.
RangeScaledMin specifies the lower value for the target range.
The conversion of value ranges by specifying range limits is known as rangetransformation. The following is specified:
� Raw value range
for the values supplied by the OPC server
� Target range
for the values to be displayed by the control and entered in it
The values of one range are automatically converted to the other value range.
Figure 6-13 Range Transformation
Syntax
object.RangeScaledMin [= value]
Using the OPC Server
364SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Number control.
value
A value of the type Float that specifies the range limits for the transformation.
If you do not specify RangeScaledMin, the value 0.0 is used.
Note
ScaleMode must be set to ScaleByRange otherwise RangeScaledMin has noeffect.
6.1.81 ScaleMode
SIMATIC Number Control
Specifies the scaling mode used to scale the values. The value can also bespecified with ScaleProperty.
You can set the scaling mode as follows:
� Formula
� Range Transformation
Formula
(PLC Value * Scale) + Offset = displayed value
PLC Value is the value of Value when the control is connected to the OPC server.
Scale is the value of Factor.
Offset is the value of Offset.
Displayed value is the content of the Text property.
Range Transformation
You specify a source range of process values and a target range of displayedvalues. You can transform the values of one range into the other.
Using the OPC Server
365SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Syntax
object.ScaleMode [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
A value or constant that specifies the scaling mode.
The available options are as follows:
ScaleNone or 0 No scaling.
ByFormula or 1 The formula with Factor and Offset is used to scale thevalue.
ByRange or 2 The range transformation method is used to scale thevalue.
If you do not specify ScaleMode, no scaling takes place.
Note
ScaleMode specifies whether or not Factor, Offset, RangeRawMax,RangeRawMin, RangeScaledMax, and RangeScaledMin have any effect.
6.1.82 ServerName
SIMATIC NET OPC Data Control
Specifies the name (ProgID) of the OPC server that provides the required processvariables.
Syntax
object.ServerName [= value]
Using the OPC Server
366SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC NET OPC Data control.
value
String representing the ProgID of the OPC server that will be used by the object.
For SIMATIC NET, the value is, for example, OPC.SimaticNET.
6.1.83 ShowButtons
SIMATIC Number Control
Specifies whether or not the buttons for input deleting are displayed for the control.
Syntax
object.ShowButtons [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Boolean expression specifies whether the buttons are displayed.
The available options are as follows:
True The buttons are displayed to the right of the display field.When a new value is entered, the buttons are activated.If you write or modify a value, you must confirm the value withthe button for input.If you cancel a change, you must click the button for deleting.
False The buttons are not displayed.
Using the OPC Server
367SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.84 ShowErrorBoxes
SIMATIC NET OPC Data Control
SIMATIC Number Control
Specifies whether the default error messages are displayed when a user erroroccurs. For each error, an Error event is generated.
All errors that affect connection establishment to the OPC server are notified with aConnectionError event.
Syntax
object.ShowErrorBoxes [= value]
Explanations
object
An instance of the SIMATIC NET OPC Data control or an instance of the SIMATICNumber control.
value
Boolean expression that specifies whether error messages are displayed.
The available options are as follows:
True The control displays the specified error messages.
False The error messages are deactivated.
If you do not specify ShowErrorBoxes, the control displays the default errormessages.
Note
SIMATIC Computing returns English error messages. If you want to display themessages in other languages, deactivate the ShowErrorBoxes option and writeprogram code for error handling.
Using the OPC Server
368SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.85 SmallChange
SIMATIC Slider Control
Specifies how far the slider of the slider control is moved when the control isselected and the up/down or left/right arrow key is pressed.
Value is increased by SmallChange when the right or up arrow key is pressed. It isreduced by SmallChange when the left or down arrow key is pressed.
Syntax
object.SmallChange [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
A value or constant that specifies the extent of the change.
6.1.86 Ticks
SIMATIC Slider Control
Sets the number of ticks or scale marks of the control.
If, for example, Ticks has the value 10, the scale of the control is divided into 10parts.
Syntax
object.Ticks [= value]
Explanations
object
An instance of the SIMATIC Slider control.
value
Constant that specifies how many scale marks are displayed.
If you do not specify Ticks, the default value 10 is used.
Using the OPC Server
369SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.1.87 TrueCaption
SIMATIC Button Control
Decides the text displayed in the control when Value is set to True.
Syntax
object.TrueCaption [= value]
Explanations
object
An instance of the SIMATIC Button control.
value
String containing the text.
6.1.88 TrueColor
SIMATIC Button Control
Specifies the color of the control if Value is set to True.
Syntax
object.TrueColor [= value]
Explanations
object
An instance of the SIMATIC Button control.
value
Value or constant that specifies the foreground or background color of the control.
The available options are as follows:
Standard Colors Selection of colors using the RGB colorpalette.
Windows System Colors Selection of colors using system colors.The system colors depend on thecontainer.
Using the OPC Server
370SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.89 UpperLimit
SIMATIC Number Control
Specifies the upper limit value for values entered by the user. The value is checkedby LimitCheck.
If a value higher than the limit value is entered, the control does not write this valueto the property Value property. In this case, an Error event and aLimitCheckFailed event are generated. The condition for the Error event is thatShowErrorBoxes is activated.
Syntax
object.UpperLimit [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value of the type Float that specifies the upper limit for the limit check.
If you do not specify UpperLimit, the value 100.0 is used.
Note
LimitCheck must be set to Upper or Both otherwise UpperLimit has no effect.
6.1.90 Value
SIMATIC Button Control
SIMATIC Number Control
SIMATIC Slider Control
This property connects the SIMATIC NET OPC Data Control with a processvariable of the OPC server.
Value can have values of different data types.
Syntax
object.Value [= value]
Using the OPC Server
371SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
object
An instance of the SIMATIC Display control.
value
Value of the type variant that specifies the value of the control.
Note
If Enabled is set to false, the bidirectional connection between Value andConvertedValue is disabled. Changes to ConvertedValue are not applied to theValue property.
When Value changes, a ChangeEvent is generated.
6.1.91 WriteMode
SIMATIC Number Control
Specifies whether or not the Number control passes on entered valuesautomatically to the Value property and therefore also to the SIMATIC NET OPCData Control.
Syntax
object.WriteMode [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Value or constant that specifies whether or not the control passes the enteredvalues automatically to Value.
The available options are as follows:
Automatic or 0 The new value is automatically passed to Value andtherefore also to the OPC server (default).
Manual or 1 The new value is not passed on unless the Write methodis called in the program code.
If you do not specify WriteMode, the value is automatically passed to Value.
Using the OPC Server
372SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.92 ZeroPad
SIMATIC Number Control
Specifies whether the number displayed by the control is padded from the left withleading zeros until the maximum size of the data type is reached
Syntax
object.ZeroPad [= value]
Explanations
object
An instance of the SIMATIC Number control.
value
Boolean expression that specifies whether or not the display number is paddedwith leading zeros.
The available options are as follows:
True Pads the number with leading zeros up to the maximumnumber of places for the specified data type.
False Does not pad the number with leading zeros.
If you do not specify ZeroPad, the number is not padded with leading zeros.
6.1.93 AddNotification
SIMATIC NET OPC Data Control
Adds an event notification in the event table of the OPC Data Control. If thetransferred process variable changes, the ValueChanged event is generated withthe notified ID.
Syntax
result=object.AddNotification(ItemIDs, UserIDs, Errors)
Using the OPC Server
373SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Explanations
result
Value of the type Long that indicates whether or not an error has occurred. If result= 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
ItemIDs
OPC ItemID of the type String() that specifies which process variables aremonitored for changes.
UserID
Freely selectable ID for every ItemID of the type String(). The ID is specified by theuser. It can be used by the user program to identify an event.
Errors
Return parameter of the type Variant that signals whether registration wassuccessful for each ItemID.
6.1.94 Connect
SIMATIC NET OPC Data Control
Establishes the configured connection to the OPC server.
Syntax
result = object.Connect
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
Note
If an error occurs during the connect phase, this can be detected with theConnectionError event and error handling started.
Using the OPC Server
374SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.95 Disconnect
SIMATIC NET OPC Data Control
Terminates all connections.
Syntax
result = object.Disconnect
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
6.1.96 GetItemProperties
SIMATIC NET OPC Data Control
Returns the values of the properties of the specified OPC item.
Syntax
result = object.GetItemProperties(ItemID, Count, PropertyIDs,PropertyValues, Errors)
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
ItemID
OPC ItemID of the process variable of the type String for which the current valuesof the OPC properties will be queried.
Using the OPC Server
375SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Count
Parameter of the type Long that specifies the number of properties for whichvalues will be queried.
PropertyIDs
Parameter of the type Variant containing a list of the PropertyIDs to be queried.
PropertyValues
Return parameter of the type Variant containing a list of the requested values.
Errors
Return parameter of the type Variant that indicates whether registration wassuccessful for each PropertyID.
6.1.97 QueryAvailableItemProperties
SIMATIC NET OPC Data Control
Returns a list of OPC properties along with a description for the specified OPCitem.
Syntax
result=object.QueryAvailableItemProperties(ItemID,Count,PropertyIDs, Descriptions, DataTypes)
Explanations
result
Value of the type Long that indicates whether or not an error has occurred. If result= 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
ItemID
OPC ItemID of the process variable as String for which information about its OPCproperties will be queried.
Count
Return parameter of the type Long that specifies how many properties exist for thespecified OPC item.
Using the OPC Server
376SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
PropertyIDs
Return parameter of the type Variant that contains a list of the PropertyIDssupported by the specified item.
PropertyID is used as an input parameter in the GetItemProperties method toquery the current value of the property.
Descriptions
Return parameter of the type Variant containing a list of the descriptive texts for theindividual properties.
DataTypes
Return parameter of the type Variant containing a list of the data type codes for theindividual properties. The data type codes correspond to the codes defined forCOM.
6.1.98 ReadMultiVariables
SIMATIC NET OPC Data Control
Reads the values of the variables connected to the OPC server.
Syntax
result = object.ReadMultiVariables (VarItemIDs, VarValues,VarErrors {,VarQualities} {,VarTimeStamps})
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
VarItemIDs
Variable of the type Variant that specifies the array of OPC ItemIDs to identify thevariables to be read from the OPC server.
VarValues
Return variable of the type Variant containing the array of corresponding values ofthe specified variables of the OPC server.
VarErrors
Using the OPC Server
377SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Variable of the type Variant containing the array with the status Long of each returnvariable.
VarQualities
Return variable of the type Variant containing the array with corresponding qualityof the specified variables.
VarTimeStamps
Return variable of the type Variant containing the array with correspondingtimestamp of the specified variables.
6.1.99 ReadVariable
SIMATIC NET OPC Data Control
Reads the value of a specific variable from the OPC server.
Syntax
result = object.ReadVariable (ItemID, Value, Quality,Timestamp)
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
ItemID
String with the ItemID of the variable on the OPC server that will be read.
Value
Return variable of the type Variant containing the content of the specified variablein the OPC server.
Quality
Return value of the type Long containing the quality of the variable.
TimeStamp
Return variable of the type Date containing the OPC timestamp.
Using the OPC Server
378SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.100 Write
SIMATIC Number Control
Writes the value of ConvertedValue to Value.
This method can only be used when WriteMode is set to Manual.
Syntax
object.Write
Explanation
object
An instance of the SIMATIC Number control.
6.1.101 WriteMultiVariables
SIMATIC NET OPC Data Control
Writes new values for several variables to the process variables made available bythe OPC server.
Syntax
result = object.WriteMultiVariables (VarItemIDs, VarValues,VarErrors)
Explanations
result
Value of the type Long that indicates whether or not an error has occurred. If result= 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
VarItemIDs
Variable of the type Variant that identifies the array of OPC ItemIDs for specifyingthe process variables.
VarValues
Variable of the type Variant containing an array of corresponding values to bewritten to the specified variables.
Using the OPC Server
379SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
VarErrors
Variable of the type Variant containing the array with the status Long of eachvariable.
6.1.102 WriteVariable
SIMATIC NET OPC Data Control
Writes a new value to a specific process variable of the OPC server.
Syntax
result = object.WriteVariable (ItemID, Value)
Explanations
result
Value of the type Long that indicates whether or not an error has occurred.
If result = 0, no error occurred.
object
An instance of the SIMATIC NET OPC Data control.
ItemID
String specifying the OPC ItemID to identify an OPC process variable.
Value
Variable of the type Variant containing the value that will be written to the specifiedprocess variable.
6.1.103 Events of the SIMATIC Controls
There are fixed events for the controls to which the program can react duringruntime.
Using the OPC Server
380SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.104 Events of the Data Control
The following events are available for the Data control:
Event occurs
ConnectionError An error occurred on the connection.
ValueChanged The value or the quality of a process variable registeredwith the AddNotification method has changed. By cal-ling the ValueChanged event, the user application isnotified of the change.
6.1.105 Events of the Button Control
The following events are available for the Button control:
Event occurs
ChangeEvent The value of a property has changed.
ClickEvent The control was clicked with the mouse.
6.1.106 Events of the Number Control
The following events are available for the Number control:
Event occurs
Change The value of the Value property has changed.
Click The mouse button was pressed and released over thecontrol.
DblClick The control was double-clicked.
Error The control has detected an error.
KeyDown A key was pressed while control was active.
KeyPress A key was pressed and released while the control wasactive.
KeyUp A key was released while control was active.
LimitCheckFai-led
The limit value check failed.
MouseDown The mouse button was pressed while the mouse cursorwas over the control.
Using the OPC Server
381SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Event occurs
MouseMove The mouse cursor was moved over the control.
MouseUp The mouse button was released while the cursor wasover the control.
6.1.107 Events of the Slider Control
The following events are available for the Slider control:
Event occurs
Change The value of the Value property has changed.
Click The mouse button was pressed and released over the con-trol.
DblClick The control was double-clicked.
KeyDown A key was pressed while control was active.
KeyPress A key was pressed and released while the control was acti-ve.
KeyUp A key was released while control was active.
MouseDown The mouse button was pressed while the mouse cursorwas over the control.
MouseMove The mouse cursor was moved over the control.
MouseUp The mouse button was released while the cursor was overthe control.
6.1.108 Error Messages of the SIMATIC Controls
The Data control and the Number control can generate error messages.
Error Messages of the Data Control
If an error occurs in the Data control, the control generates a ConnectionErrorevent. Your program can receive the ConnectionError event and react to it. TheConnectionError can recognize standard COM errors, for example E_FAIL orE_OUTOFMEM .
Error Message Tables
The tables list only the most important error messages.
Using the OPC Server
382SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.1.109 Error Messages of the Data Control
The table below shows the most important error messages:
Error Code Meaning
0x80004005 General COM error.
0x8007000E Not enough free memory.
0x80070057 Invalid syntax of the variable.
0xC0040007 Invalid variable type.
0xC004000B Value to be written is too high.
6.1.110 Error Messages of the Number Control
The table below shows the most important error messages:
Error Code Meaning
C0040002 The scaling cannot be continued because the scaling for-mula is incorrect.
This error occurs when you specified a raw value range(RangeRawMin, RangeRawMax) with the length zero(Min equals Max). This would lead to division by zeroand scaling is therefore not possible.
Specify a raw value range in which RangeRawMin isless than RangeRawMax.
C0040003 The value setting of Value is invalid.
The value reported by the OPC server or by a script thataccesses Value cannot be interpreted.
Check the values you wrote to the OPC server.
Using the OPC Server
383SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Error Code Meaning
C0040004 The value setting of an entered text (value) is invalid.
This error often occurs when a bad value is entered inthe control. Normally, this is caused by an illegal charac-ter.
The permitted characters depend on the number baseand data type used. For more information, read the des-cription of the basic value properties.
Enter a permitted value.
C0040005 The COM component was not found.
The SIMATIC product or Windows has been incorrectlyinstalled. The control cannot access other componentsrequired for correct operation with the software.
Check the installation.
C0040006 The Microsoft Standard Controls cannot be created.
The SIMATIC product or Windows has been incorrectlyinstalled. The control cannot access other componentsrequired for correct operation with the software.
Check the installation.
C0040010 The limit check cannot be continued because the lowerlimit is higher than the upper limit.
This error occurs when you check the limit values of theNumber control. In this case, the lower limit (LowerLi-mit) is higher than the upper limit (UpperLimit).
Set a valid range for the limit value check.
Using the OPC Server
384SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.2 Programming the Automation Interface
The Automation Interface is a supplement to the Custom Interface. With theAutomation Interface, you have the convenience of modern development systemsand script languages when programming OPC. There is both an AutomationInterface for access to process variables (data access) and for processing eventsand alarms (Alarms & Events).
Application
You work with the Automation Interface when you want to create an applicationwith a reasonable number of variables and medium data throughput based on anoffice application or with Visual Basic.
6.2.1 Programming the Automation Interface for Data Access
For data access, there is a simple class model that groups the interfaces and theirmethods in classes.
The Automation Interface further refines the class model valid for the CustomInterface to provide the benefits and options available with structured developmentsystems such as Visual Basic.
6.2.2 What Does the Object Model of OPC Data Access Provide?
The classes of the class model of Data Access contain the following objects:
� OPCServer
� OPCGroup
� OPCItem
Additional objects can be added for the Automation Interface. To manage theOPCGroup and OPCItem objects, there are separate collection objects:OPCGroups and OPCItems. The collection objects provide functions for managingthe objects assigned to them.
There is also an OPCBrowser collection object that contains the browsingfunctions.
Using the OPC Server
385SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Object Model
The following graphic illustrates the objects and the relationships between theobjects.
Figure 6-14 Object Model of OPC Data Access
6.2.3 Points to Remember When Programming
� With the Automation Interface, optional parameters must be passed asvariants. In Visual Basic, however, the optional parameters should be declaredwith the intended type of the optional variables. This ensures that the variantcontains the correct data type.
� Asynchronous Functions
The IsSubscribed group-specific property must be set to True to allow thevariables to be monitored.
� The objects that will receive events must be declared with the supplementwithEvents in Visual Basic.
Example:
Dim withEvents MyOPCGroup as OPCGroup
� According to the OPC Specification, arrays always begin with index 1. Definethis in your program as follows:
Option Base 1 ’ARRAYs are always Option Base 1
Using the OPC Server
386SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.2.4 Objects of the Automation Interface for Data Access
Below, you will see a list of the properties, methods, and events for Data Access.Only the features specific to SIMATIC NET are described. For a detaileddescription of the properties, methods, and events, refer to the relevant OPCSpecifications.
Objects
The following objects exist for the Automation Interface for Data Access:
OPCServer Object
The OPCServer objects of the OPC server class are created by the client.
The properties of the OPCServer objects contain general information about theserver. When an object is created, an OPCGroups collection object is also createdas a property of the OPCServer object.
Properties of OPCServer
Below, you will find a list of the properties for the OPCServer object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Property Meaning
Bandwidth Returns the bandwidth of the server. Bandwidth isnot supported by the OPC server for SIMATICNET.
BuildNumber Returns the build number of the server
ClientName Specifies the name of the client. ClientName isused primarily for test purposes.
CurrentTime Returns the current time in UTC.
LastUpdateTime Returns the time in UTC at which the server lastsent data to the client
LocaleID Specifies the language for displayed texts. ForSIMATIC NET, these are German and English.
MajorVersion Returns the main version number of the server
MinorVersion Returns the secondary version number of the ser-ver
OPCGroups Specifies the collection of OPCGroup objects
Using the OPC Server
387SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
PublicGroupNames Returns the name of the public group of OPCserver. Optional public groups are not supportedby the OPC Server for SIMATIC NET.
ServerName Returns the name of the connected OPC server
ServerNode Returns the name of the network node on whichthe OPC server is executed
ServerState Returns the status of the server
StartTime Returns the time at which the server started inUTC
VendorInfo Returns vendor information. The OPC Server forSIMATIC NET returns SIMATIC NET OPC-Ser-ver as vendor information.
Methods of OPCServer
The methods for the OPCServer object are listed below. Only the features specificto SIMATIC NET are described. You will find a description of the methods in thefollowing OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
Connect Establishes a connection to the OPC server. TheProgID for OPC server is, for example, OPC.Si-maticNET.
CreateBrowser Creates an OPCBrowser collection object
Disconnect Terminates a connection to the OPC server. TheOPC Server for SIMATIC NET terminates allcommunication connections to an OPC clientafter the last link has been deleted.
GetErrorString Gets an error message for an error code. TheOPC Server for SIMATIC NET supports Germanand English error messages. Error messagesfrom the Windows operating system are dis-played in the language of the operating systeminstallation.
GetItemProperties Returns a list with the values of the requestedproperties
GetOPCServers Returns the names of the registered OPC ser-vers. The name of the OPC server for SIMATICNET is, for example, OPC.SimaticNET.
Using the OPC Server
388SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
LookupItemIDs Returns a list with ItemIDs that correspond to thePropertyIDs. The OPC Server for SIMATIC NETdoes not return PropertyIDs that could be dis-played as ItemIDs.
QueryAvailableLocaleIDs Returns the available language codes. The OPCServer for SIMATIC NET supports German andEnglish error messages. Error messages fromthe Windows operating system are displayed inthe language of the operating system installation.
QueryAvailableProperties Returns property codes and properties for anOPC item.
Events of OPCServer
Below, you will find a description of the event for the OPCServer object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theevent in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Event Meaning
ServerShutDown This is triggered when the OPC server is shutdown. The OPC Server for SIMATIC NET trig-gers this event when the shutdown command issent by the configuration program or when thePC station receives new configuration data.
Collection Object OPCBrowser
Using the OPCBrowser collection object, you can browse through the name spaceof the OPC server.
An object of the OPCBrowser class is created by the CreateBrowser method ofthe OPCServer object. Several OPCBrowser objects can be created for oneserver.
Using the OPC Server
389SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Properties of OPCBrowser
Below, you will find a list of the properties for the OPCBrowser collection object.Only the features specific to SIMATIC NET are described. You will find adescription of the properties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Property Meaning
AccessRights Decides the access rights for theShowLeafs method
Count Returns the number of entries
CurrentPosition Returns the current position in the na-me space tree
DataType Decides the data type for the Show-Leafs method
Filter Decides the filter for the ShowLeafsand ShowBranches methods
Organization Returns the organizational structure ofthe name space. The name space ofthe OPC Server for SIMATIC NET ishierarchically structured.
Methods of OPCBrowser
Below, you will find a list of the methods for the OPCBrowser collection object.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
GetAccessPaths Gets the access path of an ItemID.
For the OPC Server for SIMATIC NET, youshould not use the AccessPath parameter.
GetItemID When possible, this is returns the ItemID for anelement in the name space of the OPC server.
Item Specifies the name of an entry
MoveDown Moves the current position in the name spaceone level down
MoveTo Moves the current position in the name space tothe specified position
Using the OPC Server
390SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
MoveToRoot Moves the current position in the name space tothe root
MoveUp Moves the current position in the name spaceone level up
ShowBranches Specifies the name of the branches at the cur-rent browse position
ShowLeafs Specifies the name of the leaves at the currentbrowse position
Collection Object OPCGroups
The OPCGroups collection object is a collection of OPCGroup objects for creatingand managing OPC groups. The standard properties of OPCGroups specifystandard values for all newly created OPC groups.
If the OPC server object executes a Connect call successfully, an OPCGroupscollection object is created as a property of the OPC server object.
Note
The optional public groups are not supported by the OPC Server for SIMATICNET.
Properties of OPCGroups
Below, you will find a list of the properties for the OPCGroups collection object.Only the features specific to SIMATIC NET are described. You will find adescription of the properties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Property Meaning
Count Returns the number of groups
DefaultGroupDeadband Specifies the initial value for Deadband fornewly generated OPCGroup objects
DefaultGroupIsActive Specifies the initial value for ActiveState fornewly generated OPCGroup objects
DefaultGroupLocaleID Specifies the initial value for LocaleID fornewly generated OPCGroup objects
DefaultGroupTimeBias Specifies the initial value for TimeBias fornewly generated OPCGroup objects
Using the OPC Server
391SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
DefaultGroupUpdateRate Specifies the initial value for UpdateRate fornewly generated OPCGroup objects
Parent Returns the reference to the correspondingOPCServer object
Methods of OPCGroups
Below, you will find a list of the methods for the OPCGroups collection object. Onlythe features specific to SIMATIC NET are described. You will find a description ofthe methods in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
Add Creates a new OPCGroup object and adds it tothe collection
GetOPCGroup Specifies the reference to the name or serverhandle of an OPCGroup object
Item Returns the reference to the indexed object ofthe collection
Remove Deletes a group of the server
RemoveAll Deletes all groups of the server
Events of OPCGroups
Below, you will find a description of the event for the OPCGroups collection object.Here, only the special features for SIMATIC NET are described. You will find adetailed description of the event in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Event Meaning
GlobalDataChange Notifies value changes and the status of the activeitems of all active groups
Using the OPC Server
392SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OPCGroup Object
The OPC Group class manages the individual process variables, the OPC items.Using the OPCGroup object, a client can put OPC items into a group based onsemantic considerations and process the group as a single unit.
Monitoring variables and read and write access are group-specific. As an example,monitoring of all the OPC items in a group can be activated by calling a singlefunction.
You should therefore put all the process variables, for example, that are displayedtogether in one screen on an operator control and monitoring station into the samegroup and activate monitoring of the variables when the screen is opened.
Note
The optional public groups are not supported by the OPC Server for SIMATICNET.
Properties of OPCGroup
Below, you will find a list of the properties for the OPCGroup object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Property Meaning
ClientHandle Specifies the handle for localizing data
DeadBand Specifies the band width in which value changes do notlead to a notification
IsActive Specifies the active status of the group.Make sure you set IsActive to True if you want to monitorthe variables of this group.
IsPublic Indicates whether or not the group is a public groupThe optional public groups are not supported by the OPCServer for SIMATIC NET.
IsSubscribed Indicates whether the variables of a group will be monito-red.Make sure you set IsSubscribed to True if you want tomonitor the variables of this group.
LocaleID Specifies the language for text string as returned by theserver
Using the OPC Server
393SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
Name Specifies the name of the group
OPCItems Specifies the collection object for managing the items ofthe group
Parent Returns the reference to the corresponding OPCServerobject
ServerHandle Returns a unique handle for the group
TimeBias Specifies the time offset for converting the timestamp tolocal time
UpdateRate Specifies the interval at which a client is notified of changesto values or in the statuses of items
Methods of OPCGroup
Below, you will find a list of the methods for the OPCGroup object. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
AsyncCancel Cancels an asynchronous job
AsyncRead Sends an asynchronous read command
AsyncRefresh Creates an event for every active OPC item withthe current value from the cache.
AsyncWrite Sends an asynchronous write command
SyncRead Starts synchronous reading of values, status in-formation, and timestamp of one or more itemsof a group.
SyncWrite Starts synchronous writing of values for one ormore items of a group
Using the OPC Server
394SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Events of OPCGroup
The OPC Automation Interface returns the changes to values of active items andthe results of asynchronous operations using events.
Objects in Visual Basic that are intended to receive events must be declared withwithEvents.
Below, you will find a list of the events for the OPCGroup object. Only the featuresspecific to SIMATIC NET are described. You will find a description of the events inthe following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Event Meaning
AsyncCancelComplete This is triggered when a cancel job is completed
AsyncReadComplete This is triggered when a read job is completed
AsyncWriteComplete This is triggered when a read job is completed
DataChange This is triggered when one or more items have achanged value or a changed quality.
Collection Object OPCItems
The OPCItems collection object is a collection of OPCItem objects for creating andmanaging OPC items. The properties of OPCItems specify standard values for allnew OPC items that are created.
If an OPCGroup object is created, an OPCItems collection object is automaticallycreated. OPCItems always exists as a property of a group and is used to monitorthe OPC variables.
Properties of OPCItems
Below, you will find a list of the properties for the OPCItems object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Using the OPC Server
395SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
Count Returns the number of items in the group
DefaultAccessPath Specifies the initial value for AccessPath for newlyadded OPC items.
For the OPC Server for SIMATIC NET DefaultAc-cessPath should be empty.
DefaultIsActive Specifies the initial value for ActiveState for newlyadded OPC items
DefaultRequested-DataType
Specifies the initial value for RequestedDataTypefor newly added OPC items
Parent Returns the reference to the corresponding OPC-Group object
Methods of OPCItems
Below, you will find a list of the methods for the OPCItems object. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
AddItem Adds a new OPC item to the collection object.
AddItems Adds several OPC items to the collection object
GetOPCItem Specifies the reference to the server handlecreated by AddItem
Item Specifies the reference to an item of the collec-tion
Remove Deletes one or more items from a group
SetActive Sets the active status of one or more items of agroup
SetClientHandles Changes the client handle for one or more items
SetDataTypes Sets the data type for one or more items
Validate Checks the validity of one or more OPC items
Using the OPC Server
396SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OPCItem Object
An object of the OPC Item class represents a process variable, for example aninput module of a programmable controller. A process variable is a writable and/orreadable data item of the process I/O such as the temperature of a tank. Eachprocess variable is associated with a value, a quality and a timestamp.
Properties of OPCItem
Below, you will find a list of the properties for the OPCItem object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Property Meaning
AccessPath Returns the access path of the item. For theOPC Server for SIMATIC NET, Access Pathshould be empty.
AccessRights Returns the access rights of the variables.
CanonicalDataType Returns the original data type of the item
ClientHandle Specifies the handle for simpler assignment ofprocess variables to internal data structures ofthe client
EUInfo Returns information about the units of the value(optional). The OPC Server for SIMATIC NETdoes not support units (Engineering Units).
EUType Returns the unit of the returned value (optional).The OPC Server for SIMATIC NET does not sup-port units (Engineering Units).
IsActive Specifies whether notification events are genera-ted for the item
ItemID Returns the unique name of the item
Parent Returns the reference to the parent OPCGroupobject
Quality Returns the quality of the value read last.
RequestedDataType Specifies the requested data type for the value ofthe item
ServerHandle Returns the server handle to identify an item
Using the OPC Server
397SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
TimeStamp Returns the time at which the last value was ac-quired
Value Returns the last valid value of an item
Methods of OPCItem
Below, you will find a list of the methods for the OPCItem object. Only the featuresspecific to SIMATIC NET are described. You will find a description of the methodsin the following OPC Specification:
Data Access Automation InterfaceVersion 2.02February 4, 1999
Method Meaning
Read Reads value, quality and/or timestamp of the variable syn-chronously.
Write Sets the value of the variable synchronously
6.2.5 Programming the Automation Interface for Alarms & Events
For Alarms & Events, there is a simple class model, that groups the interfaces andtheir methods in classes.
The Automation Interface further refines the class model valid for the CustomInterface to provide the benefits and options available with structured developmentsystems such as Visual Basic.
6.2.6 What Does the Object Model of OPC Alarms & Events Provide?
The classes of the class model of Alarms & Events contain the following objects:
� OPCEventServer
� OPCEventSubscriptions
� OPCEventSubscription
� OPCEventAreaBrowsers
� OPCEventAreaBrowser
� OPCEvents
� OPCEvent
� OPCEventCondition
Using the OPC Server
398SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� OPCEventSubConditions
� OPCEventSubCondition
Additional objects can be added for the Automation Interface.
Note
Since the Event Server of SIMATIC NET is a Simple Event Server, the followingobjects are not supported: OPCEventAreaBrowsers, OPCEventAreaBrowser,OPCEventCondition, OPCEventSubConditions, OPCEventSubCondition.
Object Model
The following graphic illustrates the objects and the relationships between theobjects.
Figure 6-15 Object Model of OPC Alarms & Events
Using the OPC Server
399SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.2.7 Points to Remember When Programming
With the Automation Interface, optional parameters must be passed as variants. InVisual Basic, however, optional parameters should be declared with the targettype. This ensures that the variant contains the correct data type.
� Asynchronous Functions
The IsSubscribed group-specific property must be set to True to allow thevariables to be monitored.
� The objects that will receive events must be declared with the supplementwithEvents in Visual Basic.
Example:
Dim withEvents MyOPCGroup as OPCGroup
� According to the OPC Specification, arrays always begin with index 1. Definethis in your program as follows:
Option Base 1 ’ARRAYs are always Option Base 1
6.2.8 Objects of the Automation Interface for Alarms & Events
Below, you will see a list of the properties, methods, and events for Alarms &Events. Only the features specific to SIMATIC NET are described. For a detaileddescription of the properties, methods, and events, refer to the relevant OPCSpecifications.
Objects
The following objects exist for the Automation Interface for Alarms & Events:
OPCEventServer Object
OPCEventServer objects of the OPC Event Server class are created by the client.OPCEventServer must be created before the client can access other objects ofAlarms & Events.
The properties of the OPCEventServer objects contain general information aboutthe event server. When an object is created, an OPCEventServerSubscriptioncollection object is also created.
OPCEventServer is connected to the event server by the Connect method.
Using the OPC Server
400SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Properties of OPCEventServer
Below, you will find a list of the properties for the OPCEventServer object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Property Meaning
BuildNumber Returns the build number of the server.
ClientName Specifies the name of the client.
CurrentTime Returns the current time in UTC.
FiltersByArea Indicates whether or not the server can filter ac-cording to areas. The OPC Event Server doesnot support areas.
FiltersByCategory Indicates whether or not the server can filter ac-cording to event categories.
FiltersByEventType Indicates whether or not the server can filter ac-cording to event types.
FiltersBySeverity Indicates whether or not the server can filter ac-cording to the severity of events.
FiltersBySource Indicates whether or not the server can filter ac-cording to sources.
LastUpdateTime Returns the time in UTC at which the server lastsent data to the client.
LocaleID Specifies the language for displayed texts.
MajorVersion Returns the main version number of the server
MinorVersion Returns the secondary version number of theserver
OPCEventAreaBrow-sers
Specifies the collection of OPCAutoEventArea-Browser objects.
OPC Event Server of SIMATIC NET does notsupport OPCEventAreaBrowsers.
OPCEventSubscriptions Specifies the collection of OPCEventSubscrip-tion objects.
ServerName Returns the name of the connected OPC server.
ServerNode Returns the name of the network node on whichthe OPC server is executed.
ServerState Returns the server status.
StartTime Returns the time at which the OPC server wasstarted.
VendorInfo Returns vendor information.
Using the OPC Server
401SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Methods of OPCEventServer
Below, you will find a list of the methods for the OPCEventServer object. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Method Meaning
AckCondition Acknowledges one or more conditions on theevent server.
Connect Establishes the connection to the OPC server.
Disconnect Terminates the connection to the OPC server.
EnableConditionsByA-rea
Sets all conditions for all areas to a defined sta-tus.
EnableConditionBySrc Sets all conditions for all sources to a definedstatus.
GetConditionState Gets current status information for the condition.
GetErrorString Converts an error code to an error text.
GetOPCEventServers Returns the names of all registered event ser-vers.
QueryAvailableLoca-leIDs
Returns the available language codes.
QueryConditionNames Returns the names of the conditions valid for aspecific event category.
QueryEventAttributes Returns vendor-specific attributes
QueryEventCategories Returns the categories supported by the eventserver.
QuerySourceConditions Returns the names of conditions linked to a spe-cific source.
QuerySubConditionNa-mes
Returns the names of subconditions linked to aspecific source.
Events of OPCEventServer
Below, you will find a list of the events for the OPCEventServer object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theevent in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Using the OPC Server
402SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Event Meaning
EventServerShutDown This is triggered when the OPC server is shutdown. The OPC Server for SIMATIC NET trig-gers this event when the shutdown command issent by the configuration program or when thePC station receives new configuration data.
Collection Object OPCEventSubscriptions
The OPCEventSubscriptions collection object is a collection ofOPCEventSubscription objects and the methods with which to create, remove, andmanage them.
The properties of OPCEventSubscriptions specify standard values for all newlycreated OPCEventSubscription objects.
When the Connect call of the OPCEventServer object is successfully executed,an OPCEventSubscriptions collection object is created automatically.OPCEventSubscriptions always exists as a property of the OPCEventServer objectand is used to manage event messages.
Properties of OPCEventSubscriptions
Below, you will find a list of the properties for the OPCEventSubscriptions object.Only the features specific to SIMATIC NET are described. You will find adescription of the properties in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Property Meaning
Count Returns the number of entries
DefaultIsActive Specifies the initial value for the active status fornewly generated OPCEventSubscription objects
DefaultbufferTime Specifies the initial value for how often event no-tifications are sent for newly generated OPCE-ventSubscription objects
DefaultMaxSize Specifies the initial value for the highest numberof events that can be sent with a single eventnotification for newly generated OPCEventSubs-cription objects
Using the OPC Server
403SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Methods of OPCEventSubscriptions
Below, you will find a list of the methods for the OPCEventSubscriptions object.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Method Meaning
Add Creates a new OPCEventSubscription object and adds it tothe collection
Item Specifies the reference to the indexed object of the collec-tion
Remove Deletes an OPCEventSubscription object
RemoveAll Deletes all OPCEventSubscription objects
OPCEventSubscription Object
The OPCEventSubscription object represents a specific event subscription. Asubscription is a season ticket to a set of events. The client starts a job for theregular sending of events to the event server.
Properties of OPCEventSubscription
Below, you will find a list of the properties for the OPCEventSubscription object.Only the features specific to SIMATIC NET are described. You will find adescription of the properties in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Property Meaning
bufferTime Decides how often event notifications are sentfor the OPCEventSubscription object
IsActive Specifies the active status of the OPCEvent-Subscription object
MaxSize Specifies the highest number of events that canbe sent with a single event notification
Name Specifies the name of the OPCEventSubscriptionobject
Using the OPC Server
404SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Methods of OPCEventSubscription
Below, you will find a list of the methods for the OPCEventSubscription object.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Method Meaning
GetFilter Returns the current filter for the OPCEventSubs-cription object. The parameters of the S7 OPCEvent Server for SIMATIC NET have the follo-wing significance:
EventTypeThe event types OPC_SIMPLE_EVENT andOPC_CONDITION_EVENT are supported.
EventCategoryThe event categories are described in the sectionProperties of the OPC Event Server of SIMATICNET.
LowSeverity
HighSeverity
AreasThe OPC Event Server does not support areas.
SourcesYou can enter a connection name as the source.
GetReturnedAttributes Returns attributes for every event category thatthe server sends with the event notifications.
Refresh Refreshes all conditions.
RefreshCancel Cancels execution of the Refresh method. TheS7 OPC Event Server for SIMATIC NET doesnot support RefreshCancel.
Using the OPC Server
405SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Method Meaning
SelectReturnedAttribu-tes
For each event category, this specifies the attri-butes that are returned with the event notifica-tions by the OnEvent method
SetFilter Sets all filters so that the filter properties matchthose of the created events. The parameters ofthe S7 OPC Event Server for SIMATIC NET ha-ve the following significance:
EventTypeThe event types OPC_SIMPLE_EVENT andOPC_CONDITION_EVENT are supported.
EventCategoryS7_PROCESS_ALARM
LowSeverity
HighSeverity
AreasThe S7 OPC Event Server does not supportareas.
SourcesYou can enter a connection name as the source.
Events of OPCEventSubscription
Below, you will find a list of the events for the OPCEventSubscription object. Onlythe features specific to SIMATIC NET are described. You will find a description ofthe event in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Event Meaning
ConditionEvent This occurs when condition events are sent bythe server.
RefreshCancel This occurs when the Refresh method is inter-rupted.
The OPC Event Server for SIMATIC NET doesnot support RefreshCancel.
Using the OPC Server
406SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Event Meaning
RefreshComplete This occurs when the Refresh method is com-pleted
The OPC Event Server for SIMATIC NET doesnot support RefreshComplete.
RefreshConditionEvent This occurs when events relating to the refres-hing of conditions are sent by the server.
SimpleEvent This occurs when a group of simple events aresent by the server.
TrackingEvent This occurs when tracking events are sent by theserver.
The OPC Event Server for SIMATIC NET doesnot support TrackingEvent.
Collection Object OPCAutoEventAreaBrowsers
The OPCAutoEventAreaBrowsers collection object is a collection ofOPCAutoEventAreaBrowser objects and the methods with which to create,remove, and manage them.
Note
The OPC Event Server does not support OPCAutoEventAreaBrowsers.
OPCAutoEventAreaBrowser Object
With the OPCAutoEventAreaBrowser object, a client can browse through the areasand sources of the server. The areas are grouped together to formOPCEventAreas and the sources form OPCEventSources.
The areas and sources can be used to filter events.
Name Space of the Server
Servers have a flat or hierarchical name space. If the name space is flat,OPCEventAreas and OPCEventSources have the same areas and sources on theserver.
If the name space is hierarchical, the areas can be considered as branches in atree and the sources as leaves. The OPCAutoEventAreaBrowser object moves likea pointer along the areas. OPCEventAreas and OPCEventSources contain onlythe areas and sources in which the object exists.
Using the OPC Server
407SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Note
The OPC Event Server does not support OPCAutoEventAreaBrowser.
Collection Object OPCEvents
The OPCEvents collection object is the transfer parameter of the methods forhandling events. It contains a collection of OPCEvent objects and the methodswith which to create, remove, and manage them.
OPCEvents is generated from the event notifications sent by the server andtherefore delivers the events that have occurred.
Properties of OPCEvents
Below, you will find a list of the properties for the OPCEvents object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Property Meaning
Count Returns the number of entries
LastRefresh Specifies that the OPCEvents collection object isthe last in a series of refresh notifications
Refresh Specifies that the OPCEvents collection objectbelongs to a refresh notification
Methods of OPCEvents
Below, you will find a list of the methods for the OPCEvents object. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Method Meaning
Add Creates a new OPCEvent object and adds it tothe collection
Item Specifies the name of an entry
Using the OPC Server
408SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OPCEvent Object
The OPCEvent object contains the notification for a specific event.
Properties of OPCEvent
Below, you will find a list of the properties for the OPCEvent object. Only thefeatures specific to SIMATIC NET are described. You will find a description of theproperties in the following OPC Specification:
Alarm & Events Automation Interface StandardVersion 1.01December 15, 1999
Property Meaning
AckRequired Indicates that the condition requires an acknow-ledgment.
ActiveTime Returns the time at which the condition was acti-vated.
ActorID Returns the tracking and condition events thatrequire acknowledgment.
ChangeAckState Returns the event notification for the change tothe Acknowledge property of a condition.
ChangeActiveState Returns the event notification for the change tothe ActiveState property of a condition.
ChangeAttribute Returns the event notification for the change tothe Attribute property of a condition
ChangeEnableState OPC Event Server for SIMATIC NET does notsupport Enable property of a condition
ChangeMessage Returns the event notification for the change tothe Message property of a condition.
OPC Event Server for SIMATIC NET does notsupport ChangeMessage.
ChangeQuality Returns the event notification for the change tothe Quality property of a condition
OPC Event Server for SIMATIC NET does notsupport ChangeQuality.
ChangeSeverity Returns the event notification for the change tothe Severity property of a condition.
OPC Event Server for SIMATIC NET does notsupport ChangeSeverity.
Using the OPC Server
409SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Property Meaning
ChangeSubCondition Returns the event notification for the change tothe SubCondition property of a condition.
ConditionAcknowledged Indicates that the new status of the condition isAcknowledged.
ConditionActive Indicates that the new status of the condition isActive.
ConditionName Returns the name of the condition that refers tothe event notification.
Cookie Returns a cookie defined by the server that islinked to the event notification.
OPC Event Server for SIMATIC NET does notsupport Cookie.
EventCategory Returns the code for the event category of theevent
Message Returns a text describing the notification
OPCEventAttributes Returns the vendor-specific event attributes re-turned by the event notification
Quality Returns the quality associated with the status ofthe condition.
OPC Event Server for SIMATIC NET does notsupport Quality.
Severity Returns the severity of the event.
Source Returns the source of the event notification.
SubConditionName Returns the name of the current subcondition.
OPC Event Server for SIMATIC NET does notsupport SubConditionName .
Time Returns the time in UTC at which an event oc-curred.
Using the OPC Server
410SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OPCEventCondition Object
The OPCEventCondition object describes the current status of a condition.
Collection Object OPCEventSubConditions
The OPCEventSubConditions collection object is a collection ofOPCEventSubCondition objects. The collection represents the various statuses ofa condition on an OPC Event Server.
OPCEventSubCondition Object
The OPCEventSubCondition object represents a specific subcondition of OPCEvent Server. OPCEventSubCondition contains the attributes of the subcondition.
6.3 Programming the Custom Interface
The Custom Interface is designed in such a way that it functions ideally to meet thegiven requirements. For access using script languages, it is not suitable. For thispurpose, there is the Automation Interface.
There is both a Custom Interface for access to process variables (data access)and for processing events and alarms (Alarms & Events).
Application
You program the Custom Interface if you want to create an application with a largenumber of variables and high data throughput with C++.
CLSID
Each COM class can be uniquely identified by an identification code. This is 128bits long and is called the CLSID. Using the CLSID, the operating system can findthe DLL or EXE in which the COM class is implemented. If the client wants to usean object of a class, it references it using the CLSID.
ProgID
To simplify identification of OPC servers, a readable ProgID is assigned to theCLSIDs. The CLSID and ProgID are specified by the vendor of the OPC server.
Using the OPC Server
411SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
For the OPC server of SIMATIC NET, the following points apply to all protocols:
Interface ProgID
Data Access OPC.SimaticNET(standard OPC server for multiple protocoloperation)
OPC.SimaticNET(High-performance OPC server for S7, SR,DP single protocol mode. Symbols and DX arealso allowed)
OPC.SimaticNET.DP(OPC server for highly efficient DP access)
OPC.SimaticNet.PD(bus server PROFIDrive)
Alarms & Events for S7 OPC.SimaticNetAlarms(A&E server for S7)
OPC.SimaticNetAlarms(High-performance A&E server for S7 singleprotocol mode, symbols and DX also allowed)
OPC.SimaticNetAlarmsSNMP(A&E server for SNMP)
Steps
You create a COM object and call its methods.
Note
A Windows object is an instance of a COM class. The COM class differs from theC++ class. A class in C++ is a type definition. A COM class is an objectdescription and contains no types.
Using the OPC Server
412SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.3.1 Creating COM Objects and Querying the Status of the OPCServer
You will find a detailed description of using the Custom Interface for OPC DataAccess in the description of the examples. The description below simply outlinesthe basic sequence and makes no attempt to deal with error handling.
You create a COM object and query the status in five steps.
For examples of creating a COM object in Visual C++, refer to Sections 9.4 and9.5.
6.3.2 Objects of the Custom Interface for Data Access
This section lists the interfaces of the objects and their methods. Only the featuresspecific to SIMATIC NET are described. For a detailed description of theinterfaces, refer to the relevant OPC Specifications.
Return Values of the Methods of the Interfaces
All methods return a result of the type HResult.
6.3.3 OPCServer Object
An object of the OPC server class has various attributes that contain, for example,information on the status or the version of an OPCServer object. The class alsohas methods with which a client manages the objects of the OPC Group class.
A client application only uses the OPC server object directly using COMmechanisms. All other objects are created by the relevant OPC methods.
Using the OPC Server
413SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Interfaces of OPCServer
The graphic below shows the interfaces of the OPCServer object.
Figure 6-16 OPCServer Object
IOPCServer Interface
The IOPCServer interface contains methods for managing the objects of the OPCGroup class. Information can also be obtained about the current status of theserver.
Below, you will find a list of the methods for the IOPCServer interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Using the OPC Server
414SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
AddGroup Generates a group in the server object.
The parameter LCID is not evaluated with theOPC Server for SIMATIC NET.
The pTimeBias parameter specifies the timedifference compared with the local time zone.
The update rates used by the OPC Server forSIMATIC NET are multiples of the cycle timespecified during configuration. The minimumupdate rate is the same as the cycle time.If szName is empty, a name is generated thatstarts with the tilde character (for example~GROUP_1). User-defined names shouldtherefore not begin with a tilde.
CreateGroupEnumera-tor
Creates various enumerators for the group.
The OPC Server for SIMATIC NET does not sup-port public groups. The return values of the me-thods should therefore be identical with the inputvalues ...PRIVATE and ...PUBLIC (for PublicGroups) for the parameter dwScope.
GetErrorString Gets an error message for an error code.
The OPC Server for SIMATIC NET supportsGerman and English error texts. Error messagesfrom the Windows operating system are dis-played in the language of the operating systeminstallation.
GetGroupByName Returns an additional interface pointer to the na-me of a private group; the reference counter isincremented.
GetStatus Returns status information on the server.
The return value is the name and the version ofthe OPC server.
RemoveGroup Deletes a group in the server.
The OPC Server for SIMATIC NET does not sup-port the use of bForce. You cannot deletegroups if references to them still exist.
IOPCServerPublicGroups Interface
The OPC Server for SIMATIC NET does not support public groups and thereforedoes not support the optional IOPCServerPublicGroups interface.
Using the OPC Server
415SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
IOPCBrowseServerAddressSpace Interface
Using the optional interface IOPCBrowseServerAddressSpace, you can browsethe name space of the server. The name space contains all the OPC items knownto the server.
Below, you will find a list of the methods for the IOPCBrowseServerAddressSpaceinterface. Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
BrowseAccessPaths Gets the access path of an ItemID. BrowseAc-cessPaths is not required with the OPC Serverfor SIMATIC NET.
BrowseOPCItemIDs Returns a string of the type IEnumString, whosecontent is specified by the parameters of the call.
If the input parameter dwBrowseFilterType isset to OPC-BRANCH, the parameters vtDataTy-peFilter and dwAccessRightsFilter have noeffect.
The rules for creating a filter are as follows:*any character string including empty strings+any character string, but there must be at leastone character?exactly one character[]exactly one character from the specified setIf you use a filter character, this must be precededby a backslash (\).
ChangeBrowsePosition Changes to the higher level or to a branch in thename space
Using the OPC Server
416SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
GetItemID Gets a complete ItemID in the hierarchical namespace. The OPC Server for SIMATIC NET sup-ports GetItemID only for single leaves.
QueryOrganization Returns the structure of the name space. Thename space of the OPC Server for SIMATICNET is hierarchically structured.
IOPCItemProperties Interface
The IOPCItemProperties interface contains methods for querying server-specificinformation on an item.
Below, you will find a list of the methods for the IOPCItemProperties interface.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
QueryAvailableProperties Returns a list of available properties for an item
GetItemProperties Returns the values of the properties of an itemtransferred in a list of PropertyIDs
LookupItemIDs Returns a list of ItemIDs for a list of Proper-tyIDs
IConnectionPointContainer Interface
The IConnectionPointContainer interface is a standard COM interface for reportingasynchronous events over connection points. For more detailed information on theuse of connection points, refer to the literature on COM.
Using the OPC Server
417SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
IOPCCommon Interface
The IOPCCommon interface contains methods to inform the server of thelanguage settings and the name of the client.
Below, you will find a list of the methods for the IOPCCommon interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
SetLocaleID Sets the language code of the server. The OPCServer for SIMATIC NET supports German andEnglish.
GetLocaleID Gets the language code of the server. The OPCServer for SIMATIC NET supports German andEnglish.
QueryAvailableLoca-leIDs
Returns all available language codes of the ser-ver. The OPC Server for SIMATIC NET supportsGerman and English.
GetErrorString Returns an error text for an error code
SetClientName Transfers a text describing the client to the ser-ver
IPersistFile Interface
The optional IPersistFile interface is not supported by the OPC Server for SIMATICNET.
6.3.4 OPCGroup Object
An object of the OPC Group class manages the individual process variables, theOPC items. Using the OPCGroup objects, a client can form meaningful units ofOPC items and execute operations with them.
Using the OPC Server
418SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Interfaces of OPCGroup
The graphic below shows the interfaces of OPCGroups.
Figure 6-17 OPCGroup Object
IOPCGroupStateMgt Interface
The IOPCGroupStateMgt interface provides methods for managing groups. Youcan edit group-specific parameters and copy groups.
Below, you will find a list of the methods for the IOPCGroupStateMgt interface.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Using the OPC Server
419SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Method Meaning
CloneGroup Creates a copy of a group. The group attributesare copied with the exception of the following:
The active status is set to false.
A new server handle is assigned
szName can be empty. In this case, a uniquename is generated.
GetState Gets the status of the group.
The parameters pTimeBias and pLCID have nosignificance for the OPC Server for SIMATICNET.
SetName Changes the name of a group
SetState Changes the properties of the group.
The parameters pTimeBias and pLCID have nosignificance for the OPC Server for SIMATICNET.
The update rates used by the OPC Server forSIMATIC NET are multiples of the cycle timespecified during configuration. The minimumupdate rate is the same as the cycle time.
IOPCPublicGroupStateMgt Interface
The OPC Server for SIMATIC NET does not support public groups. For thisreason, the optional IOPCPublicGroupStateMgt interface has no significance.
IOPCAsyncIO2 Interface
The IOPCAsyncIO2 interface contains methods for asynchronous reading andwriting of items.
Asynchronous means that the client starts a read or write operation and thencontinues to execute. The interface uses connection points. This simplifiesprocessing of the transferred data.
With each value read, OPC provides a timestamp. Since the SIMATIC systems donot manage a timestamp, the time at which the value was received on the server isused as the timestamp.
Using the OPC Server
420SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Below, you will find a list of the methods for the IOPCAsyncIO2 interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
Read Sends an asynchronous read command.
The call is monitored for timeout on the server. Ifthe timeout set in the configuration elapses, the-re is a notification with the status E_ABORT.
Write Sends an asynchronous write command.
The call is monitored for timeout on the server. Ifthe timeout set in the configuration elapses, the-re is a notification with the status E_ABORT.
Cancel2 Cancels a pending job
Refresh Requests the current value from the cache foreach active item
SetEnable Allows deactivation of notification with OnData-Change
GetEnable Returns the current value for notification with On-DataChange
IOPCAsyncIO Interface
This interface contains methods for asynchronous reading and writing of items.Asynchronous means that the client starts a read or write operation and thencontinues to execute.
Asynchronous operations return a transaction ID. When the server has completedthe read or write operation, the client is notified by a message to its IAdviseSinkinterface.
Note
In version 2, the IOPCAsyncIO interface was replaced by IOPCAsyncIO2.IOPCAsyncIO2 uses connection points and is easier to handle. In future projects,use IOPCAsyncIO2.
Using the OPC Server
421SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
With each value read, OPC provides a timestamp. Since the SIMATIC systems donot manage a timestamp, the time at which the value was received on the server isused as the timestamp.
Below, you will find a list of the methods for the IOPCAsyncIO interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
Cancel Cancels a pending job.
Read Sends an asynchronous read command.
The call is monitored for timeout on the server.The configuration parameter is Read/Write Ti-meout. If this times out, there is a callback withthe status E_ABORT.
Refresh Requests a current value for every active OPCitem.
Write Sends an asynchronous write command.
The call is monitored for timeout on the server.The configuration parameter is Read/Write Ti-meout. If this times out, there is a callback withhrStatus=E_ABORT.
IOPCItemMgt Interface
The IOPCItemMgt interface contains methods for managing several items in agroup.
Below, you will find a list of the methods for the IOPCItemMgt interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Using the OPC Server
422SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
AddItems Adds one or more items to a group.
CreateEnumerator Creates an enumerator. This is the EnumOPCI-temAttributes object.
RemoveItems Deletes one or more items from a group.
SetActiveState Sets the active status of one or more items of thegroup.
SetClientHandles Sets the client handle of one or more items of thegroup.
SetDataTypes Sets the required data type of one or more itemsof the group.
ValidateItems Checks the validity of an OPC item.
IOPCSyncIO Interface
The IOPCSyncIO interface contains methods for synchronous reading and writing.Synchronous means that the client waits until a read or write operation iscompleted before it continues. The client can use the result of the read or writeoperation for further processing.
Since the OPC Server for SIMATIC NET starts a separate thread for each client,other clients are not blocked while the client waits.
Below, you will find a list of the methods for the IOPCSyncIO interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
Read Reads the values, a status information and thetimestamp of one or more items of a group.
The call is monitored for timeout on the server.The corresponding timeout is set during configu-ration for each specific protocol.
Write Writes the value for one or more items of agroup.
The call is monitored for timeout on the server.The corresponding timeout is set during configu-ration for each specific protocol.
Using the OPC Server
423SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
IDataObject Interface
The IDataObject interface is a standard COM interface for data transfer. It containsmethods for establishing a notification connection between client and a servergroup.
When the server sends the client a notification, it accesses the client over theIAdviseSink client interface by calling the OnDataChange method of IAdviseSink.
The following graphic illustrates the interaction of the interfaces IAdviseSink on theclient and IDataObject on the server.
Figure 6-18 Interaction of IAdviseSink and IDataObject
Note
IDataObject was used in version 1 of the Data Access interface for asynchronouscommunication. As of version 2, connection points are used and are both simplerand more flexible. In future projects, use version 2.
Below, you will find a list of the methods for the IDataObject interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
DAdvise Establishes a connection between server andclient
DUnadvise Terminates a connection between server andclient
IEnumOPCItemAttributes Interface
The IEnumOPCItemAttributes interface is based on the standard IEnum interface.It returns the items of a group of. The interface is provided by theCreateEnumerator method of the IOPCItemMgt interface. It is not obtainable withQueryInterface.
Using the OPC Server
424SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Below, you will find a list of the methods for the IEnumOPCItemAttributes interface.Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Data Access Custom Interface StandardVersion 2.05December 17, 2001
Method Meaning
Clone Creates an identical copy of the IEnumOPCIte-mAttributes object
Next Fetches the next OPC item of the group.
Reset Resets the list to the first item of the group
Skip Skips a number of items in the list
6.3.5 Objects of the Custom Interface for Alarms & Events
The interfaces and their methods are listed below. Only the features specific toSIMATIC NET are described. For a detailed description of the interfaces, refer tothe relevant OPC Specifications.
Return Values of the Methods of the Interfaces
All methods return a result of the type HResult.
6.3.6 OPCEventServer Object
An object of the OPC Event Server class is created by the client. The client thenuses this object when it requires the services of Alarms & Events.
The following tasks can be performed using the OPCEventServer object:
� Create message object
� Execute queries
� Activate events
� Set the language for display texts
� Register to receive server-specific events
Using the OPC Server
425SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Interfaces of OPCEventServer
The graphic below shows the interfaces of OPCEventServer.
Figure 6-19 OPCEventServer Object
IOPCCommon Interface
The IOPCCommon interface contains methods to inform the server of thelanguage settings and the name of the client.
Below, you will find a list of the methods for the IOPCCommon interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Alarms & Events Custom Interface StandardVersion 1.10October 2, 2002
Method Meaning
SetLocaleID Sets the language code of the server. TheOPC Server for SIMATIC NET supports Ger-man and English.
GetLocaleID Gets the language codes of the server. TheOPC Server for SIMATIC NET supports Ger-man and English.
QueryAvailableLocaleIDs Returns all available language codes of theserver. The OPC Server for SIMATIC NETsupports German and English.
GetErrorString Gets an error message for an error code
SetClientName Transfers a text describing the client to theserver
Using the OPC Server
426SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
IOPCEventServer Interface
The IOPCEventServer interface is the central interface for Alarms & Events. It hasthe following tasks:
� Creating subscription objects
� Creating area browsers
� Browsing event categories
� Managing conditions
Note
SIMATIC NET supports the optional areas so that no area browser is created.
Below, you will find a list of the methods for the IOPCEventServer interface. Onlythe features specific to SIMATIC NET are described. You will find a description ofthe methods in the following OPC Specification:
Alarms & Events Custom Interface StandardVersion 1.10October 2, 2002
Method Meaning
GetStatus Gets current status information about theOPC server.
CreateEventSubscription Creates a message object to notify a client.The message object is called subscriptionand is like a ticket to a set of events.
The interface required to access the messageobject is returned
QueryAvailableFilters Returns information about the filter optionssupported by the event server.
OPC Event Server for SIMATIC NET doesnot support the following filters:
OPC_FILTER_BY_EVENTS: 0x01OPC_FILTER_BY_CATEGORY: 0x02OPC_FILTER_BY_SEVERITY: 0x04OPC_FILTER_BY_SOURCE: 0x16
Using the OPC Server
427SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Method Meaning
QueryEventCategories Returns the event categories provided by theevent server.
The OPC event server for SIMATIC NET re-turns event categories only when the parame-ter dwEventType as the value OPC_SIM-PLE_EVENT or OPC_CONDITION_EVENT.
QueryConditionNames Returns the conditions provided by the eventserver for a specific event category.
QuerySubConditionNames Returns the subconditions provided by theevent server for a specific event category.
QuerySourceConditions Returns the conditions provided by the OPCEvent Server for a specific source.
QueryEventAttributes Returns the attributes provided by the eventserver for a specific event category.
The OPC Event Server for SIMATIC NET pro-vides special attributes. The attributes cannotbe used as ItemIDs with Data Access.
TranslateToItemIDs Gets the OPCItems corresponding to anevent attribute to use with an associated OPCData Access Server.
The OPC Event Server for SIMATIC NETdoes not support TranslateToItemIDs.
GetConditionState Returns information about the state of a con-dition of a source.
EnableConditionByArea Activates all conditions for all sources withinthe specified area.
EnableConditionBySource Activates all conditions for all specified sour-ces.
DisableConditionByArea Deactivates all conditions for all sources wit-hin the specified area.
OPC Event Server for SIMATIC NET doesnot support conditions. E_NOTIMPL is retur-ned.
Using the OPC Server
428SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
DisableConditionBySource Deactivates all conditions for all specifiedsources.
AckCondition Transfers an event acknowledgment to theclient. Only conditional events can be ack-nowledged
CreateAreaBrowser Creates an OPCEventAreaBrowser object tobrowse the process space
OPC Event Server for SIMATIC NET doesnot support areas. E_NOTIMPL is returned.
IConnectionPointContainer Interface
The IConnectionPointContainer interface is a standard COM interface for reportingasynchronous events over connection points. For more detailed information on theuse of connection points, refer to the literature on COM.
6.3.7 OPCEventSubscription Object
An object of the OPC Event Subscription class sends event messages to the clientthat uses the IConnectionPointContainer interface of this object.
A client can use several OPCEventSubscription objects. It can define differentfilters for the various objects.
An OPCEventSubscription corresponds to a ticket for defined events.
Interfaces of OPCEventSubscription
The graphic below shows the interfaces of OPCEventSubscription.
Figure 6-20 OPCEventSubscription Object
Using the OPC Server
429SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
IOPCEventSubscriptionMgt Interface
The IOPCEventSubscriptionMgt interface is the central interface for managing theinformation on a specific event subscription. Over the interface, for example, theevents relevant to the client can be selected.
Below, you will find a list of the methods for the IOPCEventSubscriptionMgtinterface. Only the features specific to SIMATIC NET are described. You will find adescription of the methods in the following OPC Specification:
Alarms & Events Custom Interface StandardVersion 1.10October 2, 2002
Method Meaning
SetFilter Sets the filter for selecting certain events for thisevent subscription. The filter parameters havethe following significance for the OPC EventServer for SIMATIC NET:
Event TypeThe OPC event server supports the event typesOPC_SIMPLE_EVENT andOPC_CONDITION_EVENT.
Event CategoriesThe event categories are described in the sectionProperties of the OPC Event Server of SIMATICNET.
SeverityThe severity can be configured in STEP 7 orSIMATIC NCM PC/S7. The default value, forexample forS7_PROCESS_ALARM is 500.
AreasOPC Event Server for SIMATIC NET does notsupport areas.
SourceYou can enter a connection name.
GetFilter Returns the currently used filters of the eventsubscription.
See SetFilter.
SelectReturnedAttribu-tes
Specifies the attributes returned with an eventmessage for an event category
Using the OPC Server
430SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
GetReturnedAttributes Returns the list of attributes returned with anevent message for an event category.
Refresh Sends all active and all inactive, unacknowled-ged condition messages that match the currentfilter setting to the client.
CancelRefresh Cancels execution of a current refresh.
Since no event message is are sent with Re-fresh, CancelRefresh has no effect.
GetState Returns the current state of the event subscrip-tion.
SetState Sets various properties of an event subscription.
IConnectionPointContainer Interface
The IConnectionPointContainer interface is a standard COM interface for reportingasynchronous events over connection points. For more detailed information on theuse of connection points, refer to the literature on COM.
6.3.8 OPCEventAreaBrowser Object
The OPC Event Server does not support areas and as a result theOPCEventAreaBrowser object cannot be used.
6.3.9 Interfaces of the Client for Alarms and Events
Informing the Client of Events
The client is informed of events over connection points. To allow this, the clientmust provide a COM object with the IUnknown interface and the call-specificIOPCEventSink interface to receive the calls. When it registers at a connectionpoint, the client passes a pointer to the IUnknown interface to the server.
Using the OPC Server
431SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Interfaces of the Client Object
The object that the client provides to receive messages must have the structureshown below:
Figure 6-21 Interfaces of the Client
6.3.10 IOPCEventSink Interface
The IOPCEventSink interface is the central interface of the client for receivingmessages. It contains one method that is called by the server to transfer events.
Below, you will find a list of the methods for the IOPCEventSink interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Alarms & Events Custom Interface StandardVersion 1.10October 2, 2002
Using the OPC Server
432SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Method Meaning
OnEvent Transfers one or more event messages to theclient.The *pEvents structure contains one or moreevents. The OPC Event Server enters specificvalues in the following structure elements:
SzSourceconnection information.The connection information cannot be convertedto an ItemID using TranslateToItemID and thenbe used by Data Access.
ftTimeTime at which the event happened on the partnerdevice. The time at which the message is recei-ved on the OPC Event Server is entered in theEVENT_ATTR_S7_PCTIME attribute.
szMessageALARM message number
dwEventTypeOPC_SIMPLE_EVENT
dwEventCategoryS7_PROCESS_ALARM
pEventAttributesThis structure contains the attributes deliveredwith the event. The attributes also include theassociated values of the message supplied bythe partner device.
All other structure elements are irrelevant.
Using the OPC Server
433SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.3.11 IOPCShutdown Interface
Over this connection point-based call interface, the server can inform the clientsbefore it is shut down or before it shuts itself down. This allows the clients to reactand, if required, to shut down.
Below, you will find a list of the methods for the IOPCShutdown interface. Only thefeatures specific to SIMATIC NET are described. You will find a description of themethods in the following OPC Specification:
Alarms & Events Custom Interface StandardVersion 1.10October 2, 2002
Method Meaning
ShutdownRequest The server notifies its clients that it is shuttingdown
You can set the text for the reason for theshutdown (szReason) in the configurationprogram for the OPC server.
6.3.12 Error Messages for OPC DA Process Variables
Error Codes not Dependent on the Protocol
Error Code Meaning
OPC_E_INVALIDHANDLE(0xC0040001L)
The value of the handle is invalid.
IDS_DUPLICATE(0xC0040002L)
The same value was transferred se-veral times.
IDS_UNKNOWNLCID(0xC0040003L)
The specified ”locale ID” is not sup-ported by server.
OPC_E_BADTYPE(0xC0040004L)
Conversion between the canonical-Datatype and the requestedDatatypeis not supported by the server.
OPC_E_PUBLIC(0xC0040005L)
The required operation cannot beexecuted for a ”public group”.
Using the OPC Server
434SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Error Code Meaning
OPC_E_BADRIGHTS(0xC0040006L)
The required operation (read or wri-te) is prevented by the access rightsof the item.
OPC_E_UNKNOWNITEMID(0xC0040007L)
The name (item definition) does notexist in the name space of the ser-ver.
OPC_E_INVALIDITEMID(0xC0040008L)
The name (item definition) has anillegal syntax.
OPC_E_INVALIDFILTER(0xC0040009L)
The character sequence of the filteris not permitted.
OPC_E_UNKNOWNPATH(0xC004000AL)
The connection name specified asthe AccessPath is not permitted.
OPC_E_RANGE(0xC004000BL)
The value is outside the permittedrange of values.
OPC_S_UNSUPPORTEDRATE(0x0004000DL)
The required update rate is not sup-ported by the server. The nearestpermitted value is used.
OPC_S_CLAMP(0x0004000EL)
The value transferred in the writewas accepted but it was truncatedwhen output.
OPC_S_INUSE(0x0004000FL)
The operation cannot be executedfully because there are still referen-ces to the object.
OPC_E_NOTFOUND(0xC0040011L)
The GetErrorString method returns astring in the form dwError=%lx, whe-re %lx is a hexadecimal error identi-fying unknown to the SIMATIC OPCserver.
0xC0048003L A timeout occurred, for example dueto an interrupted connection.
0xC0048004L A service used internally has closed.
0xC0048005L The required operation (read or wri-te) is prevented by the access rightsof the item.
0xC0048006L An unexpected error has occurred incommunication.
Using the OPC Server
435SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Error Code Meaning
0xC0048007L The value is above the permittedrange of values.
0xC0048008L The value is below the permittedrange of values.
0xC0048009L An error occurred during conversion.
Error Codes for the DP Protocol
Error Code Meaning
0x85270101L The DP master is not operational.
0x85270102L The DP slave is not operational.
Error Codes for the S7 Protocol
Error Code Meaning
0x85270201L Buffer send/receive services: Ther_id is invalid.
0x85270202L Domain services: The access rightsare not valid.
0x85270203L Domain services: A block error hasoccurred.
0x85270204L Domain services: A file error has oc-curred.
Error Codes for the PROFInet Protocol
Error Code Meaning
0x85270604L The value was only buffered.
0x85270607L Unknown object.
0x85270608L Unknown property.
0x85270609L The returned type does not matchthe expected type.
Using the OPC Server
436SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Error Code Meaning
0x85270612L The QoS value (Quality of Service)is not supported.
0x85270613L The system is currently saving, achange to the configuration is notcurrently possible.
0x85270615L The action cannot currently be ap-plied.
0x85270616L Access denied.
0x85270617L A hardware defect was detected.
Windows Error Codes
Error Code Meaning
0x80070005 Access denied.
0x80070057 Bad parameter.
Using the OPC Server
437SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.4 Programming the DX Interface
6.4.1 Structure of the DX Database
Items of the DX Database in the Name Space
The following section describes the structure of the DX database and provides anoverview of the tasks for which its items can be used.
The following graphic shows the arrangement of the individual items of the DXdatabase in the address space. The items for a DX connection and for a sourceserver are shown in separate graphics.
Using the OPC Server
438SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The OPC DX server of SIMATIC NET is based on the DCOM interface and theOPC DA Specification 2.05.
For detailed information on the topic of OPC-DX, referred to the OPC DataeXchange Specification, Version 1.0, Release March 5, 2003 of the OPCFoundation.
DX
The DX item represents the DX database and is arranged directly below the rootnode of the DA address space.
ServerStatus
The items in the ServerStatus branch provide basic information on the DX server,for example whether the server is running. The DX server updates these items thatcan only be read by a client.
DXConnectionsRoot
This item contains the definitions of the DX connections. DX clients can structurethe DX connections by creating branches below DXConnectionsRoot.
<DXConnectionName>
For each DX connection, there is a separate branch below theDXConnectionsRoot item. The name of a DX connection is unique within thebranch containing it.
A DX connection has attributes with which clients can specify the way in whichdata is transferred. There are two ways in which a client can access theseattributes:
� Direct access over the DA interface. In this case, most attributes can only beread.
� Using DX configuration methods. These methods for adding, changing, anddeleting DX connections also allow write access to the attributes of a DXconnection.
One exception is the Status item of a DX connection. This item can be read orwritten with the methods of the DA interface. The client can read or write the itemand its corresponding attributes with one single access. If there is write accessover the DA interface, the read-only attributes are ignored. In the same way, whenthere is read access, the write-only items are not accessible.
As an alternative, access to individual attributes using their names is possible.Remember that the attributes of “Status” with the exception ofSourceItemConnected, TargetItemConnected, Overridden and OverrideValue areread-only.
Using the OPC Server
439SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The Status item must not be confused with the item of the same name locateddirectly in the every branch below DXConnectionRoot and that affects every DXconnection within the branch.
The following graphic is an overview of the elements of a DX connection:
DA clients can register with these items to obtain notification when the value of anattribute changes.
Using the OPC Server
440SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Status
The DX server adds this item to every branch that it creates. The components ofthis item affect all DX connections located in the same branch as thecorresponding Status item. If, for example, a client writes a value forSourceItemConnected, the server writes this value to all SourceItemConnectionitems of DX connections located in a lower- level branch.
SourceServers
This branch contains all the source servers defined by the client.
<SourceServerName>
A source server is added, changed, and deleted by the client. The methods of theDX configuration services are available for these tasks. The name of a sourceserver is unique within the SourceServers branch.
The attributes of the item provide information about the operating state of thesource server, for example, the time at which the connection was last establishedto the source server. The following graphic shows the attributes of an item for asource server:
All attributes are available as DA items. Apart from the SourceServerConnecteditem, these items are read-only. DA clients can register with these items to obtainnotification when the value of an attribute changes.
To access an item a DX client must use the DX configuration methods. A DA clientcan also access over the name space.
Using the OPC Server
441SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.4.2 DX Configuration Services
Introduction
To configure the DX database described in the previous section, there are specialmethods known as the DX configuration services. These methods are definedindependently of any specific implementation, however, in the DX specification,implementations for Web services and DCOM are described. The OPC DX serverof SIMATIC NET is based on OPC Data Access Version 2.05 and provides aDCOM interface for OPC-DX.
How the DX Server Processes Requests
The DX server processes requests one after the other as they are received. Whennecessary, the DX server updates its DX database and the runtime attributes andsends a reply. The changes are visible to the clients immediately; in other words,the DX server does not wait until the changes become effective.
Due to this runtime response, clients can make changes to the DX databaseregardless of whether the corresponding source servers are available.
Necessity of DX Configuration Services
A complete configuration is possible only with the methods of the DX interface.Only the use of DX configuration services ensures that requests can be process asdescribed here. Access to the items of the DX database over the DA interface forthe purpose of configuration is possible that is restricted.
Source Server Services
There are five methods that relate to source servers:
� GetServersThis obtains information on all source servers in the DX database.
� AddServersA client uses this method to add one or more source servers to the DXdatabase.
� ModifyServersThis modifies one or more source servers. This may be necessary when thelocation of a source server in the network changes.
� DeleteServersThis deletes one or more source servers from the DX database. The ID of theserver to be deleted must be specified as a parameter. If no item identifier isspecified, all servers are deleted from the DX database.
Using the OPC Server
442SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
� CopyDefaultServerAttributesThis method copies the value of the DefaultSourceServerConnected item to theSourceServerConnected attribute of the Status item and vice versa. In onecase, the attribute of the Status item is overwritten with the default value, and inthe other case, a new default value is specified. The graphic below illustratesthe relationships:
DXConnection Services
� QueryDXConnectionsThis method returns all DX connections that satisfy certain conditions. Theselection criteria are transferred as an input parameter of the method. A DXconnection must have all the properties named in the input parameter so that itcan be selected by QueryDXConnections.
� AddDXConnectionsThis adds one or more DX connections to the DX database.
� UpdateDXConnectionsThis method updates the configuration attributes of one or more DXconnections. The input parameters of this method specify the DX connectionsaffected by the update.
� ModifyDXConnectionsThis modifies one or more DX connections. In the input parameter, the clientonly needs to specify the attributes it wants to modify.
� DeleteDXConnectionsUsing this method, a client deletes one or more DX connections within aspecific branch of the DX database. The client specifies which DX connectionsare to be deleted by specifying certain properties. Only the connections thathave these properties are deleted. If the client specifies only the branch in the DX database and no otherproperties, all the DX connections in this branch will be deleted.
Using the OPC Server
443SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
� CopyDefaultConnectionAttributesSimilar to the CopyDefaultServerAttributes method, this method copies valuesbetween the configuration attributes and the attributes of the Status item. Thismethod affects the following attributes:
- DefaultSourceItem Connected and SourceItem Connected
- DefaultTargetItem Connected and TargetItem Connected
- DefaultOverridden and Overridden
- DefaultOverrideValue and OverrideValue
ResetConfiguration
This method deletes all DX connections and source servers from the DX database.With the exception of the ConfigurationVersion attribute that is updated, thismethod returns the DX server to its original state.
The ConfigurationVersion attribute can be passed to this method as an optionalparameter. If this parameter exists, the elements of the DX database are deletedonly if the version information of the database matches the value of the parameter.
Using the OPC Server
444SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5 Programming the XML Interface
Note
The OPC XML interface is available in the SIMATIC NET Software from Version6.1 onwards.
Introduction
This section describes the methods of the XML DA interface. It introduces the tagstructure of the methods graphically and describes the individual elements andattributes.
First the syntax of the method description is shown. This is followed bydescriptions of the basic schemas. These are elements that occur more than oncein the schema definition of OPC XML-DA. Following this, we will then look at theindividual methods.
XML Schema Definition of the Data Types
In keeping with the XMLSchema2001 definition, the schema section of the WSDLof OPC XML-DA describes the complex data types that are used as theparameters of the individual methods. A precise description can be found in theOPC XML-DA Specification.
In the code of the Web service, a C# class is created for every complex data typefrom the XML schema. The methods of the Web service are described in aninterface.
6.5.1 Description of the Elements
Conventions Used in the Element Descriptions
The descriptions of the OPC-XML elements are preceded by a representation ofthe tag structure. Elements are indicated by bold text, attributes by italics. Thenesting of the tags is reflected by the depth to which they are indented. Theattributes of a tag are also indented beyond the corresponding tag.
Using the OPC Server
445SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Example
The tag structure might be as follows:
<tag1> <tag2 att1=”yes” att2=”no”>content of tag2 </tag2> <tag3>content of tag3 </tag3></tag1>
In the description of <tag1>, you would then find the structure represented asshown below:tag1
tag2
att1
att2
tag3
The elements tag2 and tag3 are indented further than the tag1 element becausethey are subelements of tag1. Immediately following tag2, you can also see theattributes att1 and att2 of this element in dark blue characters.
6.5.2 Basic Schemas
Schema Definition for OPC XML-DA
There is a schema definition for all elements of OPC-XML-DA. In thesedescriptions, we often refer to the definition of basic, commonly used elements.The section below describes some of these elements:
ItemProperty
An element used to define properties of an item.
ItemValue
An element with which the value of an item and any relevant additional information(for example, a timestamp) is specified.
OPCError
Contains the error code and description of an OPC error.
ReplyBase
An element with basic information on a server response (for example, time at whichthe response was sent).
Using the OPC Server
446SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
RequestOptions
Contains information specifying a client request in greater detail.
6.5.3 ItemProperty
Tag StructureItemProperty
Name
Description
ItemPath
ItemName
ResultID
Value
Elements and Attributes
Name
Contains the name of the property
Description
The description of the property.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
ResultID
If an error or non-critical exception occurs, this attribute contains the name ofthe OPC error.
Value
The current value of the property.
Using the OPC Server
447SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.5.4 ItemValue
Tag StructureItemValue
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Elements and Attributes
ValueTypeQualifier
This attribute is used only with values of the type time, date, and duration tospecify the data type. With all other data types, this attribute either does notexist or is ignored if it does exist.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
ClientItemHandle
A character string specified by the client in the request that the server returns inits reply. It is used by the client in more complex systems to identify and assignthe replies to the correct requests.
Timestamp
The time at which the values were last obtained from the server.
Using the OPC Server
448SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
ResultID
If an error or non-critical exception occurs, this attribute contains the name ofthe OPC error.
Diagnostic Info
Detailed server-specific diagnostic information.
Value
The value of the item. Since this attribute involves polymorphous information,the additional attribute xsi:type is necessary (for example, :xsi:type=”xsd:float”).
Quality
Information about the quality of the data. If the server does not return thisattribute, the quality is “Good”. If the quality is “Bad” or “Uncertain”, the attributeis returned.
QualityField
If the quality has the value “Good”, this attribute is not returned. If the quality is“Bad”, and a previous value for the item is known, this attribute has the value“badLastKnownValue”.
LimitField
contains a name with which the OPC limit bit field can be addressed. Thisattribute is always transferred except when the limit status is “none”.
VendorField
A numeric value that corresponds to the OPC vendor bit field. Whether or notthis attribute is transferred depends on the vendor.
6.5.5 OPCError
Tag StructureOPCError
ID
Text
Elements and Attributes
ID
Contains the name of the OPC error.
Using the OPC Server
449SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Text
A description of the error in text form. The content of the string depends of the“LocaleID” attribute.
6.5.6 ReplyBase
Tag StructureReplyBase
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
Elements and Attributes
RcvTime
Indicates the time at which the server received the request. RcvTime is amandatory attribute.
ReplyTime
Indicates the time at which the server sent the reply; a mandatory attribute.
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the response.
RevisedLocaleID
If the client specifies a value for the “LocaleID” attribute that is supported by theserver, the server returns the default value for the “LocaleID” attribute with the“RevisedLocaleID” attribute.
ServerState
Specifies the status of the server and is always returned; a mandatory attribute.
Using the OPC Server
450SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.7 RequestOptions
Tag StructureRequestOptions
ReturnErrorText
ReturnDiagnosticInfo
ReturnItemTime
ReturnItemName
ReturnItemPath
RequestDeadline
ClientRequestHandle
LocaleID
Elements and Attributes
ReturnErrorText
The default for this attribute is “TRUE”. In this case, the server returns detailederror descriptions.
ReturnDiagnosticInfo
The server returns detailed diagnostic information if the value of this attribute is“TRUE”.
ReturnItemTime
Specifies whether or not a timestamp is returned for each item. The default is“FALSE”, no value is returned.
ReturnItemName
Specifies whether or not the “ItemName” attribute is returned for each item. Thedefault is “FALSE”, no value is returned.
ReturnItemPath
Specifies whether or not the “ItemPath” attribute is returned for each item. Thedefault is “FALSE”, no value is returned.
RequestDeadline
Specifies the latest time that the client will wait for a response from the server.Data for items that are not available at this time is returned as an error. If thespecified time is earlier than the current time on the server, the entire requestfails. The clients must supply the time information as UTC time.
Using the OPC Server
451SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the response. In large and complex systems, this information helps theclient to relate the responses to the requests. Specifying this attribute isoptional.
LocaleID
An optional attribute with which the client specifies the language for certainreturned data.
6.5.8 Read
Tag StructureRead
Options
ReturnErrorText
ReturnDiagnosticInfo
ReturnItemTime
ReturnItemName
ReturnItemPath
RequestDeadline
ClientRequestHandle
LocaleID
ItemList
ItemPath
ReqType
MaxAge
Items
ItemPath
ReqType
ItemName
ClientItemHandle
MaxAge
Elements and Attributes
Read
The <Read> element contains all the information for a read job.
Using the OPC Server
452SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Options
The <Options> element contains options that are available for the XML-DArequests. This element is of the type RequestOptions. You will find informationon the attributes of this element in the relevant section of this documentation.
ItemList
The container element for the individual items. A request can contain severalitems.
The ItemPath, ReqType and MaxAge attributes can be used for the ItemList andItems elements. An attribute for an item overwrites the attribute of the same namefor ItemList.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
MaxAge
A period of time of the type xsd:int that specifies the maximum age of the data.The data should not be older than the duration specified here.
ReqType
Specifies the data type for the value of the item requested by the client. All datatypes listed in the specification are supported.
Items
Element with which a single item is specified.
ItemName
The name of the item.
ClientItemHandle
A string assigned by the client. If this attribute is specified by the client, theserver must return it.
Using the OPC Server
453SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Example
<soap:Body> <Read xmlns=”http://opcfoundation.org/webservices/XMLDA/1.0/”> <Options ReturnErrorText=”false” ReturnItemTime=”true” ReturnItemName=”true” LocaleID=”en” /> <ItemList> <Items ItemName=”Simple Types/UInt” /> <Items ItemName=”Simple Types/Int” /> <Items ItemName=”Simple Types/Float” /> </ItemList> </Read></soap:Body>
C# Interface for the Synchronous Read Web Method
When using C# user programs, the following method is available for readingvalues. Only some of the parameters listed above need to be specified:
ReplyBase Read(RequestOptions Options, ReadRequestItemList ItemList, out ReplyItemList ItemValues, out OPCError[] Error);
Using the OPC Server
454SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.9 ReadResponse
Tag StructureReadResponse
ReadResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
RItemList
Reserved
Items
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Errors
ID
Text
Elements and Attributes
ReadResponse
Using the <ReadResponse> element, the server returns the results of a readjob.
ReadResults
The <ReadResults> element contains basic information on the response of theserver.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
Using the OPC Server
455SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
RItemList
RItemList is the contain an element for the individual items of a reply. Aresponse can contain several items.
Reserved
This attribute prevents WSDL based programs from representing the return listas an array of items for code generation.
Items
Element with which a single item is specified.
This element is of the type ItemValue. You will find information on the attributesof this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this response.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
Example
<soap:Body> <ReadResponse xmlns=”http://opcfoundation.org/webservices/XMLDA/1.0/”> <ReadResult RcvTime=”2003-05-27T00:15:36.6400000-07:00” ReplyTime=”2003-05-27T00:15:36.7500000-07:00” ServerState=”running” /> <RItemList> <Items ItemName=”Simple Types/UInt” Timestamp=”2003-05-27T00:15:36.7343750-07:00”> <Value xsi:type=”xsd:unsignedInt”>4294967295</Value> </Items> <Items ItemName=”Simple Types/Int” Timestamp=”2003-05-27T00:15:36.7343750-07:00”> <Value xsi:type=”xsd:int”>2147483647</Value> </Items> <Items ItemName=”Simple Types/Float” Timestamp=”2003-05-27T00:15:36.7343750-07:00”> <Value xsi:type=”xsd:float”>3.402823E+38</Value> </Items> </RItemList> </ReadResponse></soap:Body>
Using the OPC Server
456SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.10 Write
Tag StructureWrite
ReturnValuesOnReply
Options
ReturnErrorText
ReturnDiagnosticInfo
ReturnItemTime
ReturnItemName
ReturnItemPath
RequestDeadline
ClientRequestHandle
LocaleID
ItemList
ItemPath
Items
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Elements and Attributes
Write
The <Write> element contains all the information for a write job. The write jobcan be performed for one or more items. As an option, values for the attributes“LimitBits” and “VendorBits” can also be written.
ReturnValuesOnReply
With this attribute, the client can specify whether a value should be returned foreach item. The value processed by the server for this write job is returned. It isthe same value that the server would return if there was a read job immediatelyafter the write job.
Using the OPC Server
457SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
If the write job fails, no values are returned. With write-only values, the serverreturns E_WRITEONLY.
Options
The <Options> element contains options that are available for the XML-DArequests. This element is of the type RequestOptions. You will find informationon the attributes of this element in the relevant section of this documentation.
ItemList
The container element for the individual items. A request can contain severalitems.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
Items
Element with which a single item is specified.
This element is of the type ItemValue. You will find information on the attributesof this element in the relevant section of this documentation.
Example
<soap:Body> <Write xmlns=”http://opcfoundation.org/webservices/XMLDA/1.0/”> <Options ReturnErrorText=”false” ReturnItemName=”true” LocaleID=”en” /> <ItemList> <Items ItemName=”Simple Types/UInt”> <Value xsi:type=”xsd:unsignedInt”>4294967295</Value> </Items> <Items ItemName=”Simple Types/Int”> <Value xsi:type=”xsd:int”>2147483647</Value> </Items> <Items ItemName=”Simple Types/Float”> <Value xsi:type=”xsd:float”>3.402823E+38</Value> </Items> </ItemList> </Write></soap:Body>
Using the OPC Server
458SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
C# Interface for the Synchronous Write Web Method
When using C# user programs, the following method is available for writing values. Onlysome of the parameters listed above need to be specified:
ReplyBase Write(RequestOptions Options, WriteRequestItemList ItemList, bool ReturnItemVal, out ReplyItemList ItemValues, out OPCError[] Error);
6.5.11 WriteResponse
Tag StructureWriteResponse
WriteResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
RItemList
Reserved
Items
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Errors
ID
Text
Using the OPC Server
459SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Elements and Attributes
WriteResponse
Using the <WriteResponse> element, the server returns the results of a writejob.
WriteResult
The <WriteResult> element contains basic information on the response of theserver.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
RItemList
The container element for the individual items. A response can contain severalitems.
Reserved
This attribute prevents WSDL based programs from representing the return listas an array of items for code generation.
Items
Element with which a single item is specified.
This element is of the type ItemValue. You will find information on the attributesof this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this response.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
Example
<soap:Body> <WriteResponse xmlns=”http://opcfoundation.org/webservices/XMLDA/1.0/”> <WriteResult RcvTime=”2003-05-27T05:19:26.3687500-07:00” ReplyTime=”2003-05-27T05:19:26.4687500-07:00” ServerState=”running” /> <RItemList> <Items ItemName=”Simple Types/UInt” /> <Items ItemName=”Simple Types/Int” /> <Items ItemName=”Simple Types/Float” /> </RItemList>
Using the OPC Server
460SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
</WriteResponse></soap:Body>
6.5.12 Using Subscriptions
Contact Supported over Several Method Calls
In contrast to most other Web services, the OPC XML-DA Web services support loosecontact with a subscribed Web client over several method calls. This “loose” contact isknown as a polled subscription below. The values of items can be read cyclically with apolled subscription.
Client Logon and Logoff
The client logs on the subscription with the OPC XML-DA Web service. This then noteswhich items are of interest to the client and queries their values. When a polled requestarrives from the client, the current values are returned. The subscription is terminatedby the client.
Identification Using Handles
To identify the subscription, a handle assigned by the server is transferred as a parameterwith each future call. Is also possible to specify a list of handles so that severalsubscriptions are relevant per SubscriptionPolledRefresh. This increases the efficiencyof polling.
The address of the subscription object is returned to the client as the subscription handleso that the subscription can be identified uniquely at the next SubscriptionPolledRefreshand SubscriptionCancel.
The following the graphic illustrates the use of a subscription:
Using the OPC Server
461SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Period of Validity of the Monitored Items
The SubscriptionPolledResponse method returns the values that were requested withthe SubscriptionPolledRefresh method back to the client. SubscriptionCancel discardsthe subscriptions and their items. If no further SubscriptionPolledRefresh requests arrivefrom the client within a specified period (SubscriptionPingRate), the OPC DA Web serviceterminates the subscription automatically in the same way as with the SubscriptionCancelmethod.
Using the OPC Server
462SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.13 Subscribe
Tag StructureSubscribe
ReturnValuesOnReply
SubscriptionPingRate
Options
ReturnErrorText
ReturnDiagnosticInfo
ReturnItemTime
ReturnItemName
ReturnItemPath
RequestDeadline
ClientRequestHandle
LocaleID
ItemList
ItemPath
ReqType
Deadband
RequestedSamplingRate
EnableBuffering
Items
ItemPath
ReqType
ItemName
ClientItemHandle
Deadband
RequestedSamplingRate
EnableBuffering
Elements and Attributes
Subscribe
The <Subscribe> element contains all the information on a subscribe job.
ReturnValuesOnReply
If the value of this attribute is set to TRUE, the server returns values availablefor a SubscribeResponse. If the value is FALSE, the server returns no valueswith a SubscribeResponse.
Using the OPC Server
463SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SubscriptionPingRate
The value of this attribute specifies the interval at which the server checks theexistence of the client. If the client has not communicated with the server duringthe specified period, the server can release all resources that were required forthe client’s subscription.
Options
The <Options> element contains options that are available for the XML-DArequests. This element is of the type RequestOptions. You will find informationon the attributes of this element in the relevant section of this documentation.
Item List
The container element for the individual items. A request can contain severalitems.
The ItemPath, ReqTyp, Deadband, RequestedSamplingRate, and EnableBufferingattributes can be used for the ItemList and Items elements. An attribute for an itemoverwrites the attribute of the same name for ItemList.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ReqType
Specifies the data type for the value of the item requested by the client.
Deadband
This specifies a threshold value up to which value changes of an item do nottrigger a SubscriptionPolledRefresh. This is specified as a percentage of themaximum value range of the item. The value for this parameter shouldtherefore be between 0 and 100 percent and can only be used with items of thetype integer and float.
RequestedSamplingRate
Time specified by the client in milliseconds after which the server checks thevalues for changes.
EnableBuffering
If the value of this attribute is set to TRUE, the server saves all value changesin a buffer according to the RequestedSamplingRate parameter. The serverreturns the saved data to the client at the next PolledRequest.
Using the OPC Server
464SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Item Name
The name of the item.
ClientItemHandle
A string assigned by the client. If this attribute is specified by the client, theserver must return it.
6.5.14 SubscribeResponse
Tag StructureSubscribeResponse
ServerSubHandle
SubscribeResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
RItemList
RevisedSamplingRate
Items
RevisedSamplingRate
ItemValue
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Errors
ID
Text
Using the OPC Server
465SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Elements and Attributes
SubscribeResponse
The <SubscribeResponse> element contains all the information on aSubscribeResponse.
ServerSubHandle
The value specified by the server for this value must be used withSubscriptionPolledRefresh requests and SubscriptionCancel requests. Thisattribute identifies the client that sends the request.
SubscribeResult
The <SubscribeResult> element contains basic information on the response ofthe server.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
RItemList
Contains item elements. The available values for the items are only sent to theclient when the client has requested them with a corresponding value for theReturnValuesOnReply attribute (see Subscribe).
RevisedSamplingRate
The fastest update cycle supported by the server. This value is returned by theserver to the client.
Items
Element with which a single item is specified.
This element is of the type ItemValue. You will find information on the attributesof this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this response.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
Using the OPC Server
466SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.15 SubscriptionPolledRefresh
Tag StructureSubscriptionPolledRefresh
HoldTime
WaitTime
ReturnAllItems
Options
ReturnErrorText
ReturnDiagnosticInfo
ReturnItemTime
ReturnItemName
ReturnItemPath
RequestDeadline
ClientItemHandle
LocaleID
ServerSubHandles
Elements and Attributes
SubscriptionPolledRefresh
Using this element, the client requests the server to refresh the items that weredefined in a prior Subscription request.
HoldTime
This attribute instructs the server not to send any refreshed values to the clientuntil the internal time of the server is equal to or greater than the value of thisattribute.
WaitTime
After reaching the time specified in the HoldTime attribute, the server waits forthe time specified in WaitTime before returning the response. If the value of anitem changes during the WaitTime, a response is sent immediately.
ReturnAllItems
If the value of this attribute is set to FALSE, the server returns only items thathave changes since the previous SubscriptionPolledRefresh request and thecurrent SubscriptionPolledRefresh request.
If this attribute is set to TRUE, the server returns all items that were defined inthe corresponding Subscription request.
Using the OPC Server
467SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Options
The <Options> element contains options that are available for the XML-DArequests. This element is of the type RequestOptions. You will find informationon the attributes of this element in the relevant section of this documentation.
ServerSubHandles
This attribute is used by the server to identify the subscription to be polled.
6.5.16 SubscriptionPolledRefreshResponse
Tag StructureSubscriptionPolledRefreshResponse
DataBufferOverflow
SubscriptionPolledRefreshResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
InvalidServerSubHandles
RItemList
SubscriptionHandle
Items
ValueTypeQualifier
ItemPath
ItemName
ClientItemHandle
Timestamp
ResultID
DiagnosticInfo
Value
Quality
QualityField
LimitField
VendorField
Errors
ID
Text
Using the OPC Server
468SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Elements and Attributes
SubscriptionPolledRefreshResponse
This element contains all the information that the server sends to the client asthe response to a SubscriptionPolledRefresh request.
DataBufferOverflow
If the value of this attribute is TRUE, there have been changes in the items thatcould not be saved due to lack of resources. The individual items indicatewhether or not they are affected by the lack of resources.
SubscriptionPolledRefreshResult
This element contains basic information on the response of the server. It is ofthe ReplyBase type. You will find information on the attributes of this element inthe relevant section of this documentation.
InvalidServerSubHandles
ServerSubHandles recognized as being invalid by the server.
RItemList
The <RItemList> element contains values for all items if the client transferredthe ReturnAllItems attribute with the value TRUE with itsSubscriptionPolledRefresh request. Otherwise the server returns only valuesthat have changed.
SubscriptionHandle
Handle of the RItemList specified by the client in the subscription call.
Items
Element with which a single item is specified.
This element is of the type ItemValue. You will find information on the attributesof this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this response.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
Using the OPC Server
469SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.5.17 SubscriptionCancel
Tag StructureSubscriptionCancel
ServerSubHandle
ClientRequestHandle
Elements and Attributes
SubscriptionCancel
Using the <SubscriptionCancel> element, the client ends the subscription andthe server can release the corresponding resources.
ServerSubHandle
The value assigned to this element by the server identifies the subscription thatsends the request.
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the SubscriptionCancelResponse. In large and complex systems, thisinformation helps the client to relate the responses to the requests. Specifyingthis attribute is optional.
6.5.18 SubscriptionCancelResponse
Tag StructureSubscriptionCancelResponse
ClientRequestHandle
Elements and Attributes
SubscriptionCancelResponse
Using this element, the server confirms a SubscriptionCancel request of theclient.
ClientRequestHandle
If the client used this attribute in its request, the server returns it in its response.
Using the OPC Server
470SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.19 Browse
Tag StructureBrowse
LocaleID
ClientRequestHandle
ItemPath
ItemName
ContinuationPoint
MaxElementsReturned
BrowseFilter
ElementNameFilter
VendorFilter
ReturnAllProperties
ReturnPropertyValues
ReturnErrorText
PropertyNames
Elements and Attributes
Browse
The <Browse> element contains all the information necessary for navigatingthrough a hierarchical address space.
LocaleID
An optional attribute with which the client specifies the language for certainreturned data.
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the response. In large and complex systems, this information helps theclient to relate the responses to the requests. Specifying this attribute isoptional.
Item Path
The path to the item with which navigation through the address space starts. Ifthere is a second browse request, this attribute must have the same value as inthe previous request.
ItemName
The name of the item with which navigation through the address space starts. Ifthere is a second browse request, this attribute must have the same value as inthe previous request.
Using the OPC Server
471SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
ContinuationPoint
If this is not an initial browse request, a point can be specified here from whichthe browse request is restarted.
MaxElementsReturned
Maximum number of return values.
BrowseFilter
This attribute with the enumeration data type browseFilter (all, branch, item)specifies which subset of elements will be returned.
ElementNameFilter
A regular expression used to select elements.
VendorFilter
A vendor-specific expression used to select vendor-specific information. Theeffects on the ElementNameFilter element are not defined.
ReturnAllProperties
If the value TRUE is set for this attribute, the server returns all availableproperties for each returned element. The value of the PropertyName attributeis then ignored in this case.
ReturnPropertyValues
If the value TRUE is set for this attribute, the server returns not only the namesof the properties but also the values of the properties.
ReturnErrorText
If this attribute has the value TRUE, the server returns a detailed errordescription.
PropertyNames
Names of properties returned with each element. If the value of theReturnAllProperties attribute is set to TRUE, the server returns all propertiesregardless of PropertyName.
Using the OPC Server
472SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.20 BrowseResponse
Tag StructureBrowseResponse
ContinuationPoint
MoreElements
BrowseResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
Elements
Name
Item Path
ItemName
IsItem
HasChildren
Properties
Name
Description
ItemPath
ItemName
ResultID
Value
Errors
ID
Text
Elements and Attributes
BrowseResponse
Contains all the information of a response to a Browse request.
ContinuationPoint
Here, the server can specify a point from which a following Browse request canbe started.
MoreElements
If the server does not support the ContinuationPoint attribute and the number ofreturned values exceeds the value of MaxElementsReturned, the server setsthis attribute to TRUE.
Using the OPC Server
473SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
BrowseResult
The <BrowseResponse> element contains basic information on the response ofthe server.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
Elements
Contains information on the parsed elements of the structure tree.
Name
Name of an element in the name space displayed to the user (for example, in astructure view).
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
IsItem
If the value TRUE is set for this attribute, this element is an item that can beused in read, write, and subscribe requests.
HasChildren
If the value TRUE is set for this attribute, the corresponding element haschildren.
Properties
The <Properties> element contains information on a property that can be madeaccessible using a Browse or GetProperties call.
This element is of the type ItemProperty. You will find information on theattributes of this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this request.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
Using the OPC Server
474SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.21 GetProperties
Tag StructureGetProperties
LocaleID
ClientRequestHandle
ItemPath
ReturnAllProperties
ReturnPropertyValues
ReturnErrorText
ItemIDs
ItemPath
ItemName
PropertyNames
Elements and Attributes
GetProperties
Using the <GetProperties> element, you can query properties.
LocaleID
An optional attribute with which the client specifies the language for certainreturned data.
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the response. In large and complex systems, this information helps theclient to relate the responses to the requests. Specifying this attribute isoptional.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ReturnAllProperties
If the value TRUE is set for this attribute, the server returns all properties foreach returned element. The value of the PropertyNames element is thenignored in this case.
ReturnPropertyValues
If the value TRUE is set for this attribute, the server returns not only the namesof the properties but also the values of the properties.
Using the OPC Server
475SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
ReturnErrorText
If this attribute has the value TRUE, the server returns a detailed errordescription.
ItemIDs
Contains a list of items whose properties will be queried.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
PropertyNames
Names of properties returned with each element. If the value of theReturnAllProperties attribute is set to TRUE, the server returns all propertiesregardless of PropertyNames.
Using the OPC Server
476SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
6.5.22 GetPropertiesResponse
Tag StructureGetPropertiesResponse
GetPropertiesResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
PropertyLists
ItemPath
ItemName
ResultID
Properties
Name
Description
ItemPath
ItemName
ResultID
Value
Errors
ID
Text
Elements and Attributes
GetPropertiesResponse
The server responds to GetProperties requests with this element.
GetPropertiesResult
The <GetPropertiesResult> element contains basic information on the responseof the server.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
Using the OPC Server
477SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
PropertyLists
An element of this type containing the requested properties of the item isreturned for each item.
The Item Path, ItemName, and ResultID attributes can be used for thePropertyLists and Properties elements. If these attributes are specified in aProperties element, the values of the attributes with the same name inPropertyLists are overwritten for this element.
ItemPath
The path of an element. This attribute is not supported by SIMATIC NET.
ItemName
An element can be identified uniquely in the name space of the server with theItemName attribute.
ResultID
If an error or non-critical exception occurs, this attribute contains the name ofthe OPC error.
Properties
This element is of the type ItemProperty. You will find information on theattributes of this element in the relevant section of this documentation.
Errors
An array of errors that occurred with this response.
This element is of the type OPCError. You will find information on the attributesof this element in the relevant section of this documentation.
6.5.23 GetStatus
Tag StructureGetStatus
LocaleID
ClientRequestHandle
Using the OPC Server
478SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Elements and Attributes
GetStatus
A GetStatus request checks the Web service and obtains vendor-specificinformation that is not accessible to other OPC methods.
LocaleID
An optional attribute with which the client specifies the language for certainreturned data.
ClientRequestHandle
If this attribute was included in the client’s request, it is returned by the serverwith the response. In large and complex systems, this information helps theclient to relate the responses to the requests. Specifying this attribute isoptional.
Example
<soap:Body> <GetStatus LocaleID=”de-AT” xmlns=”http://opcfoundation.org/webservices/XMLDA/1.0/” /></soap:Body>
C# Interface for the GetStatus Web Method
When using C# user programs, the following method is available for checking the Webservice:
ServerStatus GetStatus(string LocaleID, string ClientRequestHandle, out ServerStatus);
Using the OPC Server
479SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
6.5.24 GetStatusResponse
Tag StructureGetStatusResponse
GetStatusResult
RcvTime
ReplyTime
ClientRequestHandle
RevisedLocaleID
ServerState
Status
StartTime
ProductVersion
StatusInfo
VendorInfo
SupportedLocaleIDs
SupportedInterfaceVersions
Elements and Attributes
GetStatusResponse
Contains all the information of a response to a GetStatus request
GetStatusResult
The <GetStatusResult> element contains basic information on the response ofthe server.
This element is of the type ReplyBase. You will find information on the attributesof this element in the relevant section of this documentation.
Status
The <Status> element contains information on the server status.
StartTime
Time at which the server was started in UTC format.
ProductVersion
Version number of the server made up of the major, minor, and build number.
StatusInfo
Contains additional information on the server status and may belanguage-dependent.
Using the OPC Server
480SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
VendorInfo
Vendor-specific string with additional information on the server. The value ofthis attribute should include the company name and information on thesupported devices.
SupportedLocaleIDs
The locales supported by the server. A server does not need to support alllocales for all items.
SupportedInterfaceVersions
An array of strings containing the versions of the XML-DA specificationsupported by the server.
481SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Sample Programs
This section contains sample programs that use the Custom or AutomationInterface.
After you have installed the SIMATIC NET software, you will find the samples in<installationpath>\SIEMENS\SIMATIC.NET\opc2\samples
7
Sample Programs
482SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.1 Sample Program - Programming with ActiveX Controls
This sample in Visual Basic uses the ActiveX controls SIMATIC NET OPC DataControl and Siemens S7 Number Control to read and write process data.
Before you can run this program, you must activate a simulation connection thatmakes the demonstration variables used in the program available:
Step Description
1 Start the “Configuration Console” program in the Start menu:Start -> SIMATIC -> SIMATIC NET -> Settings > ConfigurationConsole
2 In the left-hand navigation window, open the property page for thesimulation module by expanding SIMATIC NET Configuration -> Modulesand click on the “CP Simulation” icon
3 Click the check box for the protocol you want to simulate.This example uses the S7 protocol. So you should click on “S7”.
4 Close the “Configuration Console” program.
Note
Before the changes take effect, you must first close all OPC clients!
7.1.1 Running the Program
Start Sample
The OPC_VB_OCX program is on your hard disk in <installationpath>\SIEMENS\SIMATIC.NET\opc2\samples\ocx
When you start the program, only the “Start Sample” button is enabled. When youclick this button, a connection is established to the configured server and you canthen use the other buttons.
Sample Programs
483SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Read Value
After you click the “Read Value” button, the values that were read are displayed inthe relevant text boxes.
Number Control
To write or modify a value, you must enter the value in the input box of the numbercontrol which activates the buttons of the number control. The entered value isactually only written when you click the button with the green check mark.Afterwards, the buttons are disabled again until you enter the next value. To cancel a modification, click the delete button. The value you have just enteredin the input box of the number control is then replaced by the last written value.Following this, the buttons are disabled again.
Stop Sample
When you click the “Stop Sample” button, the connection to the OPC server isterminated and all the buttons except for the “Start Sample” button are disabled.
7.1.2 Description of the Program
For this sample program, it is not enough to simply describe the implementation ofthe event procedures since a large part of the work is handled by the ActiveXcontrols and depends on how they are configured. We will therefore first look atsome of the aspects relating to the configuration of selected controls and then lookat the source code in greater detail.
7.1.3 Principle of Assigning Control Properties to OPC ProcessVariables
When using the SIMATIC NET OPC Data Control, an OPC process variable canbe assigned to the properties of a control, for example the text to be displayed inan editor box.
These assignments are configured in the SIMATIC NET OPC Data Control.
Sample Programs
484SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Unseen by the user, the SIMATIC NET OPC Data Control makes all the calls tothe OPC server.
7.1.4 Configuring the SIMATIC S7 Number Control
With the number control, you can display and modify process data in numericformat.
During runtime, the value of a selected process variable is displayed in the displayarea if you have configured its display in the SIMATIC NET OPC Data Control.Here, you can enter a new value. Depending on the configuration, newly enteredvalues are modified immediately or only after clicking the button for input to theOPC server.
There are various configuration options for the number control depending onwhether you simply want to use it to display process data or also want to use it tomodify process data:
Configuring the Number Control Simply as a Display Control
To use the number control simply to display process data without any operatorinput being possible, the following settings are recommended:
Sample Programs
485SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step Description
1 Open the properties pages of the number control by right-clickingon it and selecting “S7Number Properties..” in the context-sensiti-ve menu.
2 Deactivate the “Show Buttons” check box in the “General” tab.
3 In the “Appearance” tab, activate the “Locked (ReadOnly)” checkbox.
The “S7Number_Val1” number control that functions purely as a display control inthe “On Data Changed” frame is an example of such a configuration in thisprogram.
Configuring the Number Control for Writing Values
To be able to write process data using the number control, make the followingsettings for number control:
Step Description
1 Open the properties pages of the number control by right-clickingon it and selecting “S7Number Properties..” in the context-sensiti-ve menu.
2 Deactivate the “Locked (ReadOnly)” check box in the “General”tab. As default, it is not activated.
3 With the “Show Buttons” check box In the “General” tab, you canalso decide whether or not an operator has to click to confirm wri-ting or whether the value is accepted immediately.
The number control “S7Number_Write” is an example of such a configuration.
Sample Programs
486SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.1.5 Configuration of the SIMATIC NET OPC Data Control
The SIMATIC NET OPC Data Control establishes the connection between controlsfor display and the OPC server. If you want to simplify your programming tasks byusing ActiveX Controls for OPC, you must include the SIMATIC NET OPC DataControl in your project.
To benefit from the advantages of the SIMATIC NET OPC Data Control, it mustfirst be configured. Follow the steps outlined below:
Step Description
1 Open the Properties window for SIMATIC NET OPC Data Control
2 Select OPC server
3 Connect the properties of display controls with the properties ofthe OPC process variables
Opening the Properties Window
You configure the SIMATIC NET OPC Data Control in the “Properties Pages”window :
� Right-click the Data Control. The context-sensitive menu is opened.
� Select the “Properties” menu command. The “Properties Pages” window opens.
Select OPC server
To select an OPC server with which the Data Control will communicate:
� Select the “OPC Server” tab in the “Properties Pages” window.
� Enter the name of the OPC server in the “Server” box, for example“OPC.SimaticNET”. You can also select an OPC server using the “Browse...”button.
Connecting Display Controls and Process Variables
You must connect the properties of display controls with the properties of OPCprocess variables. The basic steps involved are illustrated below based on the example of a text boxand a Siemens S7 Number Control.
First, select the “Items” tab in the “Properties Pages” window and click the “AssignItems...” button. This opens a dialog in which you make the following settings:
Sample Programs
487SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Filter Properties
To make it easier and clearer to connect the display controls to the properties ofthe process variables, it is advisable to start by selecting or filtering the propertiesof the display control that you want displaying in the user controls of the “AssignItems” dialog box.
Step Description
1 Click on the “Filter...” button. The “Property Filter” window opens.
2 Click the “Add” button and enter the “Text” property name in thewindow that then opens. Confirm with “OK”.
3 Repeat step 2 for the properties “BackColor” and “Value”.
4 Close the “Property Filter” window with “OK”.
5 If the “Filter” check box is not yet activated, select it now. In the user controls list, only the properties “Text”, ”BackColor”,and “Value” are visible for the user controls assuming that thecontrol has these properties.
Properties of the “Edit_QU_1” Text Box
You will now link the “BackColor” and “Text” properties of “Edit_QU_1” with the“Quality” property of a process variable:
Step Description
1 In the list of control elements, select the “BackColor” property ofthe “Edit_QU_1” text box by clicking the entry.
2 From the list of three possible properties of the process variables,select the “Quality” property.
3 You can now make further settings: For each value of the “Quali-ty” property, define a color that the box will adopt during runtimedepending on the quality value of the monitored process variable.
Sample Programs
488SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step Description
4 From the upper box that displays the name space of the server,select the process variable you want to link to the selected pro-perty.The ItemID of the selected variable appears in the linked variablebox.You can also enter an ItemID directly in this box.
5 Repeat steps 1 to 4 with the “Text” property of the text box butinstead of the color value in step 3, enter, for example, the values“GOOD”, ”BAD” and “UNCERTAIN”.
Connecting Properties of the SIMATIC S7 Number Control
You will now connect the “Value” property of “S7Number_Val1” with the “Value”property of a process variable:
Step Description
1 In the list of control elements, select the “Value” property of the“S7Number_Val1” user control by clicking on the entry.
2 From the list of three possible properties of the process variables,select the “Value” property.
3 From the upper box that displays the name space of the server,select the process variable you want to link to the selected pro-perty.The ItemID of the selected variable appears in the linked variablebox.You can also enter an ItemID directly in this box.
4 Follow the same procedure for the other display controls that youwant to connect to properties of process variables. Once you ha-ve made all the connections you require, close the “Assign Items”dialog with “OK”.
7.1.6 Implementing the Event Procedures
The main components of this module are the event procedures for the buttons ofthe dialog that are called by Visual Basic.
Sample Programs
489SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Command_Start_Click
The “Start Sample” button is first disabled and then all other buttons enabled:
S7Number_Write.Enabled = TrueCommand_Start.Enabled = FalseCommand_Read.Enabled = TrueCommand_Exit.Enabled = True
After this, the “Connect” method of the SIMATIC NET OPC Data Control“DatCon1” establishes a connection to the OPC server that was specified in theconfiguration of the data control:
DatCon1.Connect
Command_Read_Click
After the declaration of several local variables, the “ReadVariable” function of theSIMATIC NET OPC Data Control is called.
Its return parameters are assigned to the text properties of the relevant text boxesand are therefore visible in the dialog.
Dim myValue As VariantDim myQuality As LongDim myTimeStamp As DateDim ErrorNr As LongDim ErrorString As String
ErrorNr = DatCon1.ReadVariable(”S7:[DEMO]MW0”, myValue, myQuality, myTimeStamp)
Edit_ReadVal = myValueEdit_ReadQu = GetQualityText(myQuality)Edit_ReadTS = myTimeStamp
ReadVariable
The ReadVariable function is declared as follows:
Function ReadVariable(ItemID As String, Value, Quality AsLong, TimeStamp As Date) As Long
Parameter Description
Parameter Description
ItemID String with the ItemID of the variable on the OPC server thatwill be read.
Value Return parameter of the type variant that contains the value ofthe specified variable.
Sample Programs
490SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
Quality Return parameter of the type variant that contains the qualityof the variable. The numeric value must first be converted to astring with the GetQualityText function before it can be assi-gned to the relevant text box.
TimeStamp Return parameter of the type Date containing the OPC timestamp.
Command_Exit_Click
First, the “Start Sample” button is enabled again and all other buttons disabled:
S7Number_Write.Enabled = FalseCommand_Start.Enabled = TrueCommand_Read.Enabled = FalseCommand_Exit.Enabled = False
Finally, the connection to the OPC server is terminated with the Disconnectmethod of the SIMATIC NET OPC Data Control:
DatCon1.Disconnect
GetQualityText
GetQualityText provides a string as an error message for a specified error code:
Private Function GetQualityText(Quality) As String Select Case Quality Case 0: GetQualityText = ”BAD” Case 64: GetQualityText = ”UNCERTAIN” Case 192: GetQualityText = ”GOOD” Case 8: GetQualityText = ”NOT_CONNECTED” Case 13: GetQualityText = ”DEVICE_FAILURE” Case 16: GetQualityText = ”SENSOR_FAILURE” Case 20: GetQualityText = ”LAST_KNOWN” Case 24: GetQualityText = ”COMM_FAILURE” Case 28: GetQualityText = ”OUT_OF_SERVICE” Case 132: GetQualityText = ”LAST_USABLE” Case 144: GetQualityText = ”SENSOR_CAL” Case 148: GetQualityText = ”EGU_EXCEEDED” Case 152: GetQualityText = ”SUB_NORMAL” Case 216: GetQualityText = ”LOCAL_OVERRIDE” Case Else: GetQualityText = ”UNKNOWN ERROR” End Select End Function
Sample Programs
491SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.1.7 Notes on Writing your own Programs
Before programs you have written yourself can use the Automation Interface andthe SIMATIC Controls, certain requirements must be met. Follow the steps outlinedbelow:
Step Description
1 Start the Visual Basic development environment.
2 Create a project of the required type.
3 Go to the “Project” menu and select “Components..”. In the dialogthat opens, select the following entries from the list of availablecomponents:
x ”Siemens S7 Number Control”
x ”SIMATIC NET OPC Data”
4 Arrange the required operator interface elements in the main dia-log or create a suitable application window and program the cor-responding event procedures.
Sample Programs
492SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.2 Sample Program for the OPC Automation Interface(Synchronous Communication)
This sample involves Visual Basic and uses the Automation Interface for DataAccess V2.0 of OPC to read and write data synchronously.
The description is divided into the following sections:
7.2.1 Activating the Simulation Connection
Before you can run this program, you must activate a simulation connection thatmakes the demonstration variables used in the program available:
Step Description
1 Start the “Configuration Console” program in the Start menu: Start -> SIMATIC -> SIMATIC NET -> Settings -> Configuration Console
2 In the left-hand navigation window, open the property page for thesimulation module by expanding SIMATIC NET Configuration -> Modulesand click on the “CP Simulation” icon
3 Click the check box for the protocol you want to simulate.This example uses the S7 protocol. So you should click on “S7”.
4 Close the “Configuration Console” program.
Note
Before the changes take effect, you must first close all OPC clients!
Sample Programs
493SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.2.2 Working with the Sample Program
The program is on your hard disk in <installationpath>\SIEMENS\SIMATIC.NET\opc2\samples\automation\sync
When you start the program, only the “Start Sample” button is enabled.
After you have clicked this button, the program generates the required OPCobjects. You can then use the other buttons.
After you click the “Read Value” button, the values that were read are displayed inthe relevant text boxes.
As it stands, the sample program is designed to operate with a demonstrationconnection. If you want to run the sample program in a real environment, you mustchange the following line in the program code:
Set ItemObj = GroupObj.OPCItems.AddItem(”S7:[DEMO]MW1”, 1)
You should also refer to some of the samples and the section “OPC ProcessVariables for SIMATIC NET” for more information on the structure of the ItemIDs.
Sample Programs
494SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
To write a value, this must be entered in the relevant text box. After clicking the“Write Value” button, the program displays a message about the result of thisoperation:
The “Stop Sample” button closes the program; in other words, all OPC objects aredeleted and the corresponding resources are released again.
Sample Programs
495SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.2.3 How the Program Runs
Due to the class model of OPC, a specific order must be adhered to in the methodcalls of OPC objects. To be able to create an instance of the “OPCItem” class, anobject of the “OPCGroup” class is necessary. This is, however, only possible whenan instance of the “OPCServer” class exists and a connection to this server hasbeen established.
The basic sequence of instructions for creating and deleting OPC objects isillustrated in the following graphic. The variable names of the sample program areused.
The sample program contains all the components that would normally exist in atypical client application. These include establishing the connection to the OPCserver, creating a group with variables, and reading and writing values for an item.
Sample Programs
496SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.2.4 Description of the Program
The program code in the opcsync.frm file can be divided into the followingsections:
Global Variables
At the start of this module, several global variables are declared:
Dim WithEvents ServerObj As OPCServerDim WithEvents GroupObj As OPCGroupDim ItemObj As OPCItem
Implementing the Event Procedures
The main components of this module are the event procedures for the buttons ofthe dialog that are called by MFC.
7.2.5 Command_Start_Click
The Command_Start_Click method is called when the button labeled “StartSample” is clicked and it can be divided into the following sections:
Enabling Buttons
The “Start Sample” button is first disabled and then all other buttons enabled:
Command_Start.Enabled = FalseCommand_Read.Enabled = TrueCommand_Write.Enabled = TrueCommand_Exit.Enabled = True
Generating an Object of the OPCServer Class
A new instance of the OPCServer class is now generated:
Set ServerObj = New OPCServer
Establishing a Connection to the OPC Server of SIMATIC NET
With the Connect method of the OPCServer class, a connection is established tothe OPC server of SIMATIC NET:
ServerObj.Connect (”OPC.SimaticNET”)
Sample Programs
497SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Connect
The Connect method of the OPCServer class is declared as follows:
Sub Connect(ProgID As String, [Node])
Parameter Description
ProgID Unique OPC server name assigned by the vendor.
Node Optional parameter of the Variant type that specifies the servercomputer when using DCOM.
Adding a Group
Each object of the OPCServer class has the collection object OPCGroups. Its Addfunction adds an object of the type OPCGroup to the collection:
Set GroupObj = ServerObj.OPCGroups.Add(”MyOPCGroup”)
Add
The Add function of the OPCGroups class is declared as follows:
Function Add([Name]) As OPCGroup
Parameter Description
Name Optional parameter as variant that specifies the name of thenew group.
Adding Items
Each object of the OPCGroup class in turn has the collection object OPCItems asa member. Its AddItem function creates a new object of the class OPCItem andadds it to the collection:
Set ItemObj = GroupObj.OPCItems.AddItem(”S7:[DEMO]MW1”, 1)
AddItem
The AddItem function of the OPCItems class returns an object of the OPCItemtype and is declared as follows:
Function AddItem(ItemID As String, ClientHandle As Long) AsOPCItem
Sample Programs
498SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
ItemID Please refer to some of the samples and the manual for moreinformation on the structure of the ItemID.
Client-Handle
Handle assigned by the client for an item
7.2.6 Command_Read_Click
The Command_Read_Click event routine executes a synchronous read job. Thefollowing operations are executed:
Variable Declarations
At the start of the procedure, several local variables are declared that are passedas parameters for the subsequent method call.
Dim myValue As VariantDim myQuality As VariantDim myTimeStamp As Variant
Read Synchronously
To read values synchronously, the Read method of the OPCItem class is called:
ItemObj.Read OPCDevice, myValue, myQuality, myTimeStamp
Read
The Read method of the OPCItem class is declared as follows:
Sub Read(Source As Integer, [Value], [Quality], [TimeStamp])
Parameter Description
Source ”OPCDevice” is a defined constant and member of the OPC-DataSource structure.
Value Optional return parameter that contains the value of the varia-ble after a successful read job.
Quality Optional return parameter that contains information on the in-tegrity of the data after successful execution of the read.
TimeStamp Optional return parameter. Indicates when the value of theitem last changed.
Sample Programs
499SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Display Values
The values of the local variables of the assigned to the Text property of therelevant control and therefore made visible in the dialog:
Edit_ReadVal = myValueEdit_ReadQu = GetQualityText(myQuality)Edit_ReadTS = myTimeStamp
7.2.7 Command_Write_Click
The Command_Write_Click event routine executes a synchronous write job. It isstructured as follows:
Declaration and Initialization of Local Variables
After the declaration of several local variables, the value of the ServerHandleproperty of the OPCItem object “ItemObj” is written to the only element of theServerhandles long array. The server handle is a handle assigned by the server forthe item that the client transfers to the server so that the server can access therelevant variables in its structures.
Dim Serverhandles(1) As LongDim MyValues(1) As VariantDim MyErrors() As
LongServerhandles(1) = ItemObj.ServerHandle
The value of the Text property of the text box for user input is then assigned to thefirst component of the MyValues box:
MyValues(1) = Edit_WriteVal
Write Synchronously
After all the required local variables have been declared and initialized, theSyncWrite method of the OPCGroup class is called:
GroupObj.SyncWrite 1, Serverhandles, MyValues, MyErrors
SyncWrite
The SyncWrite method of the OPCGroup class writes values of OPC itemssynchronously and is declared as follows:
Sub SyncWrite(NumItems As Long, ServerHandles() As Long, Values() As Variant, Errors() As Long)
Sample Programs
500SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
NumItems Number of items for which values are written
ServerHandles Array with server handles
Values Array with the values to be written
Errors Return parameters. Array with error codes.
GetErrorString
The GetErrorString function of the OPCServer class converts an error code into astring and is declared as shown below:
Function GetErrorString(ErrorCode As Long) As String
Parameter Description
ErrorCode Error code returned by the server
Display Values
GetErrorString converts the numeric error code in the MyErrors array into thecorresponding error text and it is then displayed by the Text property of theEdit_WriteRes text box:
Edit_WriteRes = ServerObj.GetErrorString(MyErrors(1))
7.2.8 Command_Exit_Click
The Command_Exit_Click procedure is called when the button labeled “StopSample” is clicked and it can be divided into the following sections:
Deactivating Buttons
First, the “Start Sample” button is enabled again and all other buttons disabled:
Command_Start.Enabled = TrueCommand_Read.Enabled = FalseCommand_Write.Enabled = FalseCommand_Exit.Enabled = False
Sample Programs
501SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Releasing Resources
First, the OPCItem object is released. With the RemoveAll method of theOPCGroups class, all groups and the items they contain are then removed.Afterwards, the “MyOPCGroup” OPCGroup object is released:
Set ItemObj = NothingServerObj.OPCGroups.RemoveAllSet GroupObj = Nothing
Finally, the Disconnect method of the OPCServer class disconnects from theserver and the Server object is released:
ServerObj.DisconnectSet ServerObj = Nothing
All OPC objects are deleted and all resources are released.
7.2.9 GetQualityText
GetQualityText provides a string as an error message for a specified error code:
Private Function GetQualityText(Quality) As String Select Case Quality Case 0: GetQualityText = “BAD” Case 64: GetQualityText = “UNCERTAIN” Case 192: GetQualityText = “GOOD” Case 8: GetQualityText = “NOT_CONNECTED” Case 13: GetQualityText = “DEVICE_FAILURE” Case 16: GetQualityText = “SENSOR_FAILURE” Case 20: GetQualityText = “LAST_KNOWN” Case 24: GetQualityText = “COMM_FAILURE” Case 28: GetQualityText = “OUT_OF_SERVICE” Case 132: GetQualityText = “LAST_USABLE” Case 144: GetQualityText = “SENSOR_CAL” Case 148: GetQualityText = “EGU_EXCEEDED” Case 152: GetQualityText = “SUB_NORMAL” Case 216: GetQualityText = “LOCAL_OVERRIDE” Case Else: GetQualityText = “UNKNOWN ERROR” End Select End Function
7.2.10 Notes on Writing your own Programs
Several requirements must be met before your own programs can use theAutomation interface. Follow the steps outlined below:
Sample Programs
502SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step Description
1 Start the Visual Basic development environment.
2 Create a project of the required type.
3 Go to the “Project” menu and select “References..”. A dialog isopened listing the available references. Select the following entry: “Siemens OPC DAAutomation 2.0”. This makes the OPC objects available in your project.
4 Arrange the required operator interface elements in the main dialogor create a suitable application window and program thecorresponding event procedures.
7.2.11 Using the OPC Automation Interface with the .NET-Framework
Introduction
This section describes the use and migration of the sample program forsynchronous reading and writing over the OPC Automation interface using.NET-Framework for Visual Basic.NET.
After installing the SIMATIC NET software, you will find this program on your harddisk in the following folder:
<Installationspfad>\SIEMENS\SIMATIC.NET\opc2\samples\automation\sync.net
How to work with the sample and how it executes is unchanged from the previoussample. The following section describes only the necessary changes.
Sample Programs
503SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Requirements for Using the Sample Program
A .NET-Framework version 1.1 must be installed on the computer on which youwant the sample program to run.
In the existing VB.NET project, the COM component “Siemens OPCDAAutomation 2.0” has already been added:
With the command
Imports OPCSiemensDAAutomation
it is simple to use the name space and methods of the OPC Automation interfacewith .NET Framework.
Creating a connection to the OPC server, adding a group and an item
Using the Connect, Add and AddItem methods, the procedure is analogous to theprevious sample:
ServerObj = New OPCServerServerObj.Connect((”OPC.SimaticNET”))
GroupsObj = ServerObj.OPCGroupsGroupObj = GroupsObj.Add(”MyOPCGroup”)
ItemObj = GroupObj.OPCItems.AddItem(”S7:[DEMO]MW1”, 1)
Sample Programs
504SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Read Synchronously
To read values synchronously, the Read method of the OPCItem class is called:
ItemObj.Read(OPCDevice, myValue, myQuality, myTimeStamp)
Write Synchronously
Note
Visual Basic .NET uses the value 0 as the minimum array index and not value 1 asin the previous Visual Basic and be adapted OPC Automation interface.
Array objects of the imported name space OPCSiemensDAAutomation thereforebegin with index 0. In the sample, special arrays have been created for the transfervalue is with array limits of 1:
Dim Dims() As Integer = New Integer() {1}Dim Bounds() As Integer = New Integer() {1}Dim Serverhandles As Array = Array.CreateInstance(GetType(Integer), Dims, Bounds)Dim MyErrors As Array = Array.CreateInstance(GetType(Integer), Dims, Bounds)
Dim MyValues As Array = Array.CreateInstance(GetType(Object), Dims, Bounds)
These variables must still be initialized. The server handle received its value 1when the item was added:
Serverhandles.SetValue(ItemObj.ServerHandle, 1)MyErrors.SetValue(0, 1)
The value of the Text property of the text box for user input is then assigned to thefirst component of the MyValues box:
MyValues.SetValue(Edit_WriteVal.Text, 1)
After all the required local variables have been declared and initialized, theSyncWrite method of the OPCGroup class is called:
GroupObj.SyncWrite(1, Serverhandles, MyValues, MyErrors)
Sample Programs
505SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.3 Sample Program for the OPC Automation Interface(Asynchronous Communication)
This sample involves Microsoft Visual Basic and uses the Automation Interface forData Access V2.0 of OPC to read and write data asynchronously.
The description is divided into the following sections:
� Activating the Simulation Connection
� Working with the Sample Program
� How the Program Runs
� Description of the Program
� Notes on Writing your own Programs
7.3.1 Activating the Simulation Connection
Before you can run this program, you must activate a simulation connection thatmakes the demonstration variables used in the program available:
Step Description
1 Start the “Configuration Console” program in the Start menu:Start -> SIMATIC -> SIMATIC NET -> Settings -> ConfigurationConsole
2 In the left-hand navigation window, open the property page for thesimulation module by expanding SIMATIC NET Configuration -> Modulesand click on the “CP Simulation” icon
3 Click the check box for the protocol you want to simulate.This example uses the S7 protocol. So you should click on “S7”.
4 Close the “Configuration Console” program.
Note
Before the changes take effect, you must first close all OPC clients!
Sample Programs
506SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.3.2 Working with the Sample Program
The program includes several elements that the operator can use to trigger thefollowing actions:
Operator Element Effect
Start Sample Start program
Read or Write Value Read and write values
Group Active Activate or deactivate group
Stop Sample Stop the program
7.3.3 Start Program
The program is on your hard disk in <installationpath>\SIEMENS\SIMATIC.NET\opc2\samples\automation\async
When you start the program, only the “Start Sample” button is enabled. After youhave clicked this button, the program generates the required OPC objects. You canthen use the other buttons.
Sample Programs
507SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.3.4 Read and Write Values
After you click the “Read Value” button, the value that was read and statusinformation is displayed in the relevant text boxes. As it stands, the sampleprogram is designed to operate with a demonstration connection. If you want to runthe sample program in a real environment, you must change the following lines inthe code of the OPCDA_AsyncDlg.cpp file:
Set ItemObj1 = GroupObj.OPCItems.AddItem(”S7:[DEMO]MB1”, 1)
Set ItemObj2 = GroupObj.OPCItems.AddItem(”S7:[DEMO]MW3”, 2)
To write a value, you enter it in the “Value” text box and click the “Write Value”button. The program displays a message about the result of the write operation:
Sample Programs
508SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.3.5 Activate Group
Asynchronous operations do not return a result directly (for example as a functionresult or return parameter) but make use of events.
You can activate the OPC group in the sample program by selecting the “GroupActive” check box. When changes occur, the “OnDataChange-Event” is thencreated. A procedure that executes when this event occurs, displays values andstatus information in the text boxes of “OnDataChanged”:
Events for completion of write or read operations are also generated for inactivegroups. This means that results can also be displayed for writes and reads even ifthis check box is not selected.
7.3.6 Stop the Program
The “Stop Sample” button stops the program. All OPC objects are deleted and thecorresponding resources are released.
Sample Programs
509SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.3.7 How the Program Runs
Due to the class model of OPC, a specific order must be adhered to in the methodcalls of OPC objects. To be able to create an instance of the “OPCItem” class, anobject of the “OPCGroup” class is necessary. This is, however, only possible whenan instance of the “OPCServer” class exists and a connection to this server hasbeen established.
The basic sequence of instructions for creating and deleting OPC objects isillustrated in the following graphic. The variable names of the sample program areused.
The sample program contains all the components that would normally exist in atypical client application. These include establishing the connection to the OPCserver, creating a group with variables, and reading and writing values for an item.
Sample Programs
510SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.3.8 Description of the Program
The program code in the opcsync.frm file can be divided into the followingsections:
� Declaration of constants
� Declaration of global variables
� Implementing the Event Procedures
Constants
At the beginning of the module, three constants are declared that will be requiredlater in method calls and make the program easier to read:
Const WRITEASYNC_ID = 1 Const READASYNC_ID = 2 Const REFRESHASYNC_ID = 3
Global Variables
Several global variables are then declared. To allow the OPCServer andOPCGroup objects to process events, their declaration must be supplemented with“WithEvents”:
Public WithEvents ServerObj As OPCServerPublic WithEvents GroupObj As OPCGroupDim ItemObj1 As OPCItemDim ItemObj2 As OPCItemDim Serverhandle(2) As Long
Sample Programs
511SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Implementing the Event Procedures
The main components of this module are the event procedures for the buttons ofthe dialog that are called by Visual Basic.
� Command_Start_Click
� chkGroupActive_Click
� Command_Read_Click
� Command_Write_Click
� Command_Exit_Click
� GroupObj_AsyncReadComplete
� GroupObj_AsyncWriteComplete
� GroupObj_DataChange
The file also includes the auxiliary functions
� GetQualityText
� GetErrorString
7.3.9 Command_Start_Click
The Command_Start_Click method is called when the button labeled “StartSample” is clicked and it can be divided into the following sections:
� Enabling Buttons
� Generating an Object of the OPCServer Class
� Establishing a Connection to the Server
� Adding a Group
� Setting the IsSubscribed Property
� Activating the Group
� Adding Items
� Initializing the Server Handles
Enabling Buttons
First, the “Start Sample” button is disabled and all other buttons enabled:
Command_Start.Enabled = FalseCommand_Read.Enabled = TrueCommand_Write.Enabled = TrueCommand_Exit.Enabled = TruechkGroupActive.Enabled = True
Sample Programs
512SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Generating an Object of the OPCServer Class
First, a new instance of the OPCServer class is generated:
Set ServerObj = New OPCServer
Establishing a Connection to the OPC Server of SIMATIC NET
With the Connect method of the OPCServer class, a connection is established tothe OPC server of SIMATIC NET:
ServerObj.Connect (”OPC.SimaticNET”)
Connect
The Connect method of the OPCServer class is declared as follows:Sub Connect(ProgID As String, [Node])
Parameter Description
ProgID Unique OPC server name assigned by the vendor
Node Optional parameter of the Variant type that specifies the servercomputer when using DCOM.
Adding a Group
Each object of the OPCServer class has the collection object OPCGroups. Its Addfunction adds an object of the type OPCGroup to the collection:
Set GroupObj = ServerObj.OPCGroups.Add(”MyOPCGroup”)
Add
The Add function of the OPCGroups class is declared as follows:
Function Add([Name]) As OPCGroup
Parameter Description
Name Optional parameter as variant that specifies the name of thenew group.
Setting the IsSubscribed Property
The IsSubscribed property of the OPCGroup class must be set to true if the groupis to receive asynchronous data updates:
GroupObj.IsSubscribed = True
Sample Programs
513SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Activating a Group
The procedure chkGroupActive_Click is now called to adapt the status of the groupto the status of the “Group Active” check box:
chkGroupActive_Click
Adding Items
Each object of the OPCGroup class has the collection object OPCItems. ItsAddItem function creates a new object of the class OPCItem and adds it to thecollection:
Set ItemObj1 = GroupObj.OPCItems.AddItem(”S7:[DEMO]MB1”, 1)Set ItemObj2 = GroupObj.OPCItems.AddItem(”S7:[DEMO]MW3”, 2)
AddItem
The AddItem function of the OPCItems class returns an object of the OPCItemtype and is declared as follows:
Function AddItem(ItemID As String, ClientHandle As Long) AsOPCItem
Parameter Description
ItemID Please refer to some of the samples and the manual for moreinformation on the structure of the ItemID.
Client-Handle
Handle assigned by the client for an item
Initializing the Serverhandle Variable
The Serverhandle generated by the OPC server when AddItems is called isrequired later and is therefore saved. The value of the server handle is assigned to a component of the globalServerhandle array for each of the OPCItem objects:
Serverhandle(1) = ItemObj1.ServerhandleServerhandle(2) = ItemObj2.Serverhandle
Sample Programs
514SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.3.10 The “Group Active” Check Box
The setting of the “Group Active” check box can addressed directly as shown hereusing the chkGroupActive variable that is assigned to the check box. It indicateswhether the box was activated or is inactive. Depending on the status of the checkbox, the “GroupObj” group is activated or deactivated when chkGroupActive_Clickis called:
If chkGroupActive = 1 ThenGroupObj.IsActive = TrueElseGroupObj.IsActive = FalseEnd If
7.3.11 Command_Read_Click
The Command_Read_Click event routine starts an asynchronous read job. Thefollowing operations are executed:
Variable Declarations
First, several local variables are declared some of which are passed as parametersfor the subsequent method call. The “ClientID” variable is also assigned the valueof the global constant READASYNC_ID:
Dim ClientID As LongDim ServerID As LongDim ErrorNr() As LongDim ErrorString As String
ClientID = READASYNC_ID
Asynchronous Read
The AsyncRead method of the OPCGroup class is called first so that anasynchronous read job is started.If AsyncRead method returns an error code other than 0, GetErrorString is used toget an error text that is displayed in the form of a message.The Erase function releases the memory that was allocated by the dynamicErrorNr array:
GroupObj.AsyncRead 1, Serverhandle, ErrorNr, ClientID,ServerIDIf ErrorNr(1) <> 0 ThenErrorString = ServerObj.GetErrorString(ErrorNr(1))MsgBox ErrorString, vbCritical, ”Error AsyncRead()”End IfErase ErrorNr
Sample Programs
515SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
AsyncRead
The Async Read method is defined as shown below:
Sub AsyncRead(NumItems As Long, ServerHandles() As Long, Errors() As Long, TransactionID As Long, CancelID As Long)
Parameter Description
NumItems Number of items for which values will be read.
ServerHandles Array with the server handles of the items for whichvalues will be read.
Errors Array with elements of the type Long. These varia-bles provide an error code if AsyncRead was not cal-led successfully or information indicating a successfulmethod call.
TransactionID A code number assigned by the client to identify theasynchronous transaction. This is returned by theserver with AsyncReadComplete calls.
CancelID A code number generated by the server that must bespecified if the transaction is to be canceled.
7.3.12 Command_Write_Click
The Command_Write_Click event routine starts an asynchronous write job. Thefollowing operations are executed:
Variable Declarations
First, several local variables are declared some of which are passed as parametersfor the subsequent method call. The first component of the MyValues variable is then assigned the value of the textproperty of the Edit_WriteVal text box.
Dim Serverhandles(1) As LongDim MyValues(1) As VariantDim ErrorNr() As LongDim ErrorString As StringDim Cancel_id As Long
MyValues(1) = Edit_WriteVal
Sample Programs
516SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Write Asynchronous
The AsyncWrite method of the OPCGroup class is called first so that anasynchronous write job is started.If the AsyncWrite method returns an error code other than 0, GetErrorString isused to get an error text that is displayed in the form of a message.The Erase function releases the memory that was allocated by the dynamicErrorNr array:
GroupObj.AsyncWrite 1, Serverhandle, MyValues, ErrorNr,WRITEASYNC_ID, Cancel_id
If ErrorNr(1) <> 0 ThenErrorString = ServerObj.GetErrorString(ErrorNr(1))MsgBox ErrorString, vbCritical, “Error AsyncRead()”End If
Erase ErrorNr
AsyncWrite
The AsyncWrite method is declared as follows:
Sub AsyncWrite(NumItems As Long, ServerHandles() As Long, Values() As Variant, Errors() As Long, TransactionID As Long, CancelID As Long)
Parameter Description
NumItems Number of items for which values are written.
ServerHandles Array with the server handles of the items for whichvalues are written.
Values Array with the values to be written.
Errors Array with elements of the type Long. These varia-bles provide an error code if AsyncWrite was not cal-led successfully or information indicating a successfulmethod call.
TransactionID A code number assigned by the client to identify theasynchronous transaction.
CancelID A code number generated by the server that must bespecified if the transaction is to be canceled.
Sample Programs
517SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.3.13 Command_Exit_Click
The Command_Exit_Click procedure is called when the button labeled “StopSample” is clicked and it can be divided into the following sections:
Deactivating Buttons
First, the “Start Sample” button is enabled again and all other buttons disabled:
Command_Start.Enabled = TrueCommand_Read.Enabled = FalseCommand_Write.Enabled = FalseCommand_Exit.Enabled = FalsechkGroupActive.Enabled = False
Releasing Resources
First, the OPCItem objects are released. With the RemoveAll method of theOPCGroups class, all groups and the items they contain are then removed.Afterwards, the “MyOPCGroup” OPCGroup object is released:
Set ItemObj1 = NothingSet ItemObj2 = NothingServerObj.OPCGroups.RemoveAllSet GroupObj = Nothing
Finally, the Disconnect method of the OPCServer class disconnects from theserver and the Server object is released:
ServerObj.DisconnectSet ServerObj = Nothing
All OPC objects are deleted and all resources are released.
7.3.14 GroupObj_AsyncReadComplete
To be able to receive reply messages from the server to the AsyncRead calls, youmust implement the AsyncReadComplete event of the OPCGroup object. TheOPCGroup object must also be declared with the “With Events” attribute.
The AsyncReadComplete event is generated by the Automation Server when anAsyncRead call has been executed completely. When the AsyncReadCompleteclient method is called, it transfers the results of the read operation as parameters.
The AsyncReadComplete method and its implementation are described in greaterdetail below.
Sample Programs
518SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Declaration of AsyncReadComplete
The AsyncReadComplete event of the OPCGroup class is declared as shownbelow:
Event AsyncReadComplete(TransactionID As Long, NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date, Errors() As Long)
Parameter Description
TransactionID A code number for the asynchronous write operationspecified with the AsyncRead call.
NumItems Number of items for which values exist.
ClientHandles Array with the client handles of the items whose va-lues have changed.
ItemValues Array of the type variant that contains the values ofthe items that have changed.
Qualities Array with information about the integrity of the va-lues of the individual items.
TimeStamps Array with time information for the individual items.
Errors Array with error messages for the items.
Implementation of the AsyncReadComplete Method
Dim ErrorString As String
If (TransactionID = READASYNC_ID) Then If Errors(1) = 0 Then Edit_ReadVal = ItemValues(1) Edit_ReadQu = GetQualityText(Qualities(1)) Edit_ReadTS = TimeStamps(1) Else ErrorString = ServerObj.GetErrorString(Errors(1)) MsgBox ErrorString, vbCritical, “Error AsyncReadComplete()” End IfEnd If
After the declaration of the ErrorString variable, there is a query to check whetherthe TransactionID matches the value READASYNC_ID specified with theAsyncRead call; in other words whether this return message actually belongs tothe asynchronous read job.
Sample Programs
519SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
If this is the case, and if no errors occurred during execution of the read operation,the read values are assigned to the text properties of the relevant text boxes.
If errors occurred during the read, the resulting error code is converted withGetErrorString and displayed in the form of a message.
If the TransactionID does not match the READASYNC_ID, the method isterminated immediately.
7.3.15 GroupObj_AsyncWriteComplete
To be able to receive reply messages from the server to the AsyncWrite calls, youmust implement the AsyncWriteComplete event of the OPCGroup object. TheOPCGroup object must also be declared with the “With Events” attribute.
The AsyncWriteComplete event is generated by the Automation Server when anAsyncWrite call has been executed completely. When the AsyncWriteCompleteclient method is called, it transfers the results of the read operation as parameters.
The AsyncWriteComplete method and its implementation are described in greaterdetail below:
Declaration of AsyncWriteComplete
The AsyncWriteComplete event of the OPCGroup class is declared as shownbelow:
Event AsyncWriteComplete(TransactionID As Long,NumItems As Long, ClientHandles() As Long, Errors() As Long)
Parameter Description
TransactionID A code number for the asynchronous write operationtransferred when the AsyncWrite call is made.
NumItems Number of items for which values were written.
ClientHandles Array with the client handles of the items for which va-lues were written.
Errors Array with error messages for the items.
Implementation of the AsyncWriteComplete Method
Dim ErrorString As StringIf (TransactionID = WRITEASYNC_ID) ThenIf Errors(1) = 0 Then Edit_WriteRes = ServerObj.GetErrorString(Errors(1))Else ErrorString = ServerObj.GetErrorString(Errors(1))
Sample Programs
520SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
MsgBox ErrorString, vbCritical, ”Error AsyncWriteComplete()”End IfEnd If
After the declaration of the ErrorString variable, there is a query to check whetherthe TransactionID matches the value WRITEASYNC_ID specified with theAsyncWrite call, in other words whether this return message actually belongs tothe asynchronous write job that transferred the value of WRITEASYNC_ID as theTransactionID.
If this is the case, and if no errors occurred during the write operation, the value ofthe first component of “Errors” that then contains a message about the success ofthe write operation is converted by GetErrorString and assigned to the textproperty of the Edit_WriteRes text box.
If errors occurred during asynchronous writing, the returned error code isconverted with GetErrorString and displayed as a message.
If the TransactionID does not match the READASYNC_ID, the method isterminated immediately.
7.3.16 ObjGroup_DataChange
When monitoring variables, the OPC server continuously checks whether the valueor the quality of variables has changed.
To be able to react to return messages, the client must provide the DataChangemethod that is then called by the server when the data of an active item within anactive group changes. The “IsSubscribed” property of the group must also be setto true.
As the parameters of DataChange, the OPC server transfers the changed values,qualities, and time stamp of the OPC items.
Declaration of DataChange
The DataChange event of the OPCGroup class is declared as shown below:
Event DataChange(TransactionID As Long, NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)
Sample Programs
521SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Parameter Description
TransactionID The code number for the type of method call is zero if avalue change was the cause of the method call, if thecode number is not zero, the method call was triggeredby a refresh.
NumItems Number of items for which values exist.
ClientHandles Array with the client handles of the items whose valueshave changed.
ItemValues Array of the type variant that contains the values of theitems that have changed.
Qualities Array with information about the integrity of the values ofthe individual items
TimeStamps Array with time information for the individual items
Implementation of DataChange
Dim i As Long For i = 1 To NumItems Edit_OnDataVal(i - 1) = ItemValues(i) Edit_OnDataQu(i - 1) = GetQualityText(Qualities(i)) Edit_OnDataTS(i - 1) = TimeStamps(i) Next i
In the loop, the values of the items whose data has changed are assigned to thetext properties of the text boxes in the OnDataChanged dialog group.
7.3.17 GetQualityText
GetQualityText provides a string as an error message for a specified error code:
Private Function GetQualityText(Quality) As String Select Case Quality Case 0: GetQualityText = ”BAD” Case 64: GetQualityText = ”UNCERTAIN” Case 192: GetQualityText = ”GOOD” Case 8: GetQualityText = ”NOT_CONNECTED” Case 13: GetQualityText = ”DEVICE_FAILURE” Case 16: GetQualityText = ”SENSOR_FAILURE” Case 20: GetQualityText = ”LAST_KNOWN” Case 24: GetQualityText = ”COMM_FAILURE” Case 28: GetQualityText = ”OUT_OF_SERVICE” Case 132: GetQualityText = ”LAST_USABLE” Case 144: GetQualityText = ”SENSOR_CAL” Case 148: GetQualityText = ”EGU_EXCEEDED” Case 152: GetQualityText = ”SUB_NORMAL”
Sample Programs
522SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Case 216: GetQualityText = ”LOCAL_OVERRIDE” Case Else: GetQualityText = “UNKNOWN ERROR” End Select End Function
7.3.18 GetErrorString
The GetErrorString function of the OPCServer class converts an error code into astring and is declared as shown below:
Function GetErrorString(ErrorCode As Long) As String
Parameter Description
ErrorCode Error code returned by the server
7.3.19 Notes on Writing your own Programs
Several requirements must be met before your own programs can use theAutomation interface. Follow the steps outlined below:
Step Description
1 Start the Visual Basic development environment.
2 Create a project of the required type.
3 Go to the “Project” menu and select “References..”. A dialog isopened listing the available references. Select the following entry: “Siemens OPC DAAutomation 2.0”. This makes the OPC objects available in your project.
4 Arrange the required operator interface elements in the main dialogor create a suitable application window and program thecorresponding event procedures.
Sample Programs
523SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.4 Sample Program for the OPC Custom Interface(Synchronous Communication)
This sample in Visual C++ uses the Microsoft Foundation Classes (MFC) and theCustom interface for Data Access V2.0 of OPC to read and write datasynchronously.
The description is divided into the following sections:
� Activating the Simulation Connection
� Working with the Sample Program
� How the Program Runs
� Description of the Program
� Notes on Writing your own Programs
7.4.1 Activating the Simulation Connection
Before you can run this program, you must activate a simulation connection thatmakes the demonstration variables used in the program available:
Step Description
1 Start the “Configuration Console” program in the Start menu:Start -> SIMATIC -> SIMATIC NET -> Settings -> ConfigurationConsole
2 In the left-hand navigation window, open the property page for thesimulation module by expanding SIMATIC NET Configuration -> Modulesand click on the “CP Simulation” icon
3 Click the check box for the protocol you want to simulate.This example uses the S7 protocol. So you should click on “S7”.
4 Close the “Configuration Console” program.
Note
Before the changes take effect, you must first close all OPC clients!
Sample Programs
524SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.4.2 Working with the Sample Program
When you start the program, only the “Start Sample” button is enabled. After youhave clicked this button, the program generates the required OPC objects. You canthen use the other buttons.
After you click the “Read Value” button, the values that were read are displayed inthe relevant text boxes. As it stands, the sample program is designed to operatewith a demonstration connection. If you want to run the sample program in a realenvironment, you must change the following line in the OpcSyncDlg.cpp file:
LPWSTR szItemID = L”S7:[DEMO]MW1”;
Sample Programs
525SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
To write a value, this must be entered in the relevant text box. After clicking the“Write Value” button, the program displays a message about the result of thisoperation:
The “Stop Sample” button closes the program; in other words, all objects aredeleted and the corresponding resources are released again.
7.4.3 How the Program Runs
Due to the class model of OPC, a specific order must be adhered to in the methodcalls of OPC objects. To be able to create an instance of the “OPCItem” class, anobject of the “OPCGroup” class is necessary. This is, however, only possible whenan instance of the “OPCServer” class exists and a connection to this server hasbeen established.
The basic sequence of instructions for creating and deleting OPC objects isillustrated in the following graphic. The variable names of the sample program areused.
Sample Programs
526SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The sample program contains all the components that would normally exist in atypical client application. These include establishing the connection to the OPCserver, creating a group with variables, and reading and writing values for an item.Before describing the source code in detail, we will therefore have a look at thebasic structure of an OPC application.
Step Description
1 Register with COM
2 Convert the ProgID to a CLSID
3 Establish connection to the OPC server
4 Create an OPC group
5 Adding Items
6 Request an interface pointer for IOPCSyncIO
7 Delete objects and release memory
Step 1: Register with COM
Each program that wants to use functions of the COM library must first registeritself with COM. This is the purpose of the CoInitialize() function:
HRESULT r1; r1 = CoInitialize(NULL);
Step 2: Convert the ProgID to a CLSID
To identify it, each COM server has a “ProgID” that is assigned to a worldwideunique “CLSID” (128 bits code). Since the CLSID is required as a parameter forthe later functions it must be obtained from the ProgID with theCLSIDFromProgID() function. The “ProgID” of the OPC Server of SIMATIC NET isL”OPC.SimaticNET”:
r1 = CLSIDFromProgID(L”OPC.SimaticNET”, &clsid);
Sample Programs
527SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 3: Establish the connection to the OPC server
The CoCreateInstance() function creates an instance of the class whose “CLSID”was specified.
r1 = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER,IID_IOPCServer, (void**)&m_pIOPCServer);
The result of this program section is an object of the OPC server class.CoCreateInstance also provides a pointer to the IOPCServer interface of theserver object (m_pIOPCServer variable):
Step 4: Create an OPC group
The IOPCServer interface has the AddGroup() method for creating groups:
r1 = m_pIOPCServer->AddGroup(L”grp1”, TRUE, 500, 1, &TimeBias, &PercentDeadband, LOCALE_ID, &m_GrpSrvHandle, &RevisedUpdateRate, IID_IOPCItemMgt, (LPUNKNOWN*)&m_pIOPCItemMgt);
The result of this program section is a group with the specified name and therequired properties. In addition, a pointer to the requested interface of the groupobject exists as a return parameter, in this case, IOPCItemMgt (m_pIOPCItemMgtvariable):
Sample Programs
528SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 5: Add items
The IOPCItemMgt interface has the AddItems() method for creating OPC items:
r1 = pItemMgt->AddItems(1, m_Items, &m_pItemResult,&m_pErrors);
The result of this step is the required number of items with the specified properties.The variables of the result structure m_pItemResult (server handle, data type ofthe item on the target system etc.) are initialized.
Step 6: Request an interface pointer for IOPCSyncIO
A pointer to the IOPCSyncIO interface is necessary to allow use of the methods forsynchronous reads and writes. It is requested using the already existing pointer tothe IOPCItemMgt interface:
r1 = m_pIOPCItemMgt->QueryInterface(IID_IOPCSyncIO,(void**)&m_pIOPCSyncIO);
Using the Read() and Write() methods of this interface, values for items can beread or written:
Sample Programs
529SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 7: Delete objects and release memory
Before exiting the program, the OPC objects that have been created must bedeleted and the memory reserved for them must be released. The relevantfunctions are integral parts of the previously used interfaces.
r1 = m_pIOPCItemMgt->RemoveItems(1, phServer, &pErrors);CoTaskMemFree(m_pItemResult);m_pItemResult=NULL;CoTaskMemFree(m_pErrors);m_pErrors = NULL;m_pIOPCSyncIO->Release();m_pIOPCSyncIO = NULL;m_pIOPCItemMgt->Release();m_pIOPCItemMgt = NULL;r1 = m_pIOPCServer->RemoveGroup(m_GrpSrvHandle, TRUE);m_GrpSrvHandle = NULL;m_pIOPCServer->Release();m_pIOPCServer = NULL;CoUninitialize();
7.4.4 Description of the OPCDA_SyncDlg.cpp Program
The OPCDA_SyncDlg.cpp file can be divided into the following sections:
� Declaration of global variables
� Methods of the COPCDA_SyncDlg Class
Global Variable
At the start of this module, a global variable is initialized with the item identifier. Toensure that the sample program functions correctly, this variable must be readableand writable.
const LPWSTR szItemID = L”S7:[DEMO]MW1”;
You can refer to several examples and the manual for more information on thestructure of the item IDs.
Sample Programs
530SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Methods of the COPCDA_SyncDlg Class
The main components of this module are the event procedures for the buttons ofthe main dialog that are called by MFC. Some settings must also be made in theOnInitDialog method:
� OnInitDialog
� OnStart
� OnRead
� OnWrite
� OnStop
� DestroyWindow
7.4.5 OnInitDialog
There are several class variables available for access to COM mechanisms thatare initialized when the main dialog box is initialized. These variables can be put tothe following uses:
� m_pIOPCServer is a pointer to the IOPCServer interface of the OPC serverclass.
� m_pIOPCItemMgt is a pointer to the IOPCItemMgt interface of the OPC groupclass.
� m_pIOPCSyncIO is a pointer to the IOPCSyncIO interface of the OPC groupclass.
m_pIOPCServer = NULL;m_pIOPCItemMgt = NULL;m_pIOPCSyncIO = NULL;
At the start of the program, the user can only click the “Start Sample” button. Allother buttons are disabled. This makes sure that all required OPC objects are setup correctly before write or read operations are executed. This is achieved with thefollowing program section:
m_CtrlStop.EnableWindow(FALSE);m_CtrlRead.EnableWindow(FALSE);m_CtrlWrite.EnableWindow(FALSE);
Sample Programs
531SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.4.6 OnStart
OnStart sets up the OPC objects required for running the program. First, localvariables are declared and initialized that are required for the methods of the OPCobjects.
void COpcSyncDlg::OnStart(){ HRESULT r1; CLSID clsid; LONG TimeBias = 0; FLOAT PercentDeadband = 0.0; DWORD RevisedUpdateRate; LPWSTR ErrorStr; char str[100]; Cstring szErrorText;
Then the following operations are executed:
CoInitialize
CoInitialize() initializes the COM library. The input parameter must always be“NULL”.
r1 = CoInitialize(NULL);if (r1 != S_OK){ if (r1 == S_FALSE) { MessageBox(”COM Library already initialized”, ”Error CoInitialize()”, MB_OK+MB_ICONEXCLAMATION); } else { szErrorText.Format( ”Initialisation of COM Library failed. \ Error Code= %4x”, r1); MessageBox(szErrorText, ”Error CoInitialize()”, MB_OK+MB_ICONERROR); SendMessage(WM_CLOSE); return; } }
Sample Programs
532SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
CLSIDFromProgID
CLSIDFromProgID() retrieves a worldwide unique class identifier or CLSID from aspecified ProgID. This is required for the CoCreateInstance function.
This method is declared as follows:
HRESULT CLSIDFormProgID(LPCOLESTR lpszProgID, LPCLSIDpclsid);
Parameter Description
lpszProgID Pointer to the ProgID [input parameter]
pclsid Pointer to the retrieved class identifier [return value]
In the sample program, this method retrieves the class identifier of the OPC Serverof SIMATIC NET:
r1 = CLSIDFromProgID(L”OPC.SimaticNET”, &clsid); if (r1 != S_OK) { MessageBox(”Retrieval of CLSID failed”, “Error CLSIDFromProgID()”, MB_OK+MB_ICONERROR); CoUninitialize(); SendMessage(WM_CLOSE); return; }
CoCreateInstance
CoCreateInstance() creates an instance of the class whose class identifier wasspecified. This method is declared as follows:
STDAPI CoCreateInstance (REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv);
Parameter Description
rclsid The class identifier of the required object
pUnkOuter NULL pointer if the object to be created is not part of anaggregated object. A pointer that is not a NULL pointeris interpreted as a pointer to the IUnknown interface ofthe aggregated object.
Sample Programs
533SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
dwClsContext Describes the runtime environment of the object to becreated. This specifies whether or not the executablecode that creates and manages objects of this classruns on the local machine and whether a separate pro-cess will be created for it. The constants that can beused for this are specified in the CLSCTX enumerateddata type. In the sample, CLSCTX_LOCAL_SERVER isused; in other words, the executable code for managingthe server objects runs on the same computer as thesample program but in its own process.
riid Identifier of the interface over which communication withthe object will take place, in the sample program “IOPC-Server”.
ppv Address of the pointer variable containing the requiredinterface pointer if the method call is successful.
The following method call creates an object of the OPC server class and returns apointer to the IOPCServer interface:
r1 = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER,IID_IOPCServer, (void**)&m_pIOPCServer);if (r1 != S_OK){ MessageBox(”Creation of IOPCServer-Object failed”, “Error CoCreateInstance()”, MB_OK+MB_ICONERROR); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return;}
AddGroup
The AddGroup() method of the IOPCServer creates an OPC group and is declaredas follows:
HRESULT AddGroup (LPWCSTR szName, BOOL bActive, DWORD dwRequestedUpdateRate, OPCHANDLE hClientGroup, LONG *pTimeBias, FLOAT *pPercentDeadband, DWORD dwLCID, OPCHANDLE *phServerGroup, DWORD *pRevisedUpdateRate, REFIID riid, LPUNKNOWN *ppUnk);
Sample Programs
534SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
szName Group name that can be assigned freely by theclient but must be unique within the client.
bActive FALSE if the group is to be inactive when it iscreated.TRUE if the group is to be active when it iscreated.
dwRequestedUpdateRate Specifies the shortest interval after which a clientwill be informed of changes to values or states ofitems. Specifying a suitable interval prevents infor-mation being sent to a client more quickly than itcan process it.
hClientGroup Code number that can be selected freely by theclient and that is returned by the server with cer-tain notifications. This allows the client to identifyits data. The client identifies the group with thishandle.
pTimeBias Deviation of the server time from UTC (UniversalTime Convention)
pPercentDeadband Specifies the percentage of the band width inwhich value changes do not lead to a notification.The upper and lower limit values of a value mustbe known to be able to calculate the band width.Inthis sample program, this is not the case (seeOPC Data Access Spec. 1.1, Section 4.4.1.6.).
dwLCID Selects the language to be used by the serverwhen returning texts.
phServerGroup Handle assigned by the server that must be speci-fied as a parameter with certain function calls (forexample, “RemoveGroup”). The server requiresthis to identify this group.
pRevisedUpdateRate Shortest interval returned by the server after whicha client will be informed of changes to values orstates of items.
riid Pointer to the identifier of one of the interfaces ofthe OPC group object that will be available afterthe group is created. This parameter saves callingthe “QueryInterface” method extra.
ppUnk Pointer to the required interface.
Sample Programs
535SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
When AddGroup is called in the sample program, the following settings are made:
� The bActive parameter is set to the value FALSE. Directly after it is created, thegroup is inactive; in other words, no OnDataChange callbacks are generated forthis group.
� The duration of the required update interval is 500 milliseconds.
� Any client handle can be specified since only one group is being used.
� In the sample program, there is no provision for suppressing notification ofvalue changes within a specific range. The value “0.0” is therefore entered forthe pPercentDeadband parameter.
� AddGroup will return a pointer to the IOPCItemMgt interface as the returnvalue.
r1 = m_pIOPCServer->AddGroup(L”grp1”, TRUE, 500, 1, &TimBias, &PercentDeadband, LOCALE_ID, &m_GrpSrvHandle, &RevisedUpdateRate, IID_IOPCItemMgt, (LPUNKNOWN*)&m_pIOPCItemMgt); if (r1 == OPC_S_UNSUPPORTEDRATE) { szErrorText.Format (”Revised Update Rate %d is different from Requested Update Rate 500”, RevisedUpdateRate ); AfxMessageBox(szErrorText); } else if (FAILED(r1)) { MessageBox(”Can’t add Group to Server!”, ”Error AddGroup()”, MB_OK+MB_ICONERROR); m_pIOPCServer->Release(); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return; }
Sample Programs
536SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
AddItems
The AddItems() method of the IOPCItemMgt interface creates OPC items and isdeclared as follows:
HRESULT AddItems (DWORD dwNumItems, OPCITEMDEF *pItemArray, OPCITEMRESULT **ppAddResults, HRESULT **ppErrors);
Parameter Description
dwNumItems Number of items to be inserted.
pItemArray Array with elements of the type OPCITEMDEF. Structurevariables of this type contain all the information required bythe server to create items.
ppAddResults Array with elements of the type OPCITEMRESULT. Thereturn values delivered by the OPC server are structurevariables of this type.
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if items could not be created success-fully or information about the successful method call.
Before calling AddItems, an array with elements of the type OPCITEMDEF mustbe created and initialized with valid values. When doing this, the followingsituations must be taken into account:
� An access path for the item is not necessary in the sample and an empty stringis specified here.
� The item identifier was specified at the start of the moduleOPCDA_SyncDlg.cpp and assigned to the variable szItemID.
� The item will be activated after it is created.
� The sample program uses a client handle of 1.
� The OPC Server for SIMATIC NET does not require “BinaryLargeObjects” andthe structure component dwBlobSize therefore has the value “0”.
� For the item, the server must deliver the return value in a type corresponding tothe original data type of the item.
m_Items[0].szAccessPath = L””;m_Items[0].szItemID = szItemID;m_Items[0].bActive = TRUE; m_Items[0].hClient = 1;m_Items[0].dwBlobSize = 0; m_Items[0].pBlob = NULL;m_Items[0].vtRequestedDataType = vtDataTypeItem;
Sample Programs
537SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The m_pItemResult pointer exists as a property of the COPCDA_SyncDlg class.The results returned by the server can be accessed using this variable. m_pErrorsis a pointer to the error code:
r1 = m_pIOPCItemMgt->AddItems(1, m_Items, &m_pItemResult,&m_pErrors);
If the AddItems call was not successful, the program is aborted. First, however, theprogram must release the resources it is using:
if ( (r1 != S_OK) && (r1 != S_FALSE) ){ MessageBox(”AddItems failed!”, ”Error AddItems()”, MB_OK+MB_ICONERROR); m_pIOPCItemMgt->Release(); m_pIOPCItemMgt = NULL; m_GrpSrvHandle = NULL; m_pIOPCServer->Release(); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return;}
GetErrorString
If the return value of AddItems() indicates that an error has occurred, theGetErrorString() method of the “IOPCServer” interface gets the correspondingerror message. This method is declared as follows:
HRESULT GetErrorString (HRESULT dwError, LCID dwLocale, LPWSTR *ppString);
Parameter Description
dwError Error code returned by the server
dwLocale The language identifier for the error message
ppString Double pointer to a null-terminated string to which GetEr-rorString returns the error message
else{ m_pIOPCServer ->GetErrorString(m_pErrors[0], LOCALE_ID, &ErrorStr); sprintf(str, ”%ls\n”, ErrorStr); MessageBox(str, “Result AddItems()”, MB_OK+MB_ICONEXCLAMATION);}
Sample Programs
538SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
QueryInterface
The QueryInterface() method of the “IUnknown” interface returns a pointer to aninterface whose identifier is specified as the input parameter. QueryInterface() isdeclared as follows:
HRESULT QueryInterface (REFIID iid, void **ppvObject);
Parameter Description
iid Identifier of the required interface
ppvObjekt Address of the pointer variable containing the required in-terface pointer if the method call is successful. If the objectdoes not support this interface, an error code and the NULLpointer are returned.
QueryInterface gets a pointer to the IOPCSyncIO interface that provides methodsfor synchronous reading and writing:
r1 = m_pIOPCItemMgt->QueryInterface(IID_IOPCSyncIO, (void**)&m_pIOPCSyncIO);if (r1 < 0){ MessageBox(”No IOPCSyncIO found!”, ”Error QueryInterface()”, MB_OK+MB_ICONERROR); CoTaskMemFree(m_pItemResult); m_pIOPCItemMgt->Release(); m_pIOPCItemMgt = NULL; m_GrpSrvHandle = NULL; m_pIOPCServer->Release(); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return;}
Enabling Buttons
Once OnButtonStart() has set up all necessary OPC objects, it disables the “StartSample” button. All other buttons are enabled. This strategy ensures thatOnButtonStart() is executed once only. This saves additional queries in theprogram.
m_CtrlStop.EnableWindow(TRUE);m_CtrlRead.EnableWindow(TRUE);m_CtrlWrite.EnableWindow(TRUE);m_CtrlStart.EnableWindow(FALSE);
Sample Programs
539SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The OPCITEMDEF Structure
OPCITEMDEF has the following structure:
typdef struct { LPWSTR szAccessPath; LPWSTR szItemID; BOOL bActive; OPCHANDLE hClient; DWORD dwBlobSize; BYTE *pBlob; VARTYP vtRequestedDataType; Word wReserved;} OPCITEMDEF;
Variables of OPCITEMDEF
Variable Description
szAccessPath Optional access path for the items (not required by SIMATIC NET)
szItemID ItemID assigned by the client
bActive TRUE if the client will be notified if there is a valuechange of the item in an active group; FALSE if theclient will not be notified.
hClient Handle for an item assigned by the client. The ser-ver transfers the client handle with calls to the client(for example, OnDataChange) so that the client canaccess the relevant variables in its structures.
dwBlobSize Size of a memory area on the server in which addi-tional information for faster access to the data of anitem is stored.
pBlob Pointer to the memory area described above
vtRequestedDataType Data type requested by the client
Sample Programs
540SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The OPCITEMRESULT Structure
OPCITEMRESULT has the following structure:
typdef struct { OPCHANDLE hServer; VARTYPE vtCanonicalDataType; WORD wReserved; DWORD dwAccessRights; DWORD dwBlobSize; BYTE *pBlob;} OPCITEMRESULT;
Variables of OPCITEMRESULT
Variable Description
hServer A handle for an item assigned by the server. Theclient transfers the server handle with calls to theserver so that the server can access the relevantvariables in its structures.
vtCanonicalDataType The data type used by the server for an itemdwAccessRights Information about whether an item can only be read,
only be written, or read and written.dwBlobSize Size of a memory area on the server in which addi-
tional information for faster access to the data of anitem is stored.
pBlob Pointer to the memory area described above
7.4.7 OnRead
OnRead executes a synchronous read job. The following operations are executed:
Variable Declaration
First, several local variables are declared:
void COpcSyncDlg::OnRead() { OPCHANDLE *phServer; OPCITEMSTATE *pItemValue; HRESULT *pErrors; HRESULT r1; LPWSTR ErrorStr; char str[100]; UINT qnr;
Sample Programs
541SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The server handle of the item for which the value will be read is required as aparameter for the Read() method. This identification number assigned by theserver exists in the “hServer” component of the pItemResult[0] global variable. TheAddItem() method enters its return values in this structure variable of the typeOPCITEMRESULT.
phServer = new OPCHANDLE[1];phServer[0] = m_pItemResult[0].hServer;
Read
Read reads values for OPC items synchronously. This method is declared asfollows:
HRESULT Read (OPCDATASOURCE dwSource, DWORD dwNumItems, OPCHANDLE *phServer, OPCITEMSTATE **ppItemValues, HRESULT **ppErrors);
Parameter Description
dwSource Data source. If you use OPC_DS_CACHE, the data is readfrom the cache of the OPC server; with OPC_DS_DEVICE,a read job is executed over the network.
dwNumItems Number of items for which values are read.
phServer Array with server handles
ppItemValues Array with elements of the type “OPCITEMSTATE” for theread values and additional information about the read job.
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if Read() could not be called success-fully or information about the successful method call.
Read is called with the previously initialized variables as parameters:
r1 = m_pIOPCSyncIO->Read(OPC_DS_DEVICE, 1, phServer,&pItemValue, &pErrors);
The Read method provides the values that were read and additional information inthe pItemValue array. If the read is successful, these data are displayed in therelevant text boxes of the main dialog box:
if (r1 == S_OK){ m_ReadValue = pItemValue[0].vDataValue.lVal; qnr = pItemValue[0].wQuality; m_szReadQuality = GetQualityText(qnr); m_szTimeStamp = COleDateTime(pItemValue[0].ftTimeStamp).Format(); UpdateData(FALSE);}
Sample Programs
542SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The return value S_FALSE indicates that an error code was entered in the pErrorsarray. GetErrorString gets the corresponding error message that is displayed in adialog box:
if (r1 == S_FALSE){ m_pIOPCServer->GetErrorString(pErrors[0], LOCALE_ID, &ErrorStr); sprintf(str, ”%S\n”, ErrorStr); MessageBox(str, ”Error Read()”, MB_OK+MB_ICONERROR);}
If there are no error messages and the method call was not successful, a suitabledialog box is displayed. Finally, the resources used by Read are released:
if (FAILED(r1)){ MessageBox(”Read failed!”, ”Error Read()”, MB_OK+MB_ICONERROR);}else{ CoTaskMemFree(pErrors); CoTaskMemFree(pItemValue);}
The OPCITEMSTATE Structure
typdef struct { OPCHANDLE hClient; FILETIME ftTimeStamp; WORD wQuality; WORD wReserved; VARIANT vDataValue; } OPCITEMSTATE;
Variables of OPCITEMSTATE
Variable Description
hClient The client handle of the item
ftTimeStamp Time stamp (time at which the data were received from theOPC server)
wQuality Information on the integrity of the data
vDataValue The value read for the item
Sample Programs
543SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.4.8 OnWrite
OnWrite executes a synchronous write job. The following operations are executed:
Variable Declaration
First, several local variables are declared:
void COpcSyncDlg::OnWrite() { OPCHANDLE *phServer; HRESULT *pErrors; VARIANT values[1]; HRESULT r1; LPWSTR ErrorStr; CString szOut;
The server handle of the item for which the value will be written is required as aparameter for the Write method. This identification number assigned by the serverexists in the “hServer” component of the m_pItemResult[0] global variable. TheAddItems method enters its return values in this structure variable of the typeOPCITEMRESULT:
phServer = new OPCHANDLE[1];phServer[0] = m_pItemResult[0].hServer;
The values variable is intended for storing the value to be written. The UpdateDatamethod of the CWnd class transfers the content of all controls to the relevantmember variables. This initializes the iVal component of the values structurevariable. ”2-byte integer” is specified as the data type:
UpdateData(TRUE);values[0].vt = VT_I2;values[0].iVal = m_WriteValue;
Write
Write writes values for OPC items synchronously. This method is declared asfollows:
HRESULT Write (DWORD dwNumItems, OPCHANDLE *phServer, VARIANT *pItemValues, HRESULT **ppErrors);
Parameter Description
dwNumItems Number of items for which values are written.
phServer Array with server handles
Sample Programs
544SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
pItemValues Array with the values to be written
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if Write() could not be called successfullyor information about the successful method call.
Write is called with the previously initialized variables as parameters:
r1 = m_pIOPCSyncIO->Write(1, phServer, values, &pErrors);
GetErrorString gets the error message belonging to the pErrors return value that isassigned to the member variable m_WriteRes. GetErrorString, however, adds twospecial characters for the line break that must be removed before display in a textbox.
Finally, the resources used by Write are released:
delete [] phServer;if (FAILED(r1)){ szOut.Format(”Method call IOPCSyncIO::Write \ failed with error code %x”, r1); MessageBox(szOut, ”Error Writing Item”, MB_OK+MB_ICONERROR); } else { m_pIOPCServer->GetErrorString(pErrors[0], LOCALE_ID, &ErrorStr); m_szWriteResult = ErrorStr; m_szWriteResult.Remove(’\r’); m_szWriteResult.Remove(’\n’); UpdateData(FALSE); CoTaskMemFree(pErrors); }
7.4.9 OnStop
OnStop removes the OPC objects used in the program and releases thecorresponding resources. This method is called when the “Stop Sample” button isclicked, the OnDestroy method is executed or the WM_CLOSE message is sent(after clicking the button to close the dialog box or explicitly by callingSendMessage).
The resources are released in several steps:
� RemoveItems
� RemoveGroup
� Release
� CoUninitialize
Sample Programs
545SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
RemoveItems
The RemoveItems method of the IOPCItemMgt interface removes OPC items andis declared as follows:
HRESULT RemoveItems (DWORD dwCount, OPCHANDLE *phServer, HRESULT **ppErrors);
Parameter Description
dwCount Number of items to be removed
phServer Array with the server handles of the items to be removed
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if “RemoveItems()” could not be calledsuccessfully or information about the successful methodcall.
void COpcSyncDlg::OnStop() { HRESULT r1; OPCHANDLE *phServer; HRESULT *pErrors; LPWSTR ErrorStr; char str[100];
phServer = new OPCHANDLE[1]; phServer[0] = m_pItemResult[0].hServer; r1 = m_pIOPCItemMgt->RemoveItems(1, phServer, &pErrors); if ( (r1 != S_OK) && (r1 != S_FALSE) ) { MessageBox(”RemoveItems failed!”, ”Error RemoveItems()”, MB_OK+MB_ICONERROR); } else { m_pIOPCServer->GetErrorString(pErrors[0], LOCALE_ID, &ErrorStr); sprintf(str, ”%ls\n”, ErrorStr); MessageBox(str, ”Result RemoveItems()”, MB_OK+MB_ICONEXCLAMATION); }
RemoveGroup
RemoveGroup() removes a group from the server and is declared as follows:
HRESULT RemoveGroup (OPCHANDLE hServerGroup, BOOL bForce );
Sample Programs
546SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
hServerGroup Server handle of the group to be removed.
bForce Specifies whether or not a group can be removed whenthere is still a reference to it.
r1=m_pIOPCServer->RemoveGroup(m_GrpSrvHandle, TRUE);if (r1 != S_OK){ MessageBox(”RemoveGroup failed!”, ”Error Remove Group()”, MB_OK+MB_ICONERROR);}
Release
The IOPCServer and IMalloc interfaces have the Release method with which theyrelease the resources used by the interface:
m_pIOPCSyncIO->Release();m_pIOPCSyncIO = NULL;m_pIOPCItemMgt->Release();m_pIOPCItemMgt = NULL;m_pIOPCServer->Release();m_pIOPCServer = NULL;
In addition to this, all other requested resources must be released again:
delete[] phServer; CoTaskMemFree(pErrors);CoTaskMemFree(m_pItemResult);m_pItemResult=NULL;CoTaskMemFree(m_pErrors);m_pErrors = NULL;m_GrpSrvHandle = NULL;
All buttons apart from “Start Sample” are made inactive:
m_CtrlStart.EnableWindow(TRUE);m_CtrlRead.EnableWindow(FALSE);m_CtrlStop.EnableWindow(FALSE);m_CtrlWrite.EnableWindow(FALSE);
CoUninitialize
The CoUninitialize method closes the COM library and releases all resources ofthe thread:
CoUninitialize(); }
Sample Programs
547SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.4.10 DestroyWindow
This method of the CWnd class is overwritten so that all the clean up jobs can bedone when the dialog window is closed. OnButtonStop() deletes all the OPCobjects and releases the corresponding resources. Following this, DestroyWindowof the parent class is called to release the memory used by the window object:
BOOL COPCDA_SyncDlg::DestroyWindow(){ if (m_pIOPCServer) OnStop(); return CDialog::DestroyWindow();}
7.4.11 GetQualityText
GetQualityText provides a CString object as an error message for a specified errorcode:
CString GetQualityText(UINT qnr){ CString qstr; switch(qnr) { case OPC_QUALITY_BAD: qstr = ”BAD”; break; case OPC_QUALITY_UNCERTAIN: qstr = ”UNCERTAIN”; break; case OPC_QUALITY_GOOD: qstr = ”GOOD”; break; case OPC_QUALITY_NOT_CONNECTED: qstr = ”NOT_CONNECTED”; break; case OPC_QUALITY_DEVICE_FAILURE: qstr = ”DEVICE_FAILURE”; break; case OPC_QUALITY_SENSOR_FAILURE: qstr = ”SENSOR_FAILURE”; break; case OPC_QUALITY_LAST_KNOWN: qstr = ”LAST_KNOWN”; break; case OPC_QUALITY_COMM_FAILURE: qstr = ”COMM_FAILURE”; break; case OPC_QUALITY_OUT_OF_SERVICE: qstr = ”OUT_OF_SERVICE”;
Sample Programs
548SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
break; case OPC_QUALITY_LAST_USABLE: qstr = ”LAST_USABLE”; break; case OPC_QUALITY_SENSOR_CAL: qstr = ”SENSOR_CAL”; break; case OPC_QUALITY_EGU_EXCEEDED: qstr = ”EGU_EXCEEDED”; break; case OPC_QUALITY_SUB_NORMAL: qstr = ”SUB_NORMAL”; break; case OPC_QUALITY_LOCAL_OVERRIDE: qstr = ”LOCAL_OVERRIDE”; break; default: qstr = ”UNKNOWN ERROR”; } return qstr; }
7.4.12 Notes on Writing your own Programs
Several requirements must be met before your own programs can use the Custominterface. Follow the steps outlined below:
Step Description
1 Start the Visual C++ development environment.
2 Create a project of the required type using the MFC Class Wizard.
3 Copy the files pre_opc.h and pre_opc.cpp from the sample programinto your project folder and add these files to the project (Projectmenu > Add To Project > Files ...). These files contain OPC-specificdefinitions and include statements.
4 Add the statement #include “pre_opc.h” to all the implementationfiles of your project (extension .cpp):
5 In the implementation files (extension .cpp) that use theAddGroup() or GetErrorString() methods, add the followingstatement:#define LOCALE_ID 0x409
6 Arrange the required operator interface elements in the main dialogor create a suitable application window and program thecorresponding event procedures.
Sample Programs
549SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.5 Sample Program for the OPC Custom Interface(Asynchronous Communication)
This sample uses the Custom Interface for Data Access V2.0 from OPC.
7.5.1 Activating the Simulation Connection
Before you can run this program, you must activate a simulation connection thatmakes the demonstration variables used in the program available:
Step Description
1 Start the “Configuration Console” program in the Start menu:Start -> SIMATIC -> SIMATIC NET -> Settings -> Configura-tion Console
2 In the left-hand navigation window, open the property page forthe simulation module by expanding SIMATIC NET Configuration -> Modulesand click on the “CP Simulation” icon
3 Click the check box for the protocol you want to simulate.This example uses the S7 protocol. So you should click on “S7”.
4 Close the “Configuration Console” program.
Note
Before the changes take effect, you must first close all OPC clients!
Sample Programs
550SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.5.2 Working with the Sample Program
The program includes several elements that the operator can use to trigger thefollowing actions:
Operator Element Effect
Start Sample Start program
Read or Write Item 0 Read and write values
Group Active Activate or deactivate group
Stop Sample Stop the program
7.5.3 Start Program
The program is on your hard disk in <installationpath>\SIEMENS\SIMATIC.NET\opc2\samples\custom\async.
When you start the program, only the “Start Sample” button is enabled. After youhave clicked this button, the program generates the required OPC objects. You canthen use the other buttons.
Sample Programs
551SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.5.4 Read and Write Values
After you click the “Read Item 0” button, the value that was read and statusinformation is displayed in the relevant text boxes. As it stands, the sampleprogram is designed to operate with a demonstration connection. If you want to runthe sample program in a real environment, you must change the following lines inthe OPCDA_AsyncDlg.cpp program:
const LPWSTR szItemID0 = L”S7:[DEMO]MB1”;
const LPWSTR szItemID1 = L”S7:[DEMO]MW1”;
To write a value, you enter it in the “Value” text box and click the “Write Item 0”button. The program displays a message about the result of the write operation:
Sample Programs
552SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.5.5 Activate Group
Asynchronous operations do not return a result directly (for example as a functionresult or return parameter) but make use of events.
You can activate the OPC group in the sample program by selecting the “GroupActive” check box. Among other things, the “OnDataChange” event is generated. Aprocedure that executes when this event occurs, displays values and statusinformation in the text boxes of “OnDataChanged”:
Events for completion of write or read operations are also generated by inactivegroups. This means that results can also be displayed for writes and reads even ifthis check box is not selected.
Sample Programs
553SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.5.6 Stop the Program
The “Stop Sample” button stops the program. All OPC objects are deleted and thecorresponding resources are released.
7.5.7 How the Program Runs
Due to the class model of OPC, a specific order must be adhered to in the methodcalls of OPC objects. To be able to create an instance of the “OPCItem” class, anobject of the “OPCGroup” class is necessary. This is, however, only possible whenan instance of the “OPCServer” class exists and a connection to this server hasbeen established.
The basic sequence of instructions for creating and deleting OPC objects isillustrated in the following graphic. The variable names of the sample program areused:
Sample Programs
554SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The sample program contains all the components that would normally exist in atypical client application. These include establishing the connection to the OPCserver, creating a group with variables, and reading and writing values for an item.Before describing the source code in detail, we will first have a look at the basicstructure of an OPC application.
Step Description
1 Register with COM
2 Convert the ProgID to a CLSID
3 Establish connection to the OPC server
4 Create an OPC group
5 Adding Items
6 Request an interface pointer for IOPCGroupStateMgt
7 Request an interface pointer for IOPCAsyncIO2
8 Create callback object
9 Connect OPC server and callback object of the client
10 Execute required write and read operations
11 Receive notifications of the OPC server
12 Delete objects and release memory
Step 1: Register with COM
Each program that wants to use functions of the COM library must first registeritself with COM. This is the purpose of the CoInitialize function:
HRESULT r1; r1 = CoInitialize(NULL);
Step 2: Convert the ProgID to a CLSID
To identify it, each COM server has a “ProgID” that is assigned to a worldwideunique “CLSID”. This is obtained with the CLSIDFromProgID() function. TheProgID of the OPC Server of SIMATIC NET is L”OPC.SimaticNET”:
r1 = CLSIDFromProgID(L”OPC.SimaticNET”, &clsid);
Sample Programs
555SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 3: Establish the connection to the OPC server
The CoCreateInstance() function creates an instance of the class whose “CLSID”was specified.
r1 = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER,IID_IOPCServer, (void**)&m_pIOPCServer);
The result of this program section is an object of the OPC server class.CoCreateInstance also provides a pointer to the IOPCServer interface of theserver object (m_pIOPCServer variable):
Step 4: Create an OPC group
The IOPCServer interface has the AddGroup() method for creating groups:
HRESULT r1;r1 = m_pIOPCServer ->AddGroup(L”grp1”, FALSE, 500, 1,&TimBias, &PercentDeadband, LOCALE_ID, &m_GrpSrvHandle,&RevisedUpdateRate, IID_IOPCItemMgt,(LPUNKNOWN*)&m_pIOPCItemMgt);
The result of this program section is a group with the specified name and therequired properties. AddGroup also returns a pointer to a requested interface of thegroup object as a return parameter, in this case, IOPCItemMgt (m_pIOPCItemMgtvariable):
Sample Programs
556SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 5: Add items
The IOPCItemMgt interface has the AddItems() method for creating OPC items:
HRESULT r1;r1 = m_pIOPCItemMgt->AddItems(2, m_Items, &m_pItemResult, &m_pErrors);
The result of this program section is that the server adds two items with theproperties specified in the m_Items parameter. The variables of the result structurem_pItemResult (server handle, data type of the item on the target system etc.) areinitialized.
Step 6: Request an interface pointer for IOPCGroupStateMgt
A pointer to the IOPCGroupStateMgt interface is necessary to allow use of theSetState methods. The SetState method is required later to activate anddeactivate a group. This interface pointer is also required as a parameter for theAtlAdvise and AtlUnadvise methods:
HRESULT r1; r1 = m_pIOPCItemMgt->QueryInterface(IID_IOPCGroupeStateMgt, (void**) &m_pIOPCGroupStateMgt);
The result of this program section is a pointer to the IOPCGroupStateMgt interface(m_pIOPCGroupStateMgt variable) of the group object:
Sample Programs
557SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 7: Request an interface pointer for IOPCAsyncIO2
In the same way, the program also requests the pointer to the IOPCAsyncIO2interface(m_pIOPCAsyncIO2 variable). This interface provides methods forasynchronous reading and writing of values:
r1 = m_pIOPCItemMgt ->QueryInterface(IID_IOPCAsyncIO2,(void**) &m_pIOPCAsyncIO2);
Step 8: Create callback object
To allow the OPC server to return a result of asynchronous operations, theIOPCDataCallback interface must be implemented on the client. In the sampleprogram, this is handled by the COPCDataCallback class that is derived fromIOPCDataCallback and CComObjectRoot.
The CreateInstance method creates an object of the CComObject template class:
CComObject<COPCDataCallback>* pCOPCDataCallback;CComObject<COPCDataCallback>::CreateInstance&pCOPCDataCallback);
Sample Programs
558SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 9: Connect the OPC server and callback object of the client
The AtlAdvise() method creates a connection between the OPC server and thecallback object. The GetUnknown() method first gets a pointer to the IUnknowninterface of the callback object: AtlAdvise requires this pointer as an inputparameter:
LPUNKNOWN pCbUnk;pCbUnk = pCOPCDataCallback->GetUnknown();HRESULT hRes = AtlAdvise(m_pIOPCGroupStateMgt, pCbUnk,IID_IOPCDataCallback, &m_dwAdvise);
Step 10: Execute the required write or read operationRead Operation
The Read() and Write() methods of the IOPCAsyncIO2 interface can be accessedvia the m_pIOPCAsyncIO2 pointer that was created in step 7:
r1 = m_pIOPCAsyncIO2->Read(1, phServer, 1, &dwCancelID, &pErrors);
Sample Programs
559SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 11: Receive notifications of the OPC server
If the data of an active item in an active group changes, the server calls theOnDataChange method of the callback object. On completion of a read operation,the server calls the method OnReadComplete() etc. The server transfers the returnvalues as a parameter to the relevant method.
STDMETHODIMP COPCDataCallback:: OnDataChange(WORD dwTransid,OPCHANDLE hGroup,HRESULT hrMasterquality,RESULT hrMastererror,DWORD dwCount,OPCHANDLE __RPC_FAR *phClientItems,VARIANT __RPC_FAR *pvValues,WORD __RPC_FAR *pwQualities,FILETIME __RPC_FAR *pftTimeStamps,HRESULT __RPC_FAR *pErrors)
Step 12: Delete objects and release memory
Before exiting the program, the OPC objects that have been created must bedeleted and the memory reserved for them must be released. The relevantfunctions are integral parts of the previously used interfaces. AtlUnadviseterminates the connection between the OPC server and the callback object:
HRESULT hRes = AtlUnadvise(m_pIOPCGroupStateMgt,IID_IOPCData-Callback, m_dwAdvise);m_pIOPCGroupStateMgt->Release();. . .r1 = m_pIOPCItemMgt->RemoveItems(2, phServer, &pErrors);. . .CoTaskMemFree(pErrors);CoTaskMemFree(m_pItemResult);m_pItemResult=NULL;. . .. . .
Sample Programs
560SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Releasing Memory
When using COM, it is sometimes necessary for the client to release memory thatwasrequested by the server.
The rules for this are as follows:
� [out]: The memory for a parameter with this attribute will be requested from theserver.
� [in, out]: The memory for such a parameter will be requested from the client.The server can release the memory again and reallocate it.
� [in]: The client will request the memory. The server is not responsible forreleasing the memory.
In all three cases, the reserved memory will effectively be released by the client.
7.5.8 Description of the Program Structure
This description explains the content of the following two files:
� OPCDA_AsyncDlg.cpp is the implementation file of the program-specific dialogbox class. Here, you will find the event procedures for the various buttons. Theirbodies may have been created by the MFC Class Wizard. The methods forinitializing the dialog box and for displaying the data are also defined here.
� Callback.cpp is the implementation file of the program-specific callback class.All the methods that must be provided by a client so that it can receivenotifications from an OPC server are defined in this module.
7.5.9 The OPCDA_AsyncDlg.cpp File
The OPCDA_AsyncDlg.cpp file can be divided into the following sections:
� Declaration of global variables
� The CAboutDlg Class
� Methods of the COPCDA_AsyncDlg.cpp Class
Sample Programs
561SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Declaration of the Global Variables for Storing the Item IDs
At the start of this module, two variables are initialized with the item identifiers:
const LPWSTR szItemID0 = L”S7:[DEMO]MB1”;const LPWSTR szItemID1 = L”S7:[DEMO]MW1”;
For the functionality of the program, it is important that the first variable can beboth read and written, whereas it is adequate if the second variable can be read.
You can refer to several examples and the manual for more information on thestructure of the item IDs.
If you select two variables that overlap in the memory map, both variables willchange when you write to one of them.
The CAboutDlg Class
Following this, the CAboutDlg class is defined that displays an information box.Since there is no OPC-specific code in this class, it will not be described in anydetail.
Methods of the COPCDA_AsyncDlg Class
The COPCDA_AsyncDlg class has the following methods in addition to theconstructor and destructor:
� DoDataExchange
� OnInitDialog
� OnSysCommand
� OnPaint
� OnQueryDragIcon
� OnButtonStart()
� OnButtonRead()
� OnButtonWrite()
� OnCheckActivategroup()
� OnButtonStop()
� OnDestroy
� DisplayData
� UpdateData
Sample Programs
562SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OnInitDialog
There are several class variables available for access to COM mechanisms thatare initialized when the main dialog box is initialized. These variables can be put tothe following uses:
� m_pIOPCServer is a pointer to the IOPCServer interface of the OPC serverclass.
� m_pIOPCItemMgt is a pointer to the IOPCItemMgt interface of the OPC groupclass.
� m_pIOPCGroupStateMgt is a pointer to the IOPCGroupStateMgt interface ofthe OPC group class.
m_pIOPCServer = NULL;m_pIOPCItemMgt = NULL;m_pIOPCGroupStateMgt = NULL;
At the start of the program, the user can only click the “Start Sample” button. Allother buttons and the check box are disabled. This makes sure that all requiredOPC objects are set up correctly before write or read operations are executed.
A member variable was assigned to the relevant controls with which the status canbe changed:
m_CtrlStop.EnableWindow(FALSE);m_CtrlRead.EnableWindow(FALSE);m_CtrlWrite.EnableWindow(FALSE);m_CtrlChkActive.EnableWindow(FALSE);
OnButtonStart()
OnButtonStart() sets up the OPC objects required for running the program. First,several local variables are declared that are required for the methods of the OPCobjects.
void COPCDA_AsyncDlg::OnButtonStart() { HRESULT r1; CLSID clsid; LONG TimBias = 0; FLOAT PercentDeadband = 0.0; DWORD RevisedUpdateRate; LPWSTR ErrorStr1,ErrorStr2; Cstring szErrorText; m_pItemResult = NULL; ...
Sample Programs
563SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Then the following operations are executed:
CoInitialize
CoInitialize() initializes the COM library. The input parameter must always be“NULL”.
r1 = CoInitialize(NULL);if (r1 != S_OK){ if (r1 == S_FALSE) { MessageBox(”COM Library already initialized”, ”Error CoInitialize()”, MB_OK+MB_ICONEXCLAMATION); } else { szErrorText.Format(”Initialisation of COM Library \ failed. ErrorCode= %4x”, r1); MessageBox(szErrorText, ”Error CoInitialize()”, MB_OK+MB_ICONERROR); SendMessage(WM_CLOSE); return; }}
CLSIDFromProgID
CLSIDFromProgID() retrieves a worldwide unique class identifier or CLSID from aspecified ProgID. This is required for the CoCreateInstance function.
This method is declared as follows:
HRESULT CLSIDFormProgID(LPCOLESTR lpszProgID, LPCLSID pclsid);
Parameter Description
lpszProgID Pointer to the ProgID [input parameter]
pclsid Pointer to the retrieved class identifier [return value]
In the sample program, this method retrieves the class identifier of the OPC Serverof SIMATIC NET:
r1 = CLSIDFromProgID(L”OPC.SimaticNET”, &clsid);if (r1 != S_OK){ MessageBox(”Retrival of CLSID failed”, ”Error CLSIDFromProgID()”, MB_OK+MB_ICONERROR); CoUninitialize(); SendMessage(WM_CLOSE); return;}
Sample Programs
564SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
CoCreateInstance
CoCreateInstance() creates an instance of the class whose class identifier wasspecified. This method is declared as follows:
STDAPI CoCreateInstance (REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv);
Parameter Description
rclsid The class identifier of the required object
pUnkOuter NULL pointer if the object to be created is not part of an ag-gregated object. A pointer that is not a NULL pointer is in-terpreted as a pointer to the IUnknown interface of the ag-gregated object.
dwClsContext Describes the runtime environment of the object to be crea-ted. This specifies whether or not the executable code thatcreates and manages objects of this class runs on the localmachine and whether a separate process will be created forit. The constants that can be used for this are specified inthe CLSCTX enumerated data type. In the sample,CLSCTX_LOCAL_SERVER is used; in other words, theexecutable code for managing the server objects runs onthe same computer as the sample program but in its ownprocess.
riid Identifier of the interface over which communication with theobject will take place, in the sample program “IOPCServer”.
ppv Address of the pointer variable containing the required inter-face pointer if the method call is successful.
The following method call creates an object of the OPC server class and returns apointer to the IOPCServer interface:
r1 = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IOPCServer, (void**)&m_pIOPCServer);if (r1 != S_OK){ MessageBox(”Creation of IOPCServer-Object failed”, ”Error CoCreateInstance()”, MB_OK+MB_ICONERROR); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return;}
Sample Programs
565SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
AddGroup
The AddGroup() method of the IOPCServer creates an OPC group and is declaredas follows:
HRESULT AddGroup (LPWCSTR szName, BOOL bActive, DWORD dwRequestedUpdateRate, OPCHANDLE hClientGroup, LONG *pTimeBias, FLOAT *pPercentDeadband, DWORD dwLCID, OPCHANDLE *phServerGroup, DWORD *pRevisedUpdateRate, REFIID riid, LPUNKNOWN *ppUnk);
Parameter Description
szName Group name that can be assigned freely by theclient but must be unique within the client.
bActive FALSE if the group is to be inactive when it iscreated.TRUE if the group is to be active when itis created.
dwRequestedUpdateRate Specifies the shortest interval after which a clientwill be informed of changes to values or states ofitems. Specifying a suitable interval prevents in-formation being sent to a client more quickly thanit can process it.
hClientGroup Code number that can be selected freely by theclient and that is returned by the server with cer-tain notifications. This allows the client to identifyits data. The client identifies the group with thishandle.
pTimeBias Deviation of the server time from UTC (UniversalTime Convention)
pPercentDeadband Specifies the deadband within which value chan-ges do not lead to notification. This property is,however, only effective when you use analog va-lues. The high and low limits of a value must alsobe known.In this sample program, this is not thecase (see OPC Data Access Spec. 1.1, Section4.4.1.6.)
Sample Programs
566SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
dwLCID Selects the language to be used by the serverwhen returning texts.
phServerGroup Handle assigned by the server that must be spe-cified as a parameter with certain function calls(for example, “RemoveGroup”). The server requi-res this to identify this group.
pRevisedUpdateRate Shortest interval returned by the server afterwhich a client will be informed of changes to va-lues or states of items.
riid Pointer to the identifier of one of the interfaces ofthe OPC group object that will be available afterthe group is created. This parameter saves callingthe “QueryInterface” method extra.
ppUnk Pointer to the required interface.
When AddGroup is called in the sample program, the following settings are made:
� The bActive parameter is set to the value FALSE. Directly after it is created, thegroup is inactive; in other words, no OnDataChange callbacks are generated forthis group.
� The duration of the required update interval is 500 milliseconds.
� Any client handle can be specified since only one group is being used.
� In the sample program, there is no provision for suppressing notification ofvalue changes within a specific range. The value “0.0” is therefore entered forthe pPercentDeadband parameter.
� AddGroup will return a pointer to the IOPCItemMgt interface as the returnvalue.
r1 = m_pIOPCServer->AddGroup(L”grp1”, FALSE, 500, 1, &TimBias, &PercentDeadband, LOCALE_ID, &m_GrpSrvHandle, &RevisedUpdateRate, IID_IOPCItemMgt, (LPUNKNOWN*)&m_pIOPCItemMgt);
Sample Programs
567SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
AddItems
The AddItems() method of the IOPCItemMgt interface creates OPC items and isdeclared as follows:
HRESULT AddItems (DWORD dwNumItems, OPCITEMDEF *pItemArray, OPCITEMRESULT **ppAddResults, HRESULT **ppErrors);
Parameter Description
dwNumItems Number of items to be inserted.
pItemArray Array with elements of the type OPCITEMDEF. Structurevariables of this type contain all the information required bythe server to create items.
ppAddResults Array with elements of the type OPCITEMRESULT. Thereturn values delivered by the OPC server are structurevariables of this type.
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if items could not be created success-fully or information about the successful method call.
Before calling AddItems, an array with elements of the type OPCITEMDEF mustbe created and initialized with valid values. When doing this, the followingsituations must be taken into account:
� An access path for the item is not necessary in the sample and an empty stringis specified here.
� The item identifiers were specified at the start of the moduleOPCDA_AsyncDlg.cpp and assigned to the variables szItemID1 andszItemID2.
� The item will be activated after it is created.
� The sample program uses a client handle of 0 and 1.
� The OPC Server for SIMATIC NET does not require “BinaryLargeObjects” andthe structure component dwBlobSize therefore has the value “0”.
� For the first item, the server must deliver the return value in a typecorresponding to the original data type of the item.
� For the second item, the server must deliver the return value as a two-byteinteger.
m_Items[0].szAccessPath = L””; m_Items[0].szItemID = szItemID1; m_Items[0].bActive = TRUE; m_Items[0].hClient = 0; m_Items[0].dwBlobSize = 0; m_Items[0].pBlob = NULL; m_Items[0].vtRequestedDataType = 0; m_Items[1].szAccessPath = L””;
Sample Programs
568SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
m_Items[1].szItemID = szItemID2; m_Items[1].bActive = TRUE; m_Items[1].hClient = 1; m_Items[1].dwBlobSize = 0; m_Items[1].pBlob = NULL; m_Items[1].vtRequestedDataType = VT_I2;
The m_pItemResult pointer exists as a property of the COPCDA_AsyncDlg class.The results returned by the server can be accessed using this variable. m_pErrorsis a pointer to the error code:
r1 = m_pIOPCItemMgt->AddItems(2, m_Items, &m_pItemResult,&m_pErrors);
If the AddItems call was not successful, the program is aborted. First, however, theprogram must release the resources it is using:
if ( (r1 != S_OK) && (r1 != S_FALSE) ){ MessageBox(”AddItems failed!”, ”Error AddItems()”, MB_OK+MB_ICONERROR); m_pIOPCItemMgt->Release(); m_pIOPCItemMgt = NULL; m_GrpSrvHandle = 0; m_pIOPCServer->Release(); m_pIOPCServer = NULL; CoUninitialize(); SendMessage(WM_CLOSE); return;}
GetErrorString
If the return value of AddItems() indicates that an error has occurred, theGetErrorString() method of the “IOPCServer” interface gets the correspondingerror message. This method is declared as follows:
HRESULT GetErrorString (HRESULT dwError, LCID dwLocale, LPWSTR *ppString);
Parameter Description
Parameter Description
dwError Error code returned by the server
dwLocale The language identifier for the error message
ppString Double pointer to a null-terminated string to which GetEr-rorString returns the error message
Sample Programs
569SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
else{ m_pIOPCServer ->GetErrorString(m_pErrors[0], LOCALE_ID, &ErrorStr1); m_pIOPCServer ->GetErrorString(m_pErrors[1], LOCALE_ID, &ErrorStr2); CString szOut; szOut.Format(”Item %ls :\n %ls\n\nItem %ls :\n %ls\n”, szItemID0, ErrorStr1, szItemID1, ErrorStr2); MessageBox(szOut, ”Result AddItems()”, MB_OK+MB_ICONEXCLAMATION);}
QueryInterface
The QueryInterface() method of the “IUnknown” interface returns a pointer to aninterface whose identifier is specified as the input parameter. QueryInterface() isdeclared as follows:
HRESULT QueryInterface (REFIID iid, void **ppvObject);
Parameter Description
Parameter Description
iid Identifier of the required interface
ppvObjekt Address of the pointer variable containing the required in-terface pointer if the method call is successful. If the objectdoes not support this interface, an error code and the NULLpointer are returned.
QueryInterface gets a pointer to the IOPCAsyncIO2 interface that providesmethods for asynchronous reading and writing:
r1 = m_pIOPCItemMgt ->QueryInterface(IID_IOPCAsyncIO2, (void**)& m_pIOPCAsyncIO2);if (r1 < 0){ MessageBox(”No IOPCAsyncIO found!”, ”Error QueryInterface()”, MB_OK+MB_ICONERROR); . . . return;}
Sample Programs
570SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Create callback object
The IOPCDataCallback interface must be implemented in the client program sothat notifications from the OPC server can be received. In the sample program, theimplementation makes use of the Active Template Library (ATL). TheCOPCDataCallback class specific to the sample is used as a parameter for theCComObject template class.
The CreateInstance method creates an object of the CComObject class that isaccessed via the pOPCDataCallback pointer:
CComObject<COPCDataCallback>* pCOPCDataCallback;CComObject<COPCDataCallback>::CreateInstance &pCOPCDataCallback);
Establish Connection between Dialog Box and Callback Object
OnButtonStart() calls the InformAboutDialog method of the dialog box class andpasses a pointer to the current dialog box to it (the this pointer). InformAboutDialog(in the Callback.cpp module) stores this pointer in the m_pCDlgClass membervariable.
OnReadComplete(), OnWriteComplete() and OnDataChange use this pointer tocall the DisplayData method of the dialog box. Without the information inm_pCDlgClass, there would be no reference to indicate the dialog box in which thedata are to be displayed.
pCOPCDataCallback->InformAboutDialog(this);
The relationship between the class methods of COPCDA_AsyncDlg andIOPCDataCallback is illustrated in the following graphic:
Connect OPC server and callback object of the client
The GetUnknown() method gets a pointer to the IUnknown interface of the callbackobject:
LPUNKNOWN pCbUnk; pCbUnk = pCOPCDataCallback->GetUnknown();
The AtlAdvise() method creates a connection between the OPC server and thecallback object. AtlAdvise is declared as follows:
Sample Programs
571SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
HRESULT AtlAdvise (IUnknown *pUnkCP, IUnknown *pUnk, const IID& iid, LPDWORD pdw)
Parameter Description
pUnkCP Pointer to the IUnknown interface to which the client wantsto establish a connection.
pUnk Pointer to the IUnknown interface of the callback object
iid The identifier of the connection point. Normally the identifierof the interface that implements the callback functionalityon the client is specified.
pdw Return parameters. Pointer to a code number to identify theconnection. This value is required if the connection is termi-nated with AtlUnadvise.
If AtlAdvise could not execute successfully, this is displayed in the dialog box:
HRESULT hRes = AtlAdvise(m_pIOPCGroupStateMgt, pCbUnk, IID_IOPCDataCallback, &m_dwAdvise);if (hRes != S_OK) { AfxMessageBox(”Advise failed!”); . . . return;}
Enabling Buttons
Once OnButtonStart() has set up all necessary OPC objects, it disables the “StartSample” button. All other buttons are enabled. This strategy ensures thatOnButtonStart() is executed once only. This saves additional queries in theprogram.
m_CtrlStop.EnableWindow(TRUE);m_CtrlRead.EnableWindow(TRUE);m_CtrlWrite.EnableWindow(TRUE);m_CtrlChkActive.EnableWindow(TRUE);m_CtrlStart.EnableWindow(FALSE);
Sample Programs
572SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The OPCITEMDEF Structure
OPCITEMDEF has the following structure:
typdef struct { LPWSTR szAccessPath; LPWSTR szItemID; BOOL bActive; OPCHANDLE hClient; DWORD dwBlobSize; BYTE *pBlob; VARTYP vtRequestedDataType; Word wReserved;} OPCITEMDEF;
Variables of OPCITEMDEF
Variable Description
szAccessPath Optional access path for the items (not required bySIMATIC NET)
szItemID ItemID assigned by the client
bActive TRUE if the client will be notified if there is a valuechange of the item in an active group; FALSE if theclient will not be notified.
hClient Handle for an item assigned by the client. The ser-ver transfers the client handle with calls to the client(for example, OnDataChange) so that the client canaccess the relevant variables in its structures.
dwBlobSize Size of a memory area on the server in which addi-tional information for faster access to the data of anitem is stored.
pBlob Pointer to the memory area described above
vtRequestedData-Type
Data type requested by the client
Sample Programs
573SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The OPCITEMRESULT Structure
OPCITEMRESULT has the following structure:
typdef struct { OPCHANDLE hServer; VARTYPE vtCanonicalDataType; WORD wReserved; DWORD dwAccessRights; DWORD dwBlobSize; BYTE *pBlob;} OPCITEMRESULT;
Variables of OPCITEMRESULT
Variable Description
hServer A handle for an item assigned by the server. Theclient transfers the server handle with calls to theserver so that the server can access the relevantvariables in its structures.
vtCanonicalDataType The data type used by the server for an item
dwAccessRights Information about whether an item can only beread, only be written, or read and written.
dwBlobSize Size of a memory area on the server in whichadditional information for faster access to thedata of an item is stored.
pBlob Pointer to the memory area described above
OnButtonRead()
OnButtonRead() starts an asynchronous read job. The following operations areexecuted:
Variable Declaration and Plausibility Check
After the declaration of several local variables, the program checks whether anitem exists. After successfully calling AddItems in the OnButtonStart() method, them_pItemResult variable is initialized. The m_pErrors[0] array component musthave the value S_OK, otherwise the item was not created correctly:
Sample Programs
574SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
void COPCDA_AsyncDlg::OnButtonRead(){ OPCHANDLE *phServer; DWORD dwCancelID; HRESULT *pErrors; HRESULT r1; LPWSTR ErrorStr; CString szOut
if (m_pErrors[0] != S_OK) { MessageBox(”OPC Item0 not available!”, ”Error Read async”, MB_OK+MB_ICONERROR); return; }}
Read
Read reads values for OPC items asynchronously and is declared as follows:
HRESULT Read (DWORD dwCount, OPCHANDLE * phServer, DWORD dwTransactionID, DWORD *pdwCancelID, HRESULT ** ppErrors);
Parameter Description
dwCount Number of items for which values are read
phServer Array with the server handles of the items for which va-lues are read
dwTransactionID A code number assigned by the client to identify theasynchronous transaction. This is returned by the ser-ver withOnReadComplete() calls.
pdwCancelID A code number generated by the server that must bespecified if the transaction is to be canceled.
ppErrors Array Array with elements of the type HRESULT. These varia-bles return an error code if Read() could not be calledsuccessfully or information about the successful methodcall.
The program sets up memory for an array with an element of the typeOPCHANDLE and initializes the only array element with the structure componenthServer of the m_pItemResult variable. The OPC server entered a server handlethere for the item when AddItems was called:
Sample Programs
575SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
phServer = new OPCHANDLE[1];phServer[0] = m_pItemResult [0].hServer;r1 = m_pIOPCAsyncIO2 ->Read(1, phServer, 1, &dwCancelID, &pErrors);
The return value S_FALSE indicates that one or more items could not be read. Inthis case, the GetErrorString method gets the corresponding error message anddisplays it in a dialog box:
if (r1 == S_FALSE){ m_pIOPCServer ->GetErrorString(pErrors[0], LOCALE_ID, &ErrorStr); szOut.Format (”%s”,ErrorStr); MessageBox(szOut, ” Error Reading Item0”, MB_OK+MB_ICONERROR);}
Before the end of the program, the memory reserved by OnButtonRead() isreleased again. With Array phServer, this is done with delete because the memorywas created with new. The memory area of the pErrors array was organized byCoTaskMemAlloc and is therefore released with CoTaskMemFree:
delete[] phServer;CoTaskMemFree(pErrors);}
OnButtonWrite()
OnButtonWrite() starts an asynchronous write job. The following operations areexecuted:
Variable Declaration and Plausibility Check
The variable declaration corresponds to the OnButtonRead() method. In addition,an array of the type VARIANT is declared for the result of the read operation. Tocheck whether an item exists, the content of the hServer structure component isused as in OnButtonRead():
void COPCDA_AsyncDlg::OnButtonWrite(){ OPCHANDLE *phServer; DWORD dwCancelID; VARIANT values[1]; HRESULT *pErrors; HRESULT r1; LPWSTR ErrorStr; CString szOut; if (m_pErrors[0] != S_OK) { MessageBox(”OPC Item not available!”, ”Error Write async”,
Sample Programs
576SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
MB_OK+MB_ICONERROR); return; } phServer = new OPCHANDLE[1]; phServer[0] = m_pItemResult[0].hServer; ...
Write
Write writes values for OPC items asynchronously and is declared as follows:
HRESULT Write (DWORD dwCount, OPCHANDLE *phServer, VARIANT *pItemValues, DWORD dwTransactionID, DWORD *pdwCancelID HRESULT **ppErrors);
Parameter Description
dwCount Number of items for which values are written.
phServer Array with the server handles of the items for which va-lues are written.
pItemValues Array with the values to be written
dwTransactionID A code number assigned by the client to identify theasynchronous transaction.
pdwCancelID A code number generated by the server that must bespecified if the transaction is to be canceled.
ppErrors Array with elements of the type HRESULT. These varia-bles return an error code if Write() could not be calledsuccessfully or information about the successful methodcall.
The sample does not use the dwTransactionID parameter, so any value is set:
r1 = m_pIOPCAsyncIO2 ->Write(1, phServer, values, 2,&dwCancelID, &pErrors);
If Write returns “S_FALSE” an error occurred. The program gets the correspondingerror message. If Write could not be executed, an error message to this effect isdisplayed in a dialog box. delete[] phServer releases the memory reserved by OnButtonWrite():
delete[] phServer;if (r1 == S_FALSE){ m_pIOPCServer->GetErrorString(pErrors[0], LOCALE_ID, &ErrorStr); m_WriteResult = ErrorStr; UpdateData(FALSE);}if (FAILED(r1))
Sample Programs
577SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
{ szOut.Format(”Method call IOPCAsyncIO2::Write failed \ with error code %x”, r1); MessageBox(szOut, ”Error Writing Item0”, MB_OK+MB_ICONERROR);}else{ CoTaskMemFree(pErrors);}
Apply Values from Dialog Box
The UpdateData method call with the TRUE parameter transfers the content of allcontrol variables to the relevant member variables: The value of the m_WriteValmember variable of the IDC_EDIT_WRITEVAL text box is stored in the iValcomponent of the only element of values[]. The vt component is assigned theVT_I2 type; in other words, iVal is to be interpreted as an integer with the lengthtwo bytes:
UpdateData(TRUE);values[0].vt = VT_I2;values[0].iVal = m_WriteVal;
OnCheckActivategroup()
OnCheckActivategroup() is called when the “Group Active” check box is clicked. Itactivates and deactivates the group dependent on the status of the check box.
The following operations are executed:
Apply Value from Dialog Box
The UpdateData method call with the TRUE parameter transfers the content of allcontrols to the relevant member variables:
void COPCDA_AsyncDlg::OnCheckActivategroup() { UpdateData(TRUE);
SetState
SetState specifies several properties of a group and is declared as follows:
HRESULT SetState (DWORD * pRequestedUpdateRate, DWORD * pRevisedUpdateRate, BOOL *pActive, LONG * pTimeBias, FLOAT * pPercentDeadband DWORD * pLCID, OPCHANDLE *phClientGroup);
Sample Programs
578SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
pRequestedUpdateRate Update interval required by the client for dataand state changes of items
pRevisedUpdateRate The shortest update interval that can be imple-mented for the group by the server
pActive Status of the group: TRUE to activate thegroup. FALSE to deactivate the group.
pTimeBias Deviation of the server time from UTC (Univer-sal Time Convention)
pPercentDeadband Specifies the deadband within which valuechanges do not lead to notification. This pro-perty is, however, only effective when you useanalog values. The high and low limits of a va-lue must also be known. In this sample pro-gram, this is not the case (see OPC Data Ac-cess Spec. 1.1, Section 4.4.1.6.)
pLCID Identification number for the local adaptation ofthe group (language etc.)
phClientGroup New client handle for the group
We only want to activate the group so only the pActive parameter is given a value.A suitable variable must also be available for the pRevisedUpdateRate returnparameter:
DWORD dwRevUpdateRate;HRESULT r1= m_pIOPCGroupStateMgt ->SetState (NULL, &dwRevUpdateRate, &m_bChkActivateGroup, NULL, NULL, NULL, NULL);if (FAILED(r1)){ MessageBox(”Set State failed”, ”Error”, MB_OK+MB_ICONERROR); return;}
Sample Programs
579SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
OnButtonStop()
OnButtonStop() removes the OPC objects used in the program and releases thecorresponding resources. This method is called when the “Stop Sample” button isclicked, the OnDestroy method is executed or the WM_CLOSE message is sent(after clicking the button to close the dialog box or explicitly by callingSendMessage).
The following operations are executed:
AtlUnadvise
AtlUnadvise terminates the connection between the OPC server and the callbackobject and is declared as follows:
HRESULT AtlUnadvise (IUnknown*pUnkCP, const IID &iid, DWORD dw);
Parameter Description
pUnkCP Pointer to the IUnknown interface of the object with whichthe client is connected.
iid The identifier of the connection point. Normally the identifierof the interface that implements the callback functionalityon the client is specified.
dw Identification number with which the connection can beidentified.
void COPCDA_AsyncDlg::OnButtonStop() { HRESULT r1; OPCHANDLE *phServer; HRESULT *pErrors; HRESULT hRes = AtlUnadvise(m_pIOPCGroupStateMgt, IID_IOPCDataCallback, m_dwAdvise);
Release
Each COM interface has the Release method with which it releases the resourcesused by the interface. In actual fact, Release does not remove any objects frommemory, but simply decrements the reference counter of the interface. The objectsare actually deleted only when the interface is no longer referenced.
m_pIOPCGroupStateMgt ->Release();
Sample Programs
580SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
RemoveItems
The RemoveItems method of the IOPCItemMgt interface removes OPC items andis declared as follows:
HRESULT RemoveItems (DWORD dwCount, OPCHANDLE *phServer, HRESULT **ppErrors);
Parameter Description
dwCount Number of items to be removed
phServer Array with the server handles of the items to be removed
ppErrors Array with elements of the type HRESULT. These variablesreturn an error code if “RemoveItems()” could not be calledsuccessfully or information about the successful methodcall.
This program section sets up memory for an array with an element of the typeOPCHANDLE and initializes the array elements with the structure componenthServer of the m_pItemResult variable. The OPC server entered the serverhandles there for the items when AddItems was called. After the RemoveItemscall, the memory for this array is released again:
phServer = new OPCHANDLE[2];phServer[0] = m_pItemResult[0].hServer;phServer[1] = m_pItemResult[1].hServer;r1 = m_pIOPCItemMgt ->RemoveItems(2, phServer, &pErrors);if ( (r1 != S_OK) && (r1 != S_FALSE) ){ MessageBox(”RemoveItems failed!”, ”Error RemoveItems()”, MB_OK+MB_ICONERROR);}delete[] phServer;
The memory areas for pErrors and m_pItemResult are released with theCoTaskMemFree method because they were obtained with COM mechanisms.The resources of m_pIOPCItemMgt and m_pIOPCAsyncIO2 are released byRelease:
CoTaskMemFree(pErrors);CoTaskMemFree(m_pItemResult);m_pItemResult =NULL;CoTaskMemFree(m_pErrors);m_pErrors =NULL;m_pIOPCAsyncIO2->Release();m_pIOPCAsyncIO2 = NULL;m_pIOPCItemMgt->Release();m_pIOPCItemMgt = NULL;
Sample Programs
581SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
RemoveGroup
RemoveGroup() removes a group from the server and is declared as follows:
HRESULT RemoveGroup (OPCHANDLE hServerGroup, BOOL bForce );
Parameter Description
hServerGroup Server handle of the group to be removed.
bForce Specifies whether or not a group can be removed whenthere is still a reference to it.
r1 = m_pIOPCServer->RemoveGroup(m_GrpSrvHandle, TRUE);if (r1 != S_OK){ MessageBox(”RemoveGroup failed!”, ”Error RemoveGroup()”, MB_OK+MB_ICONERROR);}m_GrpSrvHandle = NULL;
The resources of the OPC server object are released with Release, CoUninitializecloses the COM library:
m_pIOPCServer->Release();m_pIOPCServer = NULL;CoUninitialize();
Finally, the program disables all controls apart from the “Start Sample” button:
m_CtrlStart.EnableWindow(TRUE);m_CtrlStop.EnableWindow(FALSE);m_CtrlRead.EnableWindow(FALSE);m_CtrlWrite.EnableWindow(FALSE);m_CtrlChkActive.EnableWindow(FALSE);}
OnDestroy
This method of the CWnd class is overwritten so that all the clean up jobs can bedone when the dialog window is closed. OnButtonStop() deletes all the OPCobjects and releases the corresponding resources. Following this, OnDestroy ofthe parent class is called to release the memory used by the window object:
void COPCDA_AsyncDlg::OnDestroy() { if (m_pIOPCServer) OnButtonStop(); CDialog::OnDestroy();}
Sample Programs
582SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
DisplayData
The dialog box class has three methods to display data after a message from theOPC server. Different methods are necessary because the various notificationsfrom the server return different data.
The following methods are available:
� After data have changed (one method per item):
void DisplayData0 (CString ReadVal, CString ReadQuality, CString ReadTS)void DisplayData1 (CString ReadVal, CString ReadQuality, CString ReadTS)
� On completion of a read operation:
void DisplayData (long Value, CString Quality, CString TimeStamp)
� On completion of a write operation:
void DisplayData (HRESULT ErrorCode)
DisplayData0 (CString ReadVal, CString ReadQuality, CString ReadTS)
This version of DisplayData is called by the OnDataChange method of theCallback class and updates the display in the text boxes in the “On Data Changed”frame.
Note
In this case, the text boxes of Item0 are updated. To update the text boxes ofItem1, the analogous DisplayData1 method is implemented.
void COPCDA_AsyncDlg::DisplayData0(CString ReadVal, CString ReadQuality, CString ReadTS)
Parameter Description
ReadVal Value that was read
ReadQuality Information on the integrity of the data
ReadTS Time stamp (time at which the data were received from theOPC server)
The parameter values are assigned to the member variables of the dialog box.UpdateData transfers the new data from the member variables to thecorresponding controls:
{ m_Quality0 = ReadQuality; m_TimeStamp0 = ReadTS; m_Value0 = ReadVal; UpdateData(FALSE);}
Sample Programs
583SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
DisplayData (long Value, CString Quality, CString TimeStamp)
The OnReadComplete() method of the Callback class calls this method to updatethe display in the text boxes to the right of the “Read Value” button:
void COPCDA_AsyncDlg::DisplayData(long Value, CString Quality, CString TimeStamp)
Parameter Description
Value The value that was read
Quality Information on the integrity of the data
TimeStamp The time at which the data were received from the OPCserver.
The parameters are assigned to the relevant member variables of the dialog box.UpdateData transfers the new data from the member variables to thecorresponding controls:
{ m_ReadValue = Value; m_QualityRead = Quality; m_TimeStampRead = TimeStamp; UpdateData(FALSE);}
DisplayData (HRESULT ErrorCode)
The OnWriteComplete() method of the Callback class calls this method to display astatus message about the result of a write operation in text box to the right of the“Write Value” button:
void COPCDA_AsyncDlg::DisplayData(HRESULT ErrorCode)
Parameter Description
ErrorCode The error code returned by the OPC server
The GetErrorString() method of the “IOPCServer” interface gets the error messagebelonging to the error code. This message is assigned to the member variablem_WriteResult. Before UpdateData displays this message in the text box, the linebreak characters must be removed with Remove():
{ LPWSTR ErrorStr; m_pIOPCServer->GetErrorString(ErrorCode, LOCALE_ID, &ErrorStr); m_WriteResult = ErrorStr; m_WriteResult.Remove(’\r’); m_WriteResult.Remove(’\n’); UpdateData(FALSE);}
Sample Programs
584SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
UpdateData
In certain situations, changing threads during access to a resource can lead toinconsistent data or undefined states. In such cases, a thread change must beprevented explicitly. The CCriticalSection class is available for this purpose. Aftercreating an object of this class, it is only possible to change threads again whenthe Unlock() method is called.
The sample program uses this mechanism to update the controls without errorsoccurring. An object of the CCriticalSection class is created after the programstarts. Immediately following the UpdateData method call of the parent class,Unlock releases the resources again for other threads:
BOOL COPCDA_AsyncDlg::UpdateData( BOOL bSaveAndValidate ){ BOOL bRes; m_cCritSec.Lock(); bRes = CDialog::UpdateData( bSaveAndValidate ); m_cCritSec.Unlock(); return bRes;}
7.5.10 Callback.cpp and Callback.h
In the sample program, the COPCDataCallback class is the implementation of theIOPCDataCallback interface. This class provides the following methods whichnotifications can be received from the OPC server:
� OnDataChange
� OnReadComplete()
� OnWriteComplete()
� InformAboutDialog
The file also includes the auxiliary functions
GetQualityText
Sample Programs
585SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
OnDataChange
The OPC server calls this method when data changes:
STDMETHODIMP COPCDataCallback::OnDataChange( DWORD dwTransid, OPCHANDLE hGroup, HRESULT hrMasterquality, HRESULT hrMastererror, DWORD dwCount, OPCHANDLE __RPC_FAR *phClientItems, VARIANT __RPC_FAR *pvValues, WORD __RPC_FAR *pwQualities, FILETIME __RPC_FAR *pftTimeStamps, HRESULT __RPC_FAR *pErrors)
Parameter Description
dwTransid The code number for the type of method call is zero if avalue change was the cause of the method call, if thecode number is not zero, the method call was triggeredby a refresh.
hGroup The client handle of the group to allow the client to iden-tify the group
hrMasterquality Information on the integrity of the data: S_OK, ifOPC_QUALITY_MASK for all items has the valueOPC_QUALITY_GOOD, otherwise S_FALSE.
hrMastererror S_OK, if the error message for all items is S_OK, other-wise S_FALSE.
dwCount Number of items for which values exist.
phClientItems Array with the client handles of the items whose valueshave changed.
pvValues Array of the type VARIANT containing the values of theitems that have changed.
pwQualities Array with information about the integrity of the valuesof the individual items
pftTimeStamps Array with time information for the individual items
pErrors Array with error messages for the items
The task of this method is to convert the values transferred by the OPC server asparameters into objects of the type CString. The DisplayData method expects inputparameters of this type.
Sample Programs
586SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The program creates three arrays for CString objects to store the values of theitems, information on the quality of the values, and time information:
{ CString szReadVal; CString szReadQuality; CString szReadTS;
CComVariant is a wrapper class for the VARIANT data type. A CComVariant objectis created for each item in a loop. For this, the constructor is used that contains aVARIANT value as parameter:
CComVariant *pvarOut; DWORD i; for (i = 0; i<dwCount; i++) { pvarOut = new CComVariant(pvValues[i]);
In the next step, the ChangeType method converts the value that was read into astring. Since this is still an object of the CComVariant class, it is possible to accessthe string via the bstrVal component of pvarOut. The result of the Format methodis the required CString object:
pvarOut->ChangeType(VT_BSTR); szReadVal.Format(”%ls”, pvarOut->bstrVal);
Since we are interested only in the szReadVal variable, the pvarOut object isdeleted immediately after it has been used:
delete pvarOut;
GetQualityText returns quality information on the value that was read as a CStringobject. The parameter for this method is an identification number of the OPCserver:
szReadQuality = GetQualityText(pwQualities[i]);
The OPC server returns the time stamps of the items as a variable of the typeFILETIME. The result of the Format method of the COleDateTime class is the timeas a CString object:
szReadTS = COleDateTime(pftTimeStamps[i]).Format(); }
Sample Programs
587SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Once all the results have been converted to CString objects, the program callseither DisplayData0 method or the DisplayData1 method of theCOPCDA_AsyncDlg class:
switch (phClientItems[i]) { case 0: m_pCDlgClass->DisplayData0(szReadVal, szReadQuality, szReadTS); break; case 1: m_pCDlgClass->DisplayData1(szReadVal, szReadQuality, szReadTS); break; default: ASSERT(0); }}return S_OK;};
OnReadComplete()
The OPC server calls this method when an asynchronous read is completed. Theparameters of OnReadComplete() match those of OnDataChange:
STDMETHODIMP COPCDataCallback::OnReadComplete( DWORD dwTransid, OPCHANDLE hGroup, HRESULT hrMasterquality, HRESULT hrMastererror, DWORD dwCount, OPCHANDLE __RPC_FAR *phClientItems, VARIANT __RPC_FAR *pvValues, WORD __RPC_FAR *pwQualities, FILETIME __RPC_FAR *pftTimeStamps, HRESULT __RPC_FAR *pErrors )
Parameter Description
dwTransid The code number for the type of method call is zero if avalue change was the cause of the method call, if thecode number is not zero, the method call was triggeredby a refresh.
hGroup The client handle of the group to allow the client to iden-tify the group
Sample Programs
588SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Parameter Description
hrMasterquality Information on the integrity of the data: S_OK, ifOPC_QUALITY_MASK for all items has the valueOPC_QUALITY_GOOD, otherwise S_FALSE.
hrMastererror S_OK, if the error message for all items is S_OK, other-wise S_FALSE.
dwCount Number of items for which values exist.
phClientItems Array with the client handles of the items whose valueshave changed.
pvValues Array of the type VARIANT containing the values of theitems that have changed.
pwQualities Array with information about the integrity of the valuesof the individual items
pftTimeStamps Array with time information for the individual items
pErrors Array with error messages for the items
Before processing the data delivered by the OPC server, the program checks thepErrors variable. If the read was error-free, the data is evaluated as in theOnDataChange program. In this case, however, the value of the item is convertedto the “Long Integer” type:
if (pErrors[0] == S_OK){ CComVariant * pvarOut; pvarOut = new CComVariant(pvValues[0]); pvarOut->ChangeType(VT_I4); CString readQuality = GetQualityText(pwQualities[0]); CString readTS = COleDateTime(pftTimeStamps[0] ).Format(); m_pCDlgClass->DisplayData(pvarOut->intVal,readQuality, readTS); delete pvarOut;}
If an error occurred, the GetQualityText method returns the message belonging tothe error code:
else{ CString readQuality = GetQualityText(pErrors[0]); m_pCDlgClass->DisplayData(0,readQuality,””);}return S_OK;};
Sample Programs
589SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
OnWriteComplete()
The OPC server calls this method when an asynchronous write is completed.
STDMETHODIMP COPCDataCallback::OnWriteComplete( DWORD dwTransid, OPCHANDLE hGroup, HRESULT hrMastererr, DWORD dwCount, OPCHANDLE __RPC_FAR *pClienthandles, HRESULT __RPC_FAR *pErrors )
Parameter Description
dwTransid An identification number for the asynchronous write
hGroup The client handle of the group
hrMastererr S_OK, if the error message for all items is S_OK, otherwiseS_FALSE.
dwCount Number of items for which values were written.
pClienthand-les
Array with the client handles of the items for which valueswere written.
pErrors Array with error messages for the items
OnWriteComplete() calls the DisplayData method of the COPCDA_AsyncDlg classto display the error message of the OPC server:
{ m_pCDlgClass->DisplayData(pErrors[0]); return S_OK; };
InformAboutDialog
InformAboutDialog returns a reference to the dialog box:
void InformAboutDialog (COPCDA_AsyncDlg *pCDlgClass){ m_pCDlgClass = pCDlgClass;}
GetQualityText
GetQualityText provides a CString object as an error message for a specified errorcode:
CString GetQualityText(UINT qnr){ CString qstr; switch(qnr) { case OPC_QUALITY_BAD: qstr = ”BAD”; break;
Sample Programs
590SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
case OPC_QUALITY_UNCERTAIN: qstr = ”UNCERTAIN”; break; case OPC_QUALITY_GOOD: qstr = ”GOOD”; break; case OPC_QUALITY_NOT_CONNECTED: qstr = ”NOT_CONNECTED”; break; case OPC_QUALITY_DEVICE_FAILURE: qstr = ”DEVICE_FAILURE”; break; case OPC_QUALITY_SENSOR_FAILURE: qstr = ”SENSOR_FAILURE”; break; case OPC_QUALITY_LAST_KNOWN: qstr = ”LAST_KNOWN”; break; case OPC_QUALITY_COMM_FAILURE: qstr = ”COMM_FAILURE”; break; case OPC_QUALITY_OUT_OF_SERVICE: qstr = ”OUT_OF_SERVICE”; break; case OPC_QUALITY_LAST_USABLE: qstr = ”LAST_USABLE”; break; case OPC_QUALITY_SENSOR_CAL: qstr = ”SENSOR_CAL”; break; case OPC_QUALITY_EGU_EXCEEDED: qstr = ”EGU_EXCEEDED”; break; case OPC_QUALITY_SUB_NORMAL: qstr = ”SUB_NORMAL”; break; case OPC_QUALITY_LOCAL_OVERRIDE: qstr = ”LOCAL_OVERRIDE”; break; default: qstr = ”UNKNOWN ERROR”; } return qstr;}
Sample Programs
591SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.5.11 Notes on Writing your own Programs
Several requirements must be met before your own programs can use the Custominterface. Follow the steps outlined below:
Step Description
1 Start the Visual C++ development environment.
2 Create a project of the required type using the MFC Class Wizard.
3 Copy the files pre_opc.h and pre_opc.cpp from the sample programinto your project folder and add these files to the project (Projectmenu > Add To Project > Files ...). These files contain OPC-specificdefinitions and include statements.
4 Add the statement #include “pre_opc.h” to all the implementationfiles of your project (extension .cpp):
5 In the implementation files (extension .cpp) that use theAddGroup() or GetErrorString() methods, add the followingstatement:#define LOCALE_ID 0x409
6 Arrange the required operator interface elements in the main dialogor create a suitable application window and program thecorresponding event procedures.
7 Implement a callback object if you want to use asynchronousoperations over ATL. The best course is to define your own classwith the required methods.
7.6 Sample Program for the OPC Custom Interface(Asynchronous Communication) with .NET-Framework
Requirements for Using the Sample Program
After installing the SIMATIC NET software, you will find this program on your harddisk in the following folder:
<Installationpath>\SIEMENS\SIMATIC.NET\opc2\samples\dotnet\vb\async.net
A .NET-Framework version 1.1 must be installed on the computer on which youwant the sample program to run. You must also activate a simulation connection sothat the demonstration variables used in the program are available (see Section7.5.1).
Sample Programs
592SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Runtime Callable Wrapper
The sample uses the Custom interface for OPC Data Access V2.0 with .NETFramework. Access to the COM interface of the managed code of .NETapplications uses the Runtime Callable Wrapper (RCW) of the OPC Foundation.
The primary function of Runtime Callable Wrappers is the marshaling of callsbetween a .NET client and an unmanaged COM object. Marshaling means makingmemory areas available.
7.6.1 Working with the Sample Program
The program includes several elements that the operator can use to trigger thefollowing actions:
Operator Element Effect
Start Sample Start program
Read Value or Write Value Read or write values
Group Active Activate or deactivate group
Stop Sample Stop the program
Sample Programs
593SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
When you start the program, only the “Start Sample” button is enabled. After youhave clicked this button, the program generates the required OPC objects. You canthen use the other buttons.
7.6.2 Description of the Program
Introduction
The basic sequence of the individual program steps corresponds to the previoussample “OPC Custom Interface, Asynchronous Communication”. These includeestablishing the connection to the OPC server, creating a group with variables, andreading and writing values for an item. The following table shows the steps to beexecuted by the program:
Step Description
1 Select .NET components
2 Convert the ProgID to a CLSID
3 Establish connection to the OPC server
4 Create an OPC group
5 Adding Items
6 Request the interface IConnectionPointContainer
7 Request the interface IOPCAsyncIO2
8 Create callback object
9 Connect OPC server and callback object of the client
10 Execute required write and read operations
11 Receive notifications of the OPC server
12 Delete objects and release memory
Sample Programs
594SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 1: Select the .NET components
To use the Custom Interface for OPC Data Access with .NET, you must use theRuntime Callable Wrapper (RCW) described above in your Visual Basic project. Inthe sample project, the components OpcRcw.Da and OpcRcw.Comn have alreadybeen added.
If these do not appear in the selection, you can also select them using the”Browse” button from the following folder
<installationpath>\SIEMENS\SIMATIC.NET\opc2\bin
With the commands
Imports OpcRcw.ComnImports OpcRcw.Da
it is simple to use the name space and methods of the OPC Custom interface with.NET Framework.
Step 2: Convert the ProgID to a type
To identify it, each COM server has a “ProgID” that is assigned to a worldwideunique type. This is obtained with the GetTypeFromProgID() function. The ProgIDof the OPC Server of SIMATIC NET is L”OPC.SimaticNET”:
Dim typeofOPCserver As Type = Type.GetTypeFromProgID(”OPC.SimaticNET”)
Sample Programs
595SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 3: Establish the connection to the OPC server
The CreateInstance() function of the Activator class generates an instance of theclass with a previously specified type:
m_server = Activator.CreateInstance(typeofOPCserver)
The result of this section of program is an interface variable m_server of the typeIOPCServer.
Step 4: Create an OPC group
The IOPCServer interface has the AddGroup() method for creating groups:
m_server.AddGroup(”MyOPCGroup”, 0, 250, 1, pTimeBias, pDeadband, LOCALE_ID, ServerGroup, RevisedUpdateRate, GetType(IOPCGroupStateMgt).GUID, m_group)
The result of this program section is a group with the specified name and therequired properties. AddGroup() also returns a variable m_group as returnparameter, an interface to a group object, in this case IOPCGroupStateMgt. TheIOPCGroupStateMgt interface is necessary to allow use of the SetState methods.The SetState() method is required later to activate and deactivate a group.
By means of a simple assignment, the m_item variable of the type IOPCItemMgtcan be derived from the m_group interface variable.
m_item = m_group
Step 5: Add items
The IOPCItemMgt interface has the AddItems() method for creating OPC items:
m_item.AddItems(2, itemdefs, Results, pErrors)
The result of this program section is that the server adds two items with theproperties specified in the itemdefs parameter. The variables of the resultstructure Results (server handle, data type of the item on the target system etc.)are initialized.
Since the results are written to unmanaged memory by the underlying COMinterface, the access from managed .NET code must make use of the marshalingfunctions:
Sample Programs
596SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
result = Marshal.PtrToStructure(pos, GetType(OPCITEMRESULT))ServerHandle1 = result.hServerpos = New IntPtr(pos.ToInt32() + Marshal.SizeOf(GetType(OPCITEMRESULT)))result = Marshal.PtrToStructure(pos, GetType(OPCITEMRESULT))ServerHandle2 = result.hServer
The client must also make sure that the unmanaged memory is released:
Marshal.FreeCoTaskMem(Results)Marshal.FreeCoTaskMem(pErrors)
Step 6: Request the interface IConnectionPointContainer
The m_ConnectionContainer variable of the type IConnectionPointContainercan bederived from the m_group variable.
m_ConnectionContainer = m_group
The interface is required to locate the IConnectionPoint interface.
Schritt 7: Request the IOPCAsyncIO2 interfaces
The m_asyncIO2 variable of the type IOPCAsyncIO2 can be derived from them_group variable.
m_asyncIO2 = m_group
This interface provides methods for asynchronous reading and writing of values.
Step 8: Create a callback object
To allow the OPC server to return a result of asynchronous operations, theIOPCDataCallback interface must be implemented on the client.
Implements IOPCDataCallback
The connection of the IConnectionPoint interface and IOPCDataCallback of theOPC server is established using the FindConnectionPoint() method of theIConnectionPointContainer interface. This generates a callback object forasynchronous calls.
m_ConnectionContainer.FindConnectionPoint( GetType(IOPCDataCallback).GUID, m_ConnectionPoint)
Sample Programs
597SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 9: Connect the OPC server and callback object of the client
The connection between the callback object of the OPC server and the clientapplication is established by the Advise() method. The return variable m_dwCookieis an ID for the connection.
m_ConnectionPoint.Advise(Me, m_dwCookie)
Step 10: Execute the required write or read operation
The Read() and Write() methods that were generated in Step 7 can be accessedover the IOPCAsyncIO2 interface:
m_asyncIO2.Read(1, pServer, _ Transaction, CancelID, pErrors)
Step 11: Receive notifications of the OPC server
If the data of an active item in an active group changes, the server calls theOnDataChange method of the callback object. On completion of a read operation,the server calls the OnReadComplete() method, on completion of a writeoperation, the OnWriteComplete() method is called. The server passes the returnvalues as parameters to the method.
Overridable Sub OnDataChange( ByVal dwTransid As Integer, ByVal hGroup As Integer, ByVal hrMasterquality As Integer, ByVal hrMastererror As Integer, ByVal dwCount As Integer, ByVal phClientItems() As Integer, ByVal pvValues() As Object, ByVal pwQualities() As Short, ByVal pftTimeStamps() As OpcRcw.Da.FILETIME, ByVal pErrors() As Integer) Implements IOPCDataCallback.OnDataChange
Sample Programs
598SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 12: Delete objects and release memory
Before exiting the program, the OPC objects that have been created must bedeleted and the memory reserved for them must be released. The relevantfunctions are integral parts of the previously used interfaces. Unadvise() terminatesthe connection between the OPC server and the callback object:
m_ConnectionPoint.Unadvise(m_dwCookie)Marshal.ReleaseComObject(m_ConnectionPoint)m_item.RemoveItems(2, pItems, pErrors)....
Marshal.FreeCoTaskMem(pErrors)m_server.RemoveGroup(ServerGroup, True)
Releasing Memory
When using COM, it is sometimes necessary for the client to release memory thatwasrequested by the server. The rules for this are as follows:
� [out]: The memory for a parameter with this attribute will be requested from theserver.
� [in, out]: The memory for such a parameter will be requested from the client.The server can release the memory again and reallocate it.
� [in]: The client will request the memory. The server is not responsible forreleasing the memory.
captain or three cases, the reserved memory of unmanaged COM objects shouldbe released by the client.
Sample Programs
599SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.7 Sample Program for the OPC XML Interface
This sample in the C# language uses the XML interface for OPC data access. Itcontains methods to establish a connection to a Web service and to execute readand write jobs.
7.7.1 Working with the Sample Program
Start program
After starting the program, all the buttons except for “Start Sample” are disabled.Click on this button to establish a connection to the OPC XML Web service. If theWeb service is available, a dialog box displays information about the server.Otherwise, an error message is displayed.
Sample Programs
600SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Read Values
Click the “Read Value” button to read the value of the “S7:[DEMO]MW1” item. Ifthe read job executed successfully, the program displays the value of the item,information on the quality, and a time stamp in the text boxes beside the “ReadValue” button:
Writing Values
Enter the value you want to be written in the text box beside the “Write Value”button and then click the “Write Value” button. If the write job executes correctly,the program displays information on the quality of the value in the “Quality/WriteResult” text box and the time stamp in the “Time Stamp” text box.
Sample Programs
601SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Stop the program
Close the program by clicking the “Stop Sample” button. This disables the “ReadValue”, “Write Value”, and “Stop Sample” buttons. The “Start Sample” button andthe text box for the URL are enabled again.
7.7.2 Adding a Web Service to the Project
Settings in Visual Studio .NET
To allow the sample program to use the Web service of the OPC XML interface, a“Web Reference” was included in the project in Visual Studio .NET.
If you want to create programs yourself with an OPC XML interface, you will needto take the following steps:
� Open the menu Project > Add Web Reference.
� Enter the URL of the SIMATIC NET OPC XML Web service in the “Address”text box. This URL is as follows: http://<Computer address>/<Name of theOPC SIMATIC NET Web service>/SOPCWeb.asmx?wsdl
� Click on the “Add Reference” button. All the methods defined in the WSDL arethen available.
Sample Programs
602SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.7.3 The MainForm Class
Program Code
All the methods of the sample program are defined in the “MainForm” class. At thebeginning, the elements of the dialog box are declared.
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Net;namespace opcxml_da_sync{ using localhost; /// <summary> /// Summary description for Form1. /// </summary> public class MainForm : System.Windows.Forms.Form { private System.Windows.Forms.Button Button_Start_Sample; private System.Windows.Forms.Button Button_Stop_Sample; private System.Windows.Forms.Button Button_Read_Value; private System.Windows.Forms.Button Button_Write_Value; private System.Windows.Forms.TextBox Edit_URL; private System.Windows.Forms.Label Label_URL; private System.Windows.Forms.Label Label_Item0; private System.Windows.Forms.Label Label_Item_Value; private System.Windows.Forms.Label Label_Siemens; private System.Windows.Forms.Label Label_Value; private System.Windows.Forms.Label Label_Quality; private System.Windows.Forms.Label Label_Timestamp; private System.Windows.Forms.TextBox Edit_Read_Value; private System.Windows.Forms.TextBox Edit_Write_Value; private System.Windows.Forms.TextBox Edit_Read_Quality; private System.Windows.Forms.TextBox Edit_Write_Quality; private System.Windows.Forms.TextBox Edit_Read_TimeStamp; private System.Windows.Forms. TextBox Edit_Write_TimeStamp; private System.Windows.Forms.GroupBox GroupBox_URL; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
Sample Programs
603SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The Web service is an instance of the OPCXML_DataAccess class:
// proxy class for the web service private OPCXML_DataAccess m_OPCXML_DataAcess;
The name of the item is stored in the m_strItemName variable:
// ItemID used in this sample private string m_strItemName = “S7:[DEMO]MW1”;
7.7.4 The Constructor of MainForm and the Dispose Method
Program Code
The constructor of the dialog box class calls the method InitializeComponent() . Allthe elements of the dialog box are created here. The content ofInitializeComponent() is created by Visual Studio .NET automatically when thedialog box is created with the Form Designer.
public MainForm(){ // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after // InitializeComponent call
The item name appears in the dialog box because an instance of the classSystem.Windows.Forms.Label is initialized with the content of the m_strItamNamevariable:
Label_Item_Value.Text = m_strItemName; }
The Dispose() method releases all used resources at the end of the program:
/// <summary> /// Clean up any resources being used. /// </summary>
protected override void Dispose( bool disposing ){ if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing );}
Sample Programs
604SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.7.5 Creating the Dialog Box Elements
Program Code
The following section is created automatically by Visual Studio .NET when the usercreates the main dialog box of the application with the Form Designer. Thiscontains information on all elements of the dialog box, such as size, location, andlabeling of buttons. This section also specifies which events procedures areexecuted when a button is clicked.
#region Windows Form Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){ this.Button_Start_Sample = new System.Windows.Forms. Button(); this.Button_Stop_Sample = new System.Windows.Forms. Button(); this.Button_Read_Value = new System.Windows.Forms.Button(); this.Button_Write_Value = new System.Windows.Forms. Button(); this.Edit_URL = new System.Windows.Forms.TextBox(); this.Label_URL = new System.Windows.Forms.Label(); this.Label_Item0 = new System.Windows.Forms.Label(); this.Label_Item_Value = new System.Windows.Forms.Label(); this.Label_Siemens = new System.Windows.Forms.Label(); this.Label_Value = new System.Windows.Forms.Label(); this.Label_Quality = new System.Windows.Forms.Label(); this.Label_Timestamp = new System.Windows.Forms.Label(); this.Edit_Read_Value = new System.Windows.Forms.TextBox(); this.Edit_Write_Value = new System.Windows.Forms.TextBox(); this.Edit_Read_Quality = new System.Windows.Forms. TextBox(); this.Edit_Write_Quality = new System.Windows.Forms. TextBox(); this.Edit_Read_TimeStamp = new System.Windows.Forms. TextBox(); this.GroupBox_URL = new System.Windows.Forms.GroupBox(); this.Edit_Write_TimeStamp = new System.Windows.Forms. TextBox(); this.SuspendLayout(); // // Button_Start_Sample // this.Button_Start_Sample.Location = new System.Drawing. Point(24,88);
Sample Programs
605SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
this.Button_Start_Sample.Name = ”Button_Start_Sample”; this.Button_Start_Sample.Size = new System.Drawing. Size(96, 24); this.Button_Start_Sample.TabIndex = 0; this.Button_Start_Sample.Text = “Start Sample”; this.Button_Start_Sample.Click += new System.EventHandler( this.Button_Start_Sample_Click); // // Button_Stop_Sample // this.Button_Stop_Sample.Enabled = false; this.Button_Stop_Sample.Location = new System.Drawing. Point(24, 256); this.Button_Stop_Sample.Name = “Button_Stop_Sample”; this.Button_Stop_Sample.Size = new System.Drawing. Size(96, 23); this.Button_Stop_Sample.TabIndex = 1; this.Button_Stop_Sample.Text = “Stop Sample”; this.Button_Stop_Sample.Click += new System.EventHandler( this.Button_Stop_Sample_Click); // // Button_Read_Value // this.Button_Read_Value.Enabled = false; this.Button_Read_Value.Location = new System.Drawing. Point(24, 144); this.Button_Read_Value.Name = “Button_Read_Value”; this.Button_Read_Value.Size = new System.Drawing. Size(96, 23); this.Button_Read_Value.TabIndex = 2; this.Button_Read_Value.Text = “Read Value”; this.Button_Read_Value.Click += new System.EventHandler( this.Button_Read_Value_Click); // // Button_Write_Value // this.Button_Write_Value.Enabled = false; this.Button_Write_Value.Location = new System.Drawing. Point(24, 200); this.Button_Write_Value.Name = “Button_Write_Value”; this.Button_Write_Value.Size = new System.Drawing. Size(96, 23); this.Button_Write_Value.TabIndex = 3; this.Button_Write_Value.Text = ”Write Value”; this.Button_Write_Value.Click += new System.EventHandler( this.Button_Write_Value_Click); // // Edit_URL
Sample Programs
606SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
// this.Edit_URL.Location = new System.Drawing.Point(144, 32); this.Edit_URL.Name = ”Edit_URL”; this.Edit_URL.Size = new System.Drawing.Size(328, 20); this.Edit_URL.TabIndex = 4; this.Edit_URL.Text = ”http://localhost/OPC.Simatic.NET/SOPCWeb.asmx”; // // Label_URL // this.Label_URL.Location = new System.Drawing.Point(40, 35); this.Label_URL.Name = ”Label_URL”; this.Label_URL.Size = new System.Drawing.Size(96, 24); this.Label_URL.TabIndex = 5; this.Label_URL.Text = ”Input the URL:”; // // Label_Item0 // this.Label_Item0.Location = new System.Drawing. Point(144, 94); this.Label_Item0.Name = “Label_Item0”; this.Label_Item0.Size = new System.Drawing.Size(48, 23); this.Label_Item0.TabIndex = 6; this.Label_Item0.Text = “Item0 = “; // // Label_Item_Value // this.Label_Item_Value.Location = new System.Drawing. Point(192, 94); this.Label_Item_Value.Name = “Label_Item_Value”; this.Label_Item_Value.Size = new System.Drawing. Size(296, 23); this.Label_Item_Value.TabIndex = 7; // // Label_Siemens // this.Label_Siemens.Location = new System.Drawing. Point(384, 262); this.Label_Siemens.Name = “Label_Siemens”; this.Label_Siemens.Size = new System.Drawing.Size(120, 16); this.Label_Siemens.TabIndex = 8; this.Label_Siemens.Text = “(c) Siemens AG 2003”; // // Label_Value // this.Label_Value.Location = new System.Drawing. Point(144, 120); this.Label_Value.Name = ”Label_Value”;
Sample Programs
607SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
this.Label_Value.Size = new System.Drawing.Size(40, 16); this.Label_Value.TabIndex = 9; this.Label_Value.Text = ”Value”; // // Label_Quality // this.Label_Quality.Location = new System.Drawing. Point(256, 120); this.Label_Quality.Name = “Label_Quality”; this.Label_Quality.Size = new System.Drawing.Size(104, 23); this.Label_Quality.TabIndex = 10; this.Label_Quality.Text = “Quality/Write Result”; // // Label_Timestamp // this.Label_Timestamp.Location = new System.Drawing. Point(374, 120); this.Label_Timestamp.Name = “Label_Timestamp”; this.Label_Timestamp.TabIndex = 11; this.Label_Timestamp.Text = “Time Stamp”; // // Edit_Read_Value // this.Edit_Read_Value.Enabled = false; this.Edit_Read_Value.Location = new System.Drawing. Point(144, 144); this.Edit_Read_Value.Name = “Edit_Read_Value”; this.Edit_Read_Value.Size = new System.Drawing. Size(88, 20); this.Edit_Read_Value.TabIndex = 12; this.Edit_Read_Value.Text = “0”; // // Edit_Write_Value // this.Edit_Write_Value.Enabled = false; this.Edit_Write_Value.Location = new System.Drawing. Point(144, 200); this.Edit_Write_Value.Name = “Edit_Write_Value”; this.Edit_Write_Value.Size = new System.Drawing. Size(88, 20); this.Edit_Write_Value.TabIndex = 13; this.Edit_Write_Value.Text = “0”; // // Edit_Read_Quality // this.Edit_Read_Quality.Enabled = false; this.Edit_Read_Quality.Location = new System.Drawing. Point(256, 144);
Sample Programs
608SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
this.Edit_Read_Quality.Name = ”Edit_Read_Quality”; this.Edit_Read_Quality.Size = new System.Drawing. Size(96, 20); this.Edit_Read_Quality.TabIndex = 14; this.Edit_Read_Quality.Text = ””; // // Edit_Write_Quality // this.Edit_Write_Quality.Enabled = false; this.Edit_Write_Quality.Location = new System.Drawing. Point(256, 200); this.Edit_Write_Quality.Name = “Edit_Write_Quality”; this.Edit_Write_Quality.Size = new System.Drawing. Size(96, 20); this.Edit_Write_Quality.TabIndex = 15; this.Edit_Write_Quality.Text = “”; // // Edit_Read_TimeStamp // this.Edit_Read_TimeStamp.Enabled = false; this.Edit_Read_TimeStamp.Location = new System.Drawing. Point(376, 144); this.Edit_Read_TimeStamp.Name = “Edit_Read_TimeStamp”; this.Edit_Read_TimeStamp.Size = new System.Drawing. Size(112, 20); this.Edit_Read_TimeStamp.TabIndex = 16; this.Edit_Read_TimeStamp.Text = “”; // // GroupBox_URL // this.GroupBox_URL.Location = new System.Drawing. Point(24, 8); this.GroupBox_URL.Name = “GroupBox_URL”; this.GroupBox_URL.Size = new System.Drawing.Size(464, 56); this.GroupBox_URL.TabIndex = 17; this.GroupBox_URL.TabStop = false; this.GroupBox_URL.Text = “OPC XML-DA WebService”; // // Edit_Write_TimeStamp // this.Edit_Write_TimeStamp.Enabled = false; this.Edit_Write_TimeStamp.Location = new System.Drawing. Point(376, 200); this.Edit_Write_TimeStamp.Name = “Edit_Write_TimeStamp”; this.Edit_Write_TimeStamp.Size = new System. Drawing.Size(112, 20); this.Edit_Write_TimeStamp.TabIndex = 18; this.Edit_Write_TimeStamp.Text = ””;
Sample Programs
609SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
// // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(506, 293); this.Controls.Add(this.Edit_Write_TimeStamp); this.Controls.Add(this.Edit_Read_TimeStamp); this.Controls.Add(this.Edit_Write_Quality); this.Controls.Add(this.Edit_Read_Quality); this.Controls.Add(this.Edit_Write_Value); this.Controls.Add(this.Edit_Read_Value); this.Controls.Add(this.Edit_URL); this.Controls.Add(this.Label_Timestamp); this.Controls.Add(this.Label_Quality); this.Controls.Add(this.Label_Value); this.Controls.Add(this.Label_Siemens); this.Controls.Add(this.Label_Item_Value); this.Controls.Add(this.Label_Item0); this.Controls.Add(this.Label_URL); this.Controls.Add(this.Button_Write_Value); this.Controls.Add(this.Button_Read_Value); this.Controls.Add(this.Button_Stop_Sample); this.Controls.Add(this.Button_Start_Sample); this.Controls.Add(this.GroupBox_URL); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = ”MainForm”; this.Text = ”OPC XML-DA Synchron Sample C#”; this.ResumeLayout(false);}#endregion
Sample Programs
610SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
7.7.6 The Main Method
Program Code
The Main method is the starting point for the sample program. An instance of thedialog box classes generated and started by calling Application.Run.
/// <summary>/// The main entry point for the application./// </summary> [STAThread] static void Main() { Application.Run(new MainForm()); }
7.7.7 The Button_Start_Sample_Click Method
Program Code
This method is executed when you click the “Start Sample” button. The OPC XMLWeb service is represented by an instance of the OPCXML_DataAccess class.
/*----------------------------------------------------------- | Name: Button_Start_Sample_Click | Desc: Handler is being called, when button “Start Sample” | has been pressed | Notes: Create an instance of the proxy class of the | webservice -----------------------------------------------------------*/private void Button_Start_Sample_Click(object sender, System.EventArgs e){ try { if (m_OPCXML_DataAcess == null) { m_OPCXML_DataAcess = new OPCXML_DataAccess (); m_OPCXML_DataAcess.Timeout = 10000; //Timeout 10 sec. }
Sample Programs
611SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The program checks the connection to the Web service by calling methods of theWebRequest class. If the Web service is not available, an exception is triggered.
// Checking the connection to the WebService // The WebRequest class throws a WebException when // errors occur while accessing an Internet resource WebRequest myRequest = WebRequest.Create(Edit_URL.Text); WebResponse myResponse = myRequest.GetResponse(); myResponse.Close();
Using the GetStatus method, the program queries the server status. This is thefirst time that a method of the XML interface is used.
// Assigning the url to the proxy class for the // web service m_OPCXML_DataAcess.Url = Edit_URL.Text;
//Checking the webservice status ServerStatus Status; ReplyBase replay = m_OPCXML_DataAcess.GetStatus (”en”, “1”, out Status);
If the server is running correctly, the program displays a dialog box with a variety ofinformation:
if (replay.ServerState == serverState.running) { string strText = “The operation completed successfully.\n\n”; if (Status.StatusInfo != null) { strText+= “\nStatusInfo\t: “ + Status.StatusInfo; } if (Status.VendorInfo != null) { strText+= “\nVendorInfo\t: ” + Status.VendorInfo; } strText+= “\nStartTime\t\t: ” + Status.StartTime.ToString(); if (Status.ProductVersion != null) { strText+= “\nProductVersion\t:” + Status.ProductVersion; }
Sample Programs
612SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
MessageBox.Show (this, strText, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
The text box for entering the URL and the “Start Sample” button are disabled. Allremaining buttons are enabled.
Edit_URL.Enabled = false; Button_Start_Sample.Enabled = false; Edit_Write_Value.Enabled = true; Button_Read_Value.Enabled = true; Button_Write_Value.Enabled = true; Button_Stop_Sample.Enabled = true; }
If an error has occurred in the Web service, this is displayed in a dialog box:
else { string strText = “The operation is not completedsuccessfully.\n\n”; MessageBox.Show (this, strText, this.Text,MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
If an error has occurred during execution of the program, this is handled within acatch block.
catch(Exception excep) { MessageBox.Show (this, excep.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }}
Sample Programs
613SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
7.7.8 The Button_Stop_Sample_Click Method
Program Code
This method executes when you click the “Stop Sample” button. Only theappearance of the dialog box changes, the text box for the URL can be editedagain and the “Start Sample” button can be clicked. All other buttons are disabled.
/*------------------------------------------------------------- | Name: Button_Stop_Sample_Click | Desc: Handler is being called, when button “Stop Sample”has been pressed |-------------------------------------------------------------*/ private void Button_Stop_Sample_Click(object sender,System.EventArgs e) { Edit_URL.Enabled = true; Button_Start_Sample.Enabled = true; Edit_Write_Value.Enabled = false; Button_Read_Value.Enabled = false; Button_Write_Value.Enabled = false; Button_Stop_Sample.Enabled = false; }
7.7.9 The Button_Read_Value_Click Method
Program Code
This method executes when you click the “Read Value” button. The program firstgenerates all the objects necessary for the read job, an array of the typeReadRequestItemLists and an array of the type ReadRequestItem each with oneelement. In addition to this, an instance of the RequestOptions class and theOPCError class are required as return parameters.
/*---------------------------------------------------------| Name: Button_Read_Value_Click| Desc: Handler is being called, when button ”Read Value”| has been pressed| Notes: initiates an sync read request -----------------------------------------------------------*/private void Button_Read_Value_Click(object sender, System.EventArgs e){ try
Sample Programs
614SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
{ Edit_Read_Value.Text = ”0”; Edit_Read_Quality.Text = ””; Edit_Read_TimeStamp.Text = ””; /// <summary> /// Make a new ItemList for a ReadRequest /// </summary> ReadRequestItemList ItemLists = new ReadRequestItemList(); ItemLists.Items = new ReadRequestItem[1]; ItemLists.Items[0] = new ReadRequestItem(); ItemLists.Items[0].ItemPath = ””; ItemLists.Items[0].ItemName = m_strItemName; RequestOptions opt = new RequestOptions(); ReplyItemList ItemValues; OPCError[] Errors;
The Read method of the XML interface is called with previously definedparameters. If a value could be read, the dialog box displays this in the “Value” textbox. Otherwise, “0” is displayed.
m_OPCXML_DataAcess.Read (opt, ItemLists, out ItemValues, out Errors); /// <summary> /// Assign the returned values to the TextBoxes /// </summary> if(ItemValues.Items[0].Value != null) { Edit_Read_Value.Text = ItemValues.Items[0].Value.ToString(); }
else { Edit_Read_Value.Text = ”0”; }
The values for the timestamp and the quality of the values are also displayed in theappropriate text boxes.
if(ItemValues.Items[0].TimestampSpecified) { Edit_Read_TimeStamp.Text = ItemValues.Items[0].Timestamp.ToString(); } else { Edit_Read_TimeStamp.Text = ””; }
if(ItemValues.Items[0].Quality!=null) { Edit_Read_Quality.Text = ItemValues.Items[0].Quality.QualityField.ToString();
Sample Programs
615SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
} else { Edit_Read_Quality.Text = ””; } /// <summary> /// Show Errors in a Message Box /// </summary> if(Errors.Length>0) { MessageBox.Show (this, Errors[0].Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
Program errors are handled in a catch block.
catch(Exception excep) { MessageBox.Show (this, excep.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }}
7.7.10 The Button_Write_Value_Click Method
Program Code
This method executes when you click the “Write Value” button. The program firstgenerates all the objects necessary for the write job, an array of the typeWriteRequestItemList and an array of the type ItemValue each with one element.The read value is returned in a parameter of the type ReplyItemList. In addition tothis, an instance of the RequestOptions class and the OPCError class are requiredas return parameters.
/*---------------------------------------------------------- | Name: Button_Write_Value_Click | Desc: Handler is being called, when button ”Write Value” | has been pressed | Notes: initiates an sync read request ----------------------------------------------------------*/private void Button_Write_Value_Click(object sender, System.EventArgs e){ try { Edit_Write_Quality.Text = ””; /// <summary> /// Make a new ItemList for a WriteRequest /// </summary>
Sample Programs
616SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
WriteRequestItemList ItemLists = new WriteRequestItemList(); ItemLists.Items = new ItemValue[1]; ItemLists.Items[0] = new ItemValue(); ItemLists.Items[0].ItemPath = ””; ItemLists.Items[0].ItemName = m_strItemName; ItemLists.Items[0].Value = Edit_Write_Value.Text; ItemLists.Items[0].TimestampSpecified = false; RequestOptions opt = new RequestOptions(); ReplyItemList ItemValues; OPCError[] Errors;
The Write method of the XML interface is called with previously definedparameters. If a value could be written, the dialog box displays this in the “Value”text box. Otherwise, “0” is displayed.
ReplyBase replay = m_OPCXML_DataAcess.Write( opt, ItemLists, true, out ItemValues, out s); /// <summary> /// Assign the returned values to the TextBoxes /// </summary> if (ItemValues.Items[0].Value != null) { Edit_Write_Value.Text = ItemValues.Items[0].Value.ToString(); } else { Edit_Write_Value.Text = ”0”; }
The returned values for the timestamp and the quality of the values are alsodisplayed in the appropriate text boxes.
if (ItemValues.Items[0].TimestampSpecified) { Edit_Write_TimeStamp.Text = ItemValues.Items[0].Timestamp.ToString(); } else { Edit_Write_TimeStamp.Text = ””; } if (ItemValues.Items[0].Quality!=null) { Edit_Write_Quality.Text = ItemValues.Items[0].Quality.QualityField.ToString(); } else { Edit_Write_Quality.Text = ””; } /// <summary>
Sample Programs
617SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
/// Show Errors in a Message Box /// </summary> if (Errors.Length>0) { MessageBox.Show (this, Errors[0].Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
Program errors are handled in a catch block.
catch(Exception excep) { MessageBox.Show (this, excep.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }}
7.8 Sample Program Custom Interface for Alarms & Events
Introduction
This section introduces the basic steps that a client must perform to be able toprocess events.
Step 1: Initialize the COM library
Every program that wants to use the COM library must first initialize it. This is doneusing the CoInizializeEx function that has an additional parameter compared withCoInitialize for the required thread model. This allows you to decide whether theCOM object is created in the single-thread mode or in the multi - thread mode.
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
Step 2: Convert the ProgID to a CLSID
To identify it, each COM server has a “ProgID” that is assigned to a worldwideunique “CLSID”. This is obtained with the CLSIDFromProgID() function. TheProgID of the OPC Alarms & Events server of SIMATIC NET isL”OPC.SimaticNETAlarms”:
hr = CLSIDFromProgID(L”OPC.SimaticNETAlarms”, &clsidOPCEventServer);
Sample Programs
618SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 3: Create a server object
The CoCreateInstance() function creates an instance of the class whose “CLSID”was specified.
hr = CoCreateInstance (clsidOPCEventServer, NULL, CLSCTX_LOCAL_SERVER, IID_IOPCEventServer, (void**)&gpIOPCEventServer);
The result of this program section is an object of the OPC server class.CoCreateInstance also provides a pointer to the IOPCServer interface of theserver object (gpIOPCEventServer parameter):
Step 4: Register with the event server
The client must be registered with the server to obtain notification of events. TheCreateEventSubscription method of the OPCEventServer class as an object of theOPCEventSubscription class to ES server and returns a pointer to theIOPCEventSubscriptionMgt interface (pgIOPCEventSubscrMgt parameter).
hr = gpIOPCEventServer->CreateEventSubscription (TRUE, dwBufferTime, dwMaxSize, hClientSubscription, IID_IOPCEventSubscriptionMgt, (LPUNKNOWN*) &pgIOPCEventSubscrMgt, &dwRevisedBufferTime, &dwRevisedMaxSize );
Step 5: Create a callback object
To allow the event server to send a notification to the client when events occurred,the IOPCEventCallback interface must be implemented on the client. In the sampleprogram there is an object of the COPCEventCallback class for this purpose thatonce derived from CObjektRoot and IOPCEventSink.
CComObject<COPCEventCallback>::CreateInstance (&pgCOPCEventCallback);
The pgCOPCEventCallback parameter is a pointer to the callback object.
Sample Programs
619SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Step 6: Connect the event server and callback object
The AtlAdvise() method creates a connection between the OPC server and thecallback object. The first parameter is a pointer to the IUnknown interface of theobject to which the client wants to connect. The second parameter is a pointer tothe IUnknown interface of the callback object:
hr = AtlAdvise(pgIOPCEventSubscrMgt, pgCOPCEventCallback->GetUnknown(), IID_IOPCEventSink, &dwAdviseEvent);
Step 7: Receive notification is from the Alarms & Events server
If an alarm occurs, the server calls the OnEvent method of the callback object. Inthe sample program, OnEvent is implemented so that the displayEvent method ofthe CReceiveAnAlarm dialog box class displays detailed information on the event.
STDMETHODIMP COPCEventCallback::OnEvent( OPCHANDLE hClientSubscription, BOOL bRefresh, BOOL bLastRefresh, DWORD dwCount, ONEVENTSTRUCT __RPC_FAR *pEvents)
The pEvents parameter is a pointer to a structure in which the information aboutthe events is stored.
Step 8: Acknowledge received event
The client acknowledges the notification of the server with the AckConditionmethod. The pszSource parameter contains the source of the event andpszConditionName the condition whose status change must be acknowledged.Both parameters are array addresses. In the example, only one event isacknowledged. Calling AckCondition can, however, and acknowledge severalevents.
The Alarms & Events server provides the values for pszSource andpszConditionName when it calls OnEvent as the components szSource andszConditionName of the ONEVENTSTRUCT structure.
hr = gpIOPCEventServer->AckCondition(1, L”Me”, L”NoComment”, &pszSource, &pszConditionName, &ftActiveTime, &dwCookie, &pErrors);
Sample Programs
620SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Step 9: Delete objects and release memory
Before exiting the program, the OPC objects that have been created must bedeleted and the memory reserved for them must be released. AtlUnadviseterminates the connection between the OPC server and the callback object.
hr = AtlUnadvise(pgIOPCEventSubscrMgt, IID_IOPCEventSink, dwAdviseEvent);
Each COM interface has the Release method with which the reference counter ofthe interface is decremented. When the interface is no longer referenced, theoccupied resources are released.
hr=pgIOPCEventSubscrMgt->Release();
The CoUninitialize method closes the COM library for the relevant thread andreleases the resources it was using. For each successful CoInitializeEx call, theremust be a corresponding CoUninitialize call.
CoUninitialize();
621SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
FAQs
Here, you will find the most common questions asked about the following topics.
� General FAQs
� OPC Server
� CP 1613
� Softnet Industrial Ethernet
� SEND/RECEIVE for Industrial Ethernet
� CP 5613/5614
� Changing from the CP 5412 to the CP 5613/14
� Softnet PROFIBUS (general)
� CP 5511
� CP 5512
� CP 5611
� Softnet S7
� Softnet DP
� Softnet FDL
8.1 FAQs in General
8.1.1 Administrator Privileges
Administrator Privileges - Which privileges are necessary under Windows NT, 2000, XP?
To install products and software, you require administrator privileges (you must bea member of the local “Administrators” group); for operation, you require thestandard permissions of a main user.
Without Administrator Privileges - What can I do without administrator privileges?
Without administrator privileges, you can run the applications for the variousprotocols (DP, FMS, S7, FDL, TF or SEND/RECEIVE). You do, however, require atleast the standard permissions of a main user.
8
FAQs
622SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
With Administrator Privileges - What can I do with administrator privileges?
You require administrator privileges to install the software and to start and stopdrivers. This means that you can only execute the operations of the “Set PG/PCInterface” and “Configuration Console” that require restarting the moduleparameter assignment when you have administrator privileges. As a user without administrator privileges, a message is displayed to tell you thatyou do not have permission to restart the CP. You must reboot the computer or log on with administrator privileges. If youanswer the “Restart computer?” prompt with “Yes”, Windows NT or Windows 2000is restarted. If you answer with “No”, you have the option of logging off and loggingon again with administrator privileges without restarting Windows NT or Windows2000.
8.1.2 Licenses
How can I remove the license from my computer?
The license can be installed and removed without the installation program on theCD. For this purpose, there is a program called ‘authorsw.exe’. Start this programfrom the Start menu and specify the drive on which the license is located. Selectthe relevant license, insert the original license diskette and press the F7 key toreturn the license to the license diskette. It can take several minutes for the license to be written back to the diskette. DO NOT INTERRUPT THE TRANSFER OF THE LICENSE - !!! OTHERWISEYOU MAY LOSE THE LICENSE ALTOGETHER !!!!
Somehow I managed to lose the license. What do I do now?
As long as you can prove that you obtained the product legally, you will receive areplacement for the license. Your Siemens contact will help you.
I installed SIMATIC NET on a compressed drive. An error message was displayed when Itried to install the license. Can’t I install the software on a compressed drive?
You can install product files on a compressed drive, but not the license. When youinstall the license, specify, for example, the host drive of the compressed drive.
Is the license removed when I uninstall the software?
When you uninstall the software with the uninstaller, you will be asked whether ornot you want to remove the license as well and return it to the license diskette. Asan alternative, you can also return the license to the key diskette beforeuninstalling a product. In this case, you use the “authorsw.exe” program that isinstalled on your hard disk.
FAQs
623SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.1.3 Windows Versions
How real-time capable is Windows NT / Windows 2000 / Windows XP?
Windows NT and Windows 2000 are not real-time operating systems. This meansthat when programs are starting up, when files are being read, or when accessingthe LAN, your application may not be executed for several 100 ms. You canimprove the reaction times of Windows for real-time applications in the followingways:
� Make sure that the computer you are using has enough memory so thatWindows NT/ Windows 2000 seldom needs to access the page file.
� Avoid intensive access to diskettes, hard disks, or CDs as is the case whenstarting up large programs.
Where can I get service packs for Windows NT / Windows 2000 / Windows XP?
From the Microsoft Web site: http://www.microsoft.com
Which version of Windows NT / Windows 2000 / Windows XP do I need to operate SIMATICNET?
The readme file in the main folder of the CD lists the Windows NT/2000 servicepacks with which this version of the CD was tested and released.
8.1.4 Miscellaneous
NTFS File System - What do I need to remember when using the NTFS file system?
If you use the NTFS file system of Windows NT, 2000 you can assign individual,user-specific rights for each individual file. To run some functions, files must be accessed and the required result is onlyachieved when the user of the function has adequate rights to access the file andfolder. If, for example, you do not have write permission for the folder in which you wantto save a database, you will not be able to save a database in that folder. A tracefunctions only when you have write permission for the trace file. The same appliesto other log files that can be created by diagnostic tools.
FAQs
624SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Rights for the Registry - Which rights are necessary for the registry of Windows NT, 2000, XP?
The user requires permission to read entries under“HKEY_LOCAL_MACHINE\SOFTWARE\Siemens”. Modifications by the configuration tools are only permitted when the user also haswrite permission for the “SINEC” subkey and its subkeys. Without the requiredrights, a warning is displayed. In the default setting, all users have read and write permissions for the keys under“HKEY_LOCAL_MACHINE\SOFTWARE\Siemens”.
Can I use a screensaver?
Remember that if you use a screensaver, it also requires CPU time and can lead tosystem overload. Some screen savers do not release memory resources again.This means that usable main memory is continually reduced.
Can I use virus scanners?
Using a virus scanner during operation can cause problems with hardwareexpansions (for example, SIMATIC NET communication modules). It is advisable to run virus tests only when no applications are active. Following avirus test, the computer should be rebooted.
Where can I get information about other SIMATIC NET products?
You will find information about other SIMATIC NET products and current softwareversions in the following sources:
� On the CD shipped with the product
� In the “IK PI” SIMATIC NET product catalog
� On the Internet (http://www.ad.siemens.de/net)
How can I find out the product version of SIMATIC NET products?
Open “Add/Remove Programs” in the Control Panel: Start > Settings > ControlPanel > Add/Remove Programs.
When you install SIMATIC NET under Windows NT / Windows 2000 / Windows XP, variousservices are set up and are always started automatically. Are these servicesnecessary?
These services are absolutely necessary for running SIMATIC NET. Under nocircumstances remove or deactivate these services. SIMATIC NET cannot runcorrectly without these services.
FAQs
625SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
How can I check whether my hardware was installed correctly?
Use the diagnostic options provided by the “Configuration Console” program or usethe supplied sample programs to test your hardware. You will find a detaileddescription of the samples in this documentation.
FAQs
626SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.2 FAQs on the SIMATIC NET OPC Server
8.2.1 Product Characteristics
Is parallel operation of more than one protocol possible with the OPC Server of SIMATICNET?
Yes! To do this, you must configure the required protocols.
How are the cycle time and update quality of the partner device related?
QualityOfStateValueThe “QualityOfStateValue” value describes the required update quality of the data.Process values on the partner device are updated at this scan rate and if there is achange compared with the previous value, this is reported to the PROFInet OPCServer.
The time at which the change message arrives at the OPC server decides thetimestamp of the variable; the default value for QualityOfStateValue on aPROFInet OPC server is 100 ms.
Cycle TimeThe CycleTime parameter is set in ms, and specifies how often the PROFInet OPCServer reads or writes OPC items on the partner. If items are active in active groups, the PROFInet OPC Server checks whetherthere are any data changes. This is the internal scan time of the PROFInet OPC server; the default value forCycle Time on a PROFInet OPC server is 100 ms.
The times set for the cycle time and the update quality can be different. We,however, recommend that you use the same time settings for the cycle time andthe update quality. The message about data changes of active items in activegroups of an OPC client is, however, sent according to the selected OPC updaterate (default value in the OPC Scout: 500 ms).
The following selectable times determine (in the order shown) the data changesthat can be monitored:
Parameter Default
QualityOfStateValue 100 ms
Cycle Time 100 ms
UpdateRate; OPC Scout 500 ms
FAQs
627SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
This allows data changes to be recorded, for example with the OPC Scout, at leastevery 500 ms.
On completion of the OPC client installation, the error message “rundll32 cannot beinitialized” appears. Why?
If the OPC client installation is started while the hardware detection is running, theerror message “rundll32 cannot be initialized” appears on completion of theinstallation.
Wait for the hardware detection to complete before installing the OPC client or stopthe hardware detection and then install the OPC client.
Why are incorrect error messages displayed when there is more than one active protocol?
A write call via the IOPCSyncIO OPC Interface with an invalid server handlereturns the incorrect error code S_OK instead of S_FALSE.
Asynchronous writing to a symbolic OPC item that was assigned write permissionsby the Symbol File Configurator but actually only has read permissions does notdeliver a correct write return value (Write Result). The return value is “Unknownerror” instead of “inadequate access rights”.
Adding nonexistent OPC items with the OPC Scout or with the “AddItem” OPCfunction results in the error message “An internally used service has completed”instead of “Invalid item”.
Workaround: Use only one active protocol and no symbols.
Why is the DP communication system blocked?
If an OPC client terminates unexpectedly, without previously releasing the OPCserver in the DP-Inproc variant, the DP communication system remains blockedeven after the end of the program. You must reboot your computer to cancel thisinterlock. If an OPC client is not yet stable, for example during the developmentphase, you should use the Outproc variant of the OPC Server.
How do I start the OPC Server?
To start the OPC Server, the administrator or a user must be logged in on theserver.
The workstation should be protected from unauthorized access using ascreensaver. “Interactive user” must also be set for the access permissions in the“DCOMCNFG” program.
FAQs
628SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Why does the OPC Server not keep to the set delay time after the “Close OPC Server” callis sent?
Using the SIMATIC NET Configuration Console, you can set a delay after whichthe OPC Server closes down. The OPC server does not keep to this delay time.The server shuts down immediately.
Wide-ranging tests have shown that after a request from an OPC client to closedown the server no further calls should be made since this can lead to extremelyserious disturbances. For this reason, the OPC Server shuts down immediatelydespite any delay time you may have set.
Can the “Configuration Console” program be started more than once?
There are several ways of starting the “Configuration Console” a second time(direct insertion in the Microsoft Management Console, starting the msc. file in theExplorer etc.).
If the program is started more than once, consistency problems must be expectedso that it is not advisable to make use of these possibilities.
What do I need to remember when using XDB files with older software versions?
If you use the version of the SIMATIC NCM PC program from the CD 07/2001 tocreate XDB files for software of an older SIMATIC NET CD, there are two pointsyou should note:
� The “S7RTM is installed” option must be deactivated in the properties page ofthe PC station in the Configuration tab.
� A MAC address must be configured for all Ethernet modules (the “Set MACaddress / use ISO protocol” option must be activated).
Can symbols and Percent Deadband be used with the DP-Inproc variant?
The DP-Inproc variant does not support the use of a symbol file for reasons ofperformance. The use of symbols and the “Percent Deadband” OPC property istherefore not possible when using the DP-Inproc variant.
FAQs
629SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.2.2 Operating and Programming the OPC Server
I have developed a program in C++ using the Custom Interface. How can I check whetherall OLE interfaces are released again after my program closes?
If your program releases all interfaces correctly, the OPC Server automaticallyremoves itself from memory after you close your program. Start the Task Managerof Windows NT / 2000 / XP (for example with CTRL-ALT-Del, ’Task Manager’button) and click on the “Processes” tab. If the OPC Server is still running, you willsee a process with the name “SOPCSRVR.EXE” in the list.
How can I close down the OPC Server if it remains in memory due to an error after closingall the clients?
Open the page “Close OPC Server” in the “Configuration Console” and click the“Close OPC Server” button. You should NOT close the OPC Server using the TaskManager!
What do I need to remember if I abort an application with OPC or the DataOCX in thedevelopment environment with the debugger?
If an application is aborted, the chances are that it will not be able to tidy upinternal references to the OPC Server. As a result, the OPC Server continues torun and communication is not shut down. To close down the OPC server, open thepage “Close OPC Server” in the “Configuration Console” and click the “Close OPCServer” button.
Which header files do I need to include to be able to use the Custom Interface of the OPCServer?
Include all the header files from the “Simatic Net\opc2\inc” folder. You will also findthe C file “opc_i.c” in this folder. This file defines classes containing the interfacemethods. If you include this file in your project, you can access the interfacemethods directly.
You should also have a look at the sample programs!
How should I design my program for the OPC Custom interface so that communication overOPC is as efficient as possible?
Use the OPC concept of monitoring the items in groups. Use the CACHE for readcommands and activate the groups only when you really want to read values. Yourapplication is then only involved in communication tasks when values actuallychange.
FAQs
630SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
What errors does the SIMATIC NET OPC Server return when AddItem is called if I have a badpath section in the ItemID? (for example DP:[CP_WRONG])
Although the path causes the error, the ItemID parameter is wrong. As a result, theOPC_E_UNKNOWNITEMID error is returned.
Which return values need to be checked with group operations over the OPC AutomationInterface in Visual Basic?
in the function result, Visual Basic does not distinguish between a fully successfulfunction (i.e. for all elements of a group operation) or only partly successful result.You should therefore check the arrays with the return values of the individualelements when using group operations in Visual Basic. (Example: Errors withSyncRead)
What information is used by the OPC Server if a different path section is specified in theAccessPath parameter compared with the path in the ItemID parameter?
The OPC Server puts together the full name of the variable from the AccessPathand ItemID. If an ItemID is used in the AccessPath, this must NOT be included inthe ItemID as well. Otherwise, the item cannot be inserted in a group.
What does a time stamp with the value “1.1.1601 12:00” mean?
This date is the initialization value 0 of a time specified in Windows. The OPCServer returns this time stamp if no variable has been read up to now. Variablesthat can only be written have this time stamp.
Does an older time stamp mean that the value may be out of date?
No. An older time stamp says that the value has not changed since the timeindicated by the time stamp. The validity of the value is monitored constantly bythe server. A new time stamp is entered only when the value changes. TheSIMATIC NET OPC Server enters the time at which the OPC Server receives theprocess variable as the time stamp. You obtain an older time stamp, of course,only when you read from the cache. If you read from the device, the time at whichthe value is received is used as the time stamp, regardless of whether or not thevalue has changed.
How can I tell whether or not a variable is valid?
Evaluate the quality flag.
FAQs
631SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
When is the “OnDataChange” callback called by the OPC Server? (Version 1.0 of the OPCSpecification)
The OnDataChange callback can be called before the function that triggers thecallback is completed. This does not include callbacks without transaction ID. If an OPC client requires synchronization of the callback, this could beimplemented as follows:
� Copy the data to their own global process buffer in OnDataChange.
� PostMessage to the local address with the buffer as parameter.
� Use the connection points of the OPC Custom Interface 2.0
The OPC Server returns some error codes that are not described in the supplied OPCspecifications. What do the error codes mean?
Internal communications problems are coded by the SIMATIC NET OPC Serverusing specific error keys (HRESULT). These are as follows:
� C0048003 (hex): Timeout, for example due to aborted connection
� C0048004 (hex): An external server has not started
� C0048006 (hex): Unexpected communication error
As with other errors, applications can call the IOPCServer::GetErrorString methodto get a textual description of the problem.
How does the OPC Server check the syntax of transferred numeric values?
The OPC Server tolerates certain errors in transferred numeric values. An integer“123.45” is accepted without error as “123”. The real value “1,22” is accepted as“1” if the period is set as the separator in the Windows System.
I have set 200 ms as the value for the scan cycle. The update rate of the group should be500 ms. in reality, however, some update times are 700 ms.
In some situations, the update times of the protocol and the group are addedtogether. This conforms with the OPC Specification that stipulates that a groupmust not be reported faster the specified update rate. If necessary, reduce theupdate time of the group.
How should symbolic variable names be defined with the OPC Server of SIMATIC NET?
There are two basic ways of defining symbolic names:
1. Entry in the protocol-specific configuration file by using OPC Scout
2. Taking symbols from STEP 7 and creating new symbols with the Symbol FileConfigurator
These two different procedures have the following features:
FAQs
632SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Alias Defini-tions
Simple and fast entry of symbolic names
Only the part of the ItemID containing the variable namecan be replaced by an alias. The protocol ID and the con-nection name cannot be replaced
The startup phase of the OPC Server is longer when alarge number of alias names is defined.
Symbol FileConfigurator
The Symbol File Configurator simplifies the entry of largenumbers of symbols by entering them in table form.
The symbols can be hierarchically structured.
Symbols are not dependent on the structure of the ItemIDsor the protocol.
The startup phase of the OPC Server does not depend onthe number of variables.
To retain expandability and independence from protocol properties, the use of theSymbol File Configurator is advised.
If the FDL protocol is activated alongside the DP protocol in the configuration of the OPCServer, a slight loss of performance can result.
If two protocols are activated at the same time, a multiplexer is startedautomatically. This can also cause a slight loss in performance. You should onlyactivate the protocol you require.
In the SEND/RECEIVE and FDL protocols, there are read-only variables (for exampleReceive). When I enter these variables in the Symbol File Configurator, it ispossible to declare these variables as write-only. Why isn’t it possible to insertthese variables in a group?
When specifying the access rights with the Symbol File Configurator, the rights canbe restricted but not expanded. As a result, it is not possible to declare an item thatis read-only by virtue of its properties (such as the Receive buffer) as writableusing the Symbol File Configurator. By specifying access rights in the Symbol FileConfigurator, it would, on the other hand, be possible to further restrict the readrights of a previously read-only item. Such an item that can neither be read norwritten cannot be entered in a group with AddItem.
FAQs
633SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
An OPC client uses the OPC Server continuously, other OPC clients start and close againcontinuously. A slight loss of memory can be observed in the OPC Server.
The memory losses resulting from the configuration described above cannot beinfluenced by the OPC client or OPC Server and have been observed on verydiffering servers. The reason for this is the internal memory handling of MicrosoftCOM. In this case, it is advisable to close down the OPC Server when necessaryand then to restart it.
Is it possible to import BOOL arrays?
Arrays of BOOL variables defined in the STEP 7 project cannot be used by theOPC symbols.
The import function in the Symbol File Editor is performed without an errormessage being displayed, however the AddItem OPC function, for example in theOPC Scout, rejects use of the variables with the error message “Item definitiondoes not exist in the name space of the server”.
Flat browsing with the OPC Server
Hierarchical BrowsingAll items of the currently selected level are returned.
Flat BrowsingAll items of the selected level and all items of the levels below are returned.The elements of the individual levels are separated by a backslash (“\”). Theresulting string represents the item. This separator can, however, differ from serverto server; the SIMATIC NET OPC Server always returns the backslash asseparator.
8.2.3 Creating the Configuration
How is the MinimumUpdateRate of the OPC Server obtained?
Since the SIMATIC NET OPC Server can use variables of different protocols at thesame time, the MinimumUpdateRate of the OPC Server is the highest value set forthe scan cycle time for the active protocols.
Example
A scan cycle time of 100 ms is configured for DP. No other protocol is being used.100 ms is used by the OPC server as the MinimumUpdateRate. The S7 protocol isnow activated and the scan cycle time configured for this protocol is 500 ms.Result: The OPC Server now uses the value 500 ms as the MinimumUpdateRatefor all protocols.
FAQs
634SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
How can I change the access rights of OPC variables?
Local OPC information variables (such as “&statepath()”, see manual) have fixedaccess rights, normally only read rights. This can be extended or restricted bycreating and assigning a symbol to an information variable in the Symbol FileConfigurator.
Regardless of this setting, the correct access rights will be used for this local OPCinformation variable and displayed in the OPC Scout.
This does not apply to remote communication variables, the access rightsconfigured for these variables with the Symbol File Configurator are displayed inthe OPC Scout. The actual rights are checked only during run time.
How can I access the component management of the PC station?
The Station Configuration Editor is the user interface of the Station Manager. Itallows access to the component management of the PC station.
The Station Configuration Editor is started automatically after logging on with theoperating system. It enters itself as a separate icon at the far right of the task bar(system tray). Double-clicking on the icon opens the Station Configuration Editor. The Station Configuration Editor can, however, also be started manually using the“Station Configuration Editor” shortcut on the desktop.
How can I access the component management of the PC station?
The Station Configuration Editor is the user interface of the Station Manager. Itallows access to the component management of the PC station.
The Station Configuration Editor is started automatically after logging on with theoperating system. It enters itself as a separate icon at the far right of the task bar(system tray). Double-clicking on the icon opens the Station Configuration Editor. The Station Configuration Editor can, however, also be started manually using the“Station Configuration Editor” shortcut on the desktop.
Which settings do I need to make for the OPC Alarms & Events server and DP-Inproc serverfor OPC Data Access?
The DCOM configuration settings described in this documentation applyanalogously to the OPC Alarms & Events server and the DP-Inproc variant of theOPC server for Data Access.
In the “Applications” tab, however, the name of the relevant server must beselected instead of the “OPC.SimaticNet” server, as follows:
� OPC.SimaticNET.DP for the DP-Inproc variant of the OPC Data Access server
� OPC.SimaticNetAlarms for the OPC Alarms&Events server.
FAQs
635SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.2.4 The Symbol File Configurator
Is it possible to use iMAP and the OPC Symbol File Configurator at the same time?
OPC symbol files can be created and processed by the iMAP PROFInetengineering tool or using the OPC Symbol File Configurator. With a suitable configuration, the symbol file is also accessed during run time; inother words, when this file is activated in the Configuration Console and anapplication accesses the symbols.
You should avoid simultaneous access by these programs to avoidinconsistencies. Please close the relevant applications before accessing the samefile with a different application!
What is the maximum permitted length for the path of a symbol file?
The path including the drive and file name of a symbol file must not exceed 180characters.
Otherwise, the symbol file is not accepted by the OPC Server; the symbolic namespace cannot be investigated and it is not possible to insert symbolic names.
What types of symbols cannot be created with the Symbol File Configurator?
Creating symbols that contain connections to WinAC stations is not possible withthe Symbol File Configurator.
What are the effects of quotes in the name of a symbol file?
If a name in the symbol file contains a quote (’), the symbols are displayed asnon-existent.
Can symbol names for FMS items be taken from the object dictionary (OD) into the SymbolFile Configurator unchanged?
No. If you take the item from a long object dictionary (OD) when creating a newFMS symbol, the symbol name will include the period (”.”) as delimiter. Beforeapplying the symbol, the symbol name must be modified so that it contains noperiods.
8.2.5 Special Features of the FMS OPC Server
Why is it sometimes not possible to establish an asymmetrical FMS connection?
The main feature of asymmetrical FMS connections is that only one partner canestablish the connection actively. Typical connection attributes are I-D, I-O, orD-O. If the OPC Server is the active partner and with the normal configuration, thetime interval within which the server attempts to establish the connection isrestricted. If the partner does not respond within this interval, connection
FAQs
636SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
establishment is aborted. In this case, the following configuration for theconnection can be helpful:
Option “The connection is maintained permanently”
With this setting, the active end attempts to establish the connection without timerestrictions. If the active end only had a predefined interval available to establishthe connection (as in the default setting), the connection would only be establishedwhen the passive end responded within this time. This is generally only guaranteedwhen the passive end has already been started. The default setting that does notinclude this entry does not solve the problem of asymmetrical connections butdoes limit the extra load on the network resulting from connection establishmentattempts to a specific time. This is generally the better option for the much morecommon situation involving symmetrical connections.
Establishing the FMS connection to partners with a large object dictionary takes such along time that the startup of the system is delayed considerably. Is there a wayto avoid this?
Depending on the partner device, loading an object dictionary can take aconsiderable amount of time. If high indexes were configured within an objectdictionary, the connection establishment can be considerably delayed. The extraload on the network is by no means insignificant. The situation is made worsesince the communication software cannot query the object dictionaries of differentdevices at the same time.
If the system consists of several FMS servers, that are accessed by the PC as anFMS client, the startup phase of the system can take a considerable time andreliable connection establishment may not be possible. For this reason, the OPCserver provides the option of using an object dictionary loaded at a different timeand maintained in local storage.
To create a local object dictionary, you require the ODUPLOAD.EXE program. Thisis installed in the following folder:
<Installationpath>\SIEMENS\SIMATIC.NET\opc2\binFMS\ODUPLOAD.EXE
To start the program, open a DOS box and change to the relevant folder with “cd<installationpath>\SIEMENS\SIMATIC.NET\opc2\binFMS”.
Start the program with the following syntax:
odupload “conn|vfd|cp” filename [odformat [timeout]]
The “conn” parameter identifies the connection, “vfd” and “cp” specify the VFD andthe active interface profile of the communications processor via which the objectdictionary will be loaded. You can find out the interface parameter assignment byopening the “General” properties page of the module in the Configuration Console.The “filename” parameter specifies the path and file name of the local objectdictionary to be created. The optional parameter “odformat” decides whether a long(value 1) or a short (0) object dictionary is requested. The default value for thisparameter is 0. With the “timeout” parameter,the time after which an error isgenerated is specified in milliseconds. The standard value is 120000 for 2 minutes.
FAQs
637SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Example: odupload “FMS connection1|VFD 2|CP 5613 (PROFIBUS)”“c:\MyOD\OD_Conn1.od” 1 240000
Use To use the local object dictionary for a connection, two configuration steps arenecessary:
1. Configuration Configure an FMS connection between the PC station and partner device. Openthe “Partner Variables” tab in the “Properties - FMS Connection: Options” dialog.Activate the “Use locally stored object dictionary” option button. Transfer theconfiguration to the PC station as normal.
2. Local settings on the PC stationThe path of the generated local object dictionary must be specified on the PCstation. To do this, you must edit the configuration file for FMS. The configurationfile for FMS is located in<installationpath>\siemens\simatic.net\opc2\binFMS\ScoreFMS.txt.
Look for the configuration file in the section [LOCAL_FMS_OD]. If you do not find itthere, make the following entry for every connection with a local object dictionary inthis section: <VFDname>|<connectionname>=<pathODfile>
Example: [LOCAL_FMS_OD] VFD 2|FMS connection1=c:\MyOD\LocalOD_Conn1.od
8.2.6 Special Features of the DP OPC Server
Which slaves can be addressed with the OPC Server for SIMATIC NET?
All the standard slaves supported by the configuration tools SIMATIC STEP 7 orSIMATIC NCM PC can be addressed by the OPC Server. Non-standard slaves canbe addressed, however, no structured access to the inputs and outputs of theseslaves is possible.
FAQs
638SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.2.7 Special Features of the S7 OPC Server
How does the OPC Server optimize access with S7 functions? Is the optimization of the S7variable access active following installation? If it is not, how can I activate it?
The OPC Server collects the communications jobs (read/write jobs, variablemonitoring jobs) from all active clients in a central queue. The individual jobs arethen grouped together:
1. If individual jobs on a connection represent a contiguous memory area (forexample all bytes from 1 to 100 of a data block), these jobs are put together toform one job accessing an array. This optimization is active as default but canbe deactivated since it puts load on the CPU of the PC. To deactivate theoptimization, the connection-specific option “Optimize read access” or“Optimize write access” must be deactivated in the configuration.
2. Jobs to access the non-contiguous areas or different data types are groupedtogether for the specific connection. The number of jobs that can be puttogether depends on the PDU size and the length of the requested data. Thisoptimization is always active.
3. Credits are used; in other words, the number of jobs processed at the sametime on one connection depends on the number of available credits.
4. Jobs on different connections are handled at the same time.
Which S7 variable types are not supported by some S7 CPUs?
The variable types supported by the S7 protocol are not all currently implementedin all S7 CPUs. For this reason, the variable types STRING, TIMER andCOUNTER must not be used. With bit arrays, the array size must be a multiple of8.
When I browse the S7 items, I only see the connection names. The blocks and variables arenot displayed. Why is this?
To allow browsing, the OPC Server must already have established communicationconnections to the S7 partners. If this is not possible (for example because the S7PLC is not ready for communication), the browser displays only the connectionnames. Make sure that the S7 partner is ready for communication.
Is it possible for two PCs to communicate using the S7 protocol?
The buffer send/receive services of the S7 protocol also allow a PC-PC link usingthe S7 protocol. A connection for the server functionality must be configured onone PC. The following settings must be made for this connection in theconfiguration:
Deactivate “Active connection establishment”
FAQs
639SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
On the server PC, the S7 OPC Server must be started by a client (for exampleOPC Scout) and suitable BSEND/BRECEIVE variables must be set up for theconnection.
For the client PC, a suitable connection must be configured as follows:
Activate “Active connection establishment”
Select “Always establish connection”
What consistency is guaranteed in communication with an S7 partner?
The S7 devices guarantee that data records up to a certain size are consistentwithin the controller (depending on the type of controller). With larger data packets,it is possible that the program of the controller will be interrupted and that anotherprogram section will change the data.
When accessing arrays over the OPC Server that are longer than the length of aPDU, the data transfer must be distributed over several jobs. As a result ofhandling the job over several cycles, not only changes to the data by the programof the controller are possible but also changes resulting from a write job over thenetwork. When you design your system, you should take such possibleinconsistencies into account.
For a read job with s7_read_req or a write job with s7_write_req, the followingconsistency limits apply depending on the PDU size:
PDU size (bytes) Maximum length ofthe user data when
reading
Maximum length ofthe user data when
writing
240 222 212
256 238 228
480 462 256 *)
960 942 256 *)
*) With the s7_write_long_req call, longer user data is possible. For more detailedinformation referred to the “S7 Programming Interface” manual.
For more detailed information on consistency, refer to the S7 communicationsmanual supplied with STEP 7.
FAQs
640SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.2.8 Special Features of the SR OPC Server
Why does the S5 partner station terminate the connection to the OPC Server when the OPCScout is used to monitor a write connection?
Just like other OPC clients, OPC Scout continuously sends read jobs to the partnerdevice. An S5 controller reacts to a read job on a write connection by terminatingthe connection. This is also the reaction to a write job on a fetch connection.Configure the mode of the SEND/RECEIVE connection accordingly.
When using the “Generate values” function, the connection aborts and the OPC Scout nolonger reacts. How can I get control of the program again?
If the OPC Scout writes cyclic values using the “Generate values” function, and ifthere is an interruption on the connection, the OPC Scout can no longer becontrolled by the operator because the write operation uses synchronous calls. It isnot even possible to close the program.
You will only be able to work with the program either when the connection isre-established or after the OPC server shuts down (Configuration Console ->Close OPC Server). Please note that in the latter case all other communication viathe OPC Server will be aborted.
Is it possible to read and write SEND/RECEIVE OPC items simultaneously?
SEND/RECEIVE OPC servers always require two items for reading and writing.This is a system characteristic of the SEND/RECEIVE protocol. This can lead todisplay problems on the visualization clients that often have only one field fordisplaying and setting a value. In this case, it is advisable to use the S7 protocolfor displaying values.
8.2.9 Special Features of the FDL OPC Server
If write jobs are sent to a communications partner in quick succession (for example withGenerate Values in OPC Scout), some of these jobs are rejected. What is thecause and how can I get round the problem?
Write jobs to a partner device can only be accepted when a receive resource(Await indication) is prepared on the partner device. This receive resource is filledwith data when it is received and then passed to the processing application. Thisapplication is then responsible for preparing a new receive resource. In thesituation described here, the receiving station cannot prepare receive resourcesquickly enough. With the connection-specific “Maximum retries” parameter, thenumber of repetitions in case of “No resource” can be set for the FDL OPC Server.
FAQs
641SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Why does the OPC Server not always obtain the actual value of a SEND/RECEIVE variablecorrectly?
The SEND variable has the access right “RW“. This variable can be written and read although the SEND/RECEIVE partner doesnot provide for the item being read back.
When this item is read back, the OPC Server returns the last successfully writtenvalue.If no value has yet been written successfully for this item, the quality “bad” isreturned. The actual value of the variable cannot therefore be obtained by the OPC Server.
8.2.10 OPC Scout
How do you use the “csv” file created by OPC Scout as a result of the print command?
These files contain the stored table in a form separated by commas (hence theacronym CSV = “comma separated values”). This can be imported into Excel.
The OPC Scout displays a different time from the actual local time as the time stamp. Why?
To allow time information to be compared in automation systems distributedworldwide, the OPC standard stipulates the display of the time stamp in UTCformat (Universal Coordinated Time). UTC is a standard world time previouslyknown as Greenwich Mean Time. The OPC Scout displays this time.
OPC Scout monitors values. If the communication connection breaks down, OPC Scoutsometimes displays a random value, for example, “1\\0\\0\\0”. Why does it dothis?
In the OPC Automation interface for Data Access, there is no parameter fortransferring errors in the definition of the OnDataChange function, while this existsin the OPC Custom interface for Data Access. As a result, the OPC Scout as anOPC Automation client cannot recognize when an error has occurred during dataacquisition. The OPC Scout displays the transfer values even if the values areundefined according to the specification of the Custom interface.
How do I specify decimal numbers in the OPC Scout when writing values?
The OPC Scout transfers the values entered in the “Write values of items” dialogunchanged to the OPC Server. Here, string is used as the data type. The OPCServer makes the type conversion using operating system functions.
FAQs
642SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
When you make entries in the OPC Scout, you therefore use the separatorspecified in the Windows Control Panel as the decimal symbol (Regional Settings).If you use the wrong decimal symbol, this might be ignored during the typeconversion. In an English Windows installation, the decimal symbol is the period,whereas in a German installation it is the comma.
When entering values with the OPC Scout, it is the responsibility of the user tomake sure that the values are correctly represented for the data type of the item.As an example, no rounding strategy is defined when entering numbers withdecimal places for variables of an integer type such as bytes. The individualelements within arrays are also not handled in exactly the same way as singularvariables of the element type by the conversion routines of the operating system.
What is a maximum length of a variable value in the OPC Scout?
In the OPC Scout, the input and output of values is restricted to a displayablelength of 2048 bytes per variable.
This means, for example, that you can only use a send buffer reliably for a BSENDvariable with a length of 511 bytes.
As soon as the displayable length exceeds 2048 bytes, no more data is displayed.
How many variables can be used per project?
The OPC Scout V2.2 can utilize up to 100 percent of the CPU depending on thenumber of variables to be monitored.
You should therefore plan the number of variables in the project based on theupdate rate and the frequency of changes in the variables if you want to use theOPC Scout.
Date-and-time variables are displayed without the time. Why?
When displaying the value 00:00:00 (midnight) of variables of the Date-and-Timetype, the OPC Scout displays only the day but not the time. All other times aredisplayed correctly.
What do I need to remember about the “New Definition” function when using theSEND/RECEIVE protocol?
If you make entries in the form “SR:[connection]send,Bxx,yy“, note the following:The information entered in the input dialog box for the address range and numberof values is not correct.
To make a correct entry for these items, you must know the default size of thesend buffer. The default size of the send buffer is specified when configuring thedatabase using STEP 7 or NCM PC. When you enter the address, remember that this can only have a value between 0and the default size of the send buffer minus 1. If 25 was configured as the size of the send buffer, addresses between 0 and 24are possible.
FAQs
643SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The maximum value for the number of values is calculated as follows:
(size of the send buffer - address) / (size of the selected data type), rounded down
Why can some variables not be entered with the “New Definition” function?
The “New Definition” is used to enter items. In the following situations, itemscannot be entered with this function:
Items in the form “SR:[connection]sendXXXX,range” cannot be entered with thisfunction (where XXXX represents the size of the send buffer). In such situations,insert any item and then move the item to the right-hand pane of the dialog. Afterselecting the item, the “Modify variable” menu command is available in thecontext-sensitive menu. You can then change the variable name to the requiredformat.
Items in the following forms cannot be entered with this function:
� SR:[connection]fetch,range
� SR:[connection]write,range
Can the local server be configured as an external server?
The documentation for the OPC Scout describes that either the local OPC Serveris used or the client communicates with an external server by remote access.
Please remember that by configuring the (D)COM properties of the OPC server(for example OPC.SimaticNet, modifications made with the DCOMCNFG operatingsystem application) the local server (Server -> Local server) can be addressed asan external server. This entry therefore makes both variants possible in the GroupNavigator.
When using the “Generate values” function, the connection aborts and the OPC Scout nolonger reacts. How can I get control of the program again?
If the OPC Scout writes cyclic values using the “Generate values” function, and ifthere is an interruption on the connection, the OPC Scout can no longer becontrolled by the operator because the write operation uses synchronous calls. It isnot even possible to close the program.
You will only be able to work with the program either when the connection isre-established or after the OPC server shuts down (Configuration Console ->Close OPC Server). Please note that in the latter case all other communication viathe OPC Server will be aborted.
FAQs
644SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.2.11 DCOM Configuration
After the DCOM configuration of the OPC Server using the Microsoft tool “dcomcnfg.exe”,the properties pages of the network adapters are missing in the Control Panelof Windows 2000 / Windows XP (“Network and Dial-Up Connections”).
This problem occurs with other COM servers and is not peculiar to SIMATIC NETsoftware. This must be counted as a characteristic of Windows 2000.
8.2.12 PROFInet OPC Server
Errors occur during communication or the wrong process variables are accessed. Whydoes this happen?
If you use the S7 and PROFInet protocols with S7 extended variables at the sametime, the names of the S7 connections configured in SIMATIC STEP 7 must not beidentical to the device names specified in iMAP (displayed in the plant view).
Otherwise, the connections configured in SIMATIC STEP 7 are used for thePROFInet S7 extended variables. This results in communication errors or accessto the wrong process variables.
Note
If you use the S7 protocol and PROFInet at the same time, you can open the sym-bol file created for PROFInet with the Symbol File Configurator and check the con-nection names.
Why do S7-OPC symbols no longer work after installing iMap
If the PROFInet configuration iMap 1.0 is installed after the SIMATIC NETSoftware Product CD 07/2001, S7-OPC symbols can no longer be monitored overconfigured connections. In the OPC Scout, you can no longer add a symbolic itemfor monitoring.
Remedy:
Reregistering the latest symbol file server of the SIMATIC NET Software ProductCD 07/2001 after overinstalling iMap. This COM server is in the folder
<Windowfolder>\system32
Reregister in the command prompt with: ”regsvr32 s7sntfsx.dll” in the abovementioned folder.
FAQs
645SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
How can I prevent overflow of the Event Viewer?
If there are no PROFInet partners, the Windows Event Viewer displays a warning.This warning is displayed each time an attempt is made to access this DCOMconnection. In Windows 2000 / XP, this occurs at intervals of approximately 10seconds whereas the intervals are significantly longer in Windows NT 4.0. As aresult, the Event Viewer can overflow and it is possible that other system eventsare overwritten.
Remedy:You can configure the Event Viewer in Windows:
� Set filters for DCOM
� Change the setting for “overwriting events older than” (default 7 days)
� Select “do not overwrite events”, no event is lost
� Increase the maximum log size (default 512 Kbytes).
Is it possible to read out the values of the configured variables?
When monitoring OPC PROFInet variables (active OPC PROFInet items in anactive OPC group), the PROFInet OPC Server establishes a connection to thesevariables on the PROFInet partner device. On this interconnection, only datachanges are reported to the OPC Server, constant reading out of the value isunnecessary. This strategy reduces bus load and greatly improves performance.
The disadvantage is the restricted number of possible connections to PROFInetcomponents since an interconnection is required for each OPC item beingmonitored. You should take this into account when configuring your system. Makesure that you also read the instructions on the SIMATIC iMap PROFInetengineering tool.
Re-establishing a connection takes several minutes; what factors influence the time takento re-establish a connection?
The connection monitoring of the PROFInet OPC Server allows it to detect thebreakdown of a connection.
The time taken to re-establish the connection and the associated change in thequality of the items from “BAD” to “GOOD” can take up to several minutes. Theactual time required depends, on other things, on the restart response of thepartner.
FAQs
646SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.2.13 SIMATIC NET OPC DataOCX
Why is no event message output on connection establishment?
When using the “Automatic connect” property (default setting) of the DataOCX, thetime at which the OPC server establishes the connections to the communicationpartner and the time at which the VB application is ready to receive an eventmessage on the connection establishment are not synchronized.
It is possible that the connection establishment takes place before the applicationis ready to receive events so that an event message on the connectionestablishment cannot be received.
RemedyDeactivate the “Automatic connect” property in the DataOCX and call the“Connect” method in the program when the application is initialized.
Out-of-date values are displayed in the visualization control. Why?
When you interconnect process variables with controls for visualization, theValue_Changed callback is not synchronized with the transfer of the data value tothe control for visualization. It is therefore possible that when the value is read outin the visualization control within the Value_Changed_Callback, an out-of-datevalue is read.
RemedyUse the current value transferred in Value_Changed.
8.2.14 OPC XML-DA
Which requirements must be met so that trace output can be created for OPC XML-DA Webservices?
To allow trace output for OPC XML-DA Web services, you must have writepermission for the Microsoft Internet information services Web server ASPNET.The path of the trace file can be selected using the “Configuration Console”program. Assign this folder the required write permissions for the ASPNET user.Otherwise, no trace file can be created.
What is the correct order when installing OPC XML-DA Web services?
The order specified in the installation instructions in Step 1 “Adding the WindowsComponent Internet Information Services (IIS)” and in Step 2 “Installing Microsoft.NET Framework” must be adhered to. If Microsoft .NET Framework is alreadyinstalled, it must be uninstalled.
FAQs
647SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
The basic recommended steps installation are as follows:
Step 1: Install IIS.
Step 2: Install .NET Framework.
Step 3: Configure IIS.
Step 4: Start the sample program.
With the Windows 2003 server, step 2 can be omitted because this operatingsystem already contains .NET Framework.
What do I need to remember when browsing with the OPC XML-DA Web service?
The OPC XML-DA Web service allows browsing in the name space of theSIMATIC NET OPC server. To avoid problems when browsing, it is advisable toclose the OPC Scout.
How can I exit the XML Web service?
The XML Web service cannot be exited with the “Exit OPC Server” button in the“Configuration Console” program. Instead, exit the Windows component InternetInformation Services (IIS).
Which S7 strings cannot be read with OPC XML-DA Web services?
Reading S7 strings with OPC XML-DA Web services does not work if the S7 stringcontains a character that is invalid for XML strings. Characters with the followingdecimal code must not be used in an S7 string:
� 8 through 0
� 11
� 12
� 31 through 14
FAQs
648SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.3 FAQs on the CP 1613
8.3.1 General Information on Installation
Entry Missing in “Bindings” in Windows NT - What do I do when there is an entry in “Adapters” in the Control Panel ofWindows NT after installing the CP 1613 but there is no entry in “Bindings”?
The entry in “Bindings” (Start -> Settings -> Control Panel -> Network ->Bindings) was prevented because you selected “Bindings”.
Remedy
If the CP 1613 is not entered in “Bindings”, follow the steps outlined below toobtain a correct installation:
1. Uninstall the CP 1613.
2. Install the CP 1613 again after booting your computer. Caution: Under nocircumstances open the “Bindings” tab before you exit the “Network” dialog box(taskbar Start \ Settings \ Control Panel \ Network).
BIOS Settings under Windows NT - Which BIOS settings are relevant?
If the BIOS of your computer has a setting “Plug & Play O/S”, set this option to“[NO]” if you use Windows NT. After installing a CP, it is advisable to set theparameter “Reset Configuration Data” in the BIOS to [YES] to reset thePlug-and-Play configuration. This parameter is normally located close to the “Plug& Play O/S” parameter.
Important: Under Windows 2000, the “Plug & Play O/S” must be set to [YES]!
Remedy
Exit “Network” immediately after installation. When you close the dialog box, youwill be prompted to enter a TCP/IP address.
The installation of the “Siemens CP 1613 NDIS Adapter” driver was ejected by the systembecause no CP 1613 module is inserted — What can I do?
If you have not plugged in a CP 1613 module, it is not possible to install the“Siemens CP 1613 NDIS Adapter” driver.
FAQs
649SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Remedy
Install a CP 1613 module in your computer and install the “Siemens CP 1613 NDISAdapter” driver again. Follow the instructions in the installation manual of the CP1613 while installing the module and driver.
8.3.2 Installation along with Other Modules
Avoiding Incorrect Installation - How do I avoid problems in Windows NT if I want to install anothercommunications processor in addition to the CP 1613?
When you install the second network adapter in Windows NT, the followingsituation can arise: If you select the “Bindings” tab ( Start \ Settings \ Control Panel \ Network \Bindings) when setting the network parameters after installing the second networkadapter, and then set the TCP/IP address in the “Protocols” tab and then exit the“Network” “Dr. Watson” may display the following error message: rundll32.exe Application Error - The installation of the CP 1613 is now incorrect.
The computer no longer boots after installation - What should I do if the computer no longer boots after installing a CP 1613along with an ISA module?
In some computers there is sometimes a resource conflict involving the interrupts(IRQ) when the PCI IRQs in the BIOS are set to “Auto Select”. The computereither does not boot at all or the drivers are not started.
Remedy
Reserve IRQs for the ISA cards in the BIOS. These IRQs are then no longer usedfor PCI modules by the BIOS and a resource conflict is avoided.
Installing a CP 1613 along with other network adapters - What do I need to remember?
When, for example, you install the drivers of a 3COM PCI network adapter 3C905,their network monitor “Smartagent” is also installed.If you install a CP 1613 as well, not only all the previously installed protocols butalso the “Smartagent” is bound to the CP 1613. Deactivate this entry, since the CP1613 does not support this network monitor. Follow the steps outlined below.
FAQs
650SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Remedy
1. Navigate to the “Bindings” dialog box (taskbar Start \ Settings \ Control Panel \Network \ Bindings).
2. In the list box “Show bindings for:”, select “All adapters”.
3. Display all the protocols of the “Siemens CP 1613 NDIS Adapters” in the listbox below. Reaction: For example, the entry “3COM dRMON Smartagent PCSoftware” appears.
4. Click the “Disable” button.
Why can you specify two TCP/IP addresses when configuring the CP 1613?
On the one hand, the CP 1613 communications processor is designed foroperation with office communications protocols, for example, TCP/IP. In this case,the CP 1613 NDIS adapter must be installed and office communications protocolswill be assigned to it. The office communications protocols run on the PC. On the other hand, the CP 1613 can also be used for automation with theSIEMENS industrial protocols, for example SEND/RECEIVE, SAPI S7, STEP 7and TF. With the exception of TF, these protocols can be handled either over thetransport protocol ISO or TCP/IP. Both transport protocols run in the firmware ofthe CP 1613. The adapter between the TCP/IP transport protocol and theSIEMENS industrial protocols is implemented according to RFC 1006.On the CP 1613, a total of two TCP/IP transport protocol functions can beoperated at the same time:
� The office communications adapter
� The adapter of the SIEMENS industrial protocols
Both adapters must be assigned different TCP/IP addresses to identify themuniquely.
8.3.3 Miscellaneous
The driver for the CP 1613 does not start up after turning the computer off and on again.
What is the reason and what can I do?
When a computer has to be restarted, a reproducible restart is only possible whenall volatile information was actually deleted prior to turning off. Some computers simply change to standby mode when the operating system isclosed down and some information is retained.
FAQs
651SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Remedy
To ensure a reproducible restart on the computer with new data from non-volatilememory, follow the steps below:
1. Close down your operating system. Reaction The computer changes to thestandby mode.
2. Turn off the power to your computer for at least one minute. Reaction Allunnecessary data now disappears.
3. Turn on the power to your computer again and boot it again.
Ping Function - Why does the CP 1613 not respond?
You enter a “ping” for a CP 1613 installed in your own computer, and the CP doesnot respond. This function is not implemented. Only CPs outside the local system can be addressed with “Ping”.
During communication with an OSM V1.0 (or other device capable of autonegotiation), theCP 1613 sporadically sends bad frames - What causes these transmission errors?
The bad frames (truncated frames, CRC errors etc.) occur when the OSM V1.0 isset to full duplex mode.
Since the OSM V1.0 does not operate with autonegotiation, its ports can be setpermanently to half or full duplex mode by DIP switches. Its data transmission rateis also set internally to 10 Mbps.
The CP 1613, on the other hand, always works with autonegotiation even if theduplex mode and data transmission rate are fixed.
Every device (in this case the CP 1613) that works with autonegotiation andcommunicates with a partner that does not have autonegotiation (in this case theOSM V1.0) can recognize its data transmission rate, however not its duplex mode.The CP 1613 then automatically assumes that the partner operates in half duplexmode. If, on the other hand, the partner device is in full duplex mode, thesetransmission problems occur.
This problem can be observed not only with an OSM V1.0 but with every devicethat does not use autonegotiation.
Remedy
If a partner device that does not have autonegotiation (for example the OSM V1.0)communicates with the CP 1613, the partner device must be set to half duplexmode. In this respect, the settings on the CP 1613 are irrelevant.
It is worth mentioning that the OSM V2.0 does provide autonegotiation and theproblem outlined above no longer occurs with this version.
FAQs
652SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Time-of-day frames and intervals - Which intervals are approved for receiving time-of-day frames?
� 1 s and
� 10 s
What do I need to remember when starting an application?
Do not start an application with the AUTOSTART program group, otherwiseproblems with the license server may occur. When you boot, the license servertakes some time to start.
What do I need to remember when using a TF database?
Every CP 1613 module has a default MAC address that can be edited manually. Ifyou activate a TF database, the address is taken from the database. This MACaddress is retained even after you deactivate TF. Prior to activating TF, you shouldtherefore note the original MAC address so that you can use it again whennecessary.
Plugging in different connecting cables (TP, ITP or AUI) - What do I need to remember when plugging in different connecting cables?
If all the options for network parameters in the “Set PG/PC Interface” or“Configuration Console” programs are set to automatic, the card will adapt itselfautomatically to the attached network.Only one network cable can be connected to a CP 1613 at any one time.
What are the time limits for removing and plugging in the Ethernet cable without existingISO connections being terminated?
For ISO data exchange,16 repetitions at intervals of one second are set on the CP1613; in other words, if the cable is disconnected for longer than 16 seconds, theISO connections will terminate. If the time is kept below 16 seconds, no problemswill occur.
If there is no data exchange on an established connection, a “sign of life” is sent atintervals of 10 seconds. If there is no response to this ten times in succession, theconnection is automatically terminated. In the case of such a “quiet” connection,the cable can therefore be removed for up to 100 seconds without the connectionbeing terminated.
The information above applies, as already mentioned, to the data transfer phase.In the connection establishment phase, the connection establishment request issent every two seconds and up to 32 attempts are made. The interruption cantherefore be up to approximately 64 seconds during the connection establishmentphase. If this is exceeded, the connection establishment is aborted and noconnection will result.
CAUTION: The information above does not apply to fault-tolerant connections (Hconnections) !
FAQs
653SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.4 FAQs on SOFTNET Industrial Ethernet
Set PG/PC Interface / Configuration Console - Which combination of interface parameter settings is not permitted?
“ISO Ind. Ethernet -> SIMATIC NET NDIS-Ether”
When can data be lost during data transmission?
When using the TCP/IP transport protocol, if the connection is terminated(CLOSE_REQ) immediately following a SEND_DATA or SEND_EOM_DATA, thedata can be overtaken by the close request and is then lost.
Remedy
We recommend that you implement your own acknowledgment mechanisms abovethe transport layer.With the ISO protocol, transport data cannot be overtaken and no data lossoccurs.
When using the RFC1006 adapter “S7ONTCP.DLL”, if there is a high transmission load withshort messages (< 10 bytes), the connections sometimes break down. How canyou get round this problem?
� You should take measures to attempt to distribute the message load.
� At a higher layer, implement mechanisms to ensure that the CP has receivedand processed the messages.
When sending over the RFC1006 adapter, the sockets put the messages in abuffer if they cannot be sent immediately. The user is informed that the messageshave been sent even though they have only been placed in the buffer of the socket(because they will be sent later).
What are the effects of a high transmission load with short messages (<10 bytes) with TCP(RFC1006)?
If send jobs are initiated in the user program more quickly than they can beprocessed by the recipient, this can lead to buffer overload and cause a breakdownon the connection. This problem occurs particularly with a high transmission loadand short messages (<10 bytes).
Remedy
You can avoid the connection breakdown by reducing the number of send jobs atthe user program end.
FAQs
654SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Which error messages can be ignored?
If you select the “SIEMENS Industrial Ethernet (ISO)” protocol from the list ofnetwork protocols and then click on the “Properties” button, the following errormessage appears: “The software component could not be configured.” This message does not affect your communication with SIMATIC S7 and SIMATICS5 devices and can be ignored.
With which network cards was Softnet IE tested?
With the PCI network card SIMATIC NET CP 1612, 3COM 3C905 and thePCMCIA card SIMATIC NET CP 1512, XIRCOM Credit Card Ethernet 10/100.
Can a CP 1613 be operated at the same time as SOFTNET IE?
This combination has not been approved.
Is it possible to operate SOFTNET IE with several network adapters installed?
The Siemens ISO protocol can only be bound to one Ethernet network adapter. IfSOFTNET Industrial Ethernet is installed, the SIEMENS ISO protocol is bound toall Ethernet-compliant adapters! You should therefore remove the Siemens ISOprotocol from the Ethernet adapters that are not used with the SIEMENS ISOprotocol in the Control Panel (taskbar Start \ Control Panel \ Network \Configuration).This also applies to installed modules such as the adapter for dial-up networking.
What is the maximum number of S7 connections?
The following table shows the maximum number of S7 connections depending onthe PDU size and number of credits:
PDUSize
Number of S7 Connectionswith Credit 1
Number of S7 Connectionswith Credit 2
112 64 32
240 64 32
480 64 32
960 64 32
FAQs
655SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Number of Applications/Connections
The values of the following set of parameters have been tested and areguaranteed.
Parameter Value forSEND/RECEIVE
Value for SAPI-S7
Maximum frame lengthof a job/request
4096 bytes 240 bytes, 480 bytes,960 bytes dependingon the partner
Maximum number ofsimultaneously esta-blished connections
64 64
Maximum number ofpartner stations
15 15
Maximum number ofsimultaneously activeuser programs
6 3
Maximum number ofsimultaneous jobs/re-quests per connection
1 send job
1 receive job
2 requests
Maximum number ofactive application (incl.OPC Server) accesspoints
8 8
With blocks of data >1024 bytes
64
Deviations from these settings for certain parameters that mean using less systemresources may release extra system resources for other parameters.
Note that the actual useful data length is less than the frame length and dependson the particular job type.
What is the significance of the “Keepalive Time” for TCP/IP (RFC1006)?
The “Keepalive time” monitoring time of TCP/IP (RFC1006) specifies the intervalafter which TCP checks whether or not a connection still exists. With all approvedoperating systems, the default setting is 2 hours:
Windows NT, Windows 2000, Windows XP
You can configure the settings with the “Configuration Console” program or modifythem in your STEP 7 project.
FAQs
656SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Why is the TCP/IP connection terminated in Windows 2000 10 seconds after disconnectingthe network cable regardless of the selected keepalive time?
In Windows 2000 Professional / Windows XP, TCP/IP has a link monitoringfunction. As a result, removing the TP cable from the network adapter causes aremote_abort after approximately 10 s.
8.5 FAQs on SEND/RECEIVE for Industrial Ethernet
What do I need to remember when activating the trace for the SEND/RECEIVE programminginterface?
To activate modified settings, the SEND/RECEIVE user program must berestarted.
What restrictions apply to the SEND/RECEIVE programming interface?
In a SEND/RECEIVE user program, the SRMD_set() initializations must be calledfrom within the same thread. The same window and the same message ID mustalways be passed as the parameter.
What happens when using the functions and calls of the SEND/RECEIVE interface if I usea TSAP that has already been assigned during connection establishment?
This double assignment is not detected by SOFTNET for Industrial Ethernet. Thevalue of ISO-Reason-Code contained in the job block is immaterial.
What functional restrictions are there for a SEND/RECEIVE job when using the TCP/IPtransport protocol?
Passive connection establishment can only be initiated by a user program. The simultaneous use of several user programs with passive connectionestablishment is not currently possible.The components vc_buf1_ptr and vc_buf1_length are not currently supported invariable array 2.
What differences are there on the user interfaces SEND/RECEIVE or SAPI-S7 between theISO and the TCP/IP (RFC1006) transport protocol?
An acknowledged message with the ISO transport protocol (for example withSEND/RECEIVE, opcode=SEND_EOM_DATA and response=OK_RESP) confirmsthe reception of the data at the connection partner, whereas an acknowledgedmessage when using the TCP/IP (RFC1006) transport protocol simply confirmstransmission of the data to the connection partner.
When can data be lost during data transmission?
When using the TCP/IP transport protocol, if the connection is terminated(CLOSE_REQ) immediately following a SEND_DATA or SEND_EOM_DATA, thedata can be overtaken by the close request and is then lost.
FAQs
657SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Remedy
We recommend that you implement your own acknowledgment mechanisms abovethe transport layer.With the ISO protocol, transport data cannot be overtaken and no data lossoccurs.
Which SIMATIC programmable controllers can I communicate with using theSEND/RECEIVE programming interface?
With the SEND/RECEIVE programming interface, you can communicate with theS5 and S7 SIMATIC programmable controllers from a PC/PG (primarily withSIMATIC S5).
What do I need to remember about segmented jobs with the SEND/RECEIVE programminginterface?
A single packet transmitted over the SEND/RECEIVE interface can be a maximumof 4096 bytes long. This means that larger packets must be segmented. On thesender, the data must be split into blocks with a length of 4 Kbytes. The recipientmust then reassemble these blocks correctly.
If a send credit higher than 1 is used, the correct order of the individual blocks ofdata on the recipient cannot be guaranteed by the SEND/RECEIVE interface. Thismeans that the sending and receiving applications must have suitable mechanismsthat will allow the data to be reassembled in the correct order.
FAQs
658SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.6 FAQs on the CP 5613/CP 5614
What hardware resources does the module require?
The module occupies three address windows with sizes:128 bytes, 1 Mbyte, 1 Mbyte The required address ranges are assigned by the PCI-BIOS.
The module requires an interrupt. The assignment is made automatically by thePCI-BIOS. The module allows the interrupt to be used by other modules(shareable interrupt).No settings are required on the module.
What is the difference between the CP 5613 and CP 5614?
The CP 5614 has the properties of the CP 5613 and also provides the option of asecond PROFIBUS port that can be operated as a DP slave as well as allowingprogram-controlled transfer of DP data between the two ports.
Can the CP 5613 be upgraded to a CP 5614?
No.
Are the drivers for the CP 5614 different from those of the CP 5613?
No, the drivers and the firmware are the same for both CPs.
The process list in Windows NT / Windows 2000 / Windows XP contains a CI_SERV process.What does this do?
This program is necessary for the CP 5613/CP 5614 to display error messages.
FAQs
659SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.7 FAQs on Converting from the CP 5412 to the CP 5613/CP5614 and CP 5...11
What is the difference between the FDL interface and the interface of the CP 5412 (A2)?
The following FDL services are no longer implemented:
� FDL_READ_STATISTIC_COUNTER
� FDL_READ_LAS_STATISTIC_COUNTER
There is a new security mechanism that prevents more than one applicationprogram accessing a SAP.In contrast to the CP 5412 (A2), the SAPs with the numbers 0 and 50 are reservedas default. During configuration, the reservation for SAP no. 50 can, however, becanceled.With the CP 5613 / 5614, the list of SAPs and the status of the SAPs can bedisplayed (open the “LSAP List” dialog in the Configuration Console tool).
What is the difference between the DP interface of the CP 5613/CP 5614 and the DP interfaceof the CP 5412 (A2)?
The CP 5613 or CP 5614 has a different interface optimized for the transfer of DPdata.Differences in functionality:
Cyclic, global control frames that could be configured with COM PROFIBUS forthe CP 5412 (A2) are not supported by the CP 5613 or CP 5614 (and CP 5511,CP 5611).
What is the difference between the FMS programming interface and the interface of the CP5412 (A2)?
The FMS programming interface differs in the following aspects:
� FMS-5613 does not support open-responder connections.
� SAP 50 can no longer be used.
FAQs
660SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.8 FAQs on SOFTNET PROFIBUS
Is it possible to operate more than one protocol under SOFTNET at the same time?
No. Parallel operation of FDL, DP and S7 with one SOFTNET module has notbeen approved. It is, however, possible to operate these protocols at the sametime as STEP 7.
Is use of the CP 5411 still approved?
The use of a CP 5411 is no longer approved with this version.
Is it permitted to operate SOFTNET PROFIBUS CPs together or combined with HardnetCPs?
It is not possible to operate more than one CP 5...11 at the same time. Thecombination of a CP 5..11 with the CP 5613 or CP 5614 in one PC is permitted.
Are the functions ON_NOW and ACPI supported?
The ON_NOW function is not currently supported. The ACPI function has beenapproved for SOFTNET.
I have two PCs with SOFTNET modules attached to the bus and use the “PG operation”mode. When I display the bus nodes in diagnostics on one of the PCs, thesecond SOFTNET PC does not appear. How can I test the functionality of thenetwork?
The SOFTNET modules are only active in PG operation when an application hasactually started communication. For test purposes, you could, for example,execute an SCP-Open with the supplied FDL demonstration program and soactivate the CP.
I have already installed DP 5613 for Windows NT. When I install SOFTNET DP, the message‘License already installed’ appears. Can I run SOFTNET with the 5613 license?
Yes! The license is also valid for SOFTNET.
FAQs
661SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.9 FAQs on the CP 5511
8.9.1 Installing the CP 5511
Is use of the CP 5411 still approved?
The use of a CP 5411 is no longer approved with this version.
What do I need to remember when using the CP 5511?
Note on using the CP 5511 under Windows NT 4.0:
To operate a CP 5511 under Windows NT, you also require a Cardwizard fromSystemsoft.The 05/2000 CD contains the document “inSysSft.pdf” in the “sw\cp_5511” folderthat describes the procedure. Please follow the instructions in this document.Please note that you only have the right to use the Cardwizard when you operate aCP 5511.The Card & Socket Services from Award Inc. are no longer supported as of theSIMATIC NET CD 07/2001.
Is additional software required to operate the CP 5511 under Windows 2000 / Windows XPas it is for NT 4.0?
No. The Cardwizard must not be used under Windows 2000!
I have had problems operating the CP 5511. What might be the cause and what can I doabout it?
Since there are considerable differences in the hardware that can be used,particularly the PCMCIA controller used, in rare cases, there may be hardwareconflicts with the CP 5511.For more detailed information, refer to the release list (Rel551ntd.pdf). This isconstantly being updated and is available on the Web.
In the Windows NT Control Panel under PCMCIA, the CP 5511 is always marked red as beingunconfigurable. What is wrong?
Windows NT does not recognize the CP 5511 and cannot configure it. The CP canonly be configured with the supplied drivers. This display says nothing about thecorrect installation and functionality of the CP.
What are the properties of the electrical interface adapter?
The physical connection is made by an interface adapter (floating RS-485interface) that connects the CP 5511 with the transmission medium. Datatransmission rates of 9.6 Kbps to 12 Mbps are possible.
FAQs
662SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
The card is no longer recognized by the system. Is this because I have removed the interfaceadapter?
Yes! The card should only be removed and inserted along with the interfaceadapter. Remove the card, fit the interface adapter and insert the card again.
Do I need to configure anything manually on the CP 5511?
No, the CP 5511 is plug-and-play card.
What memory resources does the CP 5511 occupy?
The CP 5511 can adapt itself to your system. Starting with the largest memorysize, Windows attempts to find a free memory range for the CP from the list below.
Size DPRAM ATTRIB (4 KB)
256 KB F00000-F3FFFF EFF000-EFFFFF
256 KB F80000-FBFFFF F7F000-F7FFFF
128 KB F00000-F1FFFF EFF000-EFFFFF
128 KB F80000-F9FFFF F7F000-F7FFFF
60 KB 0D1000-0DFFFF 0D0000-0D0FFF
56 KB 0D2000-0DFFFF 0D1000-0D1FFF
48 KB 0D4000-0DFFFF 0D3000-0D3FFF
32 KB 0D8000-0DFFFF 0D7000-0D7FFF
32 KB 0D2000-0D9FFF 0D1000-0D1FFF
24 KB 0D2000-0D7FFF 0D1000-0D1FFF
24 KB 0DA000-0DFFFF 0D9000-0D9FFF
16 KB 0D2000-0D5FFF 0D1000-0D1FFF
16 KB 0D7000-0DAFFF 0D6000-0D6FFF
16 KB 0DC000-0DFFFF 0DB000-0DBFFF
8 KB 0D2000-0D3FFF 0D1000-0D1FFF
8 KB 0D5000-0D6FFF 0D4000-0D4FFF
8 KB 0DE000-0DFFFF 0DD000-0DDFFF
FAQs
663SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
When I install under Windows NT, I receive a message telling me to deactivate theAutoRelease option of the Card&Socket Services. How do I do this?
This is possible only with a manual intervention in the Registry for which yourequire administrator privileges. Follow the steps outlined below:
� Open the Registry Editor. (Start->Run->regedit.exe)
� Locate the entry’HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PCCS\Options’
� Add ’AR:OFF’ to the entry under ’CommandLine’. If, for example, you find theentry ’CommandLine’ ’/SC:OFF’, you must change this to ’/SC:OFF /AR:OFF’.
My CP 5511 does not work under Windows 2000 / Windows XP!
With Windows 2000 Pro, several cases are known in which the operating systemplaced the memory window for the CP 5511 in a range that had already beenassigned to another device resulting in a variety of errors. A modified inf file wasable to remedy the situation by restricting the possible address range for thememory window of the CP 5511 to the D segment. You can check the addresses ofthe memory window in the Configuration Console or “Set PG/PC Interface”program.To remedy the problem, follow the steps below:
Step Description
1 Save the original inf file (in the Windows\inf folder) in a differentfolder
2 Copy the new inf file (obtainable from SIMATIC Customer Sup-port on the Internet) to the Windows\inf folder.
3 Uninstall the CP 5511 in the Device Manager.
4 Remove and reinsert the CP 5511
5 Recommended: Reboot
6 Check whether or not the memory ranges are all in the D seg-ment
7 If the new addresses do not bring about any improvement, resto-re the original situation.
NoteBy restricting the DPRAM area to the D segment, you may find that the maximumconfiguration is reduced.
FAQs
664SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.9.2 Parallel Operation of the CP 5511 with other PCMCIA Cards
Can I operate a CP 5511 at the same time as a PCMCIA Ethernet adapter?
In principle yes. Remember, however, that the CP 5511 requires a lot of resources.Depending on your hardware, you may find that you do not have enough resourcesfor parallel operation. The CP 5511 cannot be operated at the same time as aPCMCIA IBM Ethernet Adapter II because this results in a memory conflict.
Installing the CP 5511 on the SNI Mobile 710 notebook!
To operate the CP 5511 under Windows NT 4.0 with an SNI MOBILE 710, yourequire at least BIOS 4.0 Release 5.1 Release Version 3C31. You can request thisBIOS version over the Hotline. ( Phone: +49 (0)911 - 895 - 7000, E-mail:[email protected])
To operate the CP 5511 under Windows Millennium and NT/2000 Pro, the followingBIOS settings are necessary: ’Advanced->PCI Devices->PC Card Controller Mode’:’ PCI’. ’Advanced->Integrated Peripherals->On Board Audio’: ’ Disabled’ ’Advanced->Memory Cache->External Cache’:’ Disabled’
Additional settings depending on the operating system:
Windows NT 4.0
’Advanced->Plug and Play OS’:’ No’
Windows 2000 / Windows XP
’Advanced->Plug and Play OS’:’ Yes’
FAQs
665SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.10 FAQs on the CP 5611
After I plugged the CP 5611 into the PCI slot, the BIOS message “Resource Conflict PCINetwork Controller as Slot ...” was displayed!
The resources required by the CP 5611 (interrupt, memory ranges) are set by thePCI BIOS and mapped to suitable system resources.The PCI BIOS has detected that the required resources are not available. Changethe hardware configuration of the computer so that the required resources are free.
The CP 5611 is correctly installed but still cannot be operated under Windows NT. What isthe reason?
Some computers have the option ’Plug&Play O/S’ under ’Advanced’ in the BIOS.For operation under Windows NT 4.0, set this option to ’No’.
I cannot start up the CP 5611 in a PG 740 P II. Are there any problems known?
If all PCI interrupts are set to ’Auto’ in the BIOS, you may encounter problems.Change the settings of the interrupts under PCI in the BIOS, for example to9,9,11,11.
FAQs
666SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.11 FAQs on PROFIBUS SOFTNET S7
How many partner stations can I communicate with at the same time using the S7 protocol?
If you establish exactly one connection to each partner station, the maximumnumber of partner stations is the same as the maximum number of connections.The maximum number of connections with the CP 5511 depends on the hardwareconfiguration. With the currently available PCMCIA drivers under Windows NT /2000 / XP, the dual-port RAM is restricted to 59 KB.
Number of Applications/Connections
The following table provides you with an overview of the basic data of the S7interface dependent on the hardware configuration.
5611 551159 KB
551155 KB
551131 KB
551123 KB
551115 KB
Maximumnumber ofsimulta-neous S7connectionsSN S7
8 8 8 8 8 8
Maximumnumber ofsimulta-neous userprocesses(with S7communica-tion)
8 8 8 8 8 8
Which development tools can the S7 programming interface be used with?
DLLs with the C calling convention (S732.dll) and with the standard callingconvention (S732std.dll ) are supplied (in the Windows\System folder). For the DLLs with the standard calling convention, import libraries for Microsoftdevelopment tools are available (s7msstd.lib) that use the standard callingconvention (for example Visual Basic). There is also an import library available forthe DLL with the C calling convention for Microsoft development tools (s7msc.lib).
How should I set the ’dev_name’ parameter when calling the ’s7_init’ and ’s7_get_vfd’functions?
The ’dev_name’ parameter identifies the access point via which you willcommunicate. This device name is the same as the entry made in the “Accesspoint of the application” box in the “Configuration Console” program. This can bethe value “CP_L2_1:” that is installed as default.
FAQs
667SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Can I also use the trace functionality of SAPI-S7 under SOFTNET?
Yes! The trace settings are made with the “Configuration Console” parameterassignment tool.
Are there services that are not supported by all S7 CPUs?
Yes, the S7_get_vfd_state_req service is not supported by the S7-300. TheBSEND/BRECEIVE functions and alarms are not supported by the S7-300.
What is Routing?
If you use this SIMATIC NET product on a PC/PG with a STEP 7 V5 product, youcan use the new routing functionality. This is not possible with older versions of thisproduct.
Routing
As of STEP 7 V5, it is possible to access S7 stations in other subnets online fromyour PG/PC, for example to load user programs or a hardware configuration or torun test and diagnostic functions. You can attach a programming device at any point in the network and establish anonline connection to all stations accessible via gateways.
Example
The gateway between a subnet and one or more other subnets is in a SIMATICstation with interfaces to the relevant subnets.
SubnetType 1
SubnetType 2
Inter-
Type 1face
Inter-
Type 2face
Connection establishment following problems on the bus.
Following a problem on the bus (for example a bus short-circuit), the connectioncan only be established again after approximately 10 seconds.
FAQs
668SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Are the times of SAPI-S7 jobs monitored?
Yes, with the ’Abort-Timeout’ value. This value specifies the maximum time forretries if the remote station does not respond. This time is specified in multiples of 51 ms (default setting: 3000). The parameterapplies both to the connection establishment phase and the data transfer phase. Inother words, if connection establishment is initiated to a station that is not attachedto the bus, there is a negative acknowledgment after approximately 150 seconds. If a job is sent to station that is no longer attached, the CP initiates a negativeacknowledgment or an abort indication at the latest after 150 seconds.
The SOFTNET CP 5...11 modules monitor the following:Connection establishment, partner stationdoes not exist
TimeOut PersistenceCount TimeOut after
500 5 25 sec
1000 5 50 sec
1000 10 50 sec
Connection breakdown, no data exchange
TimeOut PersistenceCount TimeOut after
500 5 Immediately
1000 5 Immediately
1000 10 Immediately
Connection breakdown, data exchange
TimeOut PersistenceCount TimeOut after
500 5 Immediately
1000 5 Immediately
1000 10 Immediately
What should I note about evaluating the return value of the ’s7_receive’ function?
If unexpected values occur for which no processing function is called, the’s7_discard_msg’ function must be called (for example in the default branch of asuitable switch statement).
Can I use the licenses of other products to operate SOFTNET S7?
Yes! If you have already installed the license for the product “S7-5613 for WindowsNT”, you can use this license for the S7 mode under SOFTNET.In this case, you can skip installation of the authorization in the setup.
FAQs
669SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
8.12 FAQs on PROFIBUS SOFTNET DP
8.12.1 DP Slave
Can I operate my SOFTNET DP slave purely as an input or output slave ?
Yes, this is possible.
Closing an application that uses the DP slave interface in the Task Manager or in thedebugger does not work. What can I do?
If you close the application without previously executing dps_stop and dps_close, itcan take quite a long time before the process is actually closed. Always executeDPS_stop and DPS_close before you close your application.
8.12.2 DP Master
How many slaves can be operated with SOFTNET DP?
The CP 5511 attempts to find the largest possible memory area for the dual-portRAM for access to the module. The following table provides you with an overviewof the relationship between memory size and the number of slaves that can beconfigured. Please note: The possible number of slaves also depends greatly on theconfigured length of the input/output data of the slaves. For this reason, it is onlypossible to specify broad ranges. If you do not have enough memory for yourdatabase, reduce the number of slaves by at least five.
PCMCIA Card CP 5511
Memory Size Number of Slaves
60 KB max. 50
56 KB approx. 40 to 50
48 KB approx. 25 to 40
32 KB approx. 17 to 25
24 KB approx. 10 to 16
16 KB approx. 5 to 10
8 KB max. 4
CP 5611
Memory Size Number of Slaves
256 KB 64
FAQs
670SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
PC card CP 5512
Memory Size Number of Slaves
252 KB 64
What do I need to remember if I abort my DP application in the Task Manager?
Make sure that when the DP application is aborted, a dpn_reset() call is made. IfWindows sends a WM_CLOSE message, the program must react and if it has notalready done so, it must execute a dpn_reset() call.
Can I design my SOFTNET DP application with more than one thread ?
In principle yes. However, to keep the load caused by constantly changing threadsto a minimum, it is advisable to implement the SOFTNET DP application with onlyone thread. You will also find that this increases the performance of your DPapplication.
My DP application has a multi-thread architecture. What do I need to remember ?
Make sure that the threads are correctly synchronized to exclude the possibility ofuncontrolled, simultaneous access by more than one thread to the DP driver.
What are the most important points to remember when creating a SOFTNET DP PROFIBUSapplication?
Continuous polling on the DP interface (for example “while” instructions withoutinserting “sleep” functions) can lead to poor performance on the bus because theDP drivers no longer have adequate CPU capacity available.If necessary, include pauses of a few milliseconds between the calls.
Note on the dpn_slv_diag() DP function!
The diagnostic data is not valid if the return parameter slv_state of thedpn_interface structure contains the value DPN_SLV_STAT_NOT_ACTIVE orDPN_SLV_STAT_OFFLINE.
Do I need to use the dpn_set_slv_state function in my DP application?
The use of this function is not normally necessary in a DP application since a DPslave is activated or deactivated automatically by the communications software(depending on the mode of the master). The function should only be used inexceptional situations to take a slave out of the DP cycle regardless of the mode ofthe DP master.
FAQs
671SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
I receive error messages for dpn_init that are not listed in my manual on the DPprogramming interface. What do these mean?
Two new error codes have been introduced:
� DPN_LOAD_L2_VXD_ERROR (0x0097): The layer 2 drivers for the CP 5611,the CP 5511, or for the CP 5411 (S7OASPCX.VXD) cannot be loaded.
� DPN_OPEN_L2_VXD_ERROR (0x0098): The layer 2 drivers cannot beopened. Possible causes: Permanent disturbances on the bus (for example thebus terminator is not activated); another master station with the same stationaddress is already active on the bus; for further information, refer to theWindows event log.
I work with various groups of slaves. When I try to address group 1 by setting bit 0 asdescribed in the manual, an error occurs.
Selecting groups 1 to 8 in the structure element user_data[0] functions as follows:
Set bit 0: Group 8 is selectedSet bit 1: Group 7 is selected ...Set bit 7: Group 1 is selected
I receive a dialog box telling me that my CP does not have enough memory for theconfigured slaves. I have configured 60 slaves in my DP network with a CP 5511as master. What does the message mean?
The plug-and-play card CP 5511 searches for the largest possible memory area itcan obtain during installation.If you are using other cards, it is possible that the CP only gets part of themaximum possible memory. The number of slaves that can be configured depends on the memory available tothe CP. To save memory, you should only configure slaves that are actuallyconnected to the bus. You can also try to obtain more memory for the CP 5511 by reconfiguring othercards or installing them in a different order. Otherwise, you must reduce the number of slaves.
During DP operation, the message “Bus short-circuit or bad transmission rate” appears.The dpn_reset of my DP application is then no longer acknowledged.
This can only occur in isolated situations if there is a permanent (!) busshort-circuit. Disconnect your CP 5...11 from the bus. The dpn_reset thenterminates itself. Eliminate the bus short-circuits and start your application again.
FAQs
672SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
8.13 FAQs on the FDL Protocol in SOFTNET PROFIBUS
I use the SCP_receive call in the synchronous mode but sometimes when the functionreturns there is no request block. Why does it do this?
Since the FDL interface with SOFTNET is available only for Windows NT, Windows2000 and Windows XP, and because the asynchronous mode must be used forWindows programs, the SCP_receive no longer supports the timeout parameter.This means that with SCP_receive, the value SCP_NOWAIT must always be usedin the timeout parameter.
How many request blocks and data buffers are available?
For the CP 5611, this is a fixed number; for the CP 5511 (PCMCIA card), thenumber depends on the DPRAM size available in the system. A request block isrequired for every job put on the FDL interface. All services that contain data in theuser areas of the request block (for example, SDN, SDA, SDR,AWAIT_INDICATION) require adequate data buffers during processing. The size ofthe data buffers used depends on the length of the data to be transferred.Refer to the following table:
CP Type RequestBlock
Buffersize256 by-tes
Buffersize 32 bytes
Buffersize16 bytes
Buffersize8 bytes
CP 5611 1420 768 325 325 325
CP 5511DPRAM60 KB
458 140 140 140 140
CP 551156 KB
437 128 135 135 135
CP 551148 KB
388 104 122 122 122
CP 551132 KB
255 68 76 76 76
CP 551124 KB
192 48 56 56 56
CP 551116 KB
129 28 36 36 36
CP 5511 8KB
66 8 16 16 16
Note:If no more buffers of a particular class are available, buffers from the next largerclass are allocated instead.
FAQs
673SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Which parameter assignment do I need if I want to communicate with FDL over PROFIBUS?
The FDL protocol can be used with all parameter assignments. You must,however, specify FLC with SCP_open. If, for example, you set CP_L2_1: to DP master, you can run FDL if you executeSCP_open with the parameter /CP_L2_1:/FLC. With MPI, however, there is a special FDL parameter assignment that allows datalengths up to 246 bytes but does not tolerate any other protocol.
I use the GD (Global Data) S7 protocol in my PROFIBUS network. When I open SAPs in the range of the GD protocol on my PC, they continuouslyreceive broadcasts from the S7 PLCs. The communication partner, however, always sends to this SAP. How can Ifilter to receive the correct frames?
Set SAP_ACTIVATE so that the PC only receives frames from the requiredpartner. You can do this by specifying the station address of the partner in theaccess_station field in the fdl_sap structure. This filters the frames so that you onlyreceive them from this station.
Can I use all the FDL services of the CP 5412 (A2)/CP 5613 unchanged on the SOFTNET FDLinterface?
The SOFTNET FDL interface is compatible with the FDL interface of theCP 5412 (A2)/CP 5613.However, the following services are not available:
� FDL_READ_STATISTIC_CTR
� FDL_READ_LAS_STATISTIC_CTR
� LSAP_STATUS (only local SAPs, no remote access)
� FDL_IDENT
Specifying the role with SAP_Activate under SOFTNET FDL is also restricted: If Responder or Both_Roles is requested for one of the services, only this serviceis permitted and all others are blocked.If, however, Responder or Both_Roles is specified for two or more services, allservices are enabled.
Are their differences in the events compared with the CP 5412 (A2)/CP 5613?
Yes! The SOFTNET FDL interface reports the events not_syn, time_out,uart_error, duplicate_address, out_of_ring, hardware_error.Removing the PCMCIA card during operation results in the hardware_error event.
FAQs
674SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
What does “network configuration” mean in terms of PROFIBUS ?Number of masters
The number of active stations specifies the number of active master stations in thenetwork. You set this value manually. The value must be set the same for allstations.
� Minimum possible value: 1
� Maximum possible value: the same as the setting for the highest PROFIBUSaddress
If you have activated the DP software package on your CP, you cannot set thenumber of active stations here.
Number of Slaves
The number of passive stations (slaves) is the number of stations on the networkthat do not initiate communication.The value must be set the same for all stations.
� Minimum possible value: 0
� Maximum possible value: 126
If you have activated the DP software package or the Scope PROFIBUS softwarepackage on your CP, you cannot set the number of passive stations here.
When using FDL, SCP_get_errno returns error codes that are not documented in my FDLmanual!
Here is a complete list of all the error codes
Error Code HexValue
Explanation
E_SUCCESS 0x0000
E_RESOURCES 0x012a Not enough system resources (for ex-ample, work memory).
E_PAR_ERR 0x012e Bad parameter - Check the functionparameters.
E_DPRAM 0x0132 No dual-port RAM or it cannot be writ-ten to.
SCP_RESOURCE 0x00ca Not enough system resources - Checkyour configuration.
SCP_CON-FIG_ERR
0x00cb Configuration error - Check your confi-guration.
SCP_ILLEGAL 0x00cd Invalid function call
SCP_PARAM 0x00ce Bad parameter - Check the functionparameters.
FAQs
675SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Error Code ExplanationHexValue
SCP_DEVOPEN 0x00cf Opening the device (SCP_OPEN) fai-led because it is already activated orusing the device (SCP_SEND) failedbecause the device is not yet activated.
SCP_BOARD 0x00d0 Hardware (communications processor)not reacting. Check your configuration.
SCP_SOFTWARE 0x00d1 Undefined error in the driver
SCP_MEM 0x00d2 Lack of memory in the driver
SCP_NOMESS 0x00d7 No message exists
SCP_USERMEM 0x00d8 Access to the application buffer notpossible.
SCP_TIMEOUT 0x00db Timeout (SCP_receive) not relevant forSOFTNET
EUSERMAX 0x00e1 The maximum number of users for thedevice has been reached. Close a fewapplications.
SCP_EINTR 0x00e2 Job aborted
SCP_NO_WIN_SERV
0x00e9 A utility for initialization/synchronizationcould not be started. Reinstall.
EPROTECT 0x00ea License error. Reinstall.
SCP_DB_FI-LE_DOES_NOT_EXIST
0x00f0 No database specified, irrelevant forFDL
SCP_DB_FI-LE_CLO-SE_NOT_OK
0x00f1 Failed to close the database, irrelevantfor FDL.
SCP_SEND_NOT_SUCCESSFUL
0x00f2 SCP_Send failed
SCP_RECEI-VE_NOT_SUC-CESSFUL
0x00f3 SCP_Receive failed
SCP_NO_DEVI-CE_AVAILABLE
0x00f4 No device available
SCP_ILLE-GAL_SUBSYSTEM
0x00f5 Invalid subsystem specified
SCP_ILLE-GAL_OPCODE
0x00f6 Invalid opcode specified
SCP_buf-fer_TOO_SHORT
0x00f7 Transfer buffer too short
FAQs
676SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Error Code ExplanationHexValue
SCP_buf-fer_1_TOO_SHORT
0x00f8 Transfer buffer 1 too short
SCP_ILLE-GAL_PROTO-COL_SEQUENCE
0x00f9 Illegal protocol sequence, irrelevant forFDL
SCP_ILLE-GAL_PDU_ARRI-VED
0x00fa Invalid PDU received, irrelevant forFDL
SCP_RE-QUEST_ERROR
0x00fb Request failed
SCP_NO_LICEN-SE
0x00fc No license found, reinstall
E_INIT_COM 0x0301 Error in internal driver communication
E_NO_HW 0x0310 Module not found (module does notexist, bad settings on the module, in-correct configuration of the hardwareresources or incorrect installation).Check the configuration of the accesspoint in Set PG/PC Interface.
E_HW_DEFEKT 0x0311 Hardware error (possibly defective mo-dule)
E_CNF 0x0312 Bad configuration parameter
E_BAUDRATE 0x0313 Wrong baudrate or invalid interrupt. Re-configure the CP with Set PG/PC Inter-face.
E_HSA 0x0314 Bad HSA set. You can modify the busparameters in Set PG/PC Interface.
E_TS 0x0315 The station address set is alreadybeing used in the network. You can mo-dify this in Set PG/PC Interface.
E_OCC 0x0316 Hardware device already assigned, ir-relevant for SOFTNET.
E_INT_NOT_PROV
0x0317 The specified interrupt is not available.Reconfigure the CP with Set PG/PCInterface.
E_INT_BUSY 0x0318 There is an interrupt resource conflict.Reconfigure the CP with Set PG/PCInterface.
E_SAP 0x0319 SAP deactivate: SAP not in use
FAQs
677SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Error Code ExplanationHexValue
E_UNPLUGGED 0x031a No active PROFIBUS network found.Check whether the option ’PG/PC isthe only master on the bus’ is activatedin Set PG/PC Interface. Deactivate thisoption.
E_SYNI 0x031b This occurs when there are disturban-ces on the bus or when there is an in-terrupt conflict.
E_AMPRO 0x031c Internal error
E_NO_FILE 0x0320 DLL/VxD file not found all the device isnot active. Reinstall.
E_NO_ENTRY 0x0321 The loaded DLL does not have this en-try. Reinstall.
E_VERSION 0x0330 Version conflict between SmartCabledriver and SmartCable firmware
E_NO_SMC 0x0332 Problem with COM port configurationfor SmartCable
E_ONLINE 0x0380 Internal error
E_LOGDEV 0x0381 The specified device parameter assign-ment could not be found. You can crea-te and configure a logical device withthe Set PG/PC Interface program.
E_L2DRIVER 0x0382 The layer 2 driver could not be started.Reinstall the product.
E_L4DRIVER 0x0384 The layer 4 driver could not be started.Reinstall the product.
E_SYSERROR 0x03FF Windows system error. You can findout the error number with GetLastEr-ror().
FAQs
678SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
679SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Related Literature
You want to read the specifications of the OPC Foundation or require additionalinformation on a particular topic.
Your Area of Interest is dealt with in:
You want more detailed informationon a specific topic?
Other Available Literature
You would like detailed information onOPC Data Access and OPC Alarms &Events?
OPC Specifications
9.1 Other Available Literature
Which other documents can I read?
The following documents contain additional information on topics relating toSIMATIC NET.
� Network Manual for PROFIBUS
� Network Manual for Industrial Ethernet
� TF Manual
� DP-Base Programming Interface for CP 5613/CP 5614
9
Related Literature
680SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
9.2 OPC Specifications
Which OPC Specifications exist?
The first and most fundamental specification of the OPC Foundation was the OPCData Access Specification. This provides management of process variables andvarious ways of accessing these variables.
The OPC Alarms & Events Specification covers the transfer of process alarmsand events. It is independent of the Data Access Specification.
Up to now, the OPC Foundation has published the following specifications alsoincluded on the CD SIMATIC NET Manual Collection:
OPC OverviewVersion 1.0, October 27, 1998
A brief introduction in the basic concept of OPC.
OPC Common Definition and InterfacesVersion 1.0, October 27, 1998
This document describes important interfaces available at all OPC servers.
Data Access Custom InterfaceVersion 1.1, September 11, 1997
The specification of the custom interface for Data Access, Version 1.1
Data Access Custom InterfaceVersion 2.04, September 5, 2000
The specification of the custom interface for Data Access, Version 2.04
Data Access Custom InterfaceVersion 2.05, December 17, 2001
The specification of the custom interface for Data Access, Version 2.05
Data Access Automation InterfaceVersion 2.02, February 4, 1999
The specification of the automation interface for Data Access, Version 2.02
OPC Alarms and EventsVersion 1.02, November 2, 1999
A description of the OPC Alarms & Events Server as well as the specification ofthe custom interface of this server.
Related Literature
681SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Alarm & Events Automation InterfaceVersion 1.01, December 15, 1999
The specification of the automation interface of the OPC Alarms & Events Server.
OPC XML-DA Specification - Release CandidateVersion RC1.8, June 13, 2002
The Release Candidate of the specification of the OPC XML interface for DataAccess.
To come:
� Historical Data Access, handling historical process data.
� Batch handling.
Additional specifications for tasks of the automation will follow.
Related Literature
682SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
683SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Glossary
AccessPathAccessPath is optional information for objects of the OPC Item class. The need for andthe interpretation of an access path depends on the particular server. The access pathspecifies (when necessary) the path via which the server should read or write the dataof a process variable. The access path can, for example, be a path or connectionname.
ActiveStatefor the Data Access interface: An OPC server can read, write, and monitor a processvariable. When monitoring, the server checks whether the value of the process variablehas changed after a specific interval. If the value has changed, the new value is sent tothe client automatically. The client can control the monitoring of a process variableusing the active state. Each group and each OPC item object has the active stateattribute. If a client wants to monitor a process variable, it sets the active state of theOPC item that represents the connection to this process variable to TRUE. The activestate of the group must also be set to TRUE. If a group is not active, there is nomonitoring of the process variables in the group.
Active nodeDuring communication over PROFIBUS, masters are known as active nodes orstations.
Actuator-sensor levelThe actuator-sensor level is an automation level. Within the actuator-sensor level, amaster communicates with the actuators and sensors attached to its network. The mainfeature of the actuator-sensor level is the fast reaction time for few data bits.
Alarmfor OPC Alarms & Events: An alarm is an event triggered by a condition that no longerrepresents the normal state.
AsynchronousDuring asynchronous access, the program continues to execute while data are read orwritten.
Automation levelLogical division of an automation system into separate levels to organize the tasksrequired of the system. Automation is divided into the following levels: managementlevel, cell level, field level and actuator-sensor level.
Glossary
684SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Bus topologyThis is a network with a linear structure. All nodes are connected together via acommon network, the bus. The nodes can all communicate with each other, howevernot at the same time. Only one node can send at any one time and the other nodes areonly allowed to receive. The data exchange is controlled by network access methods.
Cachefor Data Access: The cache is an interim buffer for all variables that are referencedusing OPC items. The cache is global for all users. This means that if more than oneuser references the same variable, this is stored only once in the cache. Readoperations (read or refresh) can read the data from the server cache with theOPC_DS_CACHE option.
Canonical data typeThe canonical data type is the original data type of a variable as represented internallyand supplied by the OPC Server.
Categoriesfor Alarms & Events: With the aid of categories, the events supported by an OPC EventServer can be grouped and selected. The definition of the categories is left up to thevendor of an OPC Event Server, the OPC Specification defines a list of recommendedevent categories.
Cell levelThe cell level is an automation level. At this level, all automation and optimization tasksare processed independently. At the cell level, programmable controllers, PCs, anddevices for operator control and monitoring are interconnected.
Class modelThe OPC specification separates the available interfaces and their methods into variousclasses. This structure is known as a class model. A class contains several objects andspecifies which methods and properties these objects must have as representativesof the particular class.
Client-server principleData exchange, in which a client sends communication jobs and a server processes thejobs.
CLSIDIdentification code for OLE classes
Coaxial cableTransmission medium within the cell and management level in PROFIBUS andIndustrial Ethernet. Coaxial cables are made up of several layers: A mid conductor issurrounded by an insulation jacket, the insulating material is surrounded by a wire braid,the wire braid is surrounded by an insulation jacket. Coaxial cables are used forelectrical data transmission where simple cabling and straightforward expandability areprime concerns.
Glossary
685SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
CommunicationCommunication means the transfer of data between two communication partners(devices or modules).
Communications processorProcessor for communication within automation systems. The communicationsprocessor is used to handle a communication process.
COMTo make objects implemented on different platforms or computer architecturescompatible with each other, it is necessary to specify how the platforms interpret anobject. To achieve this, the Component Object Model (COM) is used. COM defines thestandard for interaction between the components. COM allows calls within a process toa different process and even to a different computer.
COM libraryThe COM library is part of the operating system and manages information in a registerabout the COM objects known in the system, for example OPC servers. Whenaccessed by the client, the COM library finds the target object and establishes aconnection depending on its location: - Over the local COM mechanism if the targetobject and client are on the same computer - Over DCOM if the target object and clientare on different computers.
ConfiguringDuring configuration, protocol-specific system settings are made on a virtual device.
CSMA/CD(Carrier Sense Multiple Access with Collision Detection, standardized in IEEE 802.3)Stochastic (including a random element) medium access control technique. Every nodecan transmit at any time as long as the bus is not currently being used by another node.Conflicts arise due to the propagation time when two nodes begin to transmit at thesame time or within a very short time of each other while the bus is still free. The nodeslisten to the bus and detect the collision. They then start transmitting and only attemptto transmit following a randomized waiting time. Buses using the CSMA/CD techniquenormally operate at a transmission rate of 10 Mbps, for example Industrial Ethernet.
Data Communication:Data exchange between programmable controllers or between programmablecontrollers and computers.
DCOMThe object model for calls between different machines is known as DCOM (DistributedComponent Object Model) and is integrated in the operating system as of Windows NT4.0.
Detailed local stateThe detailed local state provides detailed information on the state of the local VFDusing an S7-specific information variable. To interpret the return value, you require thedescription of the local VFD. The data is transferred as data type VT_UI2.
Glossary
686SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
DP ProtocolDP is the acronym for distributed peripheral I/Os and is used within SIMATIC NET forPROFIBUS. The DP protocol allows communication with distributed I/Os.
Electrical data transmissionType of data transmission on PROFIBUS and Industrial Ethernet. Standard electricaldata transmission is on shielded, twisted pair cable. Other cable types include: versionwith PE jacket, halogen-free version, underground cable, version for hazardous areas,and trailing cables.
EthernetTechnology for local area networks (LANs) and wide area networks (WANs). Ethernetstandardizes the procedures for interconnecting several computers. It specifies how thedata flow over the network cable is controlled. Ethernet uses the CSMA/CD (CarrierSense Multiple Access with Collision Detection) medium access control technique asspecified in the international standard 802.3. With this type of medium access control, aworkstation checks whether the transmission medium is free before it startstransmission. From a logical point of view, Ethernet networks are based on a bustopology. The transmission media include shielded coaxial cables, twisted pair cables,or fiber-optic cables. SIMATIC NET Industrial Ethernet uses both the Ethernet and FastEthernet standard.
Eventfor Alarms & Events: An event is any occurrence that might be of interest to the client.Although events can also degenerated due to a condition being met, they do not needto be related to conditions. Examples of events that are not related to conditionsinclude, for example, error messages from the communications system.
Expedited dataAccelerated transmission of small amounts of data. Expedited data is supported only byISO transport and not in TCP/IP.
Field levelThe field level is an automation level. It connects the automated production plants withthe programmable controllers. The field devices measure, signal, and pass on thecommands of the cell level to the plant or process. At this level, the volume of datatransferred is relatively small. A hierarchical communication structure is typical here; inother words, several field devices communicate with one master.
FETCHThe address of the requested data is sent to the partner, the partner then returns thedata. Communication is initiated by the OPC Server.
FMS communicationFMS is the acronym for Fieldbus Message Specification and is used within SIMATICNET for PROFIBUS. FMS provides services for transferring structured data. The FMSservice belongs to layer 7 of the ISO/OSI reference model.
Glossary
687SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
FMS protocolFMS is the acronym for Fieldbus Message Specification and is used within SIMATICNET for PROFIBUS. FMS provides services for transferring structured data. The FMSservice belongs to layer 7 of the ISO/OSI reference model.
GANGlobal Area Network. This is a worldwide network connecting computers on differentcontinents. Such networks normally operate over satellite. There are varioustransmission rates and service classes. The transfer of a message from the source tothe target takes a perceptible time. Example: Internet.
Glass fiber cableTransmission medium within the cell and management level in PROFIBUS andIndustrial Ethernet. Glass fiber cables are fiber-optic cables used for optical datatransmission particularly when electrical isolation and immunity from electromagneticinterference are important.
Industrial Twisted Pair cableTransmission medium within the cell and management level in Industrial Ethernet. Atwisted-pair cable consists of two pairs of wires intertwined to produces a high immunityto interference The twisted-pair cables used in SIMATIC NET are known as IndustrialTwisted-Pair cable. These are used for electrical data transmission, particularly forstructured cabling within the factory.
In-process serverThe in-process server accesses the local server over the OPC Custom interface.An in-process server is in the same process area as the client and is only available forthis process. Normally in-process servers are implemented as DLLs.The OPC Automation interface is implemented as an in-process server.
Interface moduleMethod of attaching devices or computers in process communication. These devicesare not attached over an integrated interface but using interface modules (IM) orcommunications processors (CP).
ISO/OSI reference modelThe ISO/OSI reference model stipulates 7 logical layers in which the data exchangebetween partners in an open system is regulated. The layers are arranged one on topof the other (layer 7 is the highest layer) with each layer building on the layer below it.The ISO/OSI reference model is used, for example, to define the transmission system,access method, or connection establishment. Only peer layers communicated witheach other. The actual implementation of the individual layers is not specified by thereference model. The layers are as follows: Layer 1 (physical layer), Layer 2 (data-linklayer), Layer 3 (network layer), Layer 4 (transport layer), Layer 5 (session layer), Layer6 (presentation layer) and Layer 7 (application layer).
Glossary
688SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
IT communicationAbbreviation for information technology. In the office, E-mail and Web browsers arenormally the tools of communication; the communication paths are generally Ethernet,telephone cables, and the Internet. The SIMATIC programmable controller isincorporated in IT communication over Industrial Ethernet. The communication toolsand paths of IT communication are also available to SIMATIC, since SIMATIC supportsthe TCP/IP protocol and in particular SMTP (Simple Mail Transfer Protocol) for E-mailand HTTP (Hyper Text Transfer Protocol) for access with Web browsers.
LAN (Local Area Network)Local area networks are systems that allow exchange of data between partner-orientednodes over high-performance communication media (for example fiber-optic or coaxialcable) within a limited area. The network operator is solely responsible for the local areanetwork. Due to their “private” nature, systems can be implemented that would beunthinkable in other types of network. LANs normally have a homogeneoustransmission structure supporting rates from 10 - 300 Mbps. They can be linkedtogether directly or over GANs and WANs to form larger structures. LAN services arenot provided by public bodies. Example: Industrial Ethernet, PROFIBUS
Layer 1 of the ISO/OSI reference modelThis is known as the physical layer. It is responsible for the transparent transmission ofa raw stream of bits in the order in which they were passed down from layer 2. Thefollowing factors are specified in layer 1: The type of data transmission, the physicaltransmission medium, the transmission rate and the electrical, mechanical, andfunctional properties of the cable. The particular feature of layer 1 is the range of datatransmission media available: coaxial cable, triaxial cable, fiber-optic cable, and twistedpair.
Layer 2 of the ISO/OSI reference model
Layer 3 of the ISO/OSI reference modelThis is known as the network layer. This is responsible for getting data from one nodeto another (sender and recipient). The following factors are specified in layer 3:Internetwork addresses, routing if the path involves several systems in transit, and flowcontrol. The particular feature of layer 3 is that it specifies how communication takesplace between two subnets.
Layer 4 of the ISO/OSI reference modelThis is known as the transport layer. This provides the user with a reliable connection.The following factors are specified in layer 4: Connection establishment, datatransmission, connection termination, packet retransmission, packet sequencing andassembly. The particular feature of layer 4 is the reliable transfer of data packets.
Layer 5 of the ISO/OSI reference modelThis is known as the session layer and it synchronizes the data prior to transmission.The following factors are specified in layer 5: How a connection is established,maintained, and terminated. Repetition of a transmission from a specificsynchronization point. The particular feature of layer 5 is coordination of the datatransmission session.
Glossary
689SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Layer 6 of the ISO/OSI reference modelThis is known as the presentation layer. Participants in communication often ’speak’different languages. Prior to data exchange, layer 6 translates different systemlanguages into a uniform language with an abstract syntax. The following factors arespecified in layer 6: Data presentation and translation of the standardized presentationof the communications system into a device-specific form. The particular feature oflayer 6 is the implementation of a common communications language.
Layer 7 of the ISO/OSI reference modelThis is known as the application layer. This provides specific services for the variouscommunication applications. Application-specific communication services are specifiedin layer 7. The particular feature of layer 7 is the provision of communication servicessuch as: Read/Write and Start/Stop.
Local ServerA local server runs on the same computer as the client. Like every independentapplication, it has its own process area and name space. The OPC Server for SIMATICNET is a local server. It is implemented as an EXE file.
Logical stateThe logical state of an S7-specific information variable provides information on thesupported services. The data is transferred in the data type VT_BSTR.
Management levelThe management level is an automation level. At this level, wider-ranging tasks areexecuted and processed that affect the entire production or process operation(management functions). The tasks include storage of process values, handling ofoptimization and analysis processing functions and output of the results in the form ofreports. The required data are be collected for example from several process cells orfactories and processed centrally. It is possible to access other geographical locationsat the management level. The number of nodes can run into the thousands.
MAPAcronym for Manufacturing Automation Protocol. Standard for local area networks usedprimarily in factory automation.
masterMasters manage communication on the bus. Each master receives the token once percycle and can then exchange data with slaves or other masters. Once the token holdingtime has elapsed, the node passes the token on to the next master. The master isknown as an active node.
Master-slave principleBus access method in which an active PROFIBUS node (master) controls the entirebus data traffic centrally. It sends data to peripheral devices (slaves) and requests themto send their data. The slaves read the information from the master and output it to theperiphery. The master-slave principle is used mainly within the field level (for examplePROFIBUS-DP).
Glossary
690SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
OCXAn OCX is an ActiveX control. These are COM objects that can be employed asreusable components in the form of controls.
OLEOLE, Acronym for Object Linking and Embedding. OLE is a technology for dataexchange between different Windows programs. OLE establishes a connectionbetween a Windows server program and a Windows container program. Objects fromthe server program can then be included in a document of the container program.
OPC class modelThe OPC specification groups the interfaces and their methods in three hierarchicalclasses: OPC Server, OPC Group and OPC Item. The OPC Server class is at the topof the model and has various attributes containing information on the status and versionof an OPC Server object. The OPC Group class manages the OPC items. With anOPC group, a client can form meaningful units of OPC items and execute operationswith them. The OPC item class represents the connection to a process variable. Anobject of the OPC Server class is a sort of container for an object of the OPC groupclass; this in turn is a container for objects of the OPC item class.
OPC clientstands for a Windows application with OPC capability, such as an operator control andmonitoring system.
OPC FoundationThe OPC Foundation was founded to define and document the standard for OPCinterfaces. The foundation is supported by SIEMENS and other leading companies fromthe automation branch. Microsoft guarantees conformity with Windows.
OPC ItemThe OPC item class is the lowest class in the OPC class model. An object belonging tothe OPC item class represents a connection to a process variable.
Optical data transmissionType of data transmission on PROFIBUS and Industrial Ethernet. Optical datatransmission is on fiber-optic cable with glass or plastic fibers for both indoors andoutdoors.
Passive nodeDuring communication over PROFIBUS, slaves are known as passive nodes orstations.
PG/OP communicationA PG is a programming device and an OP is an operator panel. PG/OP allows accessto the SIMATIC programmable controllers by the STEP 5 and STEP 7 configurationsoftware. The terms PG/OP communication and PG/OP protocol are synonymous.
PG/OP protocolA PG is a programming device and an OP is an operator panel. PG/OP allows accessto the SIMATIC programmable controllers by the STEP 5 and STEP 7 configurationsoftware. The terms PG/OP communication and PG/OP protocol are synonymous.
Glossary
691SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Physical stateThe physical state of an S7-specific information variable provides information on theoperability of a real device. The data is transferred in the data type VT_BSTR.
PLCProgrammable logic controller. Interface between sensors and production machines,also used in communication and data transport between the user and the entireproduction sequences.
Point-to-point linkA point-to-point link allows data exchange over a serial link. It can be used betweenprogrammable controllers or between a programmable controller and computer.
PollingPolling is cyclic communication between DP stations. Polling means that during theproductive phase, the DP master sends cyclic polling frames to the DP slaves assignedto it. A separate polling frame is sent for each DP slave.
Process and field communicationProcess or field communication is used to connect of actuators and sensors toprogrammable logic controllers. The exchange of process signals with the actuatorsand sensors can be performed both cyclically or individually using a control command.For process and field communication SIMATIC NET has PROFIBUS-DP and theAS-Interface. To exchange signals in buildings, the EIB network is used.
PROFIBUSAcronym for Process Field Bus PROFIBUS - a standardized field bus system(standard: EN 50 170). PROFIBUS is a standardized communications system based onthe ISO/OSI reference model for communication between open systems andimplements the following layers: Layer 1 (physical layer), layer 2 (data-link layer) andlayer 7 (application layer). PROFIBUS therefore sets the standards for the transmissionmedium and medium access control as well as for user protocols and the userinterface. Data transmission is digital. To allow fast, real-time communication, theimplementation of layers 3 through 6 was deliberately omitted in PROFIBUS. Thefunctionality of these layers is provided by the LLI (Lower Layer Interface). The LLI isalso used to interface layer 7 with layer 2. Physically, PROFIBUS is an electricalnetwork using shielded twisted pair or an optical network using fiber-optic cable.
PROFIBUS-PAPROFIBUS-PA extends PROFIBUS-DP by the use of optimized transmissiontechniques for field devices (for example for supplying power to field devices over thedata line and use in hazardous areas) while retaining the communications functions ofPROFIBUS-DP. PROFIBUS-PA defines a variant of PROFIBUS-DP that allows the useof PROFIBUS in intrinsically safe areas while maintaining system integration inPROFIBUS-DP.
ProgIDUnique OPC server name assigned by the vendor.
Glossary
692SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
ProtocolA protocol is a set of rules agreed between two communication partners to allow themto communicate with each other. According to the ISO/OSI reference model, suitableprotocols are defined for each layer. Among other things, a protocol specifies thefollowing aspects of data exchange: Mode, connection establishment, data security,and transmission rate.
QualityThis provides information indicating whether or not the value of a variable could beobtained reliably. From this, you can draw conclusions about the validity of the value.
Redundant ring topologyNetwork structure as a special form of the bus topology. In the redundant ring topology,the bus structure is closed to form a ring. A fiber-optic cable serves as the transmissionmedium. The redundant ring topology ensures continuity of communication even iffaults develop in the network. If, for example, a communication node fails or if thefiber-optic cable is broken, the network reconfigures itself within a few milliseconds to afunctioning bus.
Remote serverA remote server is located on another computer. It can be accessed by the client over anetwork connection.
Ring topologyThis is a network with a ring structure. Each node has exactly one node before it andone after it. Data travels in the ring from a sender to a recipient. The data is transmittedonly in one direction through the entire network. The failure of a network node meansthe failure of the entire network.
S7 communication, S7 protocolThis is used for communication within the SIMATIC S7 and SIMATIC M7 programmablecontroller and for communication between these systems and PCs. The terms S7communication and S7 protocol are synonymous.This is known as the data-link layer. This controls the data flow and is responsible fordetecting, reporting, and correcting transmission errors. The following factors arespecified in layer 2: Medium access control, grouping of data into frames, and reliabledata transmission. The particular feature of layer 2 is the ability to select between thefollowing bus access methods: CSMA/CD and token access methods.
SEND/RECEIVE communicationSEND/RECEIVE is used for reliable data transfer between SIMATIC S7 and SIMATICS5 programmable controllers. SEND/RECEIVE belongs to layer 2 of the ISO/OSIreference model in PROFIBUS and layer 4 in Industrial Ethernet. The termsSEND/RECEIVE communication and SEND/RECEIVE protocol are synonymous.
SEND/RECEIVE protocolSEND/RECEIVE is used for reliable data transfer between SIMATIC S7 and SIMATICS5 programmable controllers. SEND/RECEIVE belongs to layer 2 of the ISO/OSIreference model in PROFIBUS and layer 4 in Industrial Ethernet. The termsSEND/RECEIVE communication and SEND/RECEIVE protocol are synonymous.
Glossary
693SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
SIMATIC programmable controllerA SIMATIC programmable controller is a fully integrated system for all automation tasksin industry. SIMATIC PLCs execute all the functions required in automation engineeringfor which various special systems were previously required. Products of other vendorscan be integrated in the system over standardized interfaces. SIMATIC is at work in awide variety of branches, for example the automobile industry, chemicals industry,building automation, semiconductor industry, Power station technology, machinebuilding industry, foodstuffs industry, paper and printing industry, traffic controltechnology, and water supply and effluent disposal technology There are various seriesof SIMATIC programmable controllers: SIMATIC S7/M7/C7, SIMATIC PG/PC, SIMATICHMI, SIMATIC S5, and SIMATIC 505.
SlaveSlave devices cannot initiate communication. They do not receive the token andrespond only to polls from the master. Slaves are therefore known as passive nodes.
SNMPSimple Network Management Protocol, a UDP-based, open protocol for managingnetworks.
SR protocolThe SEND/RECEIVE protocol is used for reliable data transfer between SIMATIC S7and SIMATIC S5 programmable controllers. SEND/RECEIVE belongs to the data linklayer, layer 4 of the ISO/OSI reference model. The terms SEND/RECEIVEcommunication and SEND/RECEIVE protocol are synonymous.
Star topologyThis is a network with a star structure. All the nodes are connected over the networkwith a server that organizes the data transfer. Failure of the server means failure of theentire network; the failure of one node does not block the network.
SynchronousDuring synchronous access, the program stops executing until a variable is read orwritten.
TCP/IPAcronym for Transmission Control Protocol/Internet Protocol TCP is a protocol thatorganizes the establishment and termination of a connection between two networks,controls data flow, and checks that data transfer is complete. IP is a protocol thatorganizes and addresses data. TCP/IP is used in worldwide and local area networks.
Transmission mediumData exchange takes place over various media. The various media differ in the span,immunity to noise, and the transmission rate. Listed in order of increasing complexityand performance, the following transmission media can be used: two-wire cable,untwisted, unshielded (for example for AS-Interface) Industrial Twisted Pair, unshielded(for example for EIB) Industrial Twisted Pair, shielded (for example for PROFIBUS)coaxial cable (for example for Industrial Ethernet) triaxial cable (for example forPROFIBUS) fiber-optic cable (for Industrial Ethernet and PROFIBUS).
Glossary
694SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
Tree topologyThis is a network with a tree structure. All nodes are attached to the network over acable. A tree-structured network is a concatenation of several bus structures of differentlengths.
Time stampFrom the time stamp, you can see when the value of the queried variable was acquired.
TopologyThe topology describes the network structure. It determines how a network (thetransmission medium) and the attachable devices or computers are interconnected.Possible structures are linear bus, star, ring, redundant ring and tree.
Triaxial cableThis is also known as shielded two-wire cable. Transmission medium within the cell andmanagement level in PROFIBUS and Industrial Ethernet. Triaxial cables are shieldedcoaxial cables; in other words they have an additional sealed aluminum outer jacket.Triaxial cables are used in electrical data transmission. They are particularly suited toan industrial environment since they are protected from external interference by theirgrounded shield.
UTCUTC (Universal Time Coordinated) is the standard world time previously known asGreenwich Mean Time.
ValueWhen a variable is queried, the corresponding value is obtained from the latest processdata and returned. This might be the value of a sensor, control parameter, statusinformation, or the status of the network connection.
VariablesVariables are placeholders that are replaced by the current values.
VFD (Virtual Field Device)A VFD simulates a field device. The OPC server registers on the VFD duringconfiguration.
Virtual devicealso known as VFD (Virtual Field Device). A VFD simulates a field device. The OPC server registers on the VFD duringconfiguration.
WAN (Wide Area Network)Connects computers in the same or in different countries (or even continents). Thenetworks are operated on metallic cables, in exceptional cases also on fiber-opticcables. Within a network, there are usually different transmission rates. Thetransmission from the source to the destination takes a perceptible time. WANs canalso be connected to GANs or can be extended to form GANs themselves. LANservices are often provided by public bodies. Example: DATEX-P network of theGerman Post Office.
Glossary
695SIMATIC NET Industrial Communication with PG/PCRelease 11/2003
C79000-G8976-C172-03
Wireless transmissionTransmission medium for PROFIBUS. Wireless data transmission makes use of theInfrared Link Module (ILM) with a range of 15 m.
Glossary
696SIMATIC NET Industrial Communication with PG/PC
Release 11/2003
C79000-G8976-C172-03
A&D Technical SupportWorldwide, available 24 hours a day:
Beijing
Nuernberg
Johnson City
Worldwide (Nuernberg)Technical Support
24 hours a day, 365 days a year
Phone: +49 (0) 180 5050-222
Fax: +49 (0) 180 5050-223
E-Mail: [email protected]
GMT: +1:00
Europe / Africa (Nuernberg)Authorization
Local time: Mon.-Fri. 8:00 to 17:00
Phone: +49 (0) 180 5050-222
Fax: +49 (0) 180 5050-223
E-Mail: [email protected]
GMT: +1:00
United States (Johnson City)Technical Support andAuthorizationLocal time: Mon.-Fri. 8:00 to 17:00
Phone: +1 (423) 262 2522
Fax: +1 (423) 262 2289
E-Mail: simatic.hotline@
sea.siemens.com
GMT: -5:00
Asia / Australia (Beijing)Technical Support andAuthorizationLocal time: Mon.-Fri. 8:00 to 17:00
Phone: +86 10 64 75 75 75
Fax: +86 10 64 74 74 74
E-Mail: adsupport.asia@
siemens.com
GMT: +8:00The languages of the SIMATIC Hotlines and the authorization hotline are generally German and English.
A&D Technical Support
A&D Technical Support
Service & Support on the InternetIn addition to our documentation, we offer our Know-how online on the internet at:http://www.siemens.com/automation/service&support
where you will find the following:
• The newsletter, which constantly provides you with up-to-date information onyour products.
• The right documents via our Search function in Service & Support.
• A forum, where users and experts from all over the world exchange theirexperiences.
• Your local representative for Automation & Drives via our representativesdatabase.
• Information on field service, repairs, spare parts and more under "Services".