领胜LDS 键盘AOI检测项目
wells
2020-07-12 5bf1b91009a182188d6d2245aa71653801eea60b
debug
16个文件已修改
501 ■■■■■ 已修改文件
src/Bro.Common.Device/DeviceBase/MotionCardBase.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Model/IOItem.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Model/MonitorSet.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Model/MotionCardRelated.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.GTSCard/GTSCardConfig.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.GTSCard/GTSCardDriver.cs 228 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.Gocator/GocatorDriver.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Models.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process.cs 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process_MotionCard.cs 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/UI/KeyIndicator.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/UI/M071_MainForm.cs 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.UI.Config/MainFrm.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
@@ -183,6 +183,10 @@
        [Editor(typeof(ComplexCollectionEditor<IODefinition>), typeof(UITypeEditor))]
        public List<IODefinition> IODefinitionCollection { get; set; } = new List<IODefinition>();
        [Category("IO配置")]
        [Description("true:输出取反 false:输出不取反")]
        public bool IsOutputReversed { get; set; } = true;
        #region IMonitorConfig
        [Category("监听设置")]
        [Description("MonitorSetCollection:监听操作配置集合")]
@@ -306,6 +310,14 @@
        [Editor(typeof(MovingOpsCollectionEditor), typeof(UITypeEditor))]
        public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>();
        [Category("3.运动延时")]
        [Description("操作前延时,单位ms")]
        public int DelayBefore { get; set; } = 0;
        [Category("3.运动延时")]
        [Description("操作后延时,单位ms")]
        public int DelayAfter { get; set; } = 0;
        public string MotionCardId = "";
        //[Category("板卡运动配置")]
src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs
@@ -29,7 +29,7 @@
        IOperationConfig backOpConfig = new OperationConfigBase();
        List<IDevice> deviceList = null;
        IDevice currentDevice = null;
        public FrmDeviceOpConfigEditor(DeviceOpBind bind)
        public FrmDeviceOpConfigEditor(DeviceOpBind bind, bool isEnableSelectDevice = true)
        {
            InitializeComponent();
@@ -56,7 +56,15 @@
                    cboDevice.SelectedIndex = 0;
            }
            if (isEnableSelectDevice)
            {
                cboDevice.Enabled = true;
            cboDevice.SelectedIndexChanged += CboDevice_SelectedIndexChanged;
            }
            else
            {
                cboDevice.Enabled = false;
            }
            if (bind.OpConfig == null)
            {
src/Bro.Common.Model/Model/IOItem.cs
@@ -109,6 +109,7 @@
        Dictionary<IODefinition, string> itemDict = new Dictionary<IODefinition, string>();
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            itemDict.Clear();
            if (context.Instance is IORefrenceItem item)
            {
                item.IOItemSource.ForEach(i =>
src/Bro.Common.Model/Model/MonitorSet.cs
@@ -206,14 +206,14 @@
        [DisplayName("触发值")]
        public int TriggerValue { get; set; } = -1;
        /// <summary>
        /// 传入数据地址的索引 按照监听地址从0开始的索引集合
        /// </summary>
        [Category("监听设置")]
        [Description("传入数据地址的索引 按照监听地址从0开始的索引")]
        [DisplayName("传入数据索引")]
        [TypeConverter(typeof(SimpleCollectionConvert<int>))]
        public List<int> InputDataIndex { get; set; } = new List<int>();
        ///// <summary>
        ///// 传入数据地址的索引 按照监听地址从0开始的索引集合
        ///// </summary>
        //[Category("监听设置")]
        //[Description("传入数据地址的索引 按照监听地址从0开始的索引")]
        //[DisplayName("传入数据索引")]
        //[TypeConverter(typeof(SimpleCollectionConvert<int>))]
        //public List<int> InputDataIndex { get; set; } = new List<int>();
        /// <summary>
        /// 监听回传
@@ -255,18 +255,27 @@
                    }
                }
                FrmOpConfigEdit frm = new FrmOpConfigEdit(ms.MethodCode, ms.Id, value as IOperationConfig)
                FrmDeviceOpConfigEditor frmDeviceOpEditor = new FrmDeviceOpConfigEditor(new DeviceOpBind() { Device = ms.InvokeDevice, OpConfig = value as IOperationConfig }, false)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    return frm.OpConfig;
                }
                else
                {
                    return frm.BackupConfig;
                }
                frmDeviceOpEditor.ShowDialog();
                frmDeviceOpEditor.Bind.OpConfig.MonitorSetId = ms.Id;
                frmDeviceOpEditor.Bind.OpConfig.DeviceId = ms.InvokeDevice;
                return frmDeviceOpEditor.Bind.OpConfig;
                //FrmOpConfigEdit frm = new FrmOpConfigEdit(ms.MethodCode, ms.Id, value as IOperationConfig)
                //{
                //    StartPosition = FormStartPosition.CenterScreen
                //};
                //if (frm.ShowDialog() == DialogResult.OK)
                //{
                //    return frm.OpConfig;
                //}
                //else
                //{
                //    return frm.BackupConfig;
                //}
            }
            return base.EditValue(context, provider, value);
