Added performance improvements for cyclic polling by using single frame building of multiple registers

- cleaned and refactored codebase
This commit is contained in:
Felix Weiß
2023-06-27 20:44:11 +02:00
parent 7be52efb7e
commit a9bd2962b4
34 changed files with 1099 additions and 958 deletions

View File

@@ -1,17 +1,21 @@
using MewtocolNet;
using MewtocolNet.Logging;
using MewtocolNet.RegisterBuilding;
using MewtocolNet.Registers;
using MewtocolTests.EncapsulatedTests;
using Xunit;
using Xunit.Abstractions;
namespace MewtocolTests {
namespace MewtocolTests
{
public class TestLivePLC {
private readonly ITestOutputHelper output;
private List<ExpectedTestData> testData = new() {
private List<ExpectedPlcInformationData> testPlcInformationData = new() {
new ExpectedTestData {
new ExpectedPlcInformationData {
PLCName = "FPX-H C30T",
PLCIP = "192.168.115.210",
@@ -20,7 +24,7 @@ namespace MewtocolTests {
ProgCapacity = 32,
},
new ExpectedTestData {
new ExpectedPlcInformationData {
PLCName = "FPX-H C14R",
PLCIP = "192.168.115.212",
@@ -32,12 +36,29 @@ namespace MewtocolTests {
};
private List<RegisterReadWriteTest> testRegisterRW = new() {
new RegisterReadWriteTest {
TargetRegister = new BoolRegister(IOType.R, 0xA, 10),
RegisterPlcAddressName = "R10A",
IntialValue = false,
AfterWriteValue = true,
},
new RegisterReadWriteTest {
TargetRegister = new NumberRegister<int>(3000),
RegisterPlcAddressName = "DT3000",
IntialValue = (int)0,
AfterWriteValue = (int)-513,
},
};
public TestLivePLC(ITestOutputHelper output) {
this.output = output;
Logger.LogLevel = LogLevel.Verbose;
Logger.OnNewLogMessage((d, m) => {
Logger.OnNewLogMessage((d, l, m) => {
output.WriteLine($"Mewtocol Logger: {d} {m}");
@@ -48,7 +69,7 @@ namespace MewtocolTests {
[Fact(DisplayName = "Connection cycle client to PLC")]
public async void TestClientConnection() {
foreach (var plc in testData) {
foreach (var plc in testPlcInformationData) {
output.WriteLine($"Testing: {plc.PLCName}");
@@ -69,7 +90,7 @@ namespace MewtocolTests {
[Fact(DisplayName = "Reading basic information from PLC")]
public async void TestClientReadPLCStatus() {
foreach (var plc in testData) {
foreach (var plc in testPlcInformationData) {
output.WriteLine($"Testing: {plc.PLCName}\n");
@@ -90,19 +111,38 @@ namespace MewtocolTests {
}
}
//[Fact(DisplayName = "Reading basic information from PLC")]
//public async void TestRegisterReadWriteAsync () {
public class ExpectedTestData {
// foreach (var plc in testPlcInformationData) {
public string PLCName { get; set; }
// output.WriteLine($"Testing: {plc.PLCName}\n");
public string PLCIP { get; set; }
// var client = new MewtocolInterface(plc.PLCIP, plc.PLCPort);
public int PLCPort { get; set; }
// foreach (var testRW in testRegisterRW) {
public CpuType Type { get; set; }
// client.AddRegister(testRW.TargetRegister);
public int ProgCapacity { get; set; }
// }
// await client.ConnectAsync();
// Assert.True(client.IsConnected);
// foreach (var testRW in testRegisterRW) {
// client.AddRegister(testRW.TargetRegister);
// }
// Assert.Equal(client.PlcInfo.CpuInformation.Cputype, plc.Type);
// Assert.Equal(client.PlcInfo.CpuInformation.ProgramCapacity, plc.ProgCapacity);
// client.Disconnect();
// }
//}
}