From 73ca607c4b6127908746f616be97d39b520495bf Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期六, 11 七月 2020 10:21:18 +0800 Subject: [PATCH] 索引 --- src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs | 66 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 1 deletions(-) diff --git a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs index 4114ea6..3ac3207 100644 --- a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs +++ b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs @@ -7,14 +7,78 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Bro.Common.Model; +using Bro.UI.Model.Winform; +using static Bro.Common.Helper.EnumHelper; +using Bro.Common.Interface; +using Bro.Common.Base; -namespace Bro.UI.Device.Winform.MotionCard +namespace Bro.UI.Device.Winform { public partial class CtrlMotionCardIOStatus : UserControl { + public List<IOItem> _monitorValues { get; set; } + public CtrlMotionCardIOStatus() { InitializeComponent(); + InitIOEvent(); + } + private IDevice Device { get; set; } + + protected MotionCardBase MotionCard + { + get => Device as MotionCardBase; + } + + public CtrlMotionCardIOStatus(IDevice device, List<IOItem> monitorValues) + { + InitializeComponent(); + Device = device; + _monitorValues = monitorValues; + InitIOEvent(); + } + + private void InitIOEvent() + { + foreach (var ctr in groupBoxIOOut.Controls) + { + if (ctr is IOIndicatorCtrl ioOut) + { + ioOut.OnIODoubleClick += IoOut_DoubleClick; + } + } + } + + private void IoOut_DoubleClick(string desc, bool isOn) + { + var index = Convert.ToInt16(desc.Substring(3)); + MotionCard.WriteOutput(index, isOn ? IOValue.FALSE : IOValue.TRUE); + } + + private void RefreshIOStatus(object sender, EventArgs e) + { + foreach (var ioItem in _monitorValues) + { + if (ioItem.IOType == Common.Helper.EnumHelper.IOType.INPUT) + { + var ioInArray = groupBoxIOIn.Controls.Find("ioIn" + ioItem.IONum, false); + if (ioInArray != null && ioInArray.Length == 1) + { + var ioIn = ioInArray[0] as IOIndicatorCtrl; + ioIn.IsOn = ioItem.Value == IOValue.TRUE; + } + } + else + { + var ioOutArray = groupBoxIOOut.Controls.Find("ioOut" + ioItem.IONum, false); + if (ioOutArray != null && ioOutArray.Length == 1) + { + var ioOut = ioOutArray[0] as IOIndicatorCtrl; + ioOut.IsOn = ioItem.Value == IOValue.TRUE; + } + } + } } } } -- Gitblit v1.8.0