Added auto prop sending

- updated readme
This commit is contained in:
Sandoun
2023-06-15 20:49:14 +02:00
parent 62f4a48bf9
commit 7864915967
4 changed files with 48 additions and 3 deletions

View File

@@ -143,10 +143,29 @@ await plc.ConnectAsync(
⚠ **Never set a register by setting the property, always use one of the provided methods**
Registers are stored in an underlying layer for automatic handling, each register has a unique name and address.
Classes that derive from `RegisterCollectionBase` reference these registers automatically using attributes.
All the heavy lifting is done automatically for you, setting this up is described [here](https://github.com/WOmed/MewtocolNet/wiki/Attribute-handled-reading)
### Asynchronous
This operations awaits a task to make sure the register was actually set to your desired value before progressing
```C#
//sets the register to false
await plc.SetRegisterAsync(nameof(registers.TestBool1), false);
//set the current second to the PLCs TIME register
await plc.SetRegisterAsync(nameof(registers.TestTime), TimeSpan.FromSeconds(DateTime.Now.Second));
```
### Synchronous
Sets the register without feedback if it was set
You can use the method to set a register
```C#
//inverts the boolean register
plc.SetRegister(nameof(registers.TestBool1), !registers.TestBool1);
@@ -158,6 +177,13 @@ plc.SetRegister(nameof(registers.TestTime), TimeSpan.FromSeconds(DateTime.Now.Se
plc.SetRegister(nameof(registers.TestString1), "Test");
```
or write to a register in your `RegisterCollectionBase` directly (you need to attach a register collection to your interface beforehand)
```C#
//inverts the boolean register
registers.TestBool1 = true;
```
You can also set a register by calling its name directly (Must be either in an attached register collection or added to the list manually)
Adding registers to a manual list