41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
using System.Net.Sockets;
|
|
using Modbus.Device;
|
|
using static System.Console;
|
|
|
|
namespace ProtosXdigitalDemo
|
|
{
|
|
public class Program
|
|
{
|
|
private const string IpAddress = "10.10.1.1";
|
|
private const int Port = 502;
|
|
|
|
public static int Main(string[] args)
|
|
{
|
|
//ConsoleSetup.ApplyDefaultAppearance();
|
|
var cmd = CommandLineParser.Parse(args); // still available
|
|
LoadFailureCodes.FailureCodeValues(); // assumed static initializer
|
|
|
|
try
|
|
{
|
|
using var tcpClient = new TcpClientConnector(IpAddress, Port).Connect();
|
|
var master = ModbusIpMaster.CreateIp(tcpClient);
|
|
|
|
ChannelCache.Initialize();
|
|
new InputReader(master).ReadAll();
|
|
new OutputExerciser(master).RunSequence();
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
// an Exit was requested
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WriteLine($"[Fatal] {ex}");
|
|
return Data.MachineState.failureCode[1];
|
|
}
|
|
|
|
return Data.MachineState.failureCode[0];
|
|
}
|
|
}
|
|
} |