7.4. Exporting Data

Eclipse SCADA internally provides process data by the Hive interface. It is the internal, programming language specific, interface of accessing data. However in many cases it is necessary to access this data again over some sort of remote interface.

Data which is provided by Hive instance can be exported using exporters. The most common exporter in Eclipse SCADA is the DA NGP exporter. It allows access to the Hive instance (DA interface) over the NGP protocol. The Java class implementing this functionality is org.eclipse.scada.da.server.ngp.Exporter.Exporter.

However there are a few other exporters which allow access to data from Eclipse SCADA via some other protocols.

The modbus exporter allows exporting DA data from Eclipse SCADA over the Modbus TCP protocol. See also http://www.simplymodbus.ca/TCP.htm.

In this case Eclipse SCADA is a Modbus TCP Slave, which is a TCP server. This means that Eclipse SCADA is waiting for incoming TCP connections from Modbus TCP Master applications.

There are two ways using this exporter. One is the explicit way, by programmatically creating a Hive instance and exporting it. See also Section 7.4.1.1, “Explicit exporting”.

The second variant is by activating the Modbus exporter service in an OSGi based application using the OSGi Hive instance. This setup can easily be done using the Configurator IDE enabling the Modbus exporter on a Master server instance.

In order to explicitly export a Hive instance first of all a hive instance is required. A simple hive example can be found in section Section 3.2.3, “Sample Hive”.

In order to export the Hive instance using the Modbus Export the StaticModbusExport Builder class has to be used.

import org.eclipse.scada.da.server.exporter.modbus.ModbusExport;
import org.eclipse.scada.da.server.exporter.modbus.StaticModbusExport;
import org.eclipse.scada.da.server.exporter.modbus.StaticModbusExport.Builder;
import org.eclipse.scada.da.server.exporter.modbus.io.UnsignedIntegerType;
import org.eclipse.scada.da.server.exporter.modbus.io.UnsignedShortIntegerType;

…

// create the builder for creating the static modbus exporter
final Builder builder = new StaticModbusExport.Builder ( this.hive );

// add exports
/*
 * note that the export the same item using two data types (16bit and 32bit)
 */
int offset = 0;
builder.addExport ( "mem1", offset, UnsignedShortIntegerType.INSTANCE );
offset += UnsignedShortIntegerType.LENGTH;
builder.addExport ( "mem1", offset, UnsignedIntegerType.INSTANCE );

// create and start the modbus exporter
this.modbusExporter = builder.build ();

The builder instance can be used to set all necessary options and parameters. Once the configuration is complete the build method must be called. It will create and start the new export instance. It is important to dispose the instance when it is no longer needed. If this application runs forever there is no need to clean up.

The method addExport registers an item from the hive to be exported using the modbus interface. The offset is, contrary to modbus, in bytes and using a zero based index. Although it is technically possible to start an export with a odd number (e.g. 1 or 5) it is not recommended, since this would mean that the whole export is not word/register aligned. Eclipse SCADA itself can read such data using the memory model definition, but many other modbus based tools cannot.

Also is it important not to overlap registers/bytes when adding exports. At the moment there is no check for overlapping exports. The length of a data type can always be checked using the method int SourceType.getLength();. Some types also have a LENGTH constant defined.

For more information about the register layout see Section 7.4.1.2, “Register layout”.

See also the page on the wiki https://wiki.eclipse.org/EclipseSCADA/Tutorials/StaticModbusExport and the sample project in GIT http://git.eclipse.org/c/eclipsescada/org.eclipse.scada.samples.git/tree/org.eclipse.scada.examples.modbus.exporter

All registers are addressed zero based. 0 is the first register, 1 is the second register. The registers are relative addresses to the start of the mapped entry.

The register layout is for the modbus export is fixed and depends on the data type. The following data types are defined: