| | |
| | | /// <summary> |
| | | /// 测量完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_02: DataCaptureHandler |
| | | public class DataCaptureHandler_02 : DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_02 Instance = new DataCaptureHandler_02(); |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | object value; |
| | | //判断DBNumber不同 【Editby shaocx,2024-06-07】 |
| | | if (_dataCaptureConfig.DbNumber.ToUpper() == "M") |
| | | { |
| | | value = plcService.ReadValuePointV2(_dataCaptureConfig.DbNumber + _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | } |
| | | else |
| | | { |
| | | value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | } |
| | | |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}测量完成【{value_02}】【{value.ToString()}】【{_dataCaptureConfig.PLCIP}】【{_dataCaptureConfig.DbNumber}】【{_dataCaptureConfig.Offset}】[{_dataCaptureConfig.DataCapturePLCType}][{plcService.IsConnected.ToString()}]"); |
| | | if (value_02.ToUpper().Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}进入测量完成【{value_02}】【{value.ToString()}】"); |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}进入测量完成【{value_02}】【{value.ToString()}】"); |
| | | |
| | | threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | wplog.QualityType = QualityType.Online.ToString(); |
| | |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}工序监控测量完成标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | if(set.PropertyType.FullName.Equals("System.String")) |
| | | if (set.PropertyType.FullName.Equals("System.String")) |
| | | { |
| | | set.SetValue(wplog, valuecol.ToString());//给动态字段赋值 |
| | | } |
| | |
| | | if (WorkingProcedure.Equals("OP30")) |
| | | { |
| | | var time = DateTimeHelper.GetDateTime(); |
| | | if (fileFindTime==null) |
| | | if (fileFindTime == null) |
| | | { |
| | | fileFindTime = time.AddMinutes(-10); |
| | | } |
| | | |
| | | |
| | | //获取文件夹名称 |
| | | List<string> directorylist = new List<string>(); |
| | | List<string> directorylist = new List<string>(); |
| | | string directory = time.ToString("yyyy-MM-dd_HH"); |
| | | string directoryOther = time.AddSeconds(-30).ToString("yyyy-MM-dd_HH"); |
| | | directorylist.Add(directory); |
| | |
| | | { |
| | | try |
| | | { |
| | | if (DataCapturePointCode.Contains("CH3")|| DataCapturePointCode.Contains("CH6")) |
| | | if (DataCapturePointCode.Contains("CH3") || DataCapturePointCode.Contains("CH6")) |
| | | {//工位3 涨断力矩 |
| | | //扫描当前时间与30秒前出现的文件,一般节拍在15秒左右(两个服务器时间不一样会导致取不到文件) |
| | | var newFiles = FileHelper.DetectNewFiles(path36 + @"\" + dir, "*.pdf", 10, fileFindTime.Value, time.AddMinutes(120)); |
| | |
| | | files.Add((FileInfo)file); |
| | | } |
| | | } |
| | | else if (DataCapturePointCode.Contains("CH4")|| DataCapturePointCode.Contains("CH5")) |
| | | else if (DataCapturePointCode.Contains("CH4") || DataCapturePointCode.Contains("CH5")) |
| | | {//工位4 预拧紧力矩 SEQ_04 |
| | | |
| | | //扫描当前时间与30秒前出现的文件,一般节拍在15秒左右(两个服务器时间不一样会导致取不到文件) |
| | |
| | | } |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}测量完成读取文件{dir}数据时异常,采集时间{fileFindTime.Value},避免工序完成异常1:", ex); |
| | | } |
| | | |
| | | } |
| | | files = files.OrderByDescending(o => o.LastWriteTime).ToList(); |
| | | if(files.Count>0) |
| | | if (files.Count > 0) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"工位【{DataCapturePointCode}】工件【{wplog.WorkPieceID??"空字符"}】文件{files[0].FullName}测量完成读取文件数据开始"); |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"工位【{DataCapturePointCode}】工件【{wplog.WorkPieceID ?? "空字符"}】文件{files[0].FullName}测量完成读取文件数据开始"); |
| | | switch (DataCapturePointCode) |
| | | { |
| | | case "OP3002CH3": |
| | | wplog.OP30QualityFilePathCH3 = files[0].FullName; |
| | | wplog.QualityStateStr= FileHelper.ReadPdfFileForSpire(files[0].FullName, "Result"); |
| | | wplog.QualityStateStr = FileHelper.ReadPdfFileForSpire(files[0].FullName, "Result"); |
| | | wplog.QualityOP30To1 = FileHelper.ReadPdfFileForSpire(files[0].FullName, "Y-Maximum");//涨断力矩 |
| | | break; |
| | | case "OP3002CH4": |
| | |
| | | fileFindTime = files[0].LastWriteTime; |
| | | } |
| | | } |
| | | else if(WorkingProcedure.Equals("OP35")) |
| | | else if (WorkingProcedure.Equals("OP35")) |
| | | { |
| | | if(wplog.OP35OK) |
| | | if (wplog.OP35OK) |
| | | { |
| | | wplog.QualityStateStr = "OK"; |
| | | } |
| | |
| | | wplog.QualityStateStr = "NG"; |
| | | } |
| | | } |
| | | else if(WorkingProcedure.Equals("OP60")) |
| | | else if (WorkingProcedure.Equals("OP60")) |
| | | { |
| | | //增加OP60 质量信息读取校验 【Editby shaocx,2024-06-07】 |
| | | if (wplog.Op60_Place_Flag == false) continue; |
| | | |
| | | var time = DateTimeHelper.GetDateTime(); |
| | | if (fileFindTime == null) |
| | |
| | | { |
| | | files.Add((FileInfo)file); |
| | | } |
| | | if(files.Count()>0) |
| | | if (files.Count() > 0) |
| | | { |
| | | files = files.OrderByDescending(o => o.LastWriteTime).ToList(); |
| | | List<OP60Info> op60Infos = new List<OP60Info>(); |
| | |
| | | {//取倒序匹配的文件名为工件号的文件 |
| | | if (file.Name.Contains("SP-" + DataCapturePointCode.Substring(DataCapturePointCode.Length - 1, 1))) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}下线完成读取到文件{file.Name},是指定的工件"); |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}下线完成读取到文件{file.Name},是指定的工件{wplog.WorkPieceID},上次获取尼伯丁文件里的时间值:{(op60QualityTime == null ? "" : op60QualityTime.ToString())}"); |
| | | |
| | | var datatable = CSVHelper.ReadCSVList(file.FullName); |
| | | if (datatable.Count < 106) |
| | |
| | | op60Infos.Add(info); |
| | | } |
| | | } |
| | | if(op60Infos.Count()>=2) |
| | | if (op60Infos.Count() >= 2) |
| | | { |
| | | if(op60QualityTime.HasValue) |
| | | if (op60QualityTime.HasValue) |
| | | { |
| | | if(op60Infos[0].datetimeHandle> op60QualityTime.Value) |
| | | if (op60Infos[0].datetimeHandle > op60QualityTime.Value) |
| | | { |
| | | wplog.QualityOP60To1 = op60Infos[0].value; |
| | | wplog.QualityOP60To2 = op60Infos[1].value; |
| | |
| | | } |
| | | else if (WorkingProcedure.Equals("OP20")) |
| | | { |
| | | //记录公用变量,保存点位M88的信息 【Editby shaocx,2024-06-07】 |
| | | if (DataCapturePointCode.Contains("OP2002C")) |
| | | {//从OP2002C读取,因为顺序是 CBA,而不是ABC |
| | | string sideValue = GetSideForOP20(plcService); |
| | | SystemValue.OP20_Side_Value = sideValue; |
| | | } |
| | | wplog.MonitoringPoint += SystemValue.OP20_Side_Value; |
| | | wplog.CreatedUserName = wplog.MonitoringPoint; |
| | | |
| | | var time = DateTimeHelper.GetDateTime(); |
| | | if (fileFindTime == null) |
| | |
| | | {//取倒序匹配的文件名为工件号的文件 |
| | | if (file.Name.Contains("SP-" + DataCapturePointCode.Substring(DataCapturePointCode.Length - 1, 1))) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}下线完成读取到文件{file.Name},是指定的工件"); |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}下线完成读取到文件{file.Name},是指定的工件{wplog.WorkPieceID},上次获取尼伯丁文件里的时间值:{(op60QualityTime == null ? "" : op60QualityTime.ToString())}"); |
| | | |
| | | var datatable = CSVHelper.ReadCSVList(file.FullName); |
| | | if (datatable.Count < 57) |
| | |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控测量标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取OP20的哪个面 |
| | | /// </summary> |
| | | /// <param name="plcService"></param> |
| | | /// <returns></returns> |
| | | private string GetSideForOP20(PLCService plcService) |
| | | { |
| | | try |
| | | { |
| | | object value_M88 = plcService.ReadValuePointV2("M88", PLCManger.GetTypeForString("int")); |
| | | int i_value_M88 = 0; |
| | | var isRight = int.TryParse(value_M88.ToString(), out i_value_M88); |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控测量标记数据时异常,获取OP20的哪个面,i_value_M88:{i_value_M88}"); |
| | | if (isRight) |
| | | { |
| | | if (i_value_M88 == 64) |
| | | { |
| | | return "1"; |
| | | } |
| | | else if (i_value_M88 == 256) |
| | | { |
| | | return "2"; |
| | | } |
| | | else if (i_value_M88 == 1024) |
| | | { |
| | | return "3"; |
| | | } |
| | | else if (i_value_M88 == 4096) |
| | | { |
| | | return "4"; |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控测量标记数据时异常,获取OP20的哪个面,:", ex); |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | public WorkPieceLogMiddle GetCH4Info(string FullName, WorkPieceLogMiddle wplog) |
| | | { |
| | | try |
| | |
| | | foreach (string line in lines2) |
| | | { |
| | | count++; |
| | | if (count==4) |
| | | if (count == 4) |
| | | {//获取质量结果 |
| | | var list = line.Split(' '); |
| | | if(list.Count()>0) |
| | | if (list.Count() > 0) |
| | | { |
| | | var str = list[list.Count() - 1].ToString().Trim(); |
| | | wplog.QualityStateStr= str.Equals("OK")?"OK":"NG"; |
| | | wplog.QualityStateStr = str.Equals("OK") ? "OK" : "NG"; |
| | | } |
| | | } |
| | | // 处理每一行的逻辑 |