| | |
| | | } |
| | | |
| | | public PLCBase Plc1; |
| | | PLCBase Plc2; |
| | | Thread ThHeartPlc; |
| | | public override void Open() |
| | | { |
| | | base.Open(); |
| | | |
| | | ML = DeviceCollection.FirstOrDefault(u => u is MachineLearningBase) as MachineLearningBase; |
| | | if (ML == null) |
| | | { |
| | |
| | | _positionCheckTimeDict.Clear(); |
| | | _positionSpecHeads.Clear(); |
| | | |
| | | mysqlhelper.IniDBIP(M141Config.IPforall); |
| | | |
| | | if (ThHeartPlc == null) |
| | | { |
| | |
| | | Thread.Sleep(3000); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 网络预热 |
| | |
| | | |
| | | if (isSaveDB) |
| | | { |
| | | if (M141Config.Isreadbasketcode) |
| | | { |
| | | p.BasketCode = M141Config.basketcode; |
| | | } |
| | | else |
| | | { |
| | | p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE); |
| | | if ("NoRead".Equals(p.BasketCode)) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"{p.PID}_{p.SEQUENCE}获取框具码失败 赋值Noread"); |
| | | } |
| | | } |
| | | |
| | | mysqlhelper.NewProduct(p); |
| | | } |
| | | |
| | |
| | | p.PID = p.PID + "_" + sequence.Split('_')[sequence.Split('_').Length - 1]; |
| | | |
| | | p.Initial(M141Config.StationCode, M141Config.WorkPositionCollection.Where(u => u.IsEnabled).Select(u => u.PositionName).ToList()); |
| | | //LogAsync(DateTime.Now, EnumHelper.LogLevel.Warning, $"未能从数据库获取产品对象,使用临时新建产品对象"); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Warning, $"未能从数据库获取产品对象,使用临时新建产品对象"); |
| | | } |
| | | |
| | | NewProductIntoList(p, false); |
| | |
| | | var errorSpec = _errorSpec.Copy(); |
| | | errorSpec.Code = "检测TBD"; |
| | | errorSpec.ActualValue = -999; |
| | | DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key }; |
| | | DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key ,Id=Guid.NewGuid().ToString()}; |
| | | ngResults.Add(ngResult); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | detectResults.AddRange(ngResults); |
| | | resultList.AddRange(detectResults); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); |
| | | RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | try |
| | | { |
| | | ConcurrentDictionary<MeasureBind, IImageSet> imgSetDicts = new ConcurrentDictionary<MeasureBind, IImageSet>(); |
| | | var positionSet = M141Config.WorkPositionCollection.Where(u => u.IsEnabled).FirstOrDefault(u => u.TriggerValue == triggerDatas[0]); |
| | | |
| | | measureBinds.AsParallel().ForAll(b => |
| | | { |
| | |
| | | try |
| | | { |
| | | imgSetDicts[b] = CollectHImage(camera, b.SnapshotOpConfig); |
| | | if (positionSet.ispiccover) |
| | | { |
| | | Plc1.WriteSingleAddress(positionSet.plcover,1,out _); |
| | | } |
| | | } |
| | | catch (Exception ea) |
| | | { |
| | |
| | | plcresult.Add(isOK); |
| | | List<string> specHeads = new List<string>(); |
| | | string head = p.GetCSVHead(ref specHeads, positionName); |
| | | if (!_positionSpecHeads.ContainsKey(positionName)) |
| | | { |
| | | _positionSpecHeads[positionName] = specHeads; |
| | | } |
| | | |
| | | _positionSpecHeads[positionName] = specHeads; |
| | | |
| | | string data = p.GetCSVData(_positionSpecHeads[positionName], positionName); |
| | | CSVRecordAsync($"{positionName}_Record_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, head); |
| | | |
| | | //UpdatePositionResultToDB(detail); |
| | | var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | //var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | |
| | | |
| | | mysqlhelper.UpdateProduct(p); |
| | | if (positionSet.IsLastPosition) |
| | | { |
| | | UpdateProductResultAsync(p); |
| | | mysqlhelper.NewForAll(p, M141Config.StationCode); |
| | | if (M141Config.IsfinDevice) |
| | | { |
| | | SummaryAllprodata(p); |
| | | } |
| | | } |
| | | }); |
| | | ReplyPlcData(positionSet, plcresult); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public void SummaryAllprodata(ProductModel p) |
| | | { |
| | | _taskFactory.StartNew(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = p.SEQUENCE; |
| | | newp.PID = p.PID; |
| | | newp.BasketCode = p.BasketCode; |
| | | newp.Result = p.Result; |
| | | newp.SN = p.SN; |
| | | newp.Details.AddRange(p.Details); |
| | | |
| | | var plist = mysqlhelper.GetProductList(p.SEQUENCE); |
| | | |
| | | if (plist != null) |
| | | { |
| | | foreach (var item in plist) |
| | | { |
| | | newp.Details.AddRange(item.Details); |
| | | } |
| | | } |
| | | |
| | | List<string> specHeadListforall = new List<string>(); |
| | | List<string> positionListforall = new List<string>(); |
| | | string csvHeadforall = p.GetCSVHead(ref specHeadListforall, ref positionListforall); |
| | | CSVRecordAsync($"AllDeviceProductRecord.csv", p.GetCSVData(specHeadListforall, positionListforall), csvHeadforall); |
| | | |
| | | } |
| | | catch(Exception exx) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, "AllDeviceProductRecord数据汇总异常 " + exx.ToString()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | |