领胜LDS 键盘AOI检测项目
src/Bro.Process/ProcessControl.cs
@@ -21,7 +21,7 @@
using System.Threading.Tasks;
using static Bro.Common.Helper.EnumHelper;
namespace Bro.Process
namespace Bro.Process
{
    [Process("", DeviceAttributeType.Device)]
    public partial class ProcessControl : IProcess
@@ -45,7 +45,6 @@
        #region Event
        public event Action<string, Bitmap, string> OnBitmapOutput;
        //public event Action<string, object> OnObjectOutput;
        public Action<DateTime, Exception> OnExceptionOccured { get; set; }
        public event Action<DeviceState> OnProcessStateChanged;
        public event Action<DateTime, string, string> OnLog;
@@ -209,10 +208,17 @@
                    d.OnLog -= OnDeviceLog;
                    d.OnLog += OnDeviceLog;
                    d.OnExceptionOccured = OnDeviceExceptionRaised;
                    d.StateChange(DeviceState.DSInit);
                    d.StateChange(DeviceState.DSOpen);
                }
            });
        }
        private void OnDeviceExceptionRaised(DateTime dt, Exception ex)
        {
            LogAsync(dt, "设备异常", ex.GetExceptionMessage());
        }
        #endregion
@@ -471,14 +477,14 @@
        /// <param name="config">操作配置,用来确认监听来源和算法路径</param>
        /// <param name="algorithemPath">算法路径,默认是配置中的第一个算法路径</param>
        /// <returns>Halcon算法</returns>
        protected HDevEngineTool GetHalconTool(IOperationConfig config, string algorithemPath = "")
        protected HDevEngineTool GetHalconTool(IOperationConfig config, string monitorSetId = "", string algorithemPath = "")
        {
            if (string.IsNullOrWhiteSpace(algorithemPath))
            {
                algorithemPath = (config as IHalconToolPath)?.GetHalconToolPathList()[0];
            }
            string key = config.MonitorSetId + "|" + algorithemPath;
            string key = (string.IsNullOrWhiteSpace(monitorSetId) ? config.MonitorSetId : monitorSetId) + "|" + algorithemPath;
            if (_halconToolDict.ContainsKey(key))
            {
                return _halconToolDict[key];
@@ -632,7 +638,7 @@
        #endregion
        #region 图像处理
        protected IImageSet CollectHImage(CameraBase camera, IOperationConfig opConfig, [CallerMemberName]string methodCode = "")
        protected IImageSet CollectHImage(CameraBase camera, IOperationConfig opConfig, [CallerMemberName] string methodCode = "")
        {
            IImageSet set = null;
@@ -726,9 +732,12 @@
            OnAlarmUpdate?.BeginInvoke(alarmMsg, null, null);
        }
        public virtual void RaisedAlarm(string alarmMsg)
        public async virtual void RaisedAlarm(string alarmMsg)
        {
            OnAlarmUpdate?.Invoke(alarmMsg);
            await Task.Run(() =>
            {
                OnAlarmUpdate?.Invoke(alarmMsg);
            });
        }
        #endregion