Fixed issues with bitwise decoding not working correctly

- refactored bitwise register assign methods
- counted up version number
This commit is contained in:
Felix Weiß
2022-06-22 15:58:24 +02:00
parent 8f9e66d5d3
commit 4c719843f2
10 changed files with 253 additions and 120 deletions

View File

@@ -30,9 +30,9 @@ namespace Examples {
//reading a value from the register collection
Console.WriteLine($"BitValue is: {registers.BitValue}");
interf.GetRegister(nameof(registers.TestInt16)).PropertyChanged += (s, e) => {
interf.GetRegister(nameof(registers.TestBool1)).PropertyChanged += (s, e) => {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(interf.GetRegister(nameof(registers.TestInt16)).StringValue);
Console.WriteLine(interf.GetRegister(nameof(registers.TestBool1)).StringValue);
Console.ResetColor();
};
@@ -44,9 +44,6 @@ namespace Examples {
await Task.Delay(2000);
//inverts the boolean register
await interf.SetRegisterAsync(nameof(registers.TestBool1), !registers.TestBool1);
Console.WriteLine("Testregister was toggled");
//adds 10 each time the plc connects to the PLCs INT regíster

View File

@@ -7,7 +7,7 @@ namespace Examples {
public class TestRegisters : RegisterCollectionBase {
//corresponds to a R100 boolean register in the PLC
[Register(100, RegisterType.R)]
[Register(1000, RegisterType.R)]
public bool TestBool1 { get; private set; }
//corresponds to a XD input of the PLC
@@ -42,6 +42,9 @@ namespace Examples {
[Register(1204, 9, BitCount.B16)]
public bool BitValue { get; private set; }
[Register(1204, 5, BitCount.B16)]
public bool FillTest { get; private set; }
//corresponds to a DT7012 - DT7013 as a 32bit time value that gets parsed as a timespan (TIME)
//the smallest value to communicate to the PLC is 10ms
[Register(7012)]