Integration with Rapid SCADA

Powerful integration capabilities with third-party software are among of the key features of Rapid SCADA. Integrated solutions which include Rapid SCADA and one or more third-party software products allow to perfectly fit customer needs in terms of functionality of the automated system. This article describes the structure of current and archive data and configuration of Rapid SCADA and learns how to integrate with the software.

Before reading this article it is recommended to carefully read Rapid SCADA Administrator’s Guide.

Structure of Rapid SCADA Data

In the context of integration with Rapid SCADA the categories of data described in the following table are the most interesting.

Data Category Default Location Description
Current data C:\SCADA\ArchiveDAT\Cur Current values and statuses of input channels
Archive data C:\SCADA\ArchiveDAT\Min
C:\SCADA\ArchiveDAT\Hour
Values and statuses of input channels at a certain time
Events C:\SCADA\ArchiveDAT\Events Events and alarms
Configuration C:\SCADA\BaseDAT Working copy of the configuration database that describes an automated system in general

The above data are stored using the particularly developed DAT file format. This format provides fast read and write access and keeps the software stable even if a file part is damaged.

Information in a DAT file can be represented as a database table consisting of columns and rows. Therefore, manipulating with Rapid SCADA data is familiar to developers and simple.

Data Retrieving Methods

Integration with Rapid SCADA implies, first of all, integration with SCADA-Server application which is included in the software. SCADA-Server manages current and archive data based on the system configuration, it receives and provides information for applications.

To read Rapid SCADA data and convert to a set of object instances use ScadaData.dll. The actual version of this library can be found in the Rapid SCADA installation directory. The library source code is available on GitHub here.

ScadaData.dll library uses .NET framework and written in C# programming language. Therefore, integration modules must be written in a one of the .NET compatible languages. Microsoft Visual Studio 2010 or higher is required for the development. Do not forget to add reference to ScadaData.dll in your project.

Further we consider two basic ways to exchange data between Rapid SCADA and third-party applications which are implemented in ScadaData.dll.

First Way. Direct File Access

Reading current and archive data

Current and archive data are stored in DAT format files as snapshot tables. Snapshot is a set of values and statuses of input channels at a certain time.

By default current and archive data and events are saved by SCADA-Server in directory C:\SCADA\ArchiveDAT. The file of current data is named current.dat. Archive files are named using mYYMMDD.dat format for minute data and hYYMMDD.dat for hourly data where YYMMDD – year, month and day of the data stored in the file. Each archive file contains data for one day.

To work with DAT files those contain snapshot tables Scada.Data.SrezAdapter class is designed.

The example of reading data from the snapshot table file:

In the given example the adapter fills the snapshot table of SrezTableLight class. In addition to SrezTableLight table, used in the example, the adapter supports loading data into instances of DataTable and Trend classes.

DataTable is a standard implementation of table in .NET. It is significantly slower in comparison with SrezTableLight, so use DataTable if it is clearly needed.

Trend class is designed for fast processing data of one input channel. This class may be used, for example, if it is necessary to display a chart of a channel values.

The following example shows how to output snapshot table data to the console:

Reading Events

Reading events from a DAT format file is similar to reading snapshots. EventAdapter class allows reading events into an instance of EventTableLight or DataTable class. EventTableLight is preferred toward DataTable due to performance. Event files are named using eYYMMDD.dat format where YYMMDD – year, month and day of the events stored in the file.

The example of reading and output events:

Writing current and archive data and events to files is not covered in this article because the function of writing these kinds of files is performed by SCADA-Server. Other applications should not directly change the data files. Instead, interact with SCADA-server via TCP as described below.

Reading the Configuration Database

The configuration database is edited using SCADA-Administrator application. After the configuration database was changed, a working copy of the database is created by clicking the appropriate button. The working copy is used by the other Rapid SCADA applications. It is stored in DAT format files and locates in C:\SCADA\BaseDAT directory by default. Each DAT file contains a single database table. The contents of these files can be viewed with the user interface of SCADA-Server.

