From 8f9e66d5d3e071e99823d4261a7932a5866ef5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Wed, 22 Jun 2022 10:13:15 +0200 Subject: [PATCH] Added string value to register base for viewmodel support - counted up version number --- Examples/Program.cs | 6 +++++ MewtocolNet/Mewtocol/Subregisters/Register.cs | 26 +++++++++++++++++++ MewtocolNet/MewtocolNet.csproj | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Examples/Program.cs b/Examples/Program.cs index f142896..93736cf 100644 --- a/Examples/Program.cs +++ b/Examples/Program.cs @@ -30,6 +30,12 @@ namespace Examples { //reading a value from the register collection Console.WriteLine($"BitValue is: {registers.BitValue}"); + interf.GetRegister(nameof(registers.TestInt16)).PropertyChanged += (s, e) => { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine(interf.GetRegister(nameof(registers.TestInt16)).StringValue); + Console.ResetColor(); + }; + //writing a value to the registers Task.Factory.StartNew(async () => { diff --git a/MewtocolNet/Mewtocol/Subregisters/Register.cs b/MewtocolNet/Mewtocol/Subregisters/Register.cs index 83a6620..507491e 100644 --- a/MewtocolNet/Mewtocol/Subregisters/Register.cs +++ b/MewtocolNet/Mewtocol/Subregisters/Register.cs @@ -19,11 +19,37 @@ namespace MewtocolNet.Registers { public event Action ValueChanged; public event PropertyChangedEventHandler PropertyChanged; + /// + /// The register name or null of not defined + /// public string Name { get; set; } + /// + /// The registers memory adress if not a special register + /// public int MemoryAdress { get; set; } + /// + /// The rgisters memory length + /// public int MemoryLength { get; set; } + + /// + /// The value of the register auto converted to a string + /// + public string StringValue => GetValueString(); + + /// + /// The name the register would have in the PLC + /// + public string RegisterPLCName => GetRegisterPLCName(); + internal bool isUsedBitwise { get; set; } + internal Register () { + ValueChanged += (obj) => { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(StringValue))); + }; + } + public virtual string BuildMewtocolIdent() { StringBuilder asciistring = new StringBuilder("D"); diff --git a/MewtocolNet/MewtocolNet.csproj b/MewtocolNet/MewtocolNet.csproj index 02a0249..aac7806 100644 --- a/MewtocolNet/MewtocolNet.csproj +++ b/MewtocolNet/MewtocolNet.csproj @@ -2,7 +2,7 @@ netstandard2.0 MewtocolNet - 0.3.3 + 0.3.4 Felix Weiss Womed true