mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
- change backend logic for register r/w - remade interface builder pattern for better syntactic sugar - refined tests
47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using CommandLine;
|
|
using MewtocolNet;
|
|
using Spectre.Console;
|
|
|
|
namespace MewTerminal.Commands.OnlineCommands;
|
|
|
|
internal class OnlineCommand : CommandLineExcecuteable {
|
|
|
|
[Option('e', "ethernet", Default = "127.0.0.1:9094", HelpText = "Ethernet config")]
|
|
public string? EthernetStr { get; set; }
|
|
|
|
[Option('s', "serial", Default = null, HelpText = "Serial port config")]
|
|
public string? SerialStr { get; set; }
|
|
|
|
public override async Task RunAsync() {
|
|
|
|
try {
|
|
|
|
if (!string.IsNullOrEmpty(SerialStr)) {
|
|
|
|
} else {
|
|
|
|
var split = EthernetStr.Split(":");
|
|
|
|
string ip = split[0];
|
|
int port = int.Parse(split[1]);
|
|
|
|
using (var plc = Mewtocol.Ethernet(ip, port).Build()) {
|
|
|
|
await AfterSetup(plc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
AnsiConsole.WriteLine($"[red]{ex.Message.ToString()}[/]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
internal virtual async Task AfterSetup(IPlc plc) => throw new NotImplementedException();
|
|
|
|
}
|