OPC Functional Specifications
OPC Functional Specifications
OPC Functional Specifications
Release Information
Uniformance 150 Revision 1 Revision Date: July 30, 1999 Document Number: RDI320.1
Honeywell Inc. Industrial Automation and Control Automation College 2820 West Kelton Lane Phoenix, AZ, 85023-3028
ii Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Contents
Contents
Copyright, Notices, and Trademarks Release Information Introducing OLE for Process Control RDI
Understanding the Real-Time System Interface Architecture Required Hardware and Software Implementing OPC Understanding the Implemented Functions and Constraints
ii ii 5
5 5 6 6
7
7 7
9
9 10 11 11 13 14 14 16 16
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification iii
Contents
16 16 16 17
19
19 19 20 20 21 21 21 22 22
23
23 23 23
Glossary
API OPC RDI
25
25 25 25
Index
27
iv Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 5
Implementing OPC
All OPC Servers support a synchronous read call and an asynchronous call. Since this is required functionality of OPC Servers, you can run the OPC RDI in polled or exception mode. The OPC interface allows for numerous data types. The client application tells the OPC server the data type the client wishes to receive. This is the method that the OPC RDI uses.
OPC does not support history recovery. The interface is designed to return five (5) data types from the OPC Server. The description on how to request these data types and the conversions into PHD data types can be found in the section Tag Source Type/Attribute Mapping.
6 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
F4 - four byte float I4 - four byte integer AS - ASCII (80 character max) US - Unicode (39 character max) Unicode data type is stored in PHD as a PHD binary value. Therefore you must write a program, using the PHD API to retrieve the values.
BO - Boolean (Logical) Boolean types are stored as an integer value, with one (1) being true and zero (0) being false.
TI - Time Time data type is stored as an integer value as the number of seconds since midnight of January 1, 1970, with the time based on UTC.
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 7
The following table shows the translation to the OPC RDI data types.
Source tagtype F4 I4 AS AS US BO TI Source attribute VALUE VALUE VALUE VALUE80 VALUE VALUE VALUE PHD tag datatype R I C C B I I OPC data type F4 I4 BSTR BSTR BSTR BOOLEAN TIME Input from OPC Server Output to OPC Server
For a complete list of source tag configuration information, refer to the section Installing the Interface.
8 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
rdi_open
Implementation Description
This subroutine initiates contact with the interface. The RDI creates a DCOM connection to the OPC server. This routine creates the OPC server instance for this RDI, and queries the OPC interface. The OPC server vendor information is retrieved and displayed in the output file. If any of the calls fail, a non-zero value is returned, forcing the RDI to restart.
Parameters
Parameter #1 - OPC server name. (For more information, refer to the section OPC Server Name.) Parameter #2 - Name of the machine with the OPC server. If the OPC Server is on the same machine as the OPC RDI use a null string for this parameter ("").
The following parameters are optional. They must follow the first 2 parameters but may be in any order:
This parameter SCANTIME Does this Causes the PHD timestamp value to be retrieved from the OPC Server. When the SCANTIME argument is not supplied, the RDI generates a timestamp after collecting the value. The OPC RDI to run in poll mode, otherwise it runs in exception mode.
POLL
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 9
Does this Limits the maximum number of items in an OPC Group. MAX_ITEMS= is the parameter name and number is the maximum number of items in an OPC Group. (Make sure there are no spaces between the parameter name and the parameter value). Some OPC servers have a maximum number of items per group. A value of zero (0) for number causes the group size to be unlimited. The default is zero (0).
DEBUG=number
Turns on the debug flags for the parameter value. DEBUG= is a parameter with a parameter value, number. Number is the value for the debug flags that must be on. If this option is not used, no debug flags are turned on. The debug flags are: DEBUG=1 Displays tag related debug flags. DEBUG=2 - Displays a list of the functions as they are called. DEBUG=4 - Reports statuses to calls that failed. DEBUG=8 - Prints time data for tags returning a data type of time. DEBUG=16 - Prints the argument information passed to the RDI when it starts up. DEBUG=32768 - Turns on miscellaneous debug flags. You can turn more than one flag on at a time by adding the flags together.
DEBUG NULL_STRING
Turns on all the debug flags. Helps to resolve the problem if there are different interpretations of a NULL value. For example, if the error is: HResult <0x80010105>: The server threw an exception. You can set this option to attempt to resolve the problem.
10 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
rdi_deltaclock
Implementation Description
This subroutine retrieves and compares the OPC server time and the PHD Server system clock times. The difference (OPC server clock - PHD Server system clock), in seconds, is returned.
Real-Time System Functions Used
IOPCServer::GetStatus vos_curtime
rdi_inittag
Implementation Description
This function validates the src_tagname in the OPC server. The src_attribute must have a value of VALUE or VALUExx where xx is the number of characters in a string. The tag[].rdi_status sets according to its validity on the OPC server. (For more information, refer to the section
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 11
rdi_statustext.) The tags are assigned to group lists for validation. Two group list types are created, a read group list and a write group list. The read group list contains all tags enabled for collection and the write group list contains all tags enabled for download (put). In the read group list, a group is created based on the scan rate of the tag and the maximum number of items that may be assigned to a group. If the OPC RDI is in the poll mode, the items are validated using the OPC groups and the OPC groups are deleted. If the OPC RDI is in exception mode, the items are added to the OPC groups. The OPC groups are not removed so the rdi_query call can use these groups. In the write group list, a group is created based on the maximum number of items that may be assigned to a group. The write groups are not removed. These groups are used by the rdi_put call. When the OPC groups are created the following interfaces are also requested:
If this RDI is an exception mode RDI, the routine to call back when an OnDataChange (exception) occurs is established. HCI utilities are used to help make the implementation of the OnDataChange simpler. A status of successful is returned unless any of the OPC function calls fail, then the return status for the failed function is returned.
RDIDATA storage
This routine, opc_rdidata, contains a byte specifying if a tag has passed initialization. The rest of the structure contains information that may be used by an OPC server to help speed up initialization of the item. If a tag is successfully validated, the opc_rdidata structure is saved within tag [].rdidata, and tag[].rdi_status is set to zero (0). Otherwise, the equivalent RDI error code is returned in tag[].rdi_status.
Group Management
As described before the OPC RDI uses groups to initialize the tags. If the OPC RDI is in exception mode all the current groups in the read group list must set the OPC group state to inactive so no values are collected while tags are initialized. If the OPC RDI is in poll mode, all the OPC groups must be deleted. The groups are recreated when init_pollgroup is called.
Real-Time System Functions Used
12 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
IOPCItemMgt::ValidateItems IOPCItemMgt::QueryInterface IOPCItemMgt::Release HciSink constructor IDataObject::DAdvise IDataObject::Release IDataObject::DUnadvise IOPCGroupStateMgt::SetState IOPCGroupStateMgt::Release IOPCAsyncIO::Release IOPCSyncIO::Release
rdi_initpoll
Implementation Description
This routine creates a list of OPC groups containing all the tags in the OPC RDI. Each OPC group contains no more than the maximum number of items allowed per OPC group. If the call fails, a non-zero error status is returned to the calling routine.
Real-Time System Functions Used
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 13
rdi_poll
Implementation Description
This routine retrieves data from the OPC server using the previously defined OPC group list. For all the OPC groups in the list, an OPC group read request is made. For every tag within the list, the following information is returned for the PHD tag:
This the values time stamp tag[].istamp Is Set to the timestamp according to the command line parameter SCANTIME, unless an error occurred retrieving the value. If an error occurred, the timestamp is set to NOW on the machine the RDI is running on. Set to 100 if the OPC items quality is good; otherwise this value is set to 1. Set to zero (0) for a good retrieval. If the OPC item failed, the tag[].rdi_status is equal to the failure code. If the OPC item quality was not good, the tag[].rdi_status is equal to the OPC quality. For more information, refer to the section rdi_statustext. the retrieved data point value Converted to a compatible PHD data type (int, float, string or binary) and stored in tag[].value.
If the call fails, a non-zero error status is returned to the calling routine.
Real-Time System Functions Used
IOPCSyncIO::Read
rdi_query
Exception Implementation Description
This function works with the OPC call-back. The call-back function is called by the OPC server when values change in an OPC group. The call-back function copies the group's data returned by the OPC server into a list of returned data, so that rdi_query can process the data. When rdi_query is called it processes the data in the list so that it maintains history even when multiple values for an item were received.
14 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
This function sets the state of the OPC groups in the read group list, to active, and refreshes the group, if the read group list is not already active. The OPC RDI checks the list of exception values to see if any groups have returned values. If any of the groups have returned values, the following information is returned for every PHD tag in the list:
This the values time stamp tag[].istamp Is Set to the timestamp associated with the value from the OPC server, unless an error occurred retrieving the value. If an error occurred, the timestamp is set to NOW on the machine the RDI is running on. Set to 100 if the OPC items quality is good; otherwise this value is set to 1. Set to zero (0) for a good retrieval. If the OPC item failed, the tag[].rdi_status is equal to the failure code. If the OPC item quality was not good, the tag[].rdi_status is equal to the OPC quality. For more information, refer to the section rdi_statustext. the retrieved data point value Converted to a compatible PHD data type (int, float, string or binary) and stored in tag[].value.
If the call fails, a non-zero error status is returned to the calling routine.
Issues
The rdi_query is designed to maintain values if it falls behind. It is possible it will never catch-up, but this can be prevented. The only time that rdi_query should have this problem is if the RDI parameter XSCANSECS is set to a value greater than the minimum tag collection frequency. For example, if you configure to collect every 10 seconds and set XSCANSECS 30, the RDI will not keep up with the exceptions that occur. Always set XSCANSECS to at least half of the minimum tag collection frequency.
Real-Time System Functions Used
IOPCGroupStateMgt::SetState IOPCGroupStateMgt::Refresh
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 15
rdi_put
Implementation Description
This routine puts the values to the OPC server using the write group list created in the rdi_inittag routine. The value for the put is obtained for the tag[].value. If the OPC item failed, the tag[].rdi_status is equal to the failure code. If any of calls fails, a non-zero error status is returned to the calling routine.
Real-Time System Functions Used
IOPCAsyncIO::Write
rdi_histquery
Implementation Description
rdi_histfetch
Implementation Description
rdi_endtag
Implementation Description
This routine stops the master list from being scanned. The following functions occur within the routine:
Clears the rdidata field of every tag within the master tag list. Purges all multi-point lists. Initializes all temporary buffers.
None.
rdi_close
Implementation Description
This routine cleans up all the memory in use, closes all the OPC groups, and releases the connection with the OPC Server. Returns a value of zero (0).
16 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
rdi_statustext
Error Codes Description
operating system OPC call OPC server OPC item confidence OPC RDI unique statuses
The Operating System, OPC Calls, and OPC server are in a common format. The data type defined for these error codes is HRESULT. An HRESULT value contains the following fields:
A 1-bit code indicating severity, where zero represents success and one (1) represents failure. A 4-bit reserved value. An 11-bit code indicating responsibility for the error or warning, also known as a facility code. A 16-bit code describing the error or warning.
An 8-bit field indicating device specific information. A 2-bit quality field with a value of 11 binary. This is equal to good quality. A 4-bit field indicating the sub status associated with the quality. A 2-bit code describing limits.
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 17
Implementation Description
This routine compares the status code to a FACILITY_NULL to determine if the status code is an HRESULT. If the facility code (the 11-bit field of an HRESULT) is not equal to a FACILITY_NULL (0), this is an operating system, OPC call, or an OPC server error. The OPC Server is required to translate Operating System HRESULTs, OPC HRESULTs, and OPC Server HRESULTs. A request is made to the OPC server to try and convert the status. If this fails, an operating system call is made to try an convert the status. For a confidence, a quality of 10 binary is invalid. If the status code is equal to a FACILITY_NULL and the lower byte of the confidence is 80 hex, the status code is an RDI unique status, and the value is contained in the upper byte of the confidence field. If status code is equal to a FACILITY_NULL and the lower byte of the confidence is not 80 hex, the status code must be an OPC item confidence.
18 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 19
20 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Updating the RDI_INTRF_PARAM.DAT File Add the following to the file %PHD_ROOT%\ntsite\RDI_INTRF_PARAM.DAT.
OPC,1,0,PHD_EXEC,RDI_OPC
Updating the RDI Parameter Configuration Form Enter the following information into the TPI RDI Parameter Configuration form:
SRC_SYSTEM OPC PARAM_NAME OPC SERVER SEQ 1 DSCR Name of the OPC Server MAND_CHK -1 DFLT VAL_TEXT
OPC
MACHINE NAME 2
Machine name where the OPC Server is located or blank if the RDI is on the same machine Set to SCANTIME to use the timestamp from the OPC server Set to POLL to run the RDI in POLL mode.
OPC
SCANTIME
=SCANTIME
OPC
POLL
=POLL
Using the RDI Specification Form You must configure the following in the OPC interface using the TPI RDI Specification form:
The RDI name must be a unique identifier, used to identify data parameters to be collected from this interface. The Source System must be set to OPC. The parameters for this instance of the RDI. For more information, refer to Updating the RDI Parameter Configuration Form.
You must run the interface configuration program rdi_services to create the appropriate interface GO and KILL files. The files are named GO_<RDI Name>.CMD and KILL_<RDI Name>.CMD where RDI name is as specified above in the TPI RDI Specification form.
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 21
Setting the Interface Startup and Parameters You must set the GO_<RDI Name>.CMD procedure for the OPC interface to pass the following parameters (in order) to the interface program:
GO_<RDI Name> Parameters
Troubleshooting
The following problems may occur:
The startup parameters from PHD are incorrectly defined. The interface has not been defined to PHD (or incorrectly defined). The name of the OPC server is incorrect.
For further problem diagnosis, refer to the Uniformance PHD System Manual or refer to the OPC server documentation.
22 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 23
Glossary
Glossary
API
Application Programming Interface. A library of C function calls which allow consistent access to data resident on an LCN.
OPC
OLE for Process Control (OPC) is a standard developed to communicate with numerous data sources related to the process control industry.
RDI
PHD Real-Time Data Interface. One RDI is used for each type of DCS, PCL, SCADA, and other real-time sources of data that are included in PHD.
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 25
Index
Index
D
data retrieval implementing for rdi_query 15 data throughput, understanding 23 data types AS or ASCII 7 BO or Boolean (logical) 7 F4 or four byte float 7 I4 or four byte integer 7 requesting specific types 7 TI or time 7 understanding translation 8 US or Unicode 7 defining API 25 OPC 25 RDI 25 describing functional modules 918
11-bit responsibility error code 17 16-bit description error code 17 1-bit severity code error code 17 2-bit limit confidence code 17 2-bit quality confidence code 17 4-bit reserved value error code 17 4-bit sub status quality confidence code 17
8
8-bit device information confidence code 17
A
API, defining 25 architecture understanding 5 AS. See ASCII data type. ASCII data type 7 attribute mapping understanding 7
E
error codes, describing 11-bit responsibility code 17 16-bit description code 17 1-bit severity code 17 2-bit limit code 17 2-bit quality code 17 4-bit reserved value 17 4-bit sub status quality code 17 8-bit device information code 17 rdi_statustext 17 exception values reporting 5
B
BO. See Boolean (logical) data type. Boolean (logical) data type 7
C
concurrent interface limitations, understanding 23 constraints in OLE for Process Control RDI does not support history recovery 6 supports poll and exception mode for reading values 6
F
F4. See four byte float. four byte float data type 7 four byte integer data type 7
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 27
Index
functional modules defining return values 9 describing 918 OPC Server Name 10 rdi_close 16 rdi_deltaclock 11 rdi_endtag 16 rdi_histfetch 16 rdi_histquery 16 rdi_initpoll 13 rdi_inittag 11 rdi_open 9, 22 rdi_poll 14 rdi_put 16 rdi_query 14 rdi_statustext 12, 14, 15, 17
H
history recovery understanding in OPC RDI 6
I
I4. See four byte integer. implementation description rdi_inittag 11 implementing data retrieval for rdi_query 15 exceptions for rdi_query 14 rdi_close 16 rdi_deltaclock 11 rdi_endtag 16 rdi_histfetch 16 rdi_histquery 16 rdi_initpoll 13 rdi_open 9 rdi_poll 14 rdi_put 16 rdi_statustext 18 implementing OPC RDI 6 installing the interface 1922
included files list 19 installing OPC RDI 20 preparing system environment 19 setting TIP TAG Source Configuration information 20 setting up interface startup 22 troubleshooting 22 updating RDI Parameter Configuration 21 updating RDI Specification 21 updating RDI_INTRF_PARAM.DAT file 21 Integer 7 interface installation included files list 19 installing OPC RDI 20 preparing system environment 19 setting TPI TAG Source Configuration information 20 setting up startup 22 troubleshooting 22 updating RDI Parameter Configuration 21 updating RDI Specification 21 updating RDI_INTRF_PARAM.DAT file 21 interface performance, understanding 23 concurrent interface limitations 23 data throughput 23 tag capacity limitations 23 interface, installing 1922 introducing OLE for Process Control RDI 56 items, using instead of tags 5
M
managing tag groups using rdi_inittag 12
O
OLE for Process Control RDI architecture 5 constraints 6 describing the functional modules 918 implementing 6
28 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification
Index
OLE for Process Control RDI (cont.) installing 20 installing the interface 1922 interface performance 23 introducing 56 mapping data types 67 providing common communications 5 required hardware and software 5 using DCOM technology 5 OnDataChange using to report values 5 OPC defining 25 OPC Server Name functional module 10 real-time system functions 11 OPC. See OLE for Process Control. open technology in OLE for Process Control RDI 5
P
parameters rdi_open 9 PHD tag definitions tag field usage 7 tag source type/attribute mapping 7 understanding 78 polled values, reporting 5 process control systems the architecture 5
R
RDI defining 25 RDI Parameter Configuration updating during installation 21 RDI Specification updating during installation 21 rdi_close functional module 16 implementing 16
rdi_deltaclock functional module 11 describing implementation 11 real-time system functions 11 rdi_endtag functional module 16 implementing 16 real-time system functions 16 rdi_histfetch functional module 16 implementing 16 rdi_histquery functional module 16 implementing 16 rdi_initpoll functional module 13 implementing 13 real-time system functions 13 rdi_inittag implementing 11 rdi_inittag functional module 11 real-time system functions 12 setting up RDIDATA storage 12 using groups to initialize tags 12 RDI_INTRF_PARAM.DAT file updating during installation 21 rdi_open functional module 9, 22 describing implementation 9 understanding parameters 9 rdi_poll functional module 14 implementing 14 real-time system functions 14 rdi_put functional module 16 implementing 16 real-time system functions 16 rdi_query functional module 14 describing exception implementation 14 implementing data retrieval 15 issues 15 real-time system functions 15 rdi_statustext functional module 12, 14, 15, 17 describing error codes 17 implementing 18 RDIDATA storage, setting up with rdi_inittag 12
Uniformance OLE for Process Control Real-Time Data Interface Functional Specification 29
Index
real-time system functions OPC Server Name 11 rdi_deltaclock 11 rdi_endtag 16 rdi_initpoll 13 rdi_inittag 12 rdi_poll 14 rdi_put 16 rdi_query 15 required hardware and software 5 return values, in functional modules 9
T
tag capacity limitations, understanding 23 tag field usage understanding 7 tag source type/attribute mapping: 7 tags defining as items 5 TI. See time data type. time data type 7 TPI Tag Source Configuration information setting during installation 20 translating data types to OPCRDI data types 8 troubleshooting installation 22
S
startup setting during installation 22 system environment preparing for interface installation 19
U, V
Unicode data type 7 US. See Unicode data type.
30 Uniformance OLE for Process Control Real-Time Data Interface Functional Specification