WITS Level 0 OPC Server
This document describes the installation and configuration of the WITS Level 0 OPC Server.
|28 Oct 2004
- 'Ports' renamed to "Devices'
- Parameter LocalUpdateOnWrite added
- Statistics added
- Minor cleanup in initialisation code
|15 Apr 2005
- AutoConfiguration option added
- Support for string data types added
|03 Oct 2006
- Supports TCP/IP (both TCP/IP client and TCP/IP server)
|13 Dec 2006
- Supports TCP/IP (both TCP/IP client and TCP/IP server)
|01 Jun 2008
- Provides debug mode on writes, some unnecessary logging removed
The OPC server is installed using a Microsoft Installer package - Download.
Following installation, the OPC server then needs to be registered. This can be done in two ways:
- Run the RegisterOPC.bat file
- Start the server manually (WITSLevel0Svr.exe), and use
OPC->Register from the top menu bar
The OPC server uses an INI file for its main configuration data. It first looks
for a file called 'YourMachineName'.INI (where 'YourMachineName' is the name of your PC),
and if that is not found then it looks for a file called WitsOPC.INI.
If the OPC server is licensed (see below), by default the license key will be
written to a file called 'YourMachineName'.INI - this is just to simplify distribution
of license keys. For example, if your PC is called JUPITER, the license key would be
an entry in the file JUPITER.INI.
Demo versions will therefore most likely use the WitsOPC.INI file as the configuration file.
Two sample versions of the WitsOPC.INI file are included here:
This shows a configuration with 3 serial ports, a TCP/IP server and a TCP/IP client connection.
This shows a configuration having a single TCP/IP client connection. Here the WITS OPC server
is a TCP/IP client.
Note that these two files are just for showing how the INI files are set up. The actual
file used will be WitsOPC.INI (or your machine-specific INI file), so if you are wanting
to use one of the sample files, you will have to copy or rename it to WitsOPC.INI.
Section [WITS Level 0 OPC]
The following directives are located in the root of the configuration file. Items
(a) and (b) are both required, item (c) is optional.
a. License Key
The license key for the OPC server is a string in the configuration INI file.
The license key string is based on the machine name, combined with either the hard disk ID
(for singe user installations) or the user name (for multiuser installations).
Anything other than a valid string (for example LicenseKey=Demo) is treated as
a demo license. The server will time out after 2 hours for a demo license.
b. The number of WITS devices
The maximum number of WITS devices currently supported is 10. The number of WITS devices
is specified by the "Devices" entry, for example:
c. TCP/IP Server Port
The third directive that can be included here is the port number if the WITS OPC server
is also to act as a TCP/IP server.
This specifies the TCP/IP port that the WITS OPC server will listen on, for example:
TcpServerPort = 1001
There is no default. If you do not specify a port, the TCP/IP server function
will be disabled. Note that this directive is not required if you are only using the TCP/IP
Section [Device 1..N] - Serial Devices
For each serial WITS device, a number of additional parameters need to be specified:
- The physical comms port
- The comms parameters for each port
- A reference to the tag definition file for each device
- End of Frame timeout
- Local update on write directive
These are specified in the respective sections of the INI file, [Device 1] through to
(a) The physical comms port is the Windows port number. This can be a hardware-based comms
port, or it can be a virtual port such as those provided by USB-Serial converters. For example:
(b) The comms parameters are expressed as a string stating baud rate, parity, data bits and
stop bits. For example:
This indicates 9600 bits/sec,no parity,8 data bits, 1 stop bit.
For parity, the options are:
| ||n|| ||No parity
| ||o|| ||Odd parity
| ||e|| ||Even parity
(c) The tag definition file is a comma delimited (CSV) file. There are five columns:
For example, the following lines are taken from the default WitsDevice.csv file:
- Item - WITS Item ID, 0001 to 9999
- OPC Tag - Text string. This will be the tag in the OPC server
- Write - Indicates whether the item can be written to. The only requirement is that there be
an entry in the field. An 'x' is used in the sample but any printing character can be used
- Max - Maximum value. This is a reasonableness check, used in the event of data corruption.
If no maximum is specified, then no check is performed.
- Min - Minimum value. As for the maximum, this is a reasonableness check, used in the event of data corruption
If no minimum is specified, then no check is performed.
- Data Type - This is the WITS data type, and will be one of the following:
If omitted, the data type is assumed to be floating point
- A - ASCII data
- F - Floating point
- L - Long integer
- S - Short integer
(d) The End of Frame timeout is the length of time (in milliseconds) that the OPC server
should consider to be the end of a frame (or set of datasets) from the WITS device.
The default is 500ms, and the lower limit is 100ms. This timeout is set using a directive
(e) The Local Update on Write directive instructs the OPC server whether it should update the
local copy of an OPC item when it performs a write.
If the WITS device echoes back the written data as part of its WITS data set, then this
parameter should be set to False.
If the WITS device does not echo the written data, LocalUpdateOnWrite should be set to True.
The default is False. The parameter is set using a directive such as:
Section [Device 1..N] - TCP/IP Devices
For each TCP/IP networked WITS device, a number of additional parameters need to be specified:
- Whether the WITS OPC server is the TCP/IP client or server
- Remote Host IP address
- Remote Host Port number (only if the WITS OPC server is the TCP client)
- A reference to the tag definition file for each device (see above)
- Local update on write directive (see above)
(a) TCP/IP Client or Server. The WITS OPC server will normally act as the TCP client, for example:
The AutoConfiguration facility assists the engineer with building the WITS configuration CSV
From the main menu, select Options->AutoConfiguration
For each device, the numerical WITS ID is shown, along with the current value. Also shown are
three text columns:
- WITS ID
- Short ID
A list of OPC tags can then be built by simply using the WITS ID, the Short ID, or the Description.
This is accomplished using the entries in the Save OPC Tag List box.
- Select the WITS ID, the Short ID, or the Description from the radio buttons on the left
- Enter the file name, using the browse button "..."
- Tick the "Remove blanks" or "Update INI file" boxes as required. The "Remove blanks"
option removes blanks from the tag name (really only applicable if you are using the
Description as the tag name), while "Update INI file" will update your INI file with
the name of the CSV file that you have specified
- Press the Save button. You should then get a confirmation to say that a number of lines
have been written to the CSV file
Once the tag definition files have been created, it is necessary to restart the OPC server
for the changes to take effect.
Note that the AutoConfiguration option does not make entries in the following fields:
- Enable Writes
These fields need to be manually editted by the user.
In the case of data that is being written to the WITS device, it may be necessary to
add the WITS ID and OPC tag manually to the CSV file. This is because the WITS device
may not send the data to the OPC server by default. It should, however, echo back the data
once the OPC server has written data to it.
For example, if you are wanting to write to the Survey/Directional Record (Record #7)
Magnetic toolface, you could put an entry in the CSV file as follows:
Assuming the WITS device echoes this data back, then AutoConfiguration will display the
following data for item 716 -
Wits ID: SVYMTF
Short ID: SMTF
Description: Svy Magnetic Toolface
Diagnostics and Statistics
The OPC server provides several mechansims for reporting the status of the received WITS data
and for assisting the engineer with diagnosis of any problems.
OPC Status Codes
Each WITS item is mapped to an OPC item, which has a value and a status. WITS has two pre-defined
status codes, -9999 and -8888, which correspond to a null value and a bad sensor reading. These
have been mapped into OPC status codes 0x0C and 0x10 respectively, as shown in the following table.
The table also indicates the other OPC errors codes that have been assigned.
In the event that communications have failed, all OPC items which previously had a status of Good (0xC0)
are assigned a status of 0x18 (Communications Failure). If their status was not good at the time of the
comms failure, the existing (bad) status is retained.
|WITS Data/Status||OPC Status Code||Description of OPC Code
|-9999.0||0x0C||Bad, Device Failure
|-8888.0||0x10||Bad, Sensor Failure
|Any non-numeric value||0x0||Bad (General)
|Out of range||0x04||Bad, Configuration Error
|Communications timeout with device||0x18||Bad, Communications Failure
The OPC server keeps statistics on the following:
The statistics can be reset to zero from an OPC client by writing any value (it need not be zero) to any of the five statistics
counters. They will all automatically reset to zero when any one of them reaches 999999.
- Data Sets Sent. This is the number of scan packets sent by the OPC server.
- Data Sets Received. This is the number of data sets received, where
a WITS data set is enclosed in the "&&" and "!!" start and end delimiters.
- Data Frames Received. Each WITS transmission can consist of one or
more WITS data sets, termed a "frame" in this context.
- BadData. This counter is incremented in the following cases:
- Invalid WITS item number
- Invalid (non-numeric) WITS value
- Timeouts. The number of timeouts that have occurred when sending a
WITS data set.
Problems or Questions
Please get in touch by telephone or email if you have any problems
with the installation or operation of the OPC server.
Tel: +47 99724942
Alternatively, from 0800 to 1800 Western European time: +47 55995483