src/Bro.Common.Model/Model/MotionCardRelated.cs
@@ -138,12 +138,12 @@
        [Category("速度配置")]
        [DisplayName("加速度")]
        [Description("Acc:加速度,为0时表示不修改当前设置")]
        public double Acc { get; set; } = 1;
        public double Acc { get; set; } = 0;
        [Category("速度配置")]
        [DisplayName("减速度")]
        [Description("减速度,为0时表示不修改当前设置")]
        public double Dec { get; set; } = 1;
        public double Dec { get; set; } = 0;
    }
    /// <summary>
@@ -177,10 +177,10 @@
        [Description("HighVelocity:速度,为0时表示不修改当前设置")]
        public double HighVelocity { get; set; } = 50;
        [Category("回原点参数")]
        [DisplayName("搜索距离")]
        [Description("SearchHomeDistance:搜索距离")]
        public int SearchHomeDistance { get; set; } = 9999999;
        //[Category("回原点参数")]
        //[DisplayName("搜索距离")]
        //[Description("SearchHomeDistance:搜索距离")]
        //public int SearchHomeDistance { get; set; } = 9999999;
        [Category("回原点参数")]
        [DisplayName("偏移距离")]
src/Bro.Device.GTSCard/GTSCardConfig.cs
@@ -2,6 +2,7 @@
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.UI.Device.Winform;
using System.ComponentModel;
namespace Bro.Device.GTSCard
{
@@ -14,7 +15,6 @@
    [Device("GTSCard", "固高板卡", EnumHelper.DeviceAttributeType.InitialConfig)]
    public class GTSCardInitialConfig : MotionCardInitialConfigBase
    {
    }
    [Device("GTSCard", "固高板卡", EnumHelper.DeviceAttributeType.RunCtrl)]
src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -118,11 +118,17 @@
            {
                foreach (var operationSet in motionCardOperationConfig.OperationCollection)
                {
                    if (operationSet.DelayBefore > 0)
                        Thread.Sleep(operationSet.DelayBefore);
                    responseMessage = RunOperationSet(operationSet);
                    if (!responseMessage.Result)
                    {
                        return responseMessage;
                    }
                    if (operationSet.DelayAfter > 0)
                        Thread.Sleep(operationSet.DelayAfter);
                }
            }
            return responseMessage;
@@ -177,13 +183,16 @@
            {
                foreach (var ioOutput in operationSet.IOOutputCollection)
                {
                    var ioData = MonitorValues.FirstOrDefault(u => u.IONum == ioOutput.IOItem.IONum && u.IOType == ioOutput.IOItem.IOType)?.Value;//IO 是开、关 从MonitorValues 获取
                    if (ioOutput.CheckValue != ioData)
                    {
                        responseMessage.Result = false;
                        responseMessage.Message = $"IO输出不通过,配置:{ioOutput.GetDisplayText()},当前值:{ioData}";
                        return responseMessage;
                    }
                    WriteOutput((short)ioOutput.IOItem.IONum, ioOutput.CheckValue);
                    //var ioData = MonitorValues.FirstOrDefault(u => u.IONum == ioOutput.IOItem.IONum && u.IOType == ioOutput.IOItem.IOType)?.Value;//IO 是开、关 从MonitorValues 获取
                    //if (ioOutput.CheckValue != ioData)
                    //{
                    //    responseMessage.Result = false;
                    //    responseMessage.Message = $"IO输出不通过,配置:{ioOutput.GetDisplayText()},当前值:{ioData}";
                    //    return responseMessage;
                    //}
                }
            }
@@ -338,15 +347,22 @@
            ResponseMessage responseMessage = new ResponseMessage();
            if (opConfig is MotionOperationCollection gtsOperationCollection)
            {
                List<Task<bool>> taskList = new List<Task<bool>>();
                foreach (var movingOp in gtsOperationCollection.MovingOps)
                //List<Task<bool>> taskList = new List<Task<bool>>();
                //foreach (var movingOp in gtsOperationCollection.MovingOps)
                //{
                //    var task = SingleAxisMoving(movingOp);
                //    taskList.Add(task);
                //    task.Start();
                //}
                //Task.WaitAll(taskList.ToArray());
                //responseMessage.Result = taskList.All(u => u.GetAwaiter().GetResult());
                List<bool> resultList = new List<bool>();
                Parallel.ForEach(gtsOperationCollection.MovingOps, movingOp =>
                {
                    var task = SingleAxisMoving(movingOp);
                    taskList.Add(task);
                    task.Start();
                }
                Task.WaitAll(taskList.ToArray());
                responseMessage.Result = taskList.All(u => u.GetAwaiter().GetResult());
                    resultList.Add(SingleAxisMoving(movingOp).Result);
                });
                responseMessage.Result = resultList.All(u => u == true);
                if (!responseMessage.Result)
                {
                    responseMessage.Message = $"点位运动异常";
@@ -368,11 +384,23 @@
            resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex));
            resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm));
            trapprm.smoothTime = 1;
            trapprm.acc = optionPara.VelocityPara.Acc != 0 ? optionPara.VelocityPara.Acc : 1;
            trapprm.dec = optionPara.VelocityPara.Dec != 0 ? optionPara.VelocityPara.Dec : 1;
            if (optionPara.VelocityPara.Acc != 0)
            {
                trapprm.acc = optionPara.VelocityPara.Acc;
            }
            if (optionPara.VelocityPara.Dec != 0)
            {
                trapprm.dec = optionPara.VelocityPara.Dec;
            }
            resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm));
            if (optionPara.VelocityPara.Velocity != 0)
            {
            resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, axisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio));
            }
            var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK);
            if (!resultOK)
