From 1f2fa3f54d4a7b5a2f601c4c947a06476342e3bd Mon Sep 17 00:00:00 2001 From: patrick.xu <patrick.xu@broconcentric.com> Date: 星期五, 22 一月 2021 09:23:06 +0800 Subject: [PATCH] 1. gocator驱动将system.stop移到system.ReceiveData之后 2. 修改测量完成后状态切换逻辑,避免安全光线等干扰 3. 添加设备异常输出日志记录 4. 产品结果输出时做硬盘文件记录 --- src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs | 76 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-) diff --git a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs index b136bdc..e47edce 100644 --- a/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs +++ b/src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs @@ -7,14 +7,90 @@ 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 { 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) + { + InitializeComponent(); + Device = device; + InitIOEvent(); + } + + private void InitIOEvent() + { + foreach (var ctr in groupBoxIOOut.Controls) + { + if (ctr is IOIndicatorCtrl ioOut) + { + ioOut.Cursor = Cursors.Hand; + ioOut.OnIODoubleClick += IoOut_DoubleClick; + } + } + } + + private void IoOut_DoubleClick(string name, bool isOn) + { + var index = Convert.ToInt16(name.Substring(5)); + MotionCard.WriteOutput(index, isOn ? IOValue.FALSE : IOValue.TRUE); + } + + private void RefreshIOStatus(object sender, EventArgs e) + { + _monitorValues = MotionCard.MonitorValues; + 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; + + if (MotionCard.IConfig.IsOutputReversed) + { + ioOut.IsOn = ioItem.Value == IOValue.TRUE; + } + else + { + ioOut.IsOn = ioItem.Value == IOValue.FALSE; + } + } + } + } + + this.Invalidate(); } } } -- Gitblit v1.8.0