| | |
| | | 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 CtrlMotionCardIOStatus() |
| | | { |
| | | InitializeComponent(); |
| | | InitIOEvent(); |
| | | } |
| | | private IDevice Device { get; set; } |
| | | |
| | | protected MotionCardBase MotionCard |
| | | { |
| | | get => Device as MotionCardBase; |
| | | } |
| | | |
| | | |
| | | public CtrlMotionCardIOStatus(List<IOItem> monitorValues) |
| | | public CtrlMotionCardIOStatus(IDevice device) |
| | | { |
| | | InitializeComponent(); |
| | | _monitorValues = monitorValues; |
| | | 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) |
| | |
| | | if (ioInArray != null && ioInArray.Length == 1) |
| | | { |
| | | var ioIn = ioInArray[0] as IOIndicatorCtrl; |
| | | |
| | | ioIn.IsOn = ioItem.Value == IOValue.TRUE; |
| | | } |
| | | } |
| | |
| | | if (ioOutArray != null && ioOutArray.Length == 1) |
| | | { |
| | | var ioOut = ioOutArray[0] as IOIndicatorCtrl; |
| | | ioOut.IsOn = ioItem.Value == IOValue.TRUE; |
| | | |
| | | if (MotionCard.IConfig.IsOutputReversed) |
| | | { |
| | | ioOut.IsOn = ioItem.Value == IOValue.TRUE; |
| | | } |
| | | else |
| | | { |
| | | ioOut.IsOn = ioItem.Value == IOValue.FALSE; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.Invalidate(); |
| | | } |
| | | } |
| | | } |