From 0eaa55a507f09c22a65b962d726872ece93acff5 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周四, 21 11月 2024 21:26:34 +0800 Subject: [PATCH] 222 --- SDA/iWareSda/Devices/4-Station/StationModel/StationEntity.cs | 207 ++++++++++----------------------------------------- 1 files changed, 40 insertions(+), 167 deletions(-) diff --git a/SDA/iWareSda/Devices/4-Station/StationModel/StationEntity.cs b/SDA/iWareSda/Devices/4-Station/StationModel/StationEntity.cs index 8d0dff3..5841fab 100644 --- a/SDA/iWareSda/Devices/4-Station/StationModel/StationEntity.cs +++ b/SDA/iWareSda/Devices/4-Station/StationModel/StationEntity.cs @@ -199,7 +199,7 @@ if (!b2.result) { msg = string.Format("鍚慡tation鍦板潃{0} 鍐� " + true + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_1015_ReScan); + stationObj.W_DataFinish); return false; } int i_result = 0; @@ -215,7 +215,7 @@ if (!b2.result) { msg = string.Format("鍚慡tation鍦板潃{0} 鍐� " + value + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_1015_ReScan); + stationObj.W_DataFinish); return false; } return true; @@ -224,7 +224,36 @@ { msg = ex.Message; var logcontext = string.Format("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{0} 鍐� " + true + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, + stationObj.W_InboundFinishConfirm); + return false; + } + + return true; + } + catch (Exception ex) + { + msg = ex.Message; + var logcontext = string.Format("鍚慡tatio 鍏ュ簱瀹屾垚纭 鍑虹幇寮傚父:" + JsonConvert.SerializeObject(ex), + ""); Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); return false; } @@ -242,7 +271,7 @@ if (!b2.result) { msg = string.Format("鍚慡tation鍦板潃{0} 鍐� 璇荤爜瑙f瀽瀹屾垚 " + true + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_1015_ReScan); + stationObj.W_DataFinish); return false; } @@ -250,7 +279,7 @@ if (!b2.result) { msg = string.Format("鍚慡tation鍦板潃{0} 鍐� 搴撲綅鍙� " + toPlaceNo + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_1015_ReScan); + stationObj.W_Destination_In); return false; } @@ -258,21 +287,21 @@ if (!b2.result) { msg = string.Format("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{0} 鍐� 楂樺害 " + height + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_1015_ReScan); + stationObj.W_Height); return false; } @@ -298,51 +327,8 @@ /// <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("鍚慡tation鍦板潃{0} 鍐� " + value + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - this.DBBlockForWrite.W_Station_FinishACK); - Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); - return false; - } - //閲嶆柊鍐嶈鍙栵紝鍒ゆ柇鏄惁鍐欏叆姝g‘锛屽鏋滃啓鍏ヤ笉姝g‘锛屽氨璁や负澶辫触 銆怑ditby 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("鍚慡tation鍦板潃{0} 鍐� " + value + "澶辫触,SDA杩斿洖缁撴灉:true锛屼絾鏄疭DA鍐嶆璇诲彇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 + "鎴愬姛锛佸洜涓篜LC浠诲姟鍙�:" + plcTaskId); - return true; - } - catch (Exception ex) - { - msg = ex.Message; - var logcontext = string.Format("鍚慡tation鍦板潃{0} " + value + "鍑虹幇寮傚父:" + JsonConvert.SerializeObject(ex), - this.DBBlockForWrite.W_Station_FinishACK); - Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, logcontext, ex); - return false; - } + msg = ""; + return false; } @@ -356,93 +342,7 @@ 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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{0} 鍐� " + true + "澶辫触,杩斿洖缁撴灉:" + b2.resMsg, - address_fail); - Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, msg, null); - return false; - } - } - } - - Log4NetHelper.WriteInfoLog(Station_CacheEntity.curLogType, "WriteScanFailACK鏂规硶锛屽啓鍏� 鍥涗釜鍏ュ簱鍙f壂鎻忓け璐CK璧嬪�� ScanFailACK锛�" + address_fail + "锛夊�间负" + value + "鎴愬姛锛佸洜涓篜LC浠诲姟鍙�:" + 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; } @@ -646,33 +546,6 @@ 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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{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("鍚慡tation鍦板潃{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, $"鍐欏叆 鍙戝姩鏈哄嚭搴擄紝缁欒タ娓疨LC鍙戦�佸彂鍔ㄦ満鏁版嵁鎴愬姛锛佷换鍔″彿{plcTaskId},鏈哄瀷{value__Out_MaterialModel}锛岃璐у彿{value_Out_OrderNo},缂栧彿{value_Out_SerialNumber}" + plcTaskId); return true; } catch (Exception ex) -- Gitblit v1.9.3