| | |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + true + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_DataFinish); |
| | | return false; |
| | | } |
| | | int i_result = 0; |
| | |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + value + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_DataFinish); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | { |
| | | msg = ex.Message; |
| | | var logcontext = string.Format("向Station地址{0} " + value + "出现异常:" + JsonConvert.SerializeObject(ex), |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | ""); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | public bool InboundFinishConfirm(string stationCode, out string msg) |
| | | { |
| | | try |
| | | { |
| | | msg = ""; |
| | | var stationObj = this.DBBlockForWrite.W_StationForWriteCommList.Where(x => x.StationCode == stationCode).FirstOrDefault(); |
| | | |
| | | var view_stationObj = this.View.W_StationForWriteCommList.Where(x => x.StationCode == stationCode).FirstOrDefault(); |
| | | MessageModel b2 = this.plcService.WriteValuePoint(stationObj.W_InboundFinishConfirm, true, view_stationObj.W_DataFinish); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + true + "失败,返回结果:" + b2.resMsg, |
| | | stationObj.W_InboundFinishConfirm); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | var logcontext = string.Format("向Statio 入库完成确认 出现异常:" + JsonConvert.SerializeObject(ex), |
| | | ""); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); |
| | | return false; |
| | | } |
| | |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 读码解析完成 " + true + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_DataFinish); |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 库位号 " + toPlaceNo + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_Destination_In); |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 长度 " + length + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_Length); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(stationObj.W_Width, width, view_stationObj.W_Width); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 宽度 " + width + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_Width); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(stationObj.W_Height, height, view_stationObj.W_Height); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 高度 " + height + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_1015_ReScan); |
| | | stationObj.W_Height); |
| | | return false; |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public bool WriteStation_FinishACK(int deviceId, bool value, int plcTaskId, out string msg) |
| | | { |
| | | try |
| | | { |
| | | msg = ""; |
| | | Thread.Sleep(1000);//停留2秒 |
| | | MessageModel b2 = this.plcService.WriteValuePoint(this.DBBlockForWrite.W_Station_FinishACK, value, this.View.W_Station_FinishACK); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + value + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_Station_FinishACK); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | //重新再读取,判断是否写入正确,如果写入不正确,就认为失败 【Editby shaocx,2023-04-03】 |
| | | Thread.Sleep(1000);//停留3秒 |
| | | bool finishStation = (bool)this.plcService.ReadValuePoint(this.DBBlockForRead.R_Station_Finish, typeof(bool)); |
| | | bool finisAck = (bool)this.plcService.ReadValuePoint(this.DBBlockForWrite.W_Station_FinishACK, typeof(bool)); |
| | | if (finisAck == false && finishStation == true) |
| | | { |
| | | this.plcService.WriteValuePoint(this.DBBlockForWrite.W_Station_FinishACK, value, this.View.W_Station_FinishACK);//重发一次 20230503 王铮 |
| | | Thread.Sleep(1000);//停留2秒 |
| | | finishStation = (bool)this.plcService.ReadValuePoint(this.DBBlockForRead.R_Station_Finish, typeof(bool)); |
| | | finisAck = (bool)this.plcService.ReadValuePoint(this.DBBlockForWrite.W_Station_FinishACK, typeof(bool)); |
| | | if (finisAck == false && finishStation == true) |
| | | { |
| | | |
| | | msg = string.Format("向Station地址{0} 写 " + value + "失败,SDA返回结果:true,但是SDA再次读取PLC的地址时,获取的结果是FALSE,即认定为写入失败", |
| | | this.DBBlockForWrite.W_Station_FinishACK); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | Log4NetHelper.WriteInfoLog(Station_CacheEntity.curLogType, "写入W_Station_FinishACK(" + this.DBBlockForWrite.W_Station_FinishACK + ")值为" + value + "成功!因为PLC任务号:" + plcTaskId); |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | var logcontext = string.Format("向Station地址{0} " + value + "出现异常:" + JsonConvert.SerializeObject(ex), |
| | | this.DBBlockForWrite.W_Station_FinishACK); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); |
| | | return false; |
| | | } |
| | | msg = ""; |
| | | return false; |
| | | } |
| | | |
| | | |
| | |
| | | public bool WriteScanValidateACK(bool isReset, int deviceId, string stationCode, bool value, int plcTaskId, out string msg) |
| | | { |
| | | msg = ""; |
| | | MessageModel b2 = null; |
| | | string address_fail = ""; |
| | | string address_success = ""; |
| | | try |
| | | { |
| | | switch (stationCode) |
| | | { |
| | | case "1002": |
| | | address_fail = this.DBBlockForWrite.W_1002_ScanFailACK; |
| | | address_success = this.DBBlockForWrite.W_1002_ScanSuccessACK; |
| | | break; |
| | | case "1004": |
| | | address_fail = this.DBBlockForWrite.W_1004_ScanFailACK; |
| | | address_success = this.DBBlockForWrite.W_1004_ScanSuccessACK; |
| | | break; |
| | | case "1006": |
| | | address_fail = this.DBBlockForWrite.W_1006_ScanFailACK; |
| | | address_success = this.DBBlockForWrite.W_1006_ScanSuccessACK; |
| | | break; |
| | | case "1007": |
| | | address_fail = this.DBBlockForWrite.W_1007_ScanFailACK; |
| | | address_success = this.DBBlockForWrite.W_1007_ScanSuccessACK; |
| | | break; |
| | | default: |
| | | throw new Exception("不支持的站点"); |
| | | } |
| | | if (isReset) |
| | | {//是重置 |
| | | b2 = this.plcService.WriteValuePoint(address_success, false, this.View.W_1002_ScanSuccessACK); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + false + "失败,返回结果:" + b2.resMsg, |
| | | address_success); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(address_fail, false, this.View.W_1002_ScanFailACK); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + false + "失败,返回结果:" + b2.resMsg, |
| | | address_fail); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | {//不是重置 |
| | | if (value) |
| | | {//表示扫描验证通过 |
| | | b2 = this.plcService.WriteValuePoint(address_success, true, this.View.W_1002_ScanSuccessACK); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + true + "失败,返回结果:" + b2.resMsg, |
| | | address_success); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | {//表示扫描验证不通过 |
| | | b2 = this.plcService.WriteValuePoint(address_fail, true, this.View.W_1002_ScanFailACK); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + true + "失败,返回结果:" + b2.resMsg, |
| | | address_fail); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Log4NetHelper.WriteInfoLog(Station_CacheEntity.curLogType, "WriteScanFailACK方法,写入 四个入库口扫描失败ACK赋值 ScanFailACK(" + address_fail + ")值为" + value + "成功!因为PLC任务号:" + plcTaskId + ",isReset:" + isReset); |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | var logcontext = string.Format("WriteScanFailACK方法,向Station地址{0} " + value + "出现异常:" + JsonConvert.SerializeObject(ex), |
| | | address_fail); |
| | | if (value) |
| | | { |
| | | logcontext = string.Format("WriteScanFailACK方法,向Station地址{0} " + value + "出现异常:" + JsonConvert.SerializeObject(ex), |
| | | address_success); |
| | | } |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | |
| | | try |
| | | { |
| | | msg = ""; |
| | | MessageModel b2 = this.plcService.WriteValuePoint(this.DBBlockForWrite.W_Out_MaterialModel, value__Out_MaterialModel, this.View.W_Out_MaterialModel); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + value__Out_MaterialModel + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_Out_MaterialModel); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(this.DBBlockForWrite.W_Out_OrderNo, value_Out_OrderNo, this.View.W_Out_OrderNo); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + value_Out_OrderNo + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_Out_OrderNo); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(this.DBBlockForWrite.W_Out_SerialNumber, value_Out_SerialNumber, this.View.W_Out_SerialNumber); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station地址{0} 写 " + value_Out_SerialNumber + "失败,返回结果:" + b2.resMsg, |
| | | this.DBBlockForWrite.W_Out_SerialNumber); |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | Log4NetHelper.WriteInfoLog(Station_CacheEntity.curLogType, $"写入 发动机出库,给西港PLC发送发动机数据成功!任务号{plcTaskId},机型{value__Out_MaterialModel},订货号{value_Out_OrderNo},编号{value_Out_SerialNumber}" + plcTaskId); |
| | | return true; |
| | | } |
| | | catch (Exception ex) |