kingno
2025-06-09 305e2990bb2161177e87ab7711f9dfb205762bcd
src/Bro.M141.Process/M141Process_ImageCheck.cs
@@ -3,10 +3,12 @@
using Bro.Common.Interface;
using Bro.Common.Model;
using Bro.M135.Common;
using Bro.M135.DBManager;
using HalconDotNet;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.Util;
using Sunny.UI;
using System.Data;
using System.Data.SqlTypes;
@@ -28,6 +30,9 @@
        Dictionary<string, List<double>> dicdate = new Dictionary<string, List<double>>();
        ManualResetEvent set1 = new ManualResetEvent(false);
        ManualResetEvent set2 = new ManualResetEvent(false);
        public event Action<string> StartPrinter;
        [ProcessMethod("ImageCheck", "ImageCheckOperation", "通用图片检测操作", InvokeType.TestInvoke)]
        public ResponseMessage ImageCheckOperation(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -499,6 +504,27 @@
        [ProcessMethod("printer", "printer", "打印机打印", InvokeType.TestInvoke)]
        public ResponseMessage Printer(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
        {
            ResponseMessage msg = new ResponseMessage();
            Plc2 = invokeDevice as PLCBase;
            string message = "";
            StartPrinter.Invoke(message);
            return msg;
        }
        public void PlcwritePrinter(int add, int value)
        {
            Plc2.WriteSingleAddress(add, value, out _);
        }
        protected List<ISpec> GetSpecListFromConfigSelection(List<SpecSelector> specSelectors)
        {
@@ -508,9 +534,10 @@
                var spec = M141Config.SpecCollection.FirstOrDefault(s => s.Code == u.SpecCode);
                if (spec != null)
                {
                    var temp = spec.Copy<Spec>();
                    var temp = spec.Copy();
                    temp.ActualValue = null;
                    temp.MeasureResult = null;
                    temp.Source = "";
                    specList.Add(temp);
                }
            });
@@ -556,8 +583,6 @@
                        }
                    }
                    LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品{pid}检测项{s.Code}赋值{s.GetMeasureValueStr()},结果{s.GetMeasureResultStr()}");
                }
                else
@@ -580,12 +605,21 @@
        {
            isOK = false;
            int num = 0;
            while (p.Details.Any(u => !u.IsDone) && num < 10)
            {
                num++;
                Thread.Sleep(500);
            }
            p.InitialDetailSpecs();
            var resultList = p.Details.SelectMany(u => u.ResultList).ToList();
            resultList.ForEach(u => u.SetResult());
            var defects = resultList.GetDefectDescList();
            var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()).Where(u => u.MeasureResult != true).Select(u => u.Code);
            var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()).Where(u => u.MeasureResult != true).Select(u => u.Code);
            var ngDefectDescList = p.Details.SelectMany(u => u.DefectList ?? new List<string>()).ToList();
            defects.AddRange(ngSpecCodes);
@@ -595,6 +629,8 @@
            {
                defects.Add("TBD");
            }
            defects = defects.Distinct().ToList();
            isOK = defects.Count <= 0;
@@ -604,7 +640,7 @@
            UpdateResult(DateTime.Now, p.SN, defectClass.ClassName, "");
            //产品序号+1
            Interlocked.Increment(ref _productIndex);
            //Interlocked.Increment(ref _productIndex);
            List<ISpec> specList = new List<ISpec>();
            specList.AddRange(p.Details.SelectMany(u => u.SpecList).ToList().ConvertAll(u => (ISpec)u));