| | |
| | | using Bro.M141.Process; |
| | | using Bro.UI.Model.Winform; |
| | | using HalconDotNet; |
| | | using Newtonsoft.Json; |
| | | using NPOI.POIFS.Crypt.Dsig; |
| | | using NPOI.SS.Formula.Functions; |
| | | using NPOI.XSSF.Streaming.Values; |
| | | using System.Collections.Concurrent; |
| | | using System.Net.Sockets; |
| | | using System.Text.RegularExpressions; |
| | | using static Bro.Common.Helper.EnumHelper; |
| | | using static NPOI.HSSF.Util.HSSFColor; |
| | | using static Org.BouncyCastle.Crypto.Engines.SM2Engine; |
| | | using static Org.BouncyCastle.Math.EC.ECCurve; |
| | |
| | | |
| | | AOI1Config ConfigAOI1 => Config as AOI1Config; |
| | | |
| | | |
| | | |
| | | public override void Open() |
| | | { |
| | | |
| | | //string configPath = @"C:\Users\30263\Desktop\666.txt"; |
| | | |
| | | //string _configBackupStr = ""; |
| | | //using (StreamReader reader = new StreamReader(configPath, System.Text.Encoding.UTF8)) |
| | | //{ |
| | | // _configBackupStr = reader.ReadToEnd(); |
| | | |
| | | //} |
| | | |
| | | //ProductModel p = JsonConvert.DeserializeObject<ProductModel>(_configBackupStr, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | |
| | | base.Open(); |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("", "PositionCheck_P1", "工位1检测", InvokeType.TestInvoke)] |
| | | public ResponseMessage PositionCheck_P1(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("", "PositionCheck_P2", "工位2检测", InvokeType.TestInvoke)] |
| | | public ResponseMessage PositionCheck_P2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("", "PositionCheck_P3", "工位3检测", InvokeType.TestInvoke)] |
| | | public ResponseMessage PositionCheck_P3(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | [ProcessMethod("ImageCheck", "ReadBarcode", "读码", InvokeType.TestInvoke)] |
| | |
| | | } |
| | | else |
| | | { |
| | | ret.Add(1); |
| | | if (barcode.Split('-').Length > 5) |
| | | { |
| | | int mh = Plc1.Read(4000, 1, out _)[0]; |
| | | string codestr = barcode.Split('-')[4]; |
| | | if (codestr == "L") |
| | | { |
| | | codestr = "10"; |
| | | } |
| | | |
| | | if (codestr.Equals(mh.ToString())) |
| | | { |
| | | ret.Add(1); |
| | | } |
| | | else |
| | | { |
| | | ret.Add(2); |
| | | Plc1.WriteSingleAddress(4010, 1, out _);//给plc报警 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ret.Add(999); |
| | | } |
| | | } |
| | | |
| | | FillSpecResults(results[0].PID, results[0].Specs, ret, opConfig.Products[0].SEQUENCE); |
| | | |
| | | |
| | | opConfig.Products[0].SN = barcode; |
| | | opConfig.Products[0].Details.ForEach(u => u.SN = barcode); |
| | | opConfig.Products[0].PID = barcode + "_1"; |
| | | opConfig.Products[0].Details.ForEach(u => |
| | | { |
| | | u.SN = barcode; |
| | | u.PID = barcode + "_1"; |
| | | u.ResultList.ForEach(x => |
| | | { |
| | | |
| | | x.PID = barcode + "_1"; |
| | | |
| | | }); |
| | | }); |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"产品{opConfig.Products[0].PID}条码获取为{barcode}"); |
| | | } |
| | |
| | | Plc1.WriteSingleAddress(1514, 1, out _); |
| | | ConfigAOI1.basketcode = barcode; |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"获取到栏具码为{barcode}"); |
| | | |
| | | mysqlhelper.NewBasketcode(barcode); |
| | | RerefreshBasketcode(); |
| | | |
| | | } |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | private string BarcodeScannerCommunicate(TcpClientWrapBase client) |
| | |
| | | return "NOREAD"; |
| | | } |
| | | |
| | | |
| | | private bool CheckBarcodeValid(string barcode) |
| | | { |
| | | bool isBarcodeValid = true; |
| | |
| | | } |
| | | return isBarcodeValid; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("ImageCheck", "CheckLineProfile", "检测产品线轮廓度", InvokeType.TestInvoke)] |
| | |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("ImageCheck", "GetMatrix", "获取矩阵", InvokeType.TestInvoke)] |
| | | public ResponseMessage GetMatrix(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | ResponseMessage msg = new ResponseMessage(); |
| | | if (config is IImageCheckOperationConfig opConfig) |
| | | { |
| | | var tool = GetHalconTool(null, "", opConfig.AlgorithemPath); |
| | | var ret = tool.RunProcedure(null, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", opConfig.ImageSet.HImage } }, new List<string>() { "OUTPUT_Results" }, null); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (ret == null) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"脚本{opConfig.AlgorithemPath}运行异常,返回值为null"); |
| | | } |
| | | else if (!ret.Item1) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"脚本{opConfig.AlgorithemPath}运行异常,{ret.Item4}"); |
| | | } |
| | | else |
| | | { |
| | | List<double> datas = ret.Item2["OUTPUT_Results"].HTupleToDouble(); |
| | | opConfig.Products[0].Centermatrix = datas; |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"产品{opConfig.Products[0].PID}矩阵获取为 {string.Join(',', datas)}"); |
| | | } |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | } |