领胜LDS 键盘AOI检测项目
wells
2020-07-12 5bf1b91009a182188d6d2245aa71653801eea60b
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()
@@ -72,7 +75,7 @@
        private void MotionCard_OnAxisAlarmRaised(int axisIndex, string alarmMsg)
        {
            RaisedAlarm(alarmMsg);
            RaisedAlarm(alarmMsg);
            MachineState = MachineState.Alarm;
        }
@@ -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}", "");