daiiniel / IEC60870-5-102

10 stars 2 forks source link

IEC60870-5-102

Introduction

Library for communicating with meters or devices supporting IEC60870-5-102. The library implements the link layer and most ASDUs from the application layer of the protocol. It supports communication over:

The list of ASDUS currently implemented is:

Getting started

Creating a Master

The project containing the implementation of the library is called IEC60870-5-102 and must be added to the project in which is going to be used as a reference. All the messages exchanged with a device are handled by a Master. The namespaces to be included are:

``` using IEC60870_5_102; using IEC60870_5_102.TransportLayer; ```

The first namespace contains the definition of the Master class and the second one the different transport mediums supported by the library. In order to create a Master its link address, password and meassure point have to be know. That way a master can be implemented as:

``` using (Master master = new Master( 41744, 7, 1, new TcpEndpoint( "IP ADDRESS", 40001))) ```

Where the IP address of the server and the port have to be changed. In case a modem connection is used:

``` using (Master master = new Master( 5197, 7, 1, new ModemEndpoint( "CHANGE BY PHONE NUMBER ACCORDINGLY", "COM10", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One, "CHANGE BY SIM PIN"))) ```

Where the information of the modem connected has to be changed accordingly. In case a direct connection is used"

``` using (Master master = new Master( 5197, 7, 1, new SerialEndpoint( "COM10", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One))) ```

Creating the connection

Once a master has been instantiated the connection between the master and the meter can be stablished. That is achieved by calling the method Connect. That will create the TCP connection, open the serial port and make a data call to the configured endpoint depending on the parameters used for creating the Master. Depending on the messages to be exchanged with the device a session might be or not be needed. The master creates a new session with the device by sending the password.

``` master.Connect(); master.StartSession(); ```

Reading Operational integrators totes

Once the connection has been stablished the Master is able to send and receive messages from the device or meter. These operations have been implemented through methods of the Master class. In order to read the integrator totes the method RequestOperationalTotes can be used:

``` List integrators = master.RequestOperationalIntegratorsTotes( DateTime.Now.AddDays(-2), DateTime.Now, RegisterDirections.HourlyTotes); ```

Sample application

A sample application can be found under the project IEC60870 Test but the details of the connection and the meter have to be adapted.