@@ -389,7 +417,7 @@
        /// <param name="optionPara">运动参数对象</param>
        public override Task<bool> SingleAxisMoving(MovingOption optionPara)
        {
            return new Task<bool>(() =>
            return Task.Run(() =>
             {
                 axisImmediatePauseHandleDict[optionPara.AxisIndex].WaitOne();
                 bool isSuccessAndStop = false;
@@ -397,10 +425,10 @@
                 {
                     if (IConfig.AxisSettings.FirstOrDefault(a => a.AxisIndex == optionPara.AxisIndex)?.IsAxisEnabled ?? false)
                     {
                         string _position = "";
                         // string _position = "";
                         string motionType = optionPara.MoveMode == EnumHelper.MotionMode.Normal ? (optionPara.IsAbsolute ? "Abs" : "Rel") : optionPara.MoveMode.ToString();
                         _position = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff},{optionPara.AxisIndex},{motionType},{GetPosition(optionPara.AxisIndex)},{GetPrfPosition(optionPara.AxisIndex)},{optionPara.Destination},";
                         // _position = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff},{optionPara.AxisIndex},{motionType},{GetPosition(optionPara.AxisIndex)},{GetPrfPosition(optionPara.AxisIndex)},{optionPara.Destination},";
                         switch (optionPara.MoveMode)
                         {
@@ -435,9 +463,9 @@
                                 }
                                 break;
                         }
                         _position += $"{GetPosition(optionPara.AxisIndex)},";
                         _position += $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}";
                         LogAsync(DateTime.Now, "", _position);
                         //_position += $"{GetPosition(optionPara.AxisIndex)},";
                         //_position += $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}";
                         //LogAsync(DateTime.Now, "", _position);
                     }
                 }
                 catch (Exception ex)
@@ -680,7 +708,7 @@
                short ret = 0;
                bool isSuccessSetAxisParam = false;
                int timeout = optionPara.MovingTimeout;
                var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio;
                //var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio;
                while (CurrentState == DeviceState.DSOpen && !_isPause)
                {
                    //设置 运动参数
@@ -774,63 +802,63 @@
            var resultOK = taskList.All(u => u.GetAwaiter().GetResult());
        }
        /// <summary>
        /// 回原点
        /// </summary>
        /// <param name="movingOption">卡号</param>
        /// <param name="axisn">轴号</param>
        /// <param name="homests">轴回原点状态</param>
        public bool GoHome(MovingOption movingOption)
        {
            try
            {
                PositionReset(movingOption.AxisIndex, 1);
                GTSCardAPI.THomePrm thomeprm;
                GTSCardAPI.THomeStatus homests;
                // 启动Home捕获
                short rtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME);
                // 切换到点位运动模式
                rtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex);
                // 读取点位模式运动参数
                rtn = GTSCardAPI.GT_GetHomePrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, out thomeprm);
        ///// <summary>
        ///// 回原点
        ///// </summary>
        ///// <param name="movingOption">卡号</param>
        ///// <param name="axisn">轴号</param>
        ///// <param name="homests">轴回原点状态</param>
        //public bool GoHome(MovingOption movingOption)
        //{
        //    try
        //    {
        //        PositionReset(movingOption.AxisIndex, 1);
        //        GTSCardAPI.THomePrm thomeprm;
        //        GTSCardAPI.THomeStatus homests;
        //        // 启动Home捕获
        //        short rtn = GTSCardAPI.GT_SetCaptureMode((short)IConfig.CardNum, (short)movingOption.AxisIndex, GTSCardAPI.CAPTURE_HOME);
        //        // 切换到点位运动模式
        //        rtn = GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)movingOption.AxisIndex);
        //        // 读取点位模式运动参数
        //        rtn = GTSCardAPI.GT_GetHomePrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, out thomeprm);
                thomeprm.mode = movingOption.GoHomePara.HomeMode;//回零方式
                thomeprm.moveDir = movingOption.GoHomePara.HomeDir;//回零方向
                thomeprm.edge = movingOption.GoHomePara.Edge;
                thomeprm.velHigh = movingOption.GoHomePara.HighVelocity;
                thomeprm.velLow = movingOption.GoHomePara.LowVelocity;
                thomeprm.acc = movingOption.VelocityPara.Acc;
                thomeprm.dec = movingOption.VelocityPara.Dec;
                thomeprm.searchHomeDistance = movingOption.GoHomePara.SearchHomeDistance;//搜索距离
                thomeprm.homeOffset = movingOption.GoHomePara.HomeOffset;  //偏移距离
                thomeprm.escapeStep = movingOption.GoHomePara.EscapeStep;
                rtn = GTSCardAPI.GT_GoHome((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref thomeprm);  //启动回零
        //        thomeprm.mode = movingOption.GoHomePara.HomeMode;//回零方式
        //        thomeprm.moveDir = movingOption.GoHomePara.HomeDir;//回零方向
        //        thomeprm.edge = movingOption.GoHomePara.Edge;
        //        thomeprm.velHigh = movingOption.GoHomePara.HighVelocity;
        //        thomeprm.velLow = movingOption.GoHomePara.LowVelocity;
        //        thomeprm.acc = movingOption.VelocityPara.Acc;
        //        thomeprm.dec = movingOption.VelocityPara.Dec;
        //        thomeprm.searchHomeDistance = movingOption.GoHomePara.SearchHomeDistance;//搜索距离
        //        thomeprm.homeOffset = movingOption.GoHomePara.HomeOffset;  //偏移距离
        //        thomeprm.escapeStep = movingOption.GoHomePara.EscapeStep;
        //        rtn = GTSCardAPI.GT_GoHome((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref thomeprm);  //启动回零
                bool isStop = false;
                int repeatTime = 1000;
                do
                {
                    Thread.Sleep(10);
                    GTSCardAPI.GT_GetHomeStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out homests);
        //        bool isStop = false;
        //        int repeatTime = 1000;
        //        do
        //        {
        //            Thread.Sleep(10);
        //            GTSCardAPI.GT_GetHomeStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out homests);
                    isStop = homests.run == 0;
                    if (isStop && homests.error == 0)
                    {
                        Thread.Sleep(200);
                        PositionReset(movingOption.AxisIndex, 1);
                    }
                    repeatTime--;
                } while (!isStop && repeatTime > 0);
        //            isStop = homests.run == 0;
        //            if (isStop && homests.error == 0)
        //            {
        //                Thread.Sleep(200);
        //                PositionReset(movingOption.AxisIndex, 1);
        //            }
        //            repeatTime--;
        //        } while (!isStop && repeatTime > 0);
                return isStop;
            }
            catch (Exception ex)
            {
                AllMoveStop(true);
                OnExceptionOccured?.Invoke(DateTime.Now, ex);
                return false;
            }
        }
        //        return isStop;
        //    }
        //    catch (Exception ex)
        //    {
        //        AllMoveStop(true);
        //        OnExceptionOccured?.Invoke(DateTime.Now, ex);
        //        return false;
        //    }
        //}
        /// <summary>
        /// P2P方式回原点
