From 34ee2c9c1e7287ca1002ede66a70bdbf9268cd27 Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期四, 02 七月 2020 18:22:46 +0800 Subject: [PATCH] 合并 --- src/Bro.Common.Device/DeviceBase/MotionCardBase.cs | 135 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 132 insertions(+), 3 deletions(-) diff --git a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs index 4425373..271562e 100644 --- a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs +++ b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs @@ -1,14 +1,17 @@ -锘縰sing Bro.Common.Helper; +锘縰sing Autofac; +using Bro.Common.Helper; using Bro.Common.Interface; using Bro.Common.Model; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; +using System.ComponentModel.Design; using System.Drawing.Design; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Bro.Common.Base { @@ -22,6 +25,24 @@ public abstract ResponseMessage MoveToPoint(IOperationConfig opConfig); public abstract void ResetAlarm(); public abstract ResponseMessage Run(IOperationConfig config); + + public void ExcuteMonitorInvok(DateTime dateTime, string invokeDevice, IDevice device, IMonitorSet monitorSet) + { + OnMonitorInvoke?.BeginInvoke(dateTime, invokeDevice, device, monitorSet, null, null); + } + + public void ExcuteMonitorAlarm(DateTime dateTime, IDevice device, IWarningSet warningSet) + { + OnMonitorAlarm?.BeginInvoke(dateTime, device, warningSet, null, null); + } + + public virtual MotionCardInitialConfigBase IConfig + { + get + { + return InitialConfig as MotionCardInitialConfigBase; + } + } } public class MotionCardInitialConfigBase : InitialConfigBase, IMonitorConfig @@ -108,17 +129,20 @@ public class MotionCardOperationConfigBase : OperationConfigBase, IComplexDisplay { [Category("IO鎿嶄綔閰嶇疆")] + [DisplayName("IO棰勬鏌ュ畾涔夐泦鍚�")] [Description("IO棰勬鏌ュ畾涔夐泦鍚�")] [TypeConverter(typeof(CollectionCountConvert))] - [Editor(typeof(IORefrenceItemCollectionEditor),typeof(UITypeEditor))] + [Editor(typeof(IORefrenceItemCollectionEditor), typeof(UITypeEditor))] public List<IORefrenceItem> PreCheckIOCollection { get; set; } = new List<IORefrenceItem>(); [Category("IO鎿嶄綔閰嶇疆")] + [DisplayName("IO杈撳嚭瀹氫箟闆嗗悎")] [Description("IO杈撳嚭瀹氫箟闆嗗悎")] [TypeConverter(typeof(CollectionCountConvert))] public List<IORefrenceItem> IOOutputCollection { get; set; } = new List<IORefrenceItem>(); [Category("IO鎿嶄綔閰嶇疆")] + [DisplayName("IO纭瀹氫箟闆嗗悎")] [Description("IO纭瀹氫箟闆嗗悎")] [TypeConverter(typeof(CollectionCountConvert))] public List<IORefrenceItem> IOConfirmCollection { get; set; } = new List<IORefrenceItem>(); @@ -136,5 +160,110 @@ } } - + public class IORefrenceItemCollectionEditor : CollectionEditor + { + protected override CollectionForm CreateCollectionForm() + { + var form = base.CreateCollectionForm(); + + var prop = form.GetType().GetField("propertyBrowser", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + + if (prop != null) + { + if (prop.GetValue(form) is PropertyGrid grid) + { + grid.HelpVisible = true; + grid.ToolbarVisible = false; + } + } + + return form; + } + + //protected override object CreateInstance(Type itemType) + //{ + // return base.CreateInstance(itemType); + //} + + //protected override object[] GetItems(object editValue) + //{ + // return base.GetItems(editValue); + //} + + //protected override object SetItems(object editValue, object[] value) + //{ + // return base.SetItems(editValue, value); + //} + + public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + { + if (context.Instance is IOperationConfig opConfig) + { + if (string.IsNullOrWhiteSpace(opConfig.DeviceId)) + { + return base.EditValue(context, provider, value); + } + + using (var scope = GlobalVar.Container.BeginLifetimeScope()) + { + List<IDevice> deviceList = scope.Resolve<List<IDevice>>(); + + var device = deviceList.FirstOrDefault(u => u.Id == opConfig.DeviceId); + + if (device == null) + { + return base.EditValue(context, provider, value); + } + + if (device is MotionCardBase motionCard) + { + if (value is IORefrenceItem item) + { + item.IOItemSource = (motionCard.InitialConfig as MotionCardInitialConfigBase).IODefinitionCollection; + } + } + } + } + + return base.EditValue(context, provider, value); + } + + public IORefrenceItemCollectionEditor(Type type) : base(type) + { + } + + /// <summary> + /// 闄愬埗涓�娆¢�変竴涓疄渚� + /// </summary> + /// <returns></returns> + protected override bool CanSelectMultipleInstances() + { + return false; + } + + /// <summary> + /// 鎸囧畾鍒涘缓鐨勫璞$被鍨� + /// </summary> + /// <returns></returns> + protected override Type CreateCollectionItemType() + { + return typeof(IORefrenceItem); + } + + protected override string GetDisplayText(object value) + { + if (value is IComplexDisplay) + { + return (value as IComplexDisplay).GetDisplayText(); + } + + return base.GetDisplayText(value); + } + + //protected override void DestroyInstance(object instance) + //{ + // base.DestroyInstance(instance);//閲嶈锛佽嚜鍔ㄥ垹闄ょ粍浠剁殑璁捐鏃朵唬鐮侊紒 + //} + } + } -- Gitblit v1.8.0