| | |
| | | using Microsoft.VisualBasic; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using NPOI.SS.UserModel; |
| | | using NPOI.Util; |
| | | using NPOI.XSSF.UserModel; |
| | | using Sunny.UI; |
| | | using System.Data; |
| | | using System.Data.SqlTypes; |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("", "ProductDataUpload", "产品数据汇总", InvokeType.TestInvoke)] |
| | |
| | | } |
| | | |
| | | |
| | | private bool _isDemoStarted = false; |
| | | [ProcessMethod("OfflineDemo", "OfflineDemo", "离线测试", InvokeType.CalibInvoke)] |
| | | public ResponseMessage OfflineDemo(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | if (config is OfflineDemoOperationConfig opConfig) |
| | | { |
| | | if (_isDemoStarted) |
| | | { |
| | | _isDemoStarted = false; |
| | | } |
| | | else |
| | | { |
| | | _isDemoStarted = true; |
| | | OfflineDemoAsync(opConfig.ImageFolder, opConfig.IsOK, opConfig.SaveImageTime); |
| | | } |
| | | } |
| | | |
| | | return new ResponseMessage(); |
| | | } |
| | | |
| | | private async void OfflineDemoAsync(string imageFolder,bool isok,int saveimagetime) |
| | | { |
| | | await Task.Run(() => |
| | | { |
| | | var imageFileNames = new DirectoryInfo(imageFolder).GetFiles().Select(u => u.FullName).ToList(); |
| | | |
| | | for (int i = 0; i < imageFileNames.Count; i++) |
| | | { |
| | | if (!_isDemoStarted) |
| | | { |
| | | return; |
| | | } |
| | | var imageFile = Path.GetFileNameWithoutExtension(imageFileNames[i]); |
| | | if (imageFile.EndsWith("Fit")) |
| | | { |
| | | continue; |
| | | } |
| | | if (imageFile.EndsWith("OK")& isok == false) |
| | | { |
| | | continue; |
| | | } |
| | | if (imageFile.EndsWith("NG") & isok == true) |
| | | { |
| | | continue; |
| | | } |
| | | var nameDatas = imageFile.Split(new char[] { '_'}, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | if (nameDatas.Count != 5) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"文件{imageFile}命名不符合规范,不执行离线测试"); |
| | | continue; |
| | | } |
| | | |
| | | var sn = nameDatas[0]; |
| | | var imageSeq = nameDatas[2][^1].ToString(); |
| | | var measureBind = M141Config.MeasureBindCollection.FirstOrDefault(u => u.ImageSaveSeq == imageSeq); |
| | | |
| | | if (measureBind == null || !measureBind.IsFixed) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"离线测试,工位{(measureBind == null ? "未匹配" : $"{measureBind.WorkPosition}未开启")}"); |
| | | continue; |
| | | } |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"离线测试,产品{sn}开始工位{measureBind.WorkPosition}离线检测"); |
| | | MLImageSet imgSet = new MLImageSet(); |
| | | |
| | | imgSet.HImage = new HalconDotNet.HImage(imageFileNames[i]); |
| | | imgSet.PID = sn; |
| | | |
| | | var detectResults = ML.RunMLDetectionSync(imgSet, null, measureBind.DetectionId); |
| | | Thread.Sleep(saveimagetime); |
| | | imgSet.HImage?.Dispose(); |
| | | imgSet.HImage = null; |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | [ProcessMethod("printer", "printer", "打印机打印", InvokeType.TestInvoke)] |
| | | public ResponseMessage Printer(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | |
| | | return specList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | protected void FillSpecResults(string pid, List<ISpec> detectSpec, List<double> results, string SEQUENCE) |
| | | { |
| | | detectSpec.ForEach(s => |