@@ -840,8 +868,11 @@
        {
            try
            {
                StartCapture:
                PositionReset(movingOption.AxisIndex, 1);
                ClearStatus(movingOption.AxisIndex, 1);
                GTSCardAPI.TTrapPrm trapPrm;
                bool isStop = false;
                //搜索距离 阶段1
@@ -857,8 +888,9 @@
                sRtn = GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref trapPrm);
                // 设置点位模式目标速度,即回原点速度
                sRtn = GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HighVelocity);
                // 设置点位模式目标位置,即原点搜索距离
                sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.SearchHomeDistance);
                sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HomeDir == 1 ? 99999999 : -99999999);
                // 启动运动
                sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
@@ -880,10 +912,19 @@
                    MoveStop((short)movingOption.AxisIndex, 0);
                    throw new ProcessException($"运动轴{movingOption.AxisIndex} ,回原点超时异常");
                }
                if (isStop && capture != 1)
                {
                    ClearStatus((short)movingOption.AxisIndex, 1);
                    var axisStatus = AxisStatusList.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex);
                    if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0))
                    {
                        movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
                        goto StartCapture;
                    }
                    throw new ProcessException($"运动轴{movingOption.AxisIndex} ,回原点超时异常");
                }
@@ -957,7 +998,7 @@
            short outNum = (short)(index % 100 + 1);
            if ((int)value <= 1)
            {
                GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPO, outNum, (short)value);
                GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPO, outNum, IConfig.IsOutputReversed ? (short)(value == IOValue.TRUE ? 0 : 1) : (short)value);
            }
            else
            {
@@ -1091,8 +1132,8 @@
                        if (newValues == null || newValues.Count == 0 || newAxisMovingStatus == null || newAxisMovingStatus.Count == 0)
                            continue;
                        Stopwatch sw = new Stopwatch();
                        sw.Start();
                        //Stopwatch sw = new Stopwatch();
                        //sw.Start();
                        if (MonitorValues.Count == newValues.Count)
                        {
                            //var tempNew = newValues.DeepSerializeClone();//clone
@@ -1111,12 +1152,12 @@
                        AxisStatusList = new List<AxisMovingStatus>(newAxisMovingStatus);
                        MonitorValues = new List<IOItem>(newValues);
                        sw.Stop();
                        //sw.Stop();
                        if (sw.ElapsedMilliseconds > 20)
                        {
                            LogAsync(DateTime.Now, $"{this.Name}轮询时间:{sw.ElapsedMilliseconds}", "");
                        }
                        //if (sw.ElapsedMilliseconds > 20)
                        //{
                        //    LogAsync(DateTime.Now, $"{this.Name}轮询时间:{sw.ElapsedMilliseconds}", "");
                        //}
                        if (IConfig.MonitorInterval > 0)
                        {
@@ -1223,10 +1264,11 @@
                            monitorSet.OpConfig = new OperationConfigBase();
                        }
                        monitorSet.OpConfig.InputPara = monitorSet.InputDataIndex.ConvertAll(index =>
                        {
                            return tempNew[index].Value == IOValue.TRUE ? 1 : 0;
                        }).ToList();
                        //monitorSet.OpConfig.InputPara = monitorSet.InputDataIndex.ConvertAll(index =>
                        //{
                        //    return tempNew[index].Value == IOValue.TRUE ? 1 : 0;
                        //}).ToList();
                        monitorSet.OpConfig.InputPara = new List<int>() { (int)newIOItem.Value };
                        ExcuteMonitorInvoke(DateTime.Now, monitorSet.InvokeDevice, this, monitorSet);
                    }
@@ -1248,8 +1290,8 @@
                {
                    var rst = GTSCardAPI.GT_AxisOn((short)IConfig.CardNum, (short)axisSetting.AxisIndex);
                }
                // 所有位置请零
                PositionReset(1, axisSettings.Count);
                //// 所有位置请零
                //PositionReset(1, axisSettings.Count);
                // 正极限报警
                if ((axis_sts & 0x20) != 0)
                {
src/Bro.Device.Gocator/GocatorDriver.cs
@@ -109,12 +109,12 @@
                            if (imgSet != null)
                            {
                                imgSet.HImage = new HImage();
                                imgSet.HImage.GenImage1("int2", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
                                //imgSet.HImage = imgSet.HImage.ZoomImageSize((int)width, zoomHeight, "constant");
                                imgSet.HImage_2 = new HImage();
                                imgSet.HImage_2.GenImage1("int2", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
                                LaserScanParam para = new LaserScanParam()
                                {
src/Bro.M071.Process/M071Models.cs
@@ -392,6 +392,8 @@
                if (valuePairs == null || valuePairs.Count == 0)
                {
                    IsDone = false;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone"));
                    return;
                }
                foreach (KeyValuePair<string, double> pair in valuePairs)
src/Bro.M071.Process/M071Process.cs
@@ -5,6 +5,7 @@
using Bro.M071.DBManager;
using Bro.M071.Model;
using Bro.M071.Model.Model;
using Bro.M071.Process.UI;
using Bro.Process;
using HalconDotNet;
using Newtonsoft.Json;
@@ -12,6 +13,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
@@ -59,6 +61,7 @@
            Reset(null, null, null);
            FullReset(null);
        }
        private void InitialMotionCardBaseAxisAlarm()
@@ -178,6 +181,11 @@
        [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)]
        public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
            if (!IsAllowedWork)
            {
                throw new ProcessException(SafetyMsg, null, ExceptionLevel.Fatal);
            }
            if (MachineState != MachineState.Ready)
                throw new ProcessException("机台未就绪,请勿开始测量", null, ExceptionLevel.Fatal);
@@ -368,7 +376,9 @@
                                LogAsync(DateTime.Now, $"{m.GetDisplayText()}检测结果", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}");
                                IShapeElement indicator = null;
                                KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation);
                                indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString("f2");
                                indicator.ResultState = m.Spec.MeasureResult;
                                pMeasure.ElementList.Add(indicator);
                                //输出图形基元到界面 
                                OnElementUpdated?.BeginInvoke(indicator, null, null);
@@ -404,10 +414,10 @@
                {
                }
                //Excel报表输出 (单个产品的excel导出)
                ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet);
                //数据库保存
                SaveProductionData(measurementUnitResultAndKeyUnitDataSet);
                ////Excel报表输出 (单个产品的excel导出)
                //ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet);
                ////数据库保存
                //SaveProductionData(measurementUnitResultAndKeyUnitDataSet);
                SaveWholeImage(pMeasure);
@@ -589,7 +599,7 @@
                    Directory.CreateDirectory(dir);
                }
                map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{DateTime.Now.ToString("HHmmss")}.bmp"));
                map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{pMeasure.PResult}_{DateTime.Now.ToString("HHmmss")}.png"), ImageFormat.Png);
            }
            catch (Exception ex)
            {
@@ -718,7 +728,7 @@
                             {
                                 _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z;
                                 //_halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z;
                                 if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
                                 {
                                     LogAsync(DateTime.Now, $"{k.AliasName}检测算法异常,{error}", "");
src/Bro.M071.Process/M071Process_MotionCard.cs
@@ -26,6 +26,9 @@
            get => machineState;
            set
            {
                if (machineState == value)
                    return;
                machineState = value;
                switch (machineState)
@@ -40,9 +43,10 @@
                        Task.Run(() =>
                        {
                            lock (machineStateLock)
                            {
                                while (MachineState == MachineState.Ready)
                            {
                                lock (machineStateLock)
                                {
                                    SwitchLightGreen(true);
                                    Thread.Sleep(1000);
@@ -79,9 +83,9 @@
                        }
                        Task.Run(() =>
                        {
                            lock (machineStateLock)
                            {
                                while (MachineState == MachineState.Pause)
                            {
                                lock (machineStateLock)
                                {
                                    SwitchLightYellow(true);
                                    SwitchLightGreen(true);
@@ -102,10 +106,11 @@
                        }
                        Task.Run(() =>
                        {
                            lock (machineStateLock)
                            {
                                while (MachineState == MachineState.Resetting)
                                {
                                lock (machineStateLock)
                                {
                                    SwitchLightYellow(true);
                                    Thread.Sleep(1000);
                                    SwitchLightYellow(false);
@@ -185,6 +190,16 @@
            }
        }
        [ProcessMethod("MotionCardBase", "GotoReadyPosition", "运动到预备位置", InvokeType.TestInvoke)]
        public ProcessResponse GotoReadyPosition(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
            MotionCardDefaultRun("GotoReadyPosition", ref opConfig, ref invokeDevice);
            LogAsync(DateTime.Now, "运动到预备位置完成", "");
            return new ProcessResponse(true);
        }
        [ProcessMethod("MotionCardBase", "Reset", "简单复位操作", InvokeType.TestInvoke)]
        public ProcessResponse Reset(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
@@ -206,9 +221,23 @@
            //    }
            //}
            if (ResetTimer == null)
            {
                ResetTimer = new Timer(FullReset, null, -1, -1);
            }
            if (opConfig?.InputPara != null && opConfig.InputPara.Count > 0)
            {
                //大复位信号
                ResetTimer.Change(opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1, -1);
                if (opConfig.InputPara[0] == 0)
                    return new ProcessResponse(true);
            }
            if (!IsAllowedWork)
            {
                LogAsync(DateTime.Now, $"{(IsSafetyDoorTrigged ? "安全门" : "")}{(IsSafetyBeamTrigged ? " 安全光线" : "")}{(isEmergencyStopped ? " 急停按钮" : "")}触发中,复位失败", "");
                LogAsync(DateTime.Now, $"{SafetyMsg},复位失败", "");
                return new ProcessResponse(false);
            }
@@ -224,16 +253,13 @@
                MachineState = MachineState.Alarm;
            }
            if (ResetTimer == null)
            {
                ResetTimer = new Timer(FullReset, null, -1, -1);
            }
            if (opConfig.InputPara.Count > 0)
            {
                //大复位信号
                ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1);
            }
            //if (opConfig.InputPara?.Count > 0)
            //{
            //    //大复位信号
            //    ResetTimer.Change(-1, opConfig.InputPara[0] == 1 ? FULLRESETTIME * 1000 : -1);
            //}
            //if (invokeDevice is MotionCardBase motionCard)
            //{
@@ -298,6 +324,8 @@
            RaisedAlarm("");
            MachineState = MachineState.Ready;
            GotoReadyPosition(null, null, null);
            return new ProcessResponse(true);
        }
@@ -597,6 +625,10 @@
        {
            get => !(IsSafetyBeamTrigged || IsSafetyDoorTrigged || IsEmergencyStopped);
        }
        string SafetyMsg
        {
            get => $"{(IsSafetyBeamTrigged ? "安全光幕" : "")}{(IsSafetyDoorTrigged ? " 安全门" : "")}{(IsEmergencyStopped ? " 急停按钮" : "")}触发中";
        }
        #region 安全门 & 安全光线
        bool isSafetyDoorTrigged = false;
@@ -633,6 +665,9 @@
        [ProcessMethod("", "SafetyBeamSignal", "安全光幕信号监控,正常ON,OFF时报警", InvokeType.TestInvoke)]
        public ProcessResponse SafetyBeamSignal(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
        {
            if (MachineState != MachineState.Running || MachineState != MachineState.Alarm)
                return new ProcessResponse(true);
            if (opConfig.InputPara == null || opConfig.InputPara.Count == 0)
                throw new ProcessException("安全光幕监控未配置输入信号");
@@ -674,7 +709,7 @@
            if (opConfig.InputPara == null || opConfig.InputPara.Count == 0)
                throw new ProcessException("急停按钮未配置输入信号");
            IsEmergencyStopped = opConfig.InputPara[0] == 1;
            IsEmergencyStopped = opConfig.InputPara[0] == 0;
            if (IsEmergencyStopped)
            {
src/Bro.M071.Process/UI/KeyIndicator.cs
@@ -77,8 +77,9 @@
                    foreColor = Color.White;
                }
                g.FillRectangle(new SolidBrush(Color.FromArgb(85, backColor)), rectFill);
                g.DrawString(Text, Font, new SolidBrush(foreColor), (float)(DisplayRect.X + DisplayRect.Width / 2.0 - txtSize.Width / 2.0), (float)(DisplayRect.Y + DisplayRect.Height / 2.0 - txtSize.Height / 2.0));
                g.FillRectangle(new SolidBrush(Color.FromArgb(55, backColor)), rectFill);
            }
        }
src/Bro.M071.Process/UI/M071_MainForm.cs
@@ -53,6 +53,8 @@
            if (string.IsNullOrWhiteSpace(Config.BackgroundImagePath))
                return;
            try
            {
            this.Invoke(new Action(() =>
            {
                try
@@ -85,6 +87,10 @@
                    lvMeasures.Items.Add(item);
                });
            }));
            }
            catch (Exception ex)
            {
            }
            Process_M071.OnClearBarcode -= M071_MainForm_OnClearBarcode;
            Process_M071.OnClearBarcode += M071_MainForm_OnClearBarcode;
@@ -104,6 +110,9 @@
            Config.PropertyChanged -= Config_PropertyChanged;
            Config.PropertyChanged += Config_PropertyChanged;
            Process_M071.OnElementUpdated -= Process_M071_OnElementUpdated;
            Process_M071.OnElementUpdated += Process_M071_OnElementUpdated;
        }
        private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -223,6 +232,26 @@
        }
        #endregion
        #region 标签结果显示
        private async void Process_M071_OnElementUpdated(Common.Interface.IShapeElement obj)
        {
            if (obj is KeyIndicator keyIndicator)
            {
                this.Invoke(new Action(() =>
                {
                    var ele = cvImage.Elements.FirstOrDefault(u => u.ID == keyIndicator.ID);
                    (ele as KeyIndicator).Text = keyIndicator.Text;
                    (ele as KeyIndicator).ResultState = keyIndicator.ResultState;
                    this.Invalidate();
                }));
            }
            await Task.Delay(100);
        }
        #endregion
        #region 上方状态区
        #region 条码
@@ -261,6 +290,8 @@
        #region 机台状态
        private async void M071_MainForm_MachineStateChanged(MachineState state)
        {
            if (lblMachineState.IsHandleCreated)
            {
            lblMachineState.BeginInvoke(new Action(() =>
            {
                switch (state)
@@ -270,37 +301,48 @@
                        btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White;
                        lblMachineState.Text = "警报";
                            btnStartMeasure.Text = "开始测量";
                        btnStartMeasure.Enabled = false;
                            btnStartMeasure.BackColor = Color.Red;
                        break;
                    case MachineState.Pause:
                        btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Yellow;
                        btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.Black;
                        lblMachineState.Text = "暂停";
                        //btnStartMeasure.Text = "暂停测量";
                            btnStartMeasure.Text = "继续测量";
                        btnStartMeasure.Enabled = true;
                            btnStartMeasure.BackColor = Color.Lime;
                        break;
                    case MachineState.Ready:
                        btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime;
                        btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.White;
                        lblMachineState.Text = "就绪";
                            btnStartMeasure.Text = "开始测量";
                        btnStartMeasure.Enabled = true;
                            btnStartMeasure.BackColor = Color.Lime;
                        break;
                    case MachineState.Running:
                        btnStartMeasure.BackColor = lblMachineState.BackColor = Color.Lime;
                        btnStartMeasure.ForeColor = lblMachineState.ForeColor = Color.DarkGreen;
                        lblMachineState.Text = "运行";
                            btnStartMeasure.Text = "暂停测量";
                        btnStartMeasure.Enabled = true;
                            btnStartMeasure.BackColor = Color.Lime;
                        break;
                    case MachineState.Unknown:
                        btnStartMeasure.BackColor = lblMachineState.BackColor = SystemColors.Control;
                        btnStartMeasure.ForeColor = lblMachineState.ForeColor = SystemColors.ControlText;
                        lblMachineState.Text = "未知";
                            btnStartMeasure.Enabled = false;
                            btnStartMeasure.BackColor = Color.Red;
                        break;
                }
            }));
            }
            await Task.Delay(100);
        }
@@ -333,7 +375,7 @@
                    lblProductionState.Text = "NG";
                }
                btnStartMeasure.Text = "开始测量";
                //btnStartMeasure.Text = "开始测量";
            }));
            await Task.Delay(100);
        }
@@ -347,6 +389,15 @@
                lblProductionState.Text = "测试中";
                lblCT.Text = "";
                cvImage.Elements.ToList().ForEach(e =>
                {
                    if (e is KeyIndicator indicator)
                    {
                        indicator.Text = "";
                        indicator.ResultState = null;
                    }
                });
            }));
            await Task.Delay(100);
        }