To read information from DAT files those contain the configuration database tables, Scada.Data.BaseAdapter class is designed. Data are loaded into a table of DataTable class. The configuration database tables contain no more than 65535 rows, so DataTable performance is enough.

The example of reading the configuration database table:

Details of using DataTable are described in MSDN.

Second Way. Interaction Over TCP

TCP is used to exchange of information between SCADA-Server and other applications, for example, SCADA-Communicator and SCADA-Web. In addition to data requests, using TCP allows sending telecontrol commands to SCADA-Server. Then the commands are transferred to controllers.

SCADA-Server opens a TCP port specified in the application settings. Other applications connect to SCADA-Server as clients. The list of connected clients is available in the text file of SCADA-Server state. When connected, the client must send a user name and password to gain the rights to request data and sending commands. The user name and password are specified in the configuration database or Active Directory. The user must relate to Application role.

The following example shows how to create an object to connect to SCADA-Server and receive a snapshot table:

As seen from the example, to communicate with SCADA-Server over TCP there is a particular class Scada.Client.ServerComm. The connection settings are defined using the instance of CommSettings class. Received data of snapshot table are stored in the instance of SrezTableLight class which is already mentioned in the previous examples.

The most useful methods of ServerComm class needed for integration with Rapid SCADA are listed in the following table.

Method Name Description
ReceiveBaseTable Receives the configuration database table from SCADA-Server
ReceiveSrezTable Receives a snapshot table from SCADA-Server
ReceiveTrend Receives a trend of input channel from SCADA-Server
ReceiveEventTable Receives an event table from SCADA-Server
ReceiveFileAge Receives a file’s modification date and time from SCADA-Server
SendStandardCommand Sends a standard command to SCADA-Server
SendBinaryCommand Sends a binary command to SCADA-Server
SendRequestCommand Sends a command of extra request a device to SCADA-Server
ReceiveCommand Receives a command from SCADA-Server
SendSrez Sends a snapshot of the current data to SCADA-Server
SendArchive Sends a snapshot of the archive data to SCADA-Server
SendEvent Sends an event to SCADA-Server
CheckEvent Sends a check event command to SCADA-Server
Close Finalizes interacting with SCADA-Server and releases resources

SCADA-Server Modules

SCADA-Server functionality can be widely extended by using additional modules (plugins). Module is a library written in .NET compatible programming language, for example, C#, in compliance with certain rules. A module adds an extra logic is triggered on various internal activities of SCADA-Server. This may be start and stop, receiving new data and events, etc.

Server modules are convenient to use in the following cases:

  • If transferring information to third-party systems or databases is required immediately in the moment of its receipt by SCADA-Server.
  • If additional complex processing of data receipt by SCADA-Server is needed.
  • If it is necessary to automatically generate control commands on predefined conditions.

Microsoft Visual Studio 2010 or higher is required for the development of the modules. To implement the module create Class Library project and add two classes inherited from Scada.Server.Modules.ModView and Scada.Server.Modules.ModLogic. The first class describes the user interface of the module, and the second implements the logic of its work.

Download OpenModules solution from GitHub using the link. The solution contains a simple and easy to learn example of the test module ModTest. Create your own modules using this example as a template.

A project and classes must follow the rules of naming:

  1. A filename of a module DLL have to use Mod prefix. For instance, ModTest.dll.
  2. The required namespace of classes inherited from ModView and ModLogic is Scada.Server.Modules.
  3. The required formats of class names inherited from ModView and ModLogic are ModTestView and ModTestLogic, respectively, where ModTest is the name of the module DLL.
  4. The class names are case sensitive.

Copy the DLL file of the compiled module to the SCADA-Server modules directory. Its default location is C:\SCADA\Server\Mod\

Then open Modules page of SCADA-Server user interface, add module, save the settings and restart SCADA-Server service.

Tags: ,