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
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
SerilogSerilogTimingsSystemSystem.Collections.GenericSystem.DiagnosticsSystem.Net.Socketsusing 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
SerilogSystem.Collections.GenericSystem.TextSystem.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)