From cfed1d470b85725200724c5bc5e0bbf582589a43 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Mon, 15 Jul 2024 12:55:34 +0300 Subject: [PATCH 1/3] Fix displaying runtime parameters --- src/Configuration/DeviceBindingReader.cs | 11 ++++++++--- src/DFrm.cs | 9 +++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Configuration/DeviceBindingReader.cs b/src/Configuration/DeviceBindingReader.cs index 497722e2..98b3e130 100644 --- a/src/Configuration/DeviceBindingReader.cs +++ b/src/Configuration/DeviceBindingReader.cs @@ -575,9 +575,14 @@ private void SetBind(string description, List actions, } var devicesGroupingByAS = devices - .GroupBy(dev => dev.RuntimeParameters - .TryGetValue(IODevice.RuntimeParameter.R_AS_NUMBER, out var r_as_number) - ? int.Parse(r_as_number.ToString()) : -1) + .GroupBy(dev => + { + dev.RuntimeParameters.TryGetValue(IODevice.RuntimeParameter.R_AS_NUMBER, + out var r_as_number_str); + if (r_as_number_str != null && int.TryParse(r_as_number_str.ToString(), out var r_as_number)) + return r_as_number; + return -1; + }) .Where(r_as_dev => r_as_dev.Key != -1); foreach (var group in devicesGroupingByAS.Where(r_as_dev => r_as_dev.Count() > 1)) diff --git a/src/DFrm.cs b/src/DFrm.cs index 3bf451a3..16c9ae12 100644 --- a/src/DFrm.cs +++ b/src/DFrm.cs @@ -791,10 +791,11 @@ private void FillTypeNode(EplanDevice.IODevice dev, Node root, dev.ObjectNumber, devTypeNode); Node devNode = MakeDeviceNode(devTypeNode, devObjectNode, dev, deviceDescription); - bool isDevVisible = AddDevChannels(devNode, dev) || - (displayParamsBtn.Checked && AddDevParametersAndProperties(devNode, dev)); - - HideIncorrectDeviceTypeSubType(devNode, isDevVisible, countDev, + + bool isDevChannelsVisible = AddDevChannels(devNode, dev); + bool isDevParametersVisible = displayParamsBtn.Checked && AddDevParametersAndProperties(devNode, dev); + + HideIncorrectDeviceTypeSubType(devNode, isDevChannelsVisible || isDevParametersVisible, countDev, dev); } From 74b423baf17114e4ffaa79febe05bad1f0f7bed0 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Mon, 15 Jul 2024 13:06:00 +0300 Subject: [PATCH 2/3] Rename node --- src/DFrm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DFrm.cs b/src/DFrm.cs index 16c9ae12..3dc33ef6 100644 --- a/src/DFrm.cs +++ b/src/DFrm.cs @@ -1648,7 +1648,7 @@ private void devicesTreeViewAdv_SizeChanged(object sender, EventArgs e) public const string ParametersNodeName = "Параметры"; - public const string RuntimeParametersNodeName = "Параметры времени выполнения"; + public const string RuntimeParametersNodeName = "Рабочие параметры"; public const string PropertiesNodeName = "Свойства"; } From 74653df27529848f7da33fde6391bff180e061f1 Mon Sep 17 00:00:00 2001 From: KirillGutyrchik Date: Tue, 16 Jul 2024 11:34:44 +0300 Subject: [PATCH 3/3] Fix test --- EasyEplanner.Tests/DFrm.Test.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyEplanner.Tests/DFrm.Test.cs b/EasyEplanner.Tests/DFrm.Test.cs index 665e1bb9..16ea4d97 100644 --- a/EasyEplanner.Tests/DFrm.Test.cs +++ b/EasyEplanner.Tests/DFrm.Test.cs @@ -110,7 +110,7 @@ public void AddDevParametersTest() Assert.Multiple(() => { Assert.AreEqual("Параметры", root_v.Nodes[0].Text); - Assert.AreEqual("Параметры времени выполнения", root_v.Nodes[1].Text); + Assert.AreEqual("Рабочие параметры", root_v.Nodes[1].Text); Assert.AreEqual("P_ON_TIME Время включения", root_v.Nodes[0].Nodes[0].Text); Assert.AreEqual("P_FB Обратная связь", root_v.Nodes[0].Nodes[1].Text); Assert.AreEqual("R_AS_NUMBER", root_v.Nodes[1].Nodes[0].Text);