显示 [StringLength(50)]
public string DataCapturePointCname { get; set; }
[StringLength(50)]
public string UpdateDataCapturePointCname { get; set; }
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | { |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP10工序完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP1005: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP1005 Instance = new DataCaptureHandler_OP1005(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP10工序完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP1005: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP1005 Instance = new DataCaptureHandler_OP1005(); |
| | | |
| | | public DataCaptureHandler_OP1005() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP1005() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP1005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP1005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | 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); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP1005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | // 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); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | //反馈给PLC,写入 |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP1005 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP1005 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP1005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // } |
| | | // SystemValue.lbl_Alert_OP1005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序完成标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}工序完成标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序完成标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}工序完成标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序完成标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}工序完成标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序完成标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}工序完成标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP10设备信息采集 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP1006: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP1006 Instance = new DataCaptureHandler_OP1006(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP10设备信息采集 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP1006: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP1006 Instance = new DataCaptureHandler_OP1006(); |
| | | |
| | | public DataCaptureHandler_OP1006() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP1006() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP1006 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //if (SystemValue.value_OP1006.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1006 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //if (SystemValue.value_OP1006.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // 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); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | //反馈给PLC,写入 |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP1006 = value.ToString(); |
| | | // } |
| | | // //SystemValue.value_OP1006 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP1006 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // } |
| | | // SystemValue.lbl_Alert_OP1006 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备采集 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(LogType.PLCOP05, $"{DataCapturePointCode}工序设备采集数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备采集 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(LogType.PLCOP05, $"{DataCapturePointCode}工序设备采集数据 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备采集 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(LogType.PLCOP05, $"{DataCapturePointCode}工序设备采集数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1006 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备采集 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(LogType.PLCOP05, $"{DataCapturePointCode}工序设备采集数据 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP10 告警监控 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP1007: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP1007 Instance = new DataCaptureHandler_OP1007(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP10 告警监控 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP1007: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP1007 Instance = new DataCaptureHandler_OP1007(); |
| | | |
| | | public DataCaptureHandler_OP1007() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP1007() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | wplog.AlertTime = DateTime.Now; |
| | | Random ran = new Random(); |
| | | //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | wplog.AlertMsg = "测试告警 1101"; |
| | | // wplog.AlertTime = DateTime.Now; |
| | | // Random ran = new Random(); |
| | | // //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | // wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP1007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP1007.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP1007.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP1007 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP1007 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP1007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP1007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP1007 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP30读码完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3001: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3001 Instance = new DataCaptureHandler_OP3001(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP30读码完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3001: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3001 Instance = new DataCaptureHandler_OP3001(); |
| | | |
| | | public DataCaptureHandler_OP3001() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3001() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP3001": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | // if (wplog.WorkPieceID.Length != 22) |
| | | // {//获取到的工件号异常 |
| | | // return; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | // //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // //{ |
| | | // // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | // //} |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | // return; |
| | | // } |
| | | |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP3001": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3001.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | // } |
| | | // } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | if (wplog.WorkPieceID.Length != 22) |
| | | {//获取到的工件号异常 |
| | | return; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | // if(wplog.WorkPieceID.Length!=22) |
| | | // {//获取到的工件号异常 |
| | | // continue; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | //{ |
| | |
| | | // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | //} |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | return; |
| | | } |
| | | |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3001.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig,plcService); |
| | | if(wplog.WorkPieceID.Length!=22) |
| | | {//获取到的工件号异常 |
| | | continue; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | |
| | | foreach (var col in colConfig.Where(o=>o.DataCapturePointCode== DataCapturePointCode)) |
| | | { |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset,col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | } |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | //#region 反馈PLC |
| | | |
| | | //bool checkQualityInfoCompleteFlag = false; |
| | | //bool plcFlag = true;//反馈给PLC的标记 |
| | | //string message = ""; |
| | | //checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | //if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityState.OK) |
| | | //{ |
| | | // plcFlag = false; |
| | | // message = !checkQualityInfoCompleteFlag ? "跳序," : ""; |
| | | //message += info.QualityState != (int)QualityState.OK ? "质量不符合" : ""; |
| | | //} |
| | | ////反馈给PLC,(写入点待定) |
| | | //MessageModel fr = null; |
| | | //fr = plcService.WriteValuePoint("", "", plcFlag, PLCManger.GetTypeForString("bool")); |
| | | //if (fr.result) |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | // //#region 反馈PLC |
| | | |
| | | // //bool checkQualityInfoCompleteFlag = false; |
| | | // //bool plcFlag = true;//反馈给PLC的标记 |
| | | // //string message = ""; |
| | | // //checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // //if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityState.OK) |
| | | // //{ |
| | | // // plcFlag = false; |
| | | // // message = !checkQualityInfoCompleteFlag ? "跳序," : ""; |
| | | // //message += info.QualityState != (int)QualityState.OK ? "质量不符合" : ""; |
| | | // //} |
| | | // ////反馈给PLC,(写入点待定) |
| | | // //MessageModel fr = null; |
| | | // //fr = plcService.WriteValuePoint("", "", plcFlag, PLCManger.GetTypeForString("bool")); |
| | | // //if (fr.result) |
| | | // //{ |
| | | // // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 成功, 出现 {message}"); |
| | | // //} |
| | | // //else |
| | | // //{ |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 失败, 出现 {message} ,失败原因:{fr.resMsg}"); |
| | | // //} |
| | | // //#endregion |
| | | |
| | | // } |
| | | // SystemValue.value_OP3001 = value.ToString(); |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | //{ |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 成功, 出现 {message}"); |
| | | // Thread.Sleep(5000); |
| | | //} |
| | | //else |
| | | //{ |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 失败, 出现 {message} ,失败原因:{fr.resMsg}"); |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | //} |
| | | //#endregion |
| | | |
| | | } |
| | | SystemValue.value_OP3001 = value.ToString(); |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | |
| | | } |
| | | //catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // } |
| | | // //catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // //{ |
| | | // // SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // catch (Exception ex) |
| | | //{ |
| | | // SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3001 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP30 NOOK推出标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3003: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3003 Instance = new DataCaptureHandler_OP3003(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP30 NOOK推出标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3003: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3003 Instance = new DataCaptureHandler_OP3003(); |
| | | |
| | | public DataCaptureHandler_OP3003() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3003() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP3003": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3003 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP3003": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //if (SystemValue.value_OP3003.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //foreach (var col in colConfig) |
| | | // //{ |
| | | // // switch(col.DbNumber+ col.Offset) |
| | | // // { |
| | | // // case "": |
| | | // var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // // break; |
| | | // // } |
| | | // //} |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP3003 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3003 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3003 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //if (SystemValue.value_OP3003.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //foreach (var col in colConfig) |
| | | // } |
| | | // } |
| | | // else |
| | | //{ |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | //} |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP3003 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3003 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3003 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP30 SPC推出标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3004: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3004 Instance = new DataCaptureHandler_OP3004(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP30 SPC推出标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3004: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3004 Instance = new DataCaptureHandler_OP3004(); |
| | | |
| | | public DataCaptureHandler_OP3004() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3004() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP3004": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3004 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP3004": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3004.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // foreach (var col in colConfig) |
| | | // { |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP3004 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3004 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3004 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3004.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig) |
| | | { |
| | | switch(col.DbNumber+ col.Offset) |
| | | { |
| | | case "": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP3004 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3004 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3004 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP30 工序完成 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3005: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3005 Instance = new DataCaptureHandler_OP3005(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP30 工序完成 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3005: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3005 Instance = new DataCaptureHandler_OP3005(); |
| | | |
| | | public DataCaptureHandler_OP3005() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3005() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP3005": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{_dataCaptureConfig.WorkingProcedure}的PLC设备{DataCapturePointCode}"; |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP3005": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {_dataCaptureConfig.WorkingProcedure}工序获取到{DataCapturePointCode}标志位"); |
| | | // 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.IsDeleted = false; |
| | | // foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // { |
| | | // switch(col.DataCaptureColumnTabelName) |
| | | // { |
| | | // case "WorkPieceID": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // SystemValue.value_OP3005 = value.ToString().ToUpper(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{_dataCaptureConfig.WorkingProcedure}的PLC设备{DataCapturePointCode}"; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {_dataCaptureConfig.WorkingProcedure}工序获取到{DataCapturePointCode}标志位"); |
| | | 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.IsDeleted = false; |
| | | foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | { |
| | | switch(col.DataCaptureColumnTabelName) |
| | | { |
| | | case "WorkPieceID": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP3005 = value.ToString().ToUpper(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3005 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP30 告警监控 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3007: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3007 Instance = new DataCaptureHandler_OP3007(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP30 告警监控 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3007 : DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3007 Instance = new DataCaptureHandler_OP3007(); |
| | | |
| | | public DataCaptureHandler_OP3007() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3007() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP3007": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // /* |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | // wplog.AlertTime = DateTime.Now; |
| | | // Random ran = new Random(); |
| | | // //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | // wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | // wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // //*/ |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP3007": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3007.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // foreach (var col in colConfig) |
| | | // { |
| | | // switch (col.DbNumber + col.Offset) |
| | | // { |
| | | // case "": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP3007 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} OP30工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP30工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | wplog.AlertTime = DateTime.Now; |
| | | Random ran = new Random(); |
| | | //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3007.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig) |
| | | { |
| | | switch(col.DbNumber+ col.Offset) |
| | | { |
| | | case "": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP3007 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3007 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using iWare_SCADA_Model.TableModel; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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.TableModel; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35读码完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3501 : DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3501 Instance = new DataCaptureHandler_OP3501(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP35读码完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3501 : DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3501 Instance = new DataCaptureHandler_OP3501(); |
| | | |
| | | public DataCaptureHandler_OP3501() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3501() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | if (wplog.WorkPieceID.Length != 22) |
| | | {//获取到的工件号异常 |
| | | return; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | // if (wplog.WorkPieceID.Length != 22) |
| | | // {//获取到的工件号异常 |
| | | // return; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | // //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // //{ |
| | | // // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | // //} |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | // return; |
| | | // } |
| | | |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | // threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | // threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | // threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | // threadStatusMonitor.Threadstatue = 0; |
| | | // threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | // try |
| | | // { |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // threadStatusMonitor.Remarks= $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3501.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | |
| | | //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);//给动态字段赋值 |
| | | // //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); |
| | | // } |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | //} |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | // SystemValue.value_OP3501 = value.ToString(); |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3501 = $"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); |
| | | // } |
| | | |
| | | |
| | | return; |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控上线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控上线标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控上线标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控上线标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | threadStatusMonitor.Threadstatue = 0; |
| | | threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | try |
| | | { |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | threadStatusMonitor.Remarks= $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3501.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | } |
| | | SystemValue.value_OP3501 = value.ToString(); |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3501 = $"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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控上线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控上线标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3501 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控上线标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控上线标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35 NOOK推出标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3503: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3503 Instance = new DataCaptureHandler_OP3503(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP35 NOOK推出标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3503: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3503 Instance = new DataCaptureHandler_OP3503(); |
| | | |
| | | public DataCaptureHandler_OP3503() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3503() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3503 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3503.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | 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), $" {WorkingProcedure}工序监控NOOK标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控NOOK标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3503 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3503.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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), $" {WorkingProcedure}工序监控NOOK标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控NOOK标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP3503 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP3503 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3503 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3503 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控NOOK标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控NOOK标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控NOOK标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控NOOK标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控NOOK标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控NOOK标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控NOOK标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控NOOK标记数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控NOOK标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控NOOK标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3503 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控NOOK标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控NOOK标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35 SPC推出标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3504: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3504 Instance = new DataCaptureHandler_OP3504(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP35 SPC推出标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3504: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3504 Instance = new DataCaptureHandler_OP3504(); |
| | | |
| | | public DataCaptureHandler_OP3504() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3504() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3504 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3504.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | 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), $" {WorkingProcedure}工序监控spc标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控spc标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3504 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3504.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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), $" {WorkingProcedure}工序监控spc标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控spc标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP3504 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP3504 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3504 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3504 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控spc标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控spc标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控spc标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控spc标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控spc标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控spc标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控spc标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控spc标记数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控spc标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控spc标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3504 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控spc标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控spc标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35 工序完成 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3505: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3505 Instance = new DataCaptureHandler_OP3505(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP35 工序完成 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3505: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3505 Instance = new DataCaptureHandler_OP3505(); |
| | | |
| | | public DataCaptureHandler_OP3505() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3505() |
| | | // { |
| | | // } |
| | | |
| | | public override string WorkingProcedure |
| | | { |
| | | get { return _dataCaptureConfig.WorkingProcedure; } |
| | | } |
| | | // public override string WorkingProcedure |
| | | // { |
| | | // get { return _dataCaptureConfig.WorkingProcedure; } |
| | | // } |
| | | |
| | | public override string DataCapturePointCode |
| | | { |
| | | get { return _dataCaptureConfig.WorkingProcedure; } |
| | | } |
| | | public override string DataCapturePointCname |
| | | { |
| | | get { return _dataCaptureConfig.DataCapturePointCname; } |
| | | } |
| | | // public override string DataCapturePointCode |
| | | // { |
| | | // get { return _dataCaptureConfig.WorkingProcedure; } |
| | | // } |
| | | // 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3505 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{DataCapturePointCode}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{DataCapturePointCode}的PLC设备"; |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序获取到下线标志位"); |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3505 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{DataCapturePointCode}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3501 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{DataCapturePointCode}的PLC设备"; |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序获取到下线标志位"); |
| | | |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | { |
| | | try |
| | | { |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch(Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控读码标记 读取工件码动态赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】异常{wplog.Id},赋值列名[{col.DataCaptureColumnTabelName ?? "空字符串"}]", setex); |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // 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(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch(Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控读码标记 读取工件码动态赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】异常{wplog.Id},赋值列名[{col.DataCaptureColumnTabelName ?? "空字符串"}]", setex); |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP3505 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP3505 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3505 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3505 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}下线标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}下线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}下线标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}下线标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}下线标记数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}下线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控打码标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3505 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}下线标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}下线标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35 设备信息采集 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3506 : DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3506 Instance = new DataCaptureHandler_OP3506(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP35 设备信息采集 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3506 : DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3506 Instance = new DataCaptureHandler_OP3506(); |
| | | |
| | | public DataCaptureHandler_OP3506() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP3506() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3506 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3506 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // 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); |
| | | // } |
| | | // } |
| | | // WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | } |
| | | SystemValue.lbl_Alert_OP3506 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3506 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控设备采集 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控设备采集 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3506 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控设备采集 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控设备采集 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP35 告警监控 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP3507 : DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP3507 Instance = new DataCaptureHandler_OP3507(); |
| | | |
| | | public DataCaptureHandler_OP3507() |
| | | { |
| | | } |
| | | |
| | | 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 void RefreshDataList(List<DataCaptureConfig> dataCaptureConfig) |
| | | { |
| | | } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP3507 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP3507.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | //if (wplog.FailureType.Length > 0) |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // /// <summary> |
| | | // /// OP35 告警监控 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP3507 : DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP3507 Instance = new DataCaptureHandler_OP3507(); |
| | | |
| | | // public DataCaptureHandler_OP3507() |
| | | // { |
| | | // } |
| | | |
| | | // 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 void RefreshDataList(List<DataCaptureConfig> dataCaptureConfig) |
| | | // { |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3507 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP3507.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | // //if (wplog.FailureType.Length > 0) |
| | | // //{ |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | // //} |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP3507 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP3507 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.value_OP3507 = value.ToString(); |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // SystemValue.lbl_Alert_OP3507 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | } |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP3507 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP70读码完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP7001: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP7001 Instance = new DataCaptureHandler_OP7001(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP70读码完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP7001: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP7001 Instance = new DataCaptureHandler_OP7001(); |
| | | |
| | | public DataCaptureHandler_OP7001() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP7001() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | if (wplog.WorkPieceID.Length != 22) |
| | | {//获取到的工件号异常 |
| | | return; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | // if (wplog.WorkPieceID.Length != 22) |
| | | // {//获取到的工件号异常 |
| | | // return; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | // //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // //{ |
| | | // // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | // //} |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | // return; |
| | | // } |
| | | |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | // threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | // threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | // threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | // threadStatusMonitor.Threadstatue = 0; |
| | | // threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | // try |
| | | // { |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP7001.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | |
| | | //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);//给动态字段赋值 |
| | | // //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); |
| | | // } |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | //} |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | // SystemValue.value_OP7001 = value.ToString(); |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP7001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | |
| | | return; |
| | | } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控上线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控上线标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控上线标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控上线标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP7001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | threadStatusMonitor.Threadcode = DataCapturePointCode; |
| | | threadStatusMonitor.Threadcname = DataCapturePointCname; |
| | | threadStatusMonitor.Threadendtime = DateTime.Now; |
| | | threadStatusMonitor.Threadlastmodifytime = DateTime.Now; |
| | | threadStatusMonitor.Threadstatue = 0; |
| | | threadStatusMonitor.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | try |
| | | { |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP7001.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | } |
| | | SystemValue.value_OP7001 = value.ToString(); |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP7001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控上线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控上线标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP7001 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控上线标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控上线标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP70 工序完成 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP7005 : DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP7005 Instance = new DataCaptureHandler_OP7005(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP70 工序完成 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP7005 : DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP7005 Instance = new DataCaptureHandler_OP7005(); |
| | | |
| | | public DataCaptureHandler_OP7005() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP7005() |
| | | // { |
| | | // } |
| | | |
| | | public override string WorkingProcedure |
| | | { |
| | | get { return _dataCaptureConfig.WorkingProcedure; } |
| | | } |
| | | // public override string WorkingProcedure |
| | | // { |
| | | // get { return _dataCaptureConfig.WorkingProcedure; } |
| | | // } |
| | | |
| | | public override string DataCapturePointCode |
| | | { |
| | | get { return _dataCaptureConfig.WorkingProcedure; } |
| | | } |
| | | public override string DataCapturePointCname |
| | | { |
| | | get { return _dataCaptureConfig.DataCapturePointCname; } |
| | | } |
| | | // public override string DataCapturePointCode |
| | | // { |
| | | // get { return _dataCaptureConfig.WorkingProcedure; } |
| | | // } |
| | | // 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP7005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{DataCapturePointCode}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | SystemValue.lbl_Alert_OP7005 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{DataCapturePointCode}的PLC设备"; |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{DataCapturePointCode}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // SystemValue.lbl_Alert_OP7005 = $"{RandomHelper.GenerateRandomCode(4)} 开始采集{DataCapturePointCode}的PLC设备"; |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | |
| | | if (SystemValue.value_OP7005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序获取到下线标志位"); |
| | | // if (SystemValue.value_OP7005.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序获取到下线标志位"); |
| | | |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | { |
| | | try |
| | | { |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码动态由于字段名没找到,赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码动态赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】异常{wplog.Id},赋值列名[{col.DataCaptureColumnTabelName ?? "空字符串"}]", setex); |
| | | } |
| | | } |
| | | if (wplog.WorkPieceID.Length != 22) |
| | | {//获取到的工件号异常 |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码数据时异常:"); |
| | | continue; |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // 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(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码动态由于字段名没找到,赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码动态赋值【{_dataCaptureConfig.WorkingProcedure ?? "空字符串"}】异常{wplog.Id},赋值列名[{col.DataCaptureColumnTabelName ?? "空字符串"}]", setex); |
| | | // } |
| | | // } |
| | | // if (wplog.WorkPieceID.Length != 22) |
| | | // {//获取到的工件号异常 |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {DataCapturePointCode}工序监控下线标记 读取工件码数据时异常:"); |
| | | // continue; |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP7005 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP7005 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP7005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP7005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}下线标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控下线标记数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}下线标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}下线标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}下线标记数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}下线标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控下线标记数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7005 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}下线标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}下线标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP70 设备信息采集 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP7006: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP7006 Instance = new DataCaptureHandler_OP7006(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP70 设备信息采集 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP7006: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP7006 Instance = new DataCaptureHandler_OP7006(); |
| | | |
| | | public DataCaptureHandler_OP7006() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP7006() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP7006 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7006 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = Environment.MachineName+"自动"; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.IsDeleted = false; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // 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); |
| | | // } |
| | | // } |
| | | // WorkPieceInfoManager.EquipmentMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | } |
| | | SystemValue.lbl_Alert_OP7006 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP7006 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控设备采集 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控设备采集 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序监控设备采集 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序监控设备采集数据时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7006 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序监控设备采集 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序监控设备采集 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP70 告警监控 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP7007: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP7007 Instance = new DataCaptureHandler_OP7007(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP70 告警监控 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP7007: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP7007 Instance = new DataCaptureHandler_OP7007(); |
| | | |
| | | public DataCaptureHandler_OP7007() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP7007() |
| | | // { |
| | | // } |
| | | |
| | | 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() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | wplog.AlertTime = DateTime.Now; |
| | | Random ran = new Random(); |
| | | //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | wplog.AlertMsg = "测试告警 1101"; |
| | | // wplog.AlertTime = DateTime.Now; |
| | | // Random ran = new Random(); |
| | | // //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | // wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.故障).ToString(); |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP7007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | 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) |
| | | { |
| | | SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP7007.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | } |
| | | set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | } |
| | | catch (Exception setex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | } |
| | | } |
| | | //if(wplog.FailureType.Length>0) |
| | | { |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | } |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | // ThreadStatusMonitor threadStatusMonitor = new ThreadStatusMonitor(); |
| | | // 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) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP7007.Equals("FALSE") && value.ToString().ToUpper().Equals("TRUE")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // 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), $" {WorkingProcedure}工序监控读码标记 读取工件码动态由于字段名没找到,赋值【{WorkingProcedure ?? "空字符串"}】失败{wplog.Id}"); |
| | | // } |
| | | // set.SetValue(wplog, valuecol);//给动态字段赋值 |
| | | // } |
| | | // catch (Exception setex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {WorkingProcedure}工序监控读码标记 读取工件码动态赋值【{WorkingProcedure ?? "空字符串"}】异常{wplog.Id}", setex); |
| | | // } |
| | | // } |
| | | // //if(wplog.FailureType.Length>0) |
| | | // { |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | // threadStatusMonitor.Threadstatue = 1; |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | SystemValue.value_OP7007 = value.ToString(); |
| | | // } |
| | | // SystemValue.value_OP7007 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP7007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // } |
| | | // SystemValue.lbl_Alert_OP7007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | } |
| | | finally |
| | | { |
| | | WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{DataCapturePointCode}工序设备告警信息 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}工序设备告警信息时异常:", ex); |
| | | // } |
| | | // finally |
| | | // { |
| | | // WorkPieceInfoManager.ThreadMonitor(threadStatusMonitor); |
| | | // } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP7007 = $" {RandomHelper.GenerateRandomCode(4)} {DataCapturePointCode}工序设备告警信息 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{DataCapturePointCode}工序设备告警信息 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP80读码完成标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP8001: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP8001 Instance = new DataCaptureHandler_OP8001(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP80读码完成标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP8001: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP8001 Instance = new DataCaptureHandler_OP8001(); |
| | | |
| | | public DataCaptureHandler_OP8001() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP8001() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP8001": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | // if (wplog.WorkPieceID.Length != 22) |
| | | // {//获取到的工件号异常 |
| | | // return; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | // //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | // //{ |
| | | // // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | // //} |
| | | // } |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | // return; |
| | | // } |
| | | |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP8001": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP8001.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLog wplog = new WorkPieceLog(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | // } |
| | | // } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | |
| | | |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig, plcService); |
| | | if (wplog.WorkPieceID.Length != 22) |
| | | {//获取到的工件号异常 |
| | | return; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | // if(wplog.WorkPieceID.Length!=22) |
| | | // {//获取到的工件号异常 |
| | | // continue; |
| | | // } |
| | | // else |
| | | // {//获取其他配置的待采集项 |
| | | |
| | | //foreach (var col in colConfig.Where(o => o.DataCapturePointCode == DataCapturePointCode)) |
| | | //{ |
| | |
| | | // wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | //} |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | |
| | | return; |
| | | } |
| | | |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP8001 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | object value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP8001.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLog wplog = new WorkPieceLog(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | |
| | | //var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = PLCManger.GetWorkPieceIDForPLC(_dataCaptureConfig,plcService); |
| | | if(wplog.WorkPieceID.Length!=22) |
| | | {//获取到的工件号异常 |
| | | continue; |
| | | } |
| | | else |
| | | {//获取其他配置的待采集项 |
| | | |
| | | foreach (var col in colConfig.Where(o=>o.DataCapturePointCode== DataCapturePointCode)) |
| | | { |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset,col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.GetType().GetProperty(col.DataCaptureColumnTabelName).SetValue(wplog, valuecol);//给动态字段赋值 |
| | | |
| | | } |
| | | } |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | //#region 反馈PLC |
| | | |
| | | //bool checkQualityInfoCompleteFlag = false; |
| | | //bool plcFlag = true;//反馈给PLC的标记 |
| | | //string message = ""; |
| | | //checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | //if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityState.OK) |
| | | //{ |
| | | // plcFlag = false; |
| | | // message = !checkQualityInfoCompleteFlag ? "跳序," : ""; |
| | | //message += info.QualityState != (int)QualityState.OK ? "质量不符合" : ""; |
| | | //} |
| | | ////反馈给PLC,(写入点待定) |
| | | //MessageModel fr = null; |
| | | //fr = plcService.WriteValuePoint("", "", plcFlag, PLCManger.GetTypeForString("bool")); |
| | | //if (fr.result) |
| | | // //读取二维码后更新数据库 |
| | | // WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure),plcService, _dataCaptureConfig.IsFeedback); |
| | | |
| | | // //#region 反馈PLC |
| | | |
| | | // //bool checkQualityInfoCompleteFlag = false; |
| | | // //bool plcFlag = true;//反馈给PLC的标记 |
| | | // //string message = ""; |
| | | // //checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // //if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityState.OK) |
| | | // //{ |
| | | // // plcFlag = false; |
| | | // // message = !checkQualityInfoCompleteFlag ? "跳序," : ""; |
| | | // //message += info.QualityState != (int)QualityState.OK ? "质量不符合" : ""; |
| | | // //} |
| | | // ////反馈给PLC,(写入点待定) |
| | | // //MessageModel fr = null; |
| | | // //fr = plcService.WriteValuePoint("", "", plcFlag, PLCManger.GetTypeForString("bool")); |
| | | // //if (fr.result) |
| | | // //{ |
| | | // // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 成功, 出现 {message}"); |
| | | // //} |
| | | // //else |
| | | // //{ |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 失败, 出现 {message} ,失败原因:{fr.resMsg}"); |
| | | // //} |
| | | // //#endregion |
| | | |
| | | // } |
| | | // SystemValue.value_OP8001 = value.ToString(); |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP8001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | //{ |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 成功, 出现 {message}"); |
| | | // Thread.Sleep(5000); |
| | | //} |
| | | //else |
| | | //{ |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" 工件{wplog.WorkPieceID} {WorkingProcedure}工序反馈给PLC 失败, 出现 {message} ,失败原因:{fr.resMsg}"); |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | //} |
| | | //#endregion |
| | | |
| | | } |
| | | SystemValue.value_OP8001 = value.ToString(); |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP8001 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | |
| | | } |
| | | //catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // } |
| | | // //catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // //{ |
| | | // // SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // catch (Exception ex) |
| | | //{ |
| | | // SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8001 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | //using System.Web.UI.WebControls; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP80 NOOK推出标记 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP8003: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP8003 Instance = new DataCaptureHandler_OP8003(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP80 NOOK推出标记 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP8003: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP8003 Instance = new DataCaptureHandler_OP8003(); |
| | | |
| | | public DataCaptureHandler_OP8003() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP8003() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP8003": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8003 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP8003": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // //if (SystemValue.value_OP8003.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // //foreach (var col in colConfig) |
| | | // //{ |
| | | // // switch(col.DbNumber+ col.Offset) |
| | | // // { |
| | | // // case "": |
| | | // var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // // break; |
| | | // // } |
| | | // //} |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP8003 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP8003 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP8003 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | //var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | //if (SystemValue.value_OP8003.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | //foreach (var col in colConfig) |
| | | // } |
| | | // } |
| | | // else |
| | | //{ |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | var valuecol = plcService.ReadValuePoint("2050", "28", 25, typeof(string)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | //} |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP8003 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP8003 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP8003 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP80 测量完成后读码完成 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP8004: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP8004 Instance = new DataCaptureHandler_OP8004(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP80 测量完成后读码完成 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP8004: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP8004 Instance = new DataCaptureHandler_OP8004(); |
| | | |
| | | public DataCaptureHandler_OP8004() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP8004() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP8004": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8004 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP8004": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP8004.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // foreach (var col in colConfig) |
| | | // { |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP8004 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP8004 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP8004 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP8004.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig) |
| | | { |
| | | switch(col.DbNumber+ col.Offset) |
| | | { |
| | | case "": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP8004 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP8004 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP8004 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP80 工序完成 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP8005: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP8005 Instance = new DataCaptureHandler_OP8005(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP80 工序完成 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP8005: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP8005 Instance = new DataCaptureHandler_OP8005(); |
| | | |
| | | public DataCaptureHandler_OP8005() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP8005() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP8005": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP8005": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP8005.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // foreach (var col in colConfig) |
| | | // { |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP8005 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP8005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP8005 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP8005.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig) |
| | | { |
| | | switch(col.DbNumber+ col.Offset) |
| | | { |
| | | case "": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP8005 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP8005 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP8005 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | //using iWare_SCADA_BusinessLogical.BLL; |
| | | //using iWare_SCADA_BusinessLogical.Utils; |
| | | //using iWare_SCADA_Model; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Text; |
| | | //using System.Threading; |
| | | //using System.Threading.Tasks; |
| | | |
| | | namespace iWare_SCADA_BusinessLogical |
| | | { |
| | | /// <summary> |
| | | /// OP80 告警监控 |
| | | /// </summary> |
| | | public class DataCaptureHandler_OP8007: DataCaptureHandler |
| | | { |
| | | public static readonly DataCaptureHandler_OP8007 Instance = new DataCaptureHandler_OP8007(); |
| | | //namespace iWare_SCADA_BusinessLogical |
| | | //{ |
| | | // /// <summary> |
| | | // /// OP80 告警监控 |
| | | // /// </summary> |
| | | // public class DataCaptureHandler_OP8007: DataCaptureHandler |
| | | // { |
| | | // public static readonly DataCaptureHandler_OP8007 Instance = new DataCaptureHandler_OP8007(); |
| | | |
| | | public DataCaptureHandler_OP8007() |
| | | { |
| | | } |
| | | // public DataCaptureHandler_OP8007() |
| | | // { |
| | | // } |
| | | |
| | | 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) |
| | | // { |
| | | // //try |
| | | // //{ |
| | | // // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // // { |
| | | // // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // // { |
| | | // // case "OP8007": |
| | | // // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // // IsCaptureflag = true; |
| | | // // return; |
| | | |
| | | // // } |
| | | // // } |
| | | // //} |
| | | // //catch (Exception ex) |
| | | // //{ |
| | | // // SystemValue._lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // //} |
| | | // } |
| | | |
| | | // public override void DataCaptureStart() |
| | | // { |
| | | // if (SystemValue.isStartedImitateModel) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | |
| | | |
| | | // wplog.WorkPieceID = WorkPieceID; |
| | | // wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | // wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | // wplog.AlertTime = DateTime.Now; |
| | | // Random ran = new Random(); |
| | | // //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | // wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | // wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.生产).ToString(); |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | // return; |
| | | // } |
| | | // if (IsCaptureflag) |
| | | // { |
| | | // var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | // if (plcService == null) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | // return; |
| | | // } |
| | | // if (plcService != null && !plcService.IsConnected) |
| | | // { |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // } |
| | | // while (true) |
| | | // { |
| | | //try |
| | | //{ |
| | | // foreach (var dataCaptureColumnDict in dataCaptureConfig) |
| | | // //_dataCaptureConfig |
| | | // if (plcService == null || !plcService.IsConnected) |
| | | // { |
| | | // switch (dataCaptureColumnDict.DataCapturePointCode) |
| | | // SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | // Thread.Sleep(100); |
| | | // continue; |
| | | // } |
| | | // else |
| | | // { |
| | | // case "OP8007": |
| | | // //_dataCaptureConfig = dataCaptureColumnDict; |
| | | // IsCaptureflag = true; |
| | | // return; |
| | | // var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | // if (SystemValue.value_OP8007.Equals("0") && value.ToString().Equals("1")) |
| | | // {//当上一标记位0,当前获取标记为1时, |
| | | // //触发操作, 并给静态变量赋值为1 |
| | | // //业务代码 |
| | | // WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | // wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | // wplog.WorkingProcedure = WorkingProcedure; |
| | | // wplog.EquipmentID = WorkingProcedure; |
| | | // wplog.Remarks = WorkingProcedure; |
| | | // wplog.MonitoringPoint = DataCapturePointCode; |
| | | // wplog.WorkPieceID = "123456"; |
| | | // wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | // wplog.CreatedUserName = DataCapturePointCode; |
| | | // wplog.IsDeleted = false; |
| | | // foreach (var col in colConfig) |
| | | // { |
| | | // switch(col.DbNumber+ col.Offset) |
| | | // { |
| | | // case "": |
| | | // var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | // wplog.WorkPieceID = valuecol.ToString(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | // WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | // //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | // //反馈给PLC,写入 |
| | | |
| | | |
| | | // } |
| | | // //SystemValue.value_OP8007 = value.ToString(); |
| | | |
| | | |
| | | // } |
| | | // SystemValue.lbl_Alert_OP8007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | // if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | // { |
| | | // Thread.Sleep(5000); |
| | | // } |
| | | // else |
| | | // { |
| | | // Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | // } |
| | | |
| | | // } |
| | | // catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // SystemValue._lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} OP80工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "刷新 OP80工序监控打码标记数据时异常:", ex); |
| | | // SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | // Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | //} |
| | | } |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | // Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | // } |
| | | // } |
| | | |
| | | public override void DataCaptureStart() |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | | wplog.WorkPieceID = WorkPieceID; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | |
| | | wplog.AlertTime = DateTime.Now; |
| | | Random ran = new Random(); |
| | | //wplog.FailureType = "1101"+ ran.Next(0,100); |
| | | wplog.AlertMsg = "测试告警 1101"; |
| | | |
| | | wplog.EquipmentCurrentState = ((int)EnumEquipmentCurrentStateDisplay.生产).ToString(); |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | return; |
| | | } |
| | | if (IsCaptureflag) |
| | | { |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | if (plcService == null) |
| | | { |
| | | SystemValue.lbl_Alert_OP8007 = $"{RandomHelper.GenerateRandomCode(4)} 没有找到{_dataCaptureConfig.WorkingProcedure}的PLC设备"; |
| | | return; |
| | | } |
| | | if (plcService != null && !plcService.IsConnected) |
| | | { |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | } |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | //_dataCaptureConfig |
| | | if (plcService == null || !plcService.IsConnected) |
| | | { |
| | | SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} {_dataCaptureConfig.WorkingProcedure} PLC连接已断开,正在尝试打开!"; |
| | | plcService.Close(); |
| | | plcService.OpenService(); |
| | | Thread.Sleep(100); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | var value = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType)); |
| | | if (SystemValue.value_OP8007.Equals("0") && value.ToString().Equals("1")) |
| | | {//当上一标记位0,当前获取标记为1时, |
| | | //触发操作, 并给静态变量赋值为1 |
| | | //业务代码 |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | foreach (var col in colConfig) |
| | | { |
| | | switch(col.DbNumber+ col.Offset) |
| | | { |
| | | case "": |
| | | var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | wplog.WorkPieceID = valuecol.ToString(); |
| | | break; |
| | | } |
| | | } |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.AlertMonitor(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | |
| | | |
| | | //判断是否跳序,上一工序质量是否合格 |
| | | |
| | | |
| | | |
| | | //反馈给PLC,写入 |
| | | |
| | | |
| | | } |
| | | //SystemValue.value_OP8007 = value.ToString(); |
| | | |
| | | |
| | | } |
| | | SystemValue.lbl_Alert_OP8007 = $"abcdefg:{RandomHelper.GenerateRandomCode(4)}"; |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(_dataCaptureConfig.DataCaptureFrequency.Value); |
| | | } |
| | | |
| | | } |
| | | catch (System.Data.Entity.Validation.DbEntityValidationException ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} 读取{WorkingProcedure}工序监控打码标记 出现异常,请查看日志!"; |
| | | Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读取 {WorkingProcedure}工序监控打码标记数据时异常:", ex); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | SystemValue.lbl_Alert_OP8007 = $" {RandomHelper.GenerateRandomCode(4)} {WorkingProcedure}工序监控打码标记 不做校验,请确认配置信息!"; |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), "读{WorkingProcedure}工序监控打码标记 不做校验,请确认是否配置异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } |
| | | //} |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | //特殊处理OP50 【Editby shaocx,2024-08-16】 |
| | | string sideValue = GetSideForOP50(plcService, wplog); |
| | | wplog.MonitoringPoint += sideValue; |
| | | wplog.CreatedUserName = wplog.MonitoringPoint; |
| | | //wplog.CreatedUserName = wplog.MonitoringPoint; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.MonitoringPoint, DataCapturePointCname); |
| | | |
| | | //读取二维码后更新数据库 |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); |
| | |
| | | logMiddle.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | logMiddle.Remarks = WorkingProcedure; |
| | | logMiddle.MonitoringPoint = DataCapturePointCode; |
| | | //logMiddle.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref logMiddle, DataCapturePointCode, DataCapturePointCname); |
| | | logMiddle.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | logMiddle.CreatedUserName = DataCapturePointCode; |
| | | logMiddle.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | logMiddle.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | logMiddle.IsDeleted = false; |
| | |
| | | SystemValue.OP20_Side_Value = sideValue; |
| | | } |
| | | logMiddle.MonitoringPoint += SystemValue.OP20_Side_Value; |
| | | logMiddle.CreatedUserName = logMiddle.MonitoringPoint; |
| | | //logMiddle.CreatedUserName = logMiddle.MonitoringPoint; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref logMiddle, logMiddle.MonitoringPoint, DataCapturePointCname); |
| | | |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{DataCapturePointCode}下线完成,是指定的工件{logMiddle.WorkPieceID},工位{gongweiStr},校验通过,读取Op60_Place_Flag:true"); |
| | | |
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | |
| | | //wplog.WorkPieceID = "123456"; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | |
| | | //wplog.WorkPieceID = "123456"; |
| | | |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | wplog.WorkPieceID = "123456"; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | |
| | | { |
| | | if (SystemValue.isStartedImitateModel) |
| | | { |
| | | /* |
| | | var plcService = PLCManger.GetSinglePLCService(_dataCaptureConfig); |
| | | WorkPieceLogMiddle wplog = new WorkPieceLogMiddle(); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | |
| | | wplog.UpdatedUserName = DataCapturePointCode; |
| | | //更新WorkPieceInfo表以及插入WorkPieceLog表和WorkPieceInfoLog表 |
| | | WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); |
| | | /**/ |
| | | |
| | | return; |
| | | } |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.IsDeleted = false; |
| | |
| | | wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.IsDeleted = false; |
| | | |
| | | |
| | |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID;; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | //wplog.EquipmentID = WorkingProcedure; |
| | | wplog.Remarks = "cs"; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.IsDeleted = false; |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.IsDeleted = false; |
| | |
| | | if (valuecola.ToString().ToUpper().Equals("TRUE")) |
| | | { |
| | | wplog.CreatedUserName = "OP6002AA"; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.CreatedUserName, DataCapturePointCname); |
| | | code = plcService.ReadValuePointV2("DB2050.52.0", typeof(string), 22)?.ToString(); |
| | | quality = plcService.ReadValuePointV2("DB2050.6.0", typeof(string), 2)?.ToString(); |
| | | } |
| | | else if (valuecolb.ToString().ToUpper().Equals("TRUE")) |
| | | { |
| | | wplog.CreatedUserName = "OP6002BB"; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.CreatedUserName, DataCapturePointCname); |
| | | code = plcService.ReadValuePointV2("DB2050.76.0", typeof(string), 22)?.ToString(); |
| | | quality = plcService.ReadValuePointV2("DB2050.6.0", typeof(string), 2)?.ToString(); |
| | | } |
| | | else if (valuecolc.ToString().ToUpper().Equals("TRUE")) |
| | | { |
| | | wplog.CreatedUserName = "OP6002CC"; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.CreatedUserName, DataCapturePointCname); |
| | | code = plcService.ReadValuePointV2("DB2050.100.0", typeof(string), 22)?.ToString(); |
| | | quality = plcService.ReadValuePointV2("DB2050.6.0", typeof(string), 2)?.ToString(); |
| | | } |
| | | else if (valuecold.ToString().ToUpper().Equals("TRUE")) |
| | | { |
| | | wplog.CreatedUserName = "OP6002DD"; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.CreatedUserName, DataCapturePointCname); |
| | | code = plcService.ReadValuePointV2("DB2050.124.0", typeof(string), 22)?.ToString(); |
| | | quality = plcService.ReadValuePointV2("DB2050.6.0", typeof(string), 2)?.ToString(); |
| | | } |
| | | else |
| | | { |
| | | wplog.CreatedUserName = "OP6002EE"; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.CreatedUserName, DataCapturePointCname); |
| | | } |
| | | |
| | | wplog.WorkPieceID = code; |
| | |
| | | logMiddle.EquipmentID = _dataCaptureConfig.EquipmentID; ; |
| | | logMiddle.Remarks = logMiddle.WorkingProcedure; |
| | | logMiddle.MonitoringPoint = _DataCapturePointCode; |
| | | //logMiddle.CreatedUserName = _DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref logMiddle, DataCapturePointCode, DataCapturePointCname); |
| | | logMiddle.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | logMiddle.CreatedUserName = _DataCapturePointCode; |
| | | logMiddle.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | logMiddle.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | logMiddle.IsDeleted = false; |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName+"自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | wplog.WorkingProcedure = WorkingProcedure; |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | wplog.EquipmentID = _dataCaptureConfig.EquipmentID; |
| | | wplog.Remarks = WorkingProcedure; |
| | | wplog.MonitoringPoint = DataCapturePointCode; |
| | | //wplog.CreatedUserName = DataCapturePointCode; |
| | | SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, DataCapturePointCode, DataCapturePointCname); |
| | | wplog.CreatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.CreatedUserName = DataCapturePointCode; |
| | | wplog.UpdatedTime = DateTimeHelper.GetDateTime(); |
| | | wplog.UpdatedUserName = Environment.MachineName + "自动" + Thread.CurrentThread.ManagedThreadId.ToString(); |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime(); |
| | |
| | | /// </summary> |
| | | public class SystemBussinessHelper |
| | | { |
| | | /// <summary> |
| | | /// 设置WorkPieceLog 的创建人 |
| | | /// </summary> |
| | | /// <param name="workPieceLog"></param> |
| | | /// <param name="_DataCapturePointCode"></param> |
| | | /// <param name="_DataCapturePointName"></param> |
| | | public static void SetWorkPieceLogMiddleForCreatedUserName(ref WorkPieceLogMiddle workPieceLog, string _DataCapturePointCode, string _DataCapturePointName) |
| | | { |
| | | workPieceLog.CreatedUserName = _DataCapturePointCode; |
| | | workPieceLog.DataCapturePointCname = _DataCapturePointName; |
| | | } |
| | | /// <summary> |
| | | /// 设置WorkPieceLog 的创建人 |
| | | /// </summary> |
| | | /// <param name="workPieceLog"></param> |
| | | /// <param name="_DataCapturePointCode"></param> |
| | | /// <param name="_DataCapturePointName"></param> |
| | | public static void SetWorkPieceLogMiddleForCreatedUserName(ref WorkPieceLog workPieceLog, string _DataCapturePointCode, string _DataCapturePointName) |
| | | { |
| | | workPieceLog.CreatedUserName = _DataCapturePointCode; |
| | | workPieceLog.DataCapturePointCname = _DataCapturePointName; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置WorkPieceLog 的更新人 |
| | | /// </summary> |
| | | /// <param name="workPieceLog"></param> |
| | | /// <param name="_DataCapturePointCode"></param> |
| | | /// <param name="_DataCapturePointName"></param> |
| | | public static void SetWorkPieceLogMiddleForUpdatedUserName(ref WorkPieceLogMiddle workPieceLog, string _DataCapturePointCode, string _DataCapturePointName) |
| | | { |
| | | workPieceLog.UpdatedUserName = _DataCapturePointCode; |
| | | workPieceLog.UpdateDataCapturePointCname = _DataCapturePointName; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 是否允许修改WorkPieceState 为WIP |
| | |
| | | private void button9_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP3001.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP3001.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button11_Click(object sender, EventArgs e) |
| | |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP3003.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP3003.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button15_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP3007.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP3007.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button13_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP3004.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP3004.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button14_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP3005.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP3005.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button16_Click(object sender, EventArgs e) |
| | |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP8001.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP8001.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button21_Click(object sender, EventArgs e) |
| | |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP8003.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP8003.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button19_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP8004.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP8004.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button18_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP8005.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP8005.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | private void button17_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | |
| | | try |
| | | { |
| | | if (!SystemValue.isStartedImitateModel) |
| | | { |
| | | MessageBox.Show("请点击调试模式按钮"); |
| | | return; |
| | | } |
| | | DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | DataCaptureHandler_OP8007.Instance.DataCaptureStart(); |
| | | //try |
| | | //{ |
| | | // if (!SystemValue.isStartedImitateModel) |
| | | // { |
| | | // MessageBox.Show("请点击调试模式按钮"); |
| | | // return; |
| | | // } |
| | | // DataCaptureHandler.WorkPieceID = textBox10.Text.Trim(); |
| | | // DataCaptureHandler_OP8007.Instance.DataCaptureStart(); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MessageBox.Show($"模拟异常:{ex.Message}"); |
| | | // Log4NetHelper.WriteErrorLog(LogType.FormMain, "----button10_Click all报错:", ex); |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | [StringLength(255)] |
| | | public string OP80NewCode { get; set; } |
| | | |
| | | |
| | | [StringLength(50)] |
| | | public string DataCapturePointCname { get; set; } |
| | | |
| | | [StringLength(50)] |
| | | public string UpdateDataCapturePointCname { get; set; } |
| | | } |
| | | } |
| | |
| | | [StringLength(32)] |
| | | public string WorkingProcedure { get; set; } |
| | | |
| | | [StringLength(32)] |
| | | public string MonitoringPoint { get; set; } |
| | | |
| | | |
| | | public int? QualityState { get; set; } |
| | | |
| | |
| | | |
| | | public long? CreatedUserId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 工序创建人,值等于 CreatedUserName |
| | | /// </summary> |
| | | [StringLength(32)] |
| | | public string MonitoringPoint { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 工序创建人,值等于MonitoringPoint |
| | | /// </summary> |
| | | [StringLength(50)] |
| | | public string CreatedUserName { get; set; } |
| | | |
| | | |
| | | [StringLength(50)] |
| | | public string DataCapturePointCname { get; set; } |
| | | |
| | | [StringLength(50)] |
| | | public string UpdateDataCapturePointCname { get; set; } |
| | | |
| | | public long? UpdatedUserId { get; set; } |
| | | |
| | | [StringLength(50)] |
| | |
| | | /// 获取QC数据标记描述 【Editby shaocx,2024-06-15】 |
| | | /// </summary> |
| | | public string GetQcDataFlag_Remark { get; set; } |
| | | |
| | | |
| | | [StringLength(50)] |
| | | public string DataCapturePointCname { get; set; } |
| | | |
| | | [StringLength(50)] |
| | | public string UpdateDataCapturePointCname { get; set; } |
| | | } |
| | | } |