Architecture

Mrgada usess simple a server/client architecture. The main mrgada server is used for simple datetime synchronization between clients and authentication, while the collectors are in charge of synchronizing data between clients and PLCs.

  • Not yet implemented: public private key authentication

../_static/images/Architecture.png

Collectors

A Collector is the class that interacts with the plc. In case of s7, it reads bytes, parses those bytes, and handles writing to bytes, allowing for the same codebase for server and client SCADA applications.

ServerCollector

The ServerCollector class is a simple wraper for the TcpServer class. It allows for automatic client connection, overridable methods OnClientConnected OnDataRecieved, etc…

Dependencies

  • Serilog

  • SerilogTimings

  • System

  • System.Collections.Generic

  • System.Diagnostics

  • System.Net.Sockets

  • using System.Threading

ServerCollector
(
    string collectorName, 
    int collectorPort, 
    int connectTimeoutMilliseconds = 3000, 
    int receiveBroadcastTimeout = 200
)

ClientCollector

The ClientCollector class is a simple wraper for the TcpClient class. It allows for automatic client connection, overridable methods OnClientConnected OnDataRecieved, etc…

Dependencies

  • Serilog

  • System.Collections.Generic

  • System.Text

  • System.Threading

Constructor

ClientCollector
(
    string collectorName, 
    int collectorPort, 
    int connectTimeoutMilliseconds = 3000, 
    int receiveBroadcastTimeout = 200
)
  • collectorName : string - The name of the collector, used for logging purpuses.

  • serverPort : int - The port number, the collector will be running on.

  • connectHandlerTimeout : int - Timeout for handling connection establishment (default 3000ms).

  • receiveBroadcastTimeout : int - Timeout for receiving broadcasts (default 200ms).

Public variables

public readonly bool Connected
public readonly bool Started

Virutal methods

public virtual void OnReceive(byte[] data)
public virtual void OnConnect()
public virtual void OnDisconnect()
public virtual void OnStart()
public virtual void OnStop()

Methods

public void AddToSendQueue(byte[] data)