@@ -356,9 +407,6 @@
        private async void btnStartMeasure_Click(object sender, EventArgs e)
        {
            btnStartMeasure.Enabled = false;
            bool isBreak = false;
            if (btnStartMeasure.Text == "开始测量")
            {
                await Task.Run(() =>
@@ -369,31 +417,19 @@
                    }
                    catch (Exception ex)
                    {
                        isBreak = true;
                        LogAsync(DateTime.Now, "流程异常", ex.Message);
                        Process_M071.ExceptionRaisedInMonitor(ex);
                        btnStartMeasure.Text = "开始测量";
                    }
                });
                if (!isBreak)
                    btnStartMeasure.Text = "暂停测量";
            }
            else if (btnStartMeasure.Text == "继续测量")
            {
                Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 0 } }, null, null);
                btnStartMeasure.Text = "暂停测量";
            }
            else
            {
                Process_M071.SwitchJobStatus(new OperationConfigBase() { InputPara = new List<int>() { 1 } }, null, null);
                btnStartMeasure.Text = "继续测量";
            }
            btnStartMeasure.Enabled = true;
        }
        #region 复位操作
@@ -414,7 +450,7 @@
                Process_M071.Reset(null, null, null);
            }
            Process_M071.ResetTimer.Change(-1, 1000 * 5);
            Process_M071.ResetTimer.Change(1000 * 5, -1);
        }
        private void btnReset_MouseUp(object sender, MouseEventArgs e)
src/Bro.UI.Config/MainFrm.cs
@@ -157,6 +157,8 @@
                CloseAllDeviceFrm();
                LoadDevices();
                try
                {
                foreach (var dock in dockPanelMain.Contents)
                {
                    MenuFrmBase m = dock as MenuFrmBase;
@@ -166,6 +168,10 @@
                        m.DownloadProcess(process);
                    }
                }
                }
                catch (Exception ex)
                {
                }
            });
        }
src/Bro.UI.Device.Winform/MotionCard/CtrlMotionCardIOStatus.cs
@@ -67,7 +67,8 @@
                    if (ioInArray != null && ioInArray.Length == 1)
                    {
                        var ioIn = ioInArray[0] as IOIndicatorCtrl;
                        ioIn.IsOn = ioItem.Value == IOValue.FALSE;
                        ioIn.IsOn = ioItem.Value == IOValue.TRUE;
                    }
                }
                else
@@ -76,10 +77,18 @@
                    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();
        }
src/Bro.UI.Device.Winform/MotionCard/FrmMotionCardOperationBase.cs
@@ -76,7 +76,7 @@
        private void btnStart_Click(object sender, EventArgs e)
        {
            MotionCard.SingleAxisMoving(MotionCardMovingOption).Start();
            MotionCard.SingleAxisMoving(MotionCardMovingOption);
        }
        private void buttonSmoothStop_Click(object sender, EventArgs e)