From 76fc40d4f1e0dbd15383c0f3e29fd8bcb6dcff2a Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周五, 22 11月 2024 19:01:50 +0800 Subject: [PATCH] 2 --- CC/iWareCC_ASRS/FormCC.cs | 247 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 203 insertions(+), 44 deletions(-) diff --git a/CC/iWareCC_ASRS/FormCC.cs b/CC/iWareCC_ASRS/FormCC.cs index 115e906..dae98d6 100644 --- a/CC/iWareCC_ASRS/FormCC.cs +++ b/CC/iWareCC_ASRS/FormCC.cs @@ -1,31 +1,28 @@ -锘縰sing iWareCC.BLL; -using iWareCC.Common.Helper; +锘縰sing iWareCC.Common.Helper; using iWareCC.DeviceThreadFactory; using iWareCC.Forms; using iWareCC.RgvService; using iWareCC.SrmService; +using iWareCC.StationService; +using iWareCC.ThreadService; using iWareCC.WCF; -using iWareCommon; using iWareCommon.Common.Globle; using iWareCommon.Utils; using iWareModel; using iWareModel.Entity.AGV; using iWareSql.DataAccess; using iWareSql.DBModel; -using iWareSql.Orm; +using iWareSql.WmsDBModel; using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Linq.Expressions; using System.Net; using System.ServiceModel; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; using XiGang.Core.Model; using XiGang.Core.Model.ViewModels; @@ -34,6 +31,12 @@ { public partial class FormCC : Form { + + /// <summary> + /// 鍏ㄥ眬鈥旀槸鍚﹀彲浠ヨ繍琛屾墽琛屽嚭搴撴ā寮� + /// </summary> + public static bool IsAllowRunOutMode = false; + /// <summary> /// 1鍙峰爢鍨涙満鍏ュ簱鍙f壂鐮佸己鍒堕獙璇侀�氳繃 /// </summary> @@ -121,6 +124,9 @@ public static RgvView rgvView;//Rgv瀹炰綋绫� public static RgvService.RgvServiceClient rgvServiceClient = null; + + public static StationView stationView;//绔欑偣瀹炰綋绫� + public static StationServiceClient stationServiceClient = null; public FormCC() { InitializeComponent(); @@ -182,6 +188,9 @@ tskGetRgv1Info = new Thread(GetRgvInfo); tskGetRgv1Info.Start(); + var tskGetStationInfo = new Thread(GetStationInfo); + tskGetStationInfo.Start(); + //鍫嗗灈鏈篣I璧嬪�� SetSrmUI(); @@ -197,39 +206,35 @@ #region 鏈嶅姟绾跨▼鍚姩 //鍫嗗灈鏈轰换鍔℃湇鍔$嚎绋嬪惎鍔� - var srmService = DeviceThreadServiceFactory.GetHandle(EDeviceType.鍫嗗灈鏈�); - srmService.StartService(); + //var srmService = DeviceThreadServiceFactory.GetHandle(EDeviceType.鍫嗗灈鏈�); + // srmService.StartService(); //RGV浠诲姟鏈嶅姟绾跨▼鍚姩 - var rgvService = DeviceThreadServiceFactory.GetHandle(EDeviceType.RGV); - rgvService.StartService(); + //var rgvService = DeviceThreadServiceFactory.GetHandle(EDeviceType.RGV); + // rgvService.StartService(); //澶勭悊銆愪笅鍙戜腑銆戠殑鍑哄簱璁″垝浠诲姟 - new Thread(OutPlanTaskDecompose.HandlerIssuingTask).Start(); + // new Thread(OutPlanTaskDecompose.HandlerIssuingTask).Start(); //浠诲姟鍒嗚В绾跨▼-鍑哄簱 - new Thread(MainTaskDecompose.HandlerMainTaskDecompose).Start(); + // new Thread(MainTaskDecompose.HandlerMainTaskDecompose).Start(); //浠诲姟鍒嗚В绾跨▼-缁勭洏鍏ュ簱 - new Thread(MainTaskDecompose_ZPRK.HandlerMainTaskDecompose_ZPRK).Start(); + // new Thread(MainTaskDecompose_ZPRK.HandlerMainTaskDecompose_ZPRK).Start(); - //绌烘墭鐩樿浆杩愪换鍔� - new Thread(EmptySalverTransferTask.Handler).Start(); + new Thread(DataProcess_RobotBuffer_FinishTaskForOutbound.Handler).Start(); //鑷姩缁勭洏浠诲姟 - new Thread(AutoSalverMaterialBindTask.Handler).Start(); + new Thread(DataProcess_RobotBuffer_FinishTask.Handler).Start(); - //鑷姩缁勭洏涓嬪彂浠诲姟 - new Thread(AutoIssueInStoreTask.Handler).Start(); + new Thread(DataProcess_BZ01.Handler).Start(); //閲嶆柊鑾峰彇鍙戝姩鏈轰俊鎭� - new Thread(AutoUpdateEngineInfoTask.Handler).Start(); + new Thread(DataProcess_269.Handler).Start(); //1014搴撲綅杞繍鍒�1020绾跨▼ - new Thread(Place1014To1020Task.Handler).Start(); + new Thread(DataProcess_BZ39.Handler).Start(); - ////1009搴撲綅澧炲姞搴撳瓨绾跨▼ - //new Thread(Place1009AddStoreTask.Handler).Start(); new Thread(DeleteData).Start(); @@ -240,12 +245,12 @@ //*/ #endregion - new Thread(GetAgvVehicles).Start();//AGV杞﹁締淇℃伅 + // new Thread(GetAgvVehicles).Start();//AGV杞﹁締淇℃伅 - new Thread(OutTaskRetryToMes.Handler).Start(); + // new Thread(OutTaskRetryToMes.Handler).Start(); //鏆傛椂涓嶅惎鐢ㄨ櫄鎷熷嚭鍏ュ簱鍔熻兘 - new Thread(VirtualTaskNoOutPlanTaskHandler.Handler).Start(); + // new Thread(VirtualTaskNoOutPlanTaskHandler.Handler).Start(); } private void FormCC_Load(object sender, EventArgs e) { @@ -302,7 +307,7 @@ } else {//姝e紡妯″紡 - rgvServiceClient = new RgvServiceClient(); + stationServiceClient = new StationServiceClient(); } this.lbl_IsSimulationPLC.BackColor = IsSimulationPLC ? Color.Red : Color.Green; @@ -344,23 +349,23 @@ this.lbl_Alert_HandlerIssuingTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_HandlerIssuingTask; - this.lbl_Alert_VirtualTaskNoOutPlanTaskHandler.Text = showNowTime + SystemWarningMsg._lbl_Alert_VirtualTaskNoOutPlanTaskHandler; + this.lbl_Alert_DataProcess_RobotBuffer_FinishTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask; this.lbl_MainTaskDecompose.Text = showNowTime + SystemWarningMsg._lbl_Alert_MainTaskDecompose; this.lbl_MainTaskDecompose_ZPRK.Text = showNowTime + SystemWarningMsg._lbl_Alert_MainTaskDecompose_ZPRK; - this.lbl_Alert_LineInScan.Text = showNowTime + SystemWarningMsg._lbl_Alert_LineInScan; + this.lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound; this.lbl_Alert_DeleteData.Text = showNowTime + SystemWarningMsg._lbl_Alert_DeleteData; this.lbl_Alert_EmptySalverTransfer.Text = showNowTime + SystemWarningMsg._lbl_Alert_EmptySalverTransfer; - this.lbl_alert_AutoSalverMaterialBindTask.Text = showNowTime + SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask; + this.lbl_alert_DataProcess_BZ39.Text = showNowTime + SystemWarningMsg._lbl_alert_DataProcess_BZ39; - this.lbl_alert_AutoIssueInStoreTask.Text = showNowTime + SystemWarningMsg._lbl_alert_AutoIssueInStoreTask; + this.lbl_alert_DataProcess_BZ01.Text = showNowTime + SystemWarningMsg._lbl_alert_DataProcess_BZ01; - this.lbl_alert_AutoUpdateEngineInfoTask.Text = showNowTime + SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask; + this.lbl_alert_DataProcess_269.Text = showNowTime + SystemWarningMsg._lbl_alert_DataProcess_269; this.lbl_Alert_Place1014ClearStoreTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_Place1014To1020TaskTask; @@ -727,7 +732,7 @@ { for (int i = 0; i < waringList.Count; i++) { - DeviceWarningHandler.SaveWarning(EDevice.RGV, iWareCommon.Utils.LogType.RgvThreadService, + DeviceWarningHandler.SaveWarning(EDevice.RGV, iWareCommon.Utils.LogType.StationThreadService, waringList[i].Codek__BackingField, waringList[i].Addressk__BackingField, waringList[i].Contextk__BackingField);//鏂板鎶ヨ warningAddressList.Add(waringList[i].Addressk__BackingField); } @@ -737,12 +742,12 @@ { tb_Rgv_Alter.Text = ""; } - DeviceWarningHandler.AutoCloseWarning(EDevice.RGV, iWareCommon.Utils.LogType.RgvThreadService, warningAddressList);//鑷姩鍏抽棴鎶ヨ + DeviceWarningHandler.AutoCloseWarning(EDevice.RGV, iWareCommon.Utils.LogType.StationThreadService, warningAddressList);//鑷姩鍏抽棴鎶ヨ } catch (Exception ex) { rgvView = null; - Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.RgvThreadService, "鑾峰彇RGV淇℃伅鍑虹幇寮傚父:" + ex.Message, ex); + Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.StationThreadService, "鑾峰彇RGV淇℃伅鍑虹幇寮傚父:" + ex.Message, ex); continue; } } @@ -801,9 +806,163 @@ }; realTimeList.Add(obj); } - DeviceRgvRealTimeHandler.Update(realTimeList, iWareCommon.Utils.LogType.RgvThreadService); + DeviceRgvRealTimeHandler.Update(realTimeList, iWareCommon.Utils.LogType.StationThreadService); } + + + #endregion + + #region 绔欑偣绾跨▼鍜孶I澶勭悊 + + /// <summary> + /// 璁剧疆绔欑偣鐨刄I鏄剧ず + /// </summary> + /// <param name="obj"></param> + private void SetStationLable(object obj) + { + while (true) + { + Thread.Sleep(cycleDelay_Device); + try + { + + //lbRgv_Y.Text = "褰撳墠琛岃蛋浣嶇疆: " + rgv.R_RgvPosition; + //lbRgv_X.Text = "褰撳墠鍖哄煙浣嶇疆: " + rgv.R_RgvPosition; + //ERgvState _ERgvState = (ERgvState)Enum.Parse(typeof(ERgvState), rgv.R_State.ToString()); + //lbRgvWorkState.Text = "宸ヤ綔鐘舵��: " + _ERgvState.ToString(); + //lbRgvTaskId.Text = "浠诲姟鍙�: " + rgv.R_TaskNo; + //lbRgvIsAuto.Text = "宸ヤ綔妯″紡: " + (rgv.ModeName); + //lbRgvAlert.Text = rgv.R_AlarmCode.ToString(); + //if (rgv.R_Alarm == false) + //{ + // //妫�娴嬫槸鍚︽湁蹇冭烦 + // using (var rgvService = new RgvService.RgvServiceClient()) + // { + // //妫�娴嬫槸鍚︽湁蹇冭烦 + // var isRgvHandShare = RgvBLL.IsRgvHandShare(rgvService); + // if (!isRgvHandShare) + // { + // lbRgvAlert.Text = "RGV娌℃湁蹇冭烦"; + // } + // } + //} + //else + //{ + // lbRgvAlert.Text = rgv.R_AlarmCode.ToString(); + //} + + //// ERgvEvent _ERgvEvent = (ERgvEvent)Enum.Parse(typeof(ERgvEvent), rgv.r_ev.ToString()); + ////lbRgvEvent.Text = "浜� 浠讹細" + _ERgvEvent.ToString(); + //lbRgvTaskFinish.Text = "浠诲姟瀹屾垚锛�" + rgv.R_TaskFinish; + + } + catch (Exception) + { + continue; + } + } + } + + /// <summary> + /// 鑾峰彇Station淇℃伅 + /// </summary> + /// <param name="obj"></param> + private void GetStationInfo(object obj) + { + while (true) + { + Thread.Sleep(1000);//1绉掗挓璇诲彇涓�娆� + try + { + if (stationServiceClient == null) + { + continue; + } + stationView = stationServiceClient.GetStationInfo((int)EDevice.Station); + + + _CommmonShowAgvStation(); + + + ////鏄剧ずRGV浠诲姟瀹屾垚鍜屽畬鎴愮‘璁や俊鍙� + //this.lbl_R_RGV_Finish.Text = "RGV浠诲姟瀹屾垚:" + rgvView.R_RGV_Finish; + //this.lbl_W_RGV_FinishACK.Text = "RGV浠诲姟瀹屾垚纭:" + rgvView.W_RGV_FinishACK; + + //this.lbl_RgvCoordinate.Text = "RGV瀹炴椂鍧愭爣:" + rgvView.R_RGV_Coordinate; + + /* + //瑙f瀽RGV瀵硅薄 + foreach (var item in rgvView.R_RgvForReadCommList) + { + var control = ControlHelper.GetControlInstance(this.tPTransAsrs, "btn_" + item.StationCode); + if (item.R_AlarmCode > 0) + {//鏈夋姤璀� + if (control != null) + { + var btn = control as Button; + btn.BackColor = Color.Red; + } + } + else + { + if (control != null) + { + var btn = control as Button; + if (item.StationCode == ((int)EDevice.RGV1040).ToString()) + { + btn.BackColor = Color.Gold; + } + else if (item.StationCode == ((int)EDevice.鎷嗙洏鏈�1020).ToString()) + { + btn.BackColor = Color.DodgerBlue; + } + else if (item.StationCode == ((int)EDevice.鎻愬崌鏈�1030).ToString()) + { + btn.BackColor = Color.SteelBlue; + } + else + { + btn.BackColor = Color.SeaGreen; + } + } + } + } + + //鏄剧ずRGV鎶ヨ淇℃伅 + List<String> warningAddressList = new List<string>(); + if (rgvView.R_Rgv_WarningDBList != null && rgvView.R_Rgv_WarningDBList.Length > 0) + { + tb_Rgv_Alter.Text = String.Join(",", rgvView.R_Rgv_WarningDBList.Select(x => x.Contextk__BackingField).ToArray()); + //淇濆瓨鎶ヨ + var waringList = rgvView.R_Rgv_WarningDBList.ToList(); + if (waringList != null && waringList.Count > 0) + { + for (int i = 0; i < waringList.Count; i++) + { + DeviceWarningHandler.SaveWarning(EDevice.RGV, iWareCommon.Utils.LogType.RgvThreadService, + waringList[i].Codek__BackingField, waringList[i].Addressk__BackingField, waringList[i].Contextk__BackingField);//鏂板鎶ヨ + warningAddressList.Add(waringList[i].Addressk__BackingField); + } + } + } + else + { + tb_Rgv_Alter.Text = ""; + } + DeviceWarningHandler.AutoCloseWarning(EDevice.RGV, iWareCommon.Utils.LogType.RgvThreadService, warningAddressList);//鑷姩鍏抽棴鎶ヨ + + //*/ + } + catch (Exception ex) + { + rgvView = null; + Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.StationThreadService, "鑾峰彇绔欑偣淇℃伅鍑虹幇寮傚父:" + ex.Message, ex); + continue; + } + } + } + #endregion @@ -1422,13 +1581,13 @@ DoCommonCheckedChanged(ref SystemValue.isAllowRuning_HandlerIssuingTask, ckHandlerIssuingTask); - DoCommonCheckedChanged(ref SystemValue.isAllowRuning_VirtualTaskNoOutPlanTaskHandler, ck_VirtualTaskNoOutPlanTaskHandler); + DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTask, ck_DataProcess_RobotBuffer_FinishTask); DoCommonCheckedChanged(ref SystemValue.isAllowRuning_MainTaskDecompose, ckMainTaskDecompose); DoCommonCheckedChanged(ref SystemValue.isAllowRuning_MainTaskDecompose_ZPRK, ckMainTaskDecompose_ZPRK); - DoCommonCheckedChanged(ref SystemValue.isAllowRuning_LineInScan, checkBox_LineInScan); + DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTaskForOutbound, checkBox_DataProcess_RobotBuffer_FinishTaskForOutbound); DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DeleteData, ckDeleteData); @@ -1437,11 +1596,11 @@ DoCommonCheckedChanged(ref SystemValue.isAllowRuning_EmptySalverTransfer, ckEmptySalverTransfer); - DoCommonCheckedChanged(ref SystemValue.isAllowRuning_AutoSalverMaterialBindTask, ck_AutoSalverMaterialBindTask); + DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_BZ39, ck_DataProcess_BZ39); - DoCommonCheckedChanged(ref SystemValue.isAllowRuning_AutoIssueInStoreTask, ck_AutoIssueInStoreTask); + DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_BZ01, ck_AutoIssueInStoreTask); - DoCommonCheckedChanged(ref SystemValue.isAllowRuning_AutoUpdateEngineInfoTask, ck_AutoUpdateEngineInfoTask); + DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_269, ck_DataProcess_269); DoCommonCheckedChanged(ref SystemValue.isAllowRuning_Place1014To1020Task, ckPlace1014ClearStoreTask); @@ -1563,7 +1722,7 @@ DialogResult dr = MessageBox.Show("纭畾瑕佸惎鍔ㄣ��" + currentCheckModelText + "銆戞ā寮忓悧?", "鍚姩妯″紡", messButton); if (dr == DialogResult.OK)//濡傛灉鐐瑰嚮鈥滅‘瀹氣�濇寜閽� { - using (DbModel edm = new DbModel()) + using (WmsDBModel edm = new WmsDBModel()) { var ccSystem = BasicDataSetHandler.GetCCSystem(edm); if (ccSystem == null) @@ -1622,7 +1781,7 @@ /// <returns></returns> private bool CommonStopService() { - using (DbModel edm = new DbModel()) + using (WmsDBModel edm = new WmsDBModel()) { var ccSystem = BasicDataSetHandler.GetCCSystem(edm); if (ccSystem == null) @@ -1638,7 +1797,7 @@ ccSystem.Machine = string.Empty; ccSystem.LastMachine = Dns.GetHostName(); ccSystem.LastUnLineTime = DateTime.Now; - ccSystem.ModifyTime = DateTime.Now; + ccSystem.UpdateTime = DateTime.Now; int i = edm.SaveChanges(); if (i <= 0) -- Gitblit v1.9.3