mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Fixes
This commit is contained in:
@@ -15,7 +15,7 @@ namespace MewtocolTests {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public class TestRegisterCollection : RegisterCollectionBase {
|
||||
public class TestRegisterCollection : RegisterCollection {
|
||||
|
||||
//corresponds to a R100 boolean register in the PLC
|
||||
//can also be written as R1000 because the last one is a special address
|
||||
@@ -109,8 +109,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "Boolean R generation")]
|
||||
public void BooleanGen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestBool1));
|
||||
|
||||
@@ -122,8 +122,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "Boolean input XD generation")]
|
||||
public void BooleanInputGen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestBoolInputXD));
|
||||
|
||||
@@ -135,8 +135,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "Int16 generation")]
|
||||
public void Int16Gen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestInt16));
|
||||
|
||||
@@ -148,8 +148,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "UInt16 generation")]
|
||||
public void UInt16Gen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestUInt16));
|
||||
|
||||
@@ -161,8 +161,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "Int32 generation")]
|
||||
public void Int32Gen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestInt32));
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "UInt32 generation")]
|
||||
public void UInt32Gen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestUInt32));
|
||||
|
||||
@@ -187,8 +187,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "Float32 generation")]
|
||||
public void Float32Gen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestFloat32));
|
||||
|
||||
@@ -200,8 +200,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = "TimeSpan generation")]
|
||||
public void TimespanGen() {
|
||||
|
||||
var interf = new MewtocolInterfaceShared("192.168.0.1");
|
||||
interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
var interf = Mewtocol.Ethernet("192.168.0.1");
|
||||
interf.AddRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
var register = interf.GetRegister(nameof(TestRegisterCollection.TestTime));
|
||||
|
||||
@@ -210,22 +210,6 @@ namespace MewtocolTests {
|
||||
|
||||
}
|
||||
|
||||
//[Fact(DisplayName = "String generation")]
|
||||
//public void StringGen() {
|
||||
|
||||
// var interf = new MewtocolInterface("192.168.0.1");
|
||||
// interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller();
|
||||
|
||||
// var register = interf.GetRegister(nameof(TestRegisterCollection.TestString2));
|
||||
|
||||
// //test generic properties
|
||||
// TestBasicGeneration(register, nameof(TestRegisterCollection.TestString2), null!, 7005, "DT7005");
|
||||
|
||||
// Assert.Equal(5, ((BytesRegister<string>)register).ReservedSize);
|
||||
// Assert.Equal(4, ((BytesRegister<string>)register).MemoryLength);
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,10 +45,10 @@ namespace MewtocolTests
|
||||
AfterWriteValue = true,
|
||||
},
|
||||
new RegisterReadWriteTest {
|
||||
TargetRegister = new NumberRegister<int>(3000),
|
||||
TargetRegister = new NumberRegister<short>(3000),
|
||||
RegisterPlcAddressName = "DT3000",
|
||||
IntialValue = (int)0,
|
||||
AfterWriteValue = (int)-513,
|
||||
IntialValue = (short)0,
|
||||
AfterWriteValue = (short)-513,
|
||||
},
|
||||
|
||||
};
|
||||
@@ -73,9 +73,9 @@ namespace MewtocolTests
|
||||
|
||||
output.WriteLine($"Testing: {plc.PLCName}");
|
||||
|
||||
var cycleClient = new MewtocolInterfaceShared(plc.PLCIP, plc.PLCPort);
|
||||
var cycleClient = Mewtocol.Ethernet(plc.PLCIP, plc.PLCPort);
|
||||
|
||||
await cycleClient.ConnectAsyncOld();
|
||||
await cycleClient.ConnectAsync();
|
||||
|
||||
Assert.True(cycleClient.IsConnected);
|
||||
|
||||
@@ -94,9 +94,9 @@ namespace MewtocolTests
|
||||
|
||||
output.WriteLine($"Testing: {plc.PLCName}\n");
|
||||
|
||||
var client = new MewtocolInterfaceShared(plc.PLCIP, plc.PLCPort);
|
||||
var client = Mewtocol.Ethernet(plc.PLCIP, plc.PLCPort);
|
||||
|
||||
await client.ConnectAsyncOld();
|
||||
await client.ConnectAsync();
|
||||
|
||||
output.WriteLine($"{client.PlcInfo}\n");
|
||||
|
||||
@@ -111,38 +111,43 @@ namespace MewtocolTests
|
||||
|
||||
}
|
||||
|
||||
//[Fact(DisplayName = "Reading basic information from PLC")]
|
||||
//public async void TestRegisterReadWriteAsync () {
|
||||
[Fact(DisplayName = "Reading basic information from PLC")]
|
||||
public async void TestRegisterReadWriteAsync() {
|
||||
|
||||
// foreach (var plc in testPlcInformationData) {
|
||||
foreach (var plc in testPlcInformationData) {
|
||||
|
||||
// output.WriteLine($"Testing: {plc.PLCName}\n");
|
||||
output.WriteLine($"Testing: {plc.PLCName}\n");
|
||||
|
||||
// var client = new MewtocolInterface(plc.PLCIP, plc.PLCPort);
|
||||
var client = Mewtocol.Ethernet(plc.PLCIP, plc.PLCPort);
|
||||
|
||||
// foreach (var testRW in testRegisterRW) {
|
||||
foreach (var testRW in testRegisterRW) {
|
||||
|
||||
// client.AddRegister(testRW.TargetRegister);
|
||||
client.AddRegister(testRW.TargetRegister);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// await client.ConnectAsync();
|
||||
// Assert.True(client.IsConnected);
|
||||
await client.ConnectAsync();
|
||||
Assert.True(client.IsConnected);
|
||||
|
||||
// foreach (var testRW in testRegisterRW) {
|
||||
foreach (var testRW in testRegisterRW) {
|
||||
|
||||
// client.AddRegister(testRW.TargetRegister);
|
||||
var testRegister = client.Registers.First(x => x.PLCAddressName == testRW.RegisterPlcAddressName);
|
||||
|
||||
// }
|
||||
//test inital val
|
||||
Assert.Equal(testRW.IntialValue, testRegister.Value);
|
||||
|
||||
// Assert.Equal(client.PlcInfo.CpuInformation.Cputype, plc.Type);
|
||||
// Assert.Equal(client.PlcInfo.CpuInformation.ProgramCapacity, plc.ProgCapacity);
|
||||
await testRegister.WriteAsync(testRW.AfterWriteValue);
|
||||
|
||||
// client.Disconnect();
|
||||
//test after write val
|
||||
Assert.Equal(testRW.AfterWriteValue, testRegister.Value);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
//}
|
||||
client.Disconnect();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user