| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using iWare_SCADA_Model.MiddleModel; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Web.UI.WebControls; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using iWare_SCADA_Model.MiddleModel; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.IO; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// 测量完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3002: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3002 Instance = new DataCaptureHandler_OP3002(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// 测量完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3002: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3002 Instance = new DataCaptureHandler_OP3002(); |
| | | |
| | | public DataCaptureHandler_OP3002() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3002() |
| | | // { |
| | | // } |
| | | |
| | | public override string WorkingProcedure |
| | | { |
| | | get { return _dataCaptureConfig.WorkingProcedure; } |
| | | } |
| | | // public override string WorkingProcedure |
| | | // { |
| | | // get { return _dataCaptureConfig.WorkingProcedure; } |
| | | // } |
| | | |
| | | public override string DataCapturePointCode |
| | | { |
| | | get { return _dataCaptureConfig.DataCapturePointCode; } |
| | | } |
| | | public override string DataCapturePointCname |
| | | { |
| | | get { return _dataCaptureConfig.DataCapturePointCname; } |
| | | } |
| | | // public override string DataCapturePointCode |
| | | // { |
| | | // get { return _dataCaptureConfig.DataCapturePointCode; } |
| | | // } |
| | | // public override string DataCapturePointCname |
| | | // { |
| | | // get { return _dataCaptureConfig.DataCapturePointCname; } |
| | | // } |
| | | |
| | | |
| | | public override void RefreshDataList(List<DataCaptureConfig> dataCaptureConfig) |
| | | { |
| | | } |
| | | // public override void RefreshDataList(List<DataCaptureConfig> dataCaptureConfig) |
| | | // { |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | ThreadStatusMonitorMiddle threadStatusMonitor = new ThreadStatusMonitorMiddle(); |
| | | if (IsCaptureflag) |
| | | { |
| | | //var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | var plcService = SystemValue.GetPLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | threadStatusMonitor.ErrorMsg = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | SystemValue.PLCServiceReconnect(plcService); |
| | | //plcService.Close(); |
| | | //plcService.OpenService(); |
| | | } |
| | | string Station = "03"; |
| | | string value_02 = ""; |
| | | string path = ConfigHelper.GetConfigString("OP30QualityDataForStation");//打码机打码二维码路径 |
| | | if(string.IsNullOrEmpty(path)) |
| | | { |
| | | path = @"Z:\"; |
| | | } |
| | | if(DataCapturePointCode.Contains("CH3")) |
| | | {//工位3 涨断力矩 |
| | | path = path + "kistler_crack"; |
| | | } |
| | | else if (DataCapturePointCode.Contains("CH4")) |
| | | {//工位4 预拧紧力矩 |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // ThreadStatusMonitorMiddle threadStatusMonitor = new ThreadStatusMonitorMiddle(); |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // //var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // var plcService = SystemValue.GetPLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // SystemValue.PLCServiceReconnect(plcService); |
| | | // //plcService.Close(); |
| | | // //plcService.OpenService(); |
| | | // } |
| | | // string Station = "03"; |
| | | // string value_02 = ""; |
| | | // string path = ConfigHelper.GetConfigString("OP30QualityDataForStation");//打码机打码二维码路径 |
| | | // if(string.IsNullOrEmpty(path)) |
| | | // { |
| | | // path = @"Z:\"; |
| | | // } |
| | | // if(DataCapturePointCode.Contains("CH3")) |
| | | // {//工位3 涨断力矩 |
| | | // path = path + "kistler_crack"; |
| | | // } |
| | | // else if (DataCapturePointCode.Contains("CH4")) |
| | | // {//工位4 预拧紧力矩 |
| | | |
| | | path = path + "Bosch_Rexroth"; |
| | | } |
| | | else if (DataCapturePointCode.Contains("CH5")) |
| | | {//工位5 拧紧力矩 |
| | | // path = path + "Bosch_Rexroth"; |
| | | // } |
| | | // else if (DataCapturePointCode.Contains("CH5")) |
| | | // {//工位5 拧紧力矩 |
| | | |
| | | path = path + "Bosch_Rexroth"; |
| | | } |
| | | else if (DataCapturePointCode.Contains("CH6")) |
| | | {//工位6 衬套压装力矩 |
| | | // path = path + "Bosch_Rexroth"; |
| | | // } |
| | | // else if (DataCapturePointCode.Contains("CH6")) |
| | | // {//工位6 衬套压装力矩 |
| | | |
| | | path = path + "kistler_bush"; |
| | | } |
| | | // 质量信息:涨断力矩... 预拧紧力矩 预拧紧角度 终拧紧力矩 终拧紧角度 |
| | | //kistler_crack 涨断力矩 工位3 涨断力矩(Y - Maximum) 质量结果(Result) |
| | | //kistler_bush 压装力矩 工位6 衬套压装力矩(Y - Maximum) 衬套压装位移(Block X) 质量结果(Result) |
| | | //Bosch_Rexroth /(Ch_0_1.csv / Ch_0_2.csv 两通道 同时取最新的(或者id对应?)) 预拧紧力矩工位4 预拧紧力矩(T + Nm) 质量结果(结果) 目前文件不能自动生成 博世 力士乐拧紧系统 |
| | | //Bosch_Rexroth /(Ch_0_3.csv / Ch_0_4.csv 两通道 同时取最新的(或者id对应?)) 终拧紧工位5 拧紧力矩(T + Nm) 终拧紧角度 |
| | | while (true) |
| | | { |
| | | threadStatusMonitor.ErrorMsg = ""; |
| | | threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | //threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | threadStatusMonitor.Threadstatue = 0; |
| | | threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | SystemValue.PLCServiceReconnect(plcService); |
| | | //plcService.Close(); |
| | | //plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (value_02.ToUpper().Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | wplog.QualityType = QualityType.Online.ToString(); |
| | | // path = path + "kistler_bush"; |
| | | // } |
| | | //// 质量信息:涨断力矩... 预拧紧力矩 预拧紧角度 终拧紧力矩 终拧紧角度 |
| | | ////kistler_crack 涨断力矩 工位3 涨断力矩(Y - Maximum) 质量结果(Result) |
| | | ////kistler_bush 压装力矩 工位6 衬套压装力矩(Y - Maximum) 衬套压装位移(Block X) 质量结果(Result) |
| | | ////Bosch_Rexroth /(Ch_0_1.csv / Ch_0_2.csv 两通道 同时取最新的(或者id对应?)) 预拧紧力矩工位4 预拧紧力矩(T + Nm) 质量结果(结果) 目前文件不能自动生成 博世 力士乐拧紧系统 |
| | | ////Bosch_Rexroth /(Ch_0_3.csv / Ch_0_4.csv 两通道 同时取最新的(或者id对应?)) 终拧紧工位5 拧紧力矩(T + Nm) 终拧紧角度 |
| | | // while (true) |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = ""; |
| | | // threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | // threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | // threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | // //threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | // threadStatusMonitor.Threadstatue = 0; |
| | | // threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | // try |
| | | // { |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // SystemValue.PLCServiceReconnect(plcService); |
| | | // //plcService.Close(); |
| | | // //plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (value_02.ToUpper().Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | // wplog.QualityType = QualityType.Online.ToString(); |
| | | |
| | | |
| | | ////扫描共享目录并将新的文件扫描返回 一般节拍在15秒左右(可以确认一下) |
| | | ////扫描修改时间在上次扫描时间之前10秒到当前时间的之间的文件 |
| | | //var startTime = CommonManager.Instance.CheackPath(Environment.CurrentDirectory + $"\\LastModifyTime\\OP30Station{Station}-LastScapTime.txt", 6, -10); |
| | | //var endTime = DateTimeHelper.GetDateTime(); |
| | | //var newFiles = FileHelper.DetectNewFilesCSV(path, 10, Convert.ToDateTime(startTime), endTime); |
| | | // ////扫描共享目录并将新的文件扫描返回 一般节拍在15秒左右(可以确认一下) |
| | | // ////扫描修改时间在上次扫描时间之前10秒到当前时间的之间的文件 |
| | | // //var startTime = CommonManager.Instance.CheackPath(Environment.CurrentDirectory + $"\\LastModifyTime\\OP30Station{Station}-LastScapTime.txt", 6, -10); |
| | | // //var endTime = DateTimeHelper.GetDateTime(); |
| | | // //var newFiles = FileHelper.DetectNewFilesCSV(path, 10, Convert.ToDateTime(startTime), endTime); |
| | | |
| | | //foreach (System.IO.FileInfo file in newFiles) |
| | | //{ |
| | | // //foreach (System.IO.FileInfo file in newFiles) |
| | | // //{ |
| | | |
| | | //} |
| | | // //} |
| | | |
| | | foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | { |
| | | try |
| | | { |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | //wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | var set = wplog.GetType().GetProperty(col.DataCaptureColumnTabelName); |
| | | if (set == null) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}工序监控测量完成标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}工序监控测量完成标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | // foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // { |
| | | // try |
| | | // { |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // //wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // var set = wplog.GetType().GetProperty(col.DataCaptureColumnTabelName); |
| | | // if (set == null) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}工序监控测量完成标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}工序监控测量完成标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | |
| | | try |
| | | { |
| | | if (WorkingProcedure.Equals("OP80")) |
| | | { |
| | | //OP80 需要扫描文件读取质量信息 |
| | | //扫描修改时间在上次扫描时间之前60秒到当前时间的之间的文件 |
| | | List<FileInfo> files = new List<FileInfo>(); |
| | | var newFiles = FileHelper.DetectNewFilesCSV(path, 60, DateTimeHelper.GetDateTime(), DateTimeHelper.GetDateTime().AddHours(1)); |
| | | foreach (var file in newFiles) |
| | | { |
| | | files.Add((FileInfo)file); |
| | | } |
| | | files = files.OrderByDescending(o => o.LastAccessTime).ToList(); |
| | | foreach (var file in files) |
| | | {//取倒序匹配的文件名为工件号的文件 |
| | | if (file.Name.Contains(wplog.WorkPieceID)) |
| | | { |
| | | var datatable = CSVHelper.ReadCSVList(file.FullName); |
| | | List<string> rowFirst = new List<string>(); |
| | | List<string> rowSecond = new List<string>(); |
| | | if (datatable.Count == 2) |
| | | { |
| | | rowFirst = datatable[0].Split(',').ToList(); |
| | | rowSecond = datatable[1].Split(',').ToList(); |
| | | //给相应质量数据赋值 |
| | | wplog.OP80NewCode = rowSecond[1]; |
| | | wplog.QualityOP80To1 = rowFirst[13]; |
| | | } |
| | | else |
| | | { |
| | | wplog.Remarks = (wplog.Remarks ?? "") + $"OP80下线完成读取文件{file.FullName}异常,行数不是2行"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // try |
| | | // { |
| | | // if (WorkingProcedure.Equals("OP80")) |
| | | // { |
| | | // //OP80 需要扫描文件读取质量信息 |
| | | // //扫描修改时间在上次扫描时间之前60秒到当前时间的之间的文件 |
| | | // List<FileInfo> files = new List<FileInfo>(); |
| | | // var newFiles = FileHelper.DetectNewFilesCSV(path, 60, DateTimeHelper.GetDateTime(), DateTimeHelper.GetDateTime().AddHours(1)); |
| | | // foreach (var file in newFiles) |
| | | // { |
| | | // files.Add((FileInfo)file); |
| | | // } |
| | | // files = files.OrderByDescending(o => o.LastAccessTime).ToList(); |
| | | // foreach (var file in files) |
| | | // {//取倒序匹配的文件名为工件号的文件 |
| | | // if (file.Name.Contains(wplog.WorkPieceID)) |
| | | // { |
| | | // var datatable = CSVHelper.ReadCSVList(file.FullName); |
| | | // List<string> rowFirst = new List<string>(); |
| | | // List<string> rowSecond = new List<string>(); |
| | | // if (datatable.Count == 2) |
| | | // { |
| | | // rowFirst = datatable[0].Split(',').ToList(); |
| | | // rowSecond = datatable[1].Split(',').ToList(); |
| | | // //给相应质量数据赋值 |
| | | // wplog.OP80NewCode = rowSecond[1]; |
| | | // wplog.QualityOP80To1 = rowFirst[13]; |
| | | // } |
| | | // else |
| | | // { |
| | | // wplog.Remarks = (wplog.Remarks ?? "") + $"OP80下线完成读取文件{file.FullName}异常,行数不是2行"; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"OP80下线完成读取文件{file.FullName}不是指定工件{wplog.WorkPieceID}"); |
| | | } |
| | | } |
| | | } |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"OP80下线完成读取文件{file.FullName}不是指定工件{wplog.WorkPieceID}"); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"OP80下线完成读取文件数据时异常,避免工序完成异常:", ex); |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"OP80下线完成读取文件数据时异常,避免工序完成异常:", ex); |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | value_02 = value.ToString(); |
| | | // } |
| | | // value_02 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | threadStatusMonitor.Remarks = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | threadStatusMonitor.ThreadFrequency = 5000; |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | threadStatusMonitor.ThreadFrequency = _dataCaptureConfig.DataCaptureFrequency.Value; |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // } |
| | | // threadStatusMonitor.Remarks = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // threadStatusMonitor.ThreadFrequency = 5000; |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // threadStatusMonitor.ThreadFrequency = _dataCaptureConfig.DataCaptureFrequency.Value; |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控测量标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控测量标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | threadStatusMonitor.ErrorMsg = ""; |
| | | threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | threadStatusMonitor.Threadstatue = 0; |
| | | threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | threadStatusMonitor.Remarks = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控测量标记 不做校验,请确认配置信息!"; |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控测量标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控测量标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控测量标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // threadStatusMonitor.ErrorMsg = ""; |
| | | // threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | // threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | // threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | // threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | // threadStatusMonitor.Threadstatue = 0; |
| | | // threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | // threadStatusMonitor.Remarks = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控测量标记 不做校验,请确认配置信息!"; |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控测量标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |