diff --git a/ControlMonitorClient/FrmDeviceStatus.cs b/ControlMonitorClient/FrmDeviceStatus.cs index 7ff2d9c..34fc5a9 100644 --- a/ControlMonitorClient/FrmDeviceStatus.cs +++ b/ControlMonitorClient/FrmDeviceStatus.cs @@ -321,16 +321,19 @@ namespace wcfControlMonitorClient case 0: lblDeviceStatus.Text = "无"; break; + case 3: + lblDeviceStatus.Text = "离线"; + break; case 1: lblDeviceStatus.Text = "取货中(取货申请)"; break; case 2: lblDeviceStatus.Text = "取货完成"; break; - case 3: + case 4: lblDeviceStatus.Text = "放货中(放货申请)"; break; - case 4: + case 5: lblDeviceStatus.Text = "放货完成"; break; case 9: diff --git a/WcfControlMonitorHost/FrmHost.Designer.cs b/WcfControlMonitorHost/FrmHost.Designer.cs index 5dd99fc..1395052 100644 --- a/WcfControlMonitorHost/FrmHost.Designer.cs +++ b/WcfControlMonitorHost/FrmHost.Designer.cs @@ -94,7 +94,7 @@ this.listBox1.HorizontalScrollbar = true; this.listBox1.ItemHeight = 15; this.listBox1.Location = new System.Drawing.Point(16, 56); - this.listBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBox1.Margin = new System.Windows.Forms.Padding(4); this.listBox1.Name = "listBox1"; this.listBox1.ScrollAlwaysVisible = true; this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; @@ -196,7 +196,7 @@ this.tsStatus.Font = new System.Drawing.Font("榛戜綋", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.tsStatus.ForeColor = System.Drawing.Color.Red; this.tsStatus.Location = new System.Drawing.Point(13, 615); - this.tsStatus.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tsStatus.Margin = new System.Windows.Forms.Padding(4); this.tsStatus.Multiline = true; this.tsStatus.Name = "tsStatus"; this.tsStatus.ReadOnly = true; @@ -209,7 +209,7 @@ this.button1.Image = global::wcfControlMonitorClient.Properties.Resources.call_modul_volume_reduce; this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button1.Location = new System.Drawing.Point(727, 569); - this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button1.Margin = new System.Windows.Forms.Padding(4); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(116, 42); this.button1.TabIndex = 1565; @@ -225,7 +225,7 @@ this.listBox2.FormattingEnabled = true; this.listBox2.ItemHeight = 15; this.listBox2.Location = new System.Drawing.Point(884, 56); - this.listBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBox2.Margin = new System.Windows.Forms.Padding(4); this.listBox2.Name = "listBox2"; this.listBox2.Size = new System.Drawing.Size(469, 499); this.listBox2.TabIndex = 1567; @@ -258,7 +258,7 @@ this.button4.Image = global::wcfControlMonitorClient.Properties.Resources.MSN; this.button4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button4.Location = new System.Drawing.Point(1127, 569); - this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button4.Margin = new System.Windows.Forms.Padding(4); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(209, 42); this.button4.TabIndex = 1569; @@ -407,7 +407,7 @@ this.button3.Image = global::wcfControlMonitorClient.Properties.Resources.SCDCNCLL; this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.button3.Location = new System.Drawing.Point(892, 569); - this.button3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button3.Margin = new System.Windows.Forms.Padding(4); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(157, 42); this.button3.TabIndex = 1569; @@ -419,14 +419,14 @@ // timer1 // this.timer1.Enabled = true; - this.timer1.Interval = 10000; + this.timer1.Interval = 5000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // pbF1S7 // this.pbF1S7.Image = global::wcfControlMonitorClient.Properties.Resources.linkerror; this.pbF1S7.Location = new System.Drawing.Point(407, 32); - this.pbF1S7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pbF1S7.Margin = new System.Windows.Forms.Padding(4); this.pbF1S7.Name = "pbF1S7"; this.pbF1S7.Size = new System.Drawing.Size(29, 21); this.pbF1S7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -448,7 +448,7 @@ // this.btcelltest.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btcelltest.Location = new System.Drawing.Point(580, 576); - this.btcelltest.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btcelltest.Margin = new System.Windows.Forms.Padding(4); this.btcelltest.Name = "btcelltest"; this.btcelltest.Size = new System.Drawing.Size(123, 36); this.btcelltest.TabIndex = 2668; @@ -461,7 +461,7 @@ // this.btStopOut.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btStopOut.Location = new System.Drawing.Point(296, 576); - this.btStopOut.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btStopOut.Margin = new System.Windows.Forms.Padding(4); this.btStopOut.Name = "btStopOut"; this.btStopOut.Size = new System.Drawing.Size(123, 36); this.btStopOut.TabIndex = 2667; @@ -474,7 +474,7 @@ // this.btStopIn.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btStopIn.Location = new System.Drawing.Point(427, 576); - this.btStopIn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btStopIn.Margin = new System.Windows.Forms.Padding(4); this.btStopIn.Name = "btStopIn"; this.btStopIn.Size = new System.Drawing.Size(123, 36); this.btStopIn.TabIndex = 2666; @@ -487,7 +487,7 @@ // this.btStopTest.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btStopTest.Location = new System.Drawing.Point(165, 576); - this.btStopTest.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btStopTest.Margin = new System.Windows.Forms.Padding(4); this.btStopTest.Name = "btStopTest"; this.btStopTest.Size = new System.Drawing.Size(123, 36); this.btStopTest.TabIndex = 2665; @@ -500,7 +500,7 @@ // this.btStartTest.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.btStartTest.Location = new System.Drawing.Point(35, 576); - this.btStartTest.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btStartTest.Margin = new System.Windows.Forms.Padding(4); this.btStartTest.Name = "btStartTest"; this.btStartTest.Size = new System.Drawing.Size(123, 36); this.btStartTest.TabIndex = 2664; @@ -521,7 +521,8 @@ // // timer2 // - this.timer2.Interval = 3500; + this.timer2.Enabled = true; + this.timer2.Interval = 1000; this.timer2.Tick += new System.EventHandler(this.Timer2_Tick); // // InOutModelChange @@ -552,7 +553,7 @@ this.Controls.Add(this.button3); this.Controls.Add(this.button1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "FrmHost"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; diff --git a/WcfControlMonitorHost/FrmHost.cs b/WcfControlMonitorHost/FrmHost.cs index 045d6e6..9f748d7 100644 --- a/WcfControlMonitorHost/FrmHost.cs +++ b/WcfControlMonitorHost/FrmHost.cs @@ -1006,10 +1006,12 @@ namespace wcfControlMonitorClient if (mi.S7connectOnline["S7 connection_1"] == 0) { pbF1S7.Image = wcfControlMonitorClient.Properties.Resources.linkok; + SControlMonitor.PLCClient = false; } else { pbF1S7.Image = wcfControlMonitorClient.Properties.Resources.linkerror; + SControlMonitor.PLCClient = true; } //if (mi.S7connectOnline["S7 connection_2"] == 0) //{ @@ -1695,34 +1697,41 @@ namespace wcfControlMonitorClient private void Timer2_Tick(object sender, EventArgs e) { - timer2.Enabled = false; - try + + try { + CStaticClass.WcfControl.UpdateAGVStationMassge(); + } + catch (Exception ex) { - { - //string errtext = string.Empty; - //if (CStaticClass.WcfControl.updatestatus(out errtext) == false) - //{ - // if (tsStatus.Text.IndexOf(errtext) < 0) - // { - // tsStatus.Text += errtext; - // } - //} + } + //timer2.Enabled = false; + //try + + //{ + // //string errtext = string.Empty; + // //if (CStaticClass.WcfControl.updatestatus(out errtext) == false) + // //{ + // // if (tsStatus.Text.IndexOf(errtext) < 0) + // // { + // // tsStatus.Text += errtext; + // // } + // //} - } - catch (Exception ex) - { - if (tsStatus.Text.IndexOf(ex.Message) < 0) - { - tsStatus.Text += ex.Message; - } - } - finally - { - timer2.Enabled = true; - } + //} + //catch (Exception ex) + //{ + // if (tsStatus.Text.IndexOf(ex.Message) < 0) + // { + // tsStatus.Text += ex.Message; + // } + //} + //finally + //{ + // timer2.Enabled = true; + //} } /// /// 瀹氭椂鍣:瀹氭椂鍙戦佸嚭鍏ュ簱妯″紡 diff --git a/WcfControlMonitorLib/SControlMonitor.cs b/WcfControlMonitorLib/SControlMonitor.cs index 3534b74..797819d 100644 --- a/WcfControlMonitorLib/SControlMonitor.cs +++ b/WcfControlMonitorLib/SControlMonitor.cs @@ -64,6 +64,7 @@ namespace WcfControlMonitorLib private Object thisLock = new Object(); DataView dvclient = new DataView();//20161229 string sqlstr = string.Empty; + public static bool PLCClient = false; #endregion /// /// 鏋勯犲嚱鏁 @@ -5285,8 +5286,7 @@ namespace WcfControlMonitorLib {//20120420 errtext = OPCClient.CCommonOPCClient.OpcError; RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("SControlMonitor.DealWithDeviceState鏃讹紝璁㈤槄缁:{0}鍙戠敓寮傚父,{1}锛", deviceindex, errtext)); - OnRefreshMonitor(rmea); - + OnRefreshMonitor(rmea); return false; } errtext = string.Empty; DataView dv = new DataView(); DataView dvsp = new DataView(); DataView dvbc = new DataView(); DataView dvyanshi = new DataView(); @@ -8807,6 +8807,19 @@ namespace WcfControlMonitorLib } return true; } + + + //璁惧绂荤嚎鏃堕渶瑕侀噸缃暟鎹簱AGV绔欏彴鐨勫 + public void UpdateAGVStationMassge() { + + if (!SControlMonitor.PLCClient) + { + StringBuilder sql = new StringBuilder(); + sql.Remove(0, sql.Length); + sql.Append("update T_AGVIOStation set F_AGVIOStatus=0"); + dbo.ExecuteSql(sql.ToString()); + } + } } } diff --git a/webapi/WindowsFormsApp1/APIChannel.cs b/webapi/WindowsFormsApp1/APIChannel.cs index 311ca04..9c07466 100644 --- a/webapi/WindowsFormsApp1/APIChannel.cs +++ b/webapi/WindowsFormsApp1/APIChannel.cs @@ -33,6 +33,8 @@ namespace WindowsFormsApp1 static String ERROR = String.Empty; private static NancyHost _server; static string address = CommonClassLib.AppSettings.GetValue("Serveradderss"); + public static bool Lock2 = false; + //private static ServiceReference1.I_Managely5Client I_ManageClient = new ServiceReference1.I_Managely5Client(); public static void Start() { @@ -137,107 +139,109 @@ namespace WindowsFormsApp1 #region WMS璋冪敤, 鍦ㄦ澶勭悊锛屽彇娑堜换鍔 鍗曟潯褰㈠紡 Post["/api/wcs/thirdParty/cancelWmsTask", true] = async (x, ct) => { - dbo.TransBegin(); + try { - var body = this.Request.Body; - int length = (int)body.Length; - byte[] data = new byte[length]; - body.Read(data, 0, length); - string jsonStr = System.Text.Encoding.Default.GetString(data); - CommonClassLib.CCarryConvert.WriteLog("WEBAPI", "鏀跺埌鎶ユ枃", jsonStr.ToString(), ""); - CCallService.WMS_WCS_PARAM_Priority wms_wcs_cancel = Model.JsonHelper.Deserialize(jsonStr); - CCallService.WCS_WMS_PARAM_Priority wcs_wms_cancel = new CCallService.WCS_WMS_PARAM_Priority(); //杩斿洖鐨勬姤鏂 - string err = string.Empty; - string returnJson = string.Empty; - StringBuilder sql = new StringBuilder(); - DataView dv = new DataView(); - DataView dv1 = new DataView(); - if (wms_wcs_cancel != null) - { - //CCallService.CANCEL_DATA canceldata = new CCallService.CANCEL_DATA(); - //canceldata = wms_wcs_cancel.data; - // CCallService.CANCEL_RES_DATA cancelReturn = new CCallService.CANCEL_RES_DATA(); - wms_wcs_cancel.taskId = wms_wcs_cancel.taskId.Trim('D').Trim('C'); - sql.Clear(); - sql.Append("select * from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); - dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; - if (dv.Count == 1)//瀛樺湪闇瑕佸垹闄ょ殑浠诲姟 - { - int stepOk = Convert.ToInt32(dv[0]["FIntoStepOK"]);//鎷嗗垎涓嬪彂 - int FSTATUS = Convert.ToInt32(dv[0]["FSTATUS"]);//浠诲姟鏈墽琛 - if (stepOk == 0)//鏈媶鍒 + + dbo.TransBegin(); + var body = this.Request.Body; + int length = (int)body.Length; + byte[] data = new byte[length]; + body.Read(data, 0, length); + string jsonStr = System.Text.Encoding.Default.GetString(data); + CommonClassLib.CCarryConvert.WriteLog("WEBAPI", "鏀跺埌鎶ユ枃", jsonStr.ToString(), ""); + CCallService.WMS_WCS_PARAM_Priority wms_wcs_cancel = Model.JsonHelper.Deserialize(jsonStr); + CCallService.WCS_WMS_PARAM_Priority wcs_wms_cancel = new CCallService.WCS_WMS_PARAM_Priority(); //杩斿洖鐨勬姤鏂 + string err = string.Empty; + string returnJson = string.Empty; + StringBuilder sql = new StringBuilder(); + DataView dv = new DataView(); + DataView dv1 = new DataView(); + if (wms_wcs_cancel != null) + { + //CCallService.CANCEL_DATA canceldata = new CCallService.CANCEL_DATA(); + //canceldata = wms_wcs_cancel.data; + // CCallService.CANCEL_RES_DATA cancelReturn = new CCallService.CANCEL_RES_DATA(); + wms_wcs_cancel.taskId = wms_wcs_cancel.taskId.Trim('D').Trim('C'); + sql.Clear(); + sql.Append("select * from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); + dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; + if (dv.Count == 1)//瀛樺湪闇瑕佸垹闄ょ殑浠诲姟 { - //鏆備笉鑰冭檻鏁版嵁搴撴墽琛屽垹闄ゆ寚浠ゅけ璐ョ殑鎯呭喌 - sql.Clear(); - sql.Append("delete from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); - dbo.ExecuteSql(sql.ToString()); - //鍚屾椂杩樿鍒犻櫎IOControl琛ㄧ殑浠诲姟淇℃伅 - sql.Clear(); - sql.Append("delete from IO_CONTROL where MANAGE_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); + int stepOk = Convert.ToInt32(dv[0]["FIntoStepOK"]);//鎷嗗垎涓嬪彂 + int FSTATUS = Convert.ToInt32(dv[0]["FSTATUS"]);//浠诲姟鏈墽琛 + if (stepOk == 0)//鏈媶鍒 + { + //鏆備笉鑰冭檻鏁版嵁搴撴墽琛屽垹闄ゆ寚浠ゅけ璐ョ殑鎯呭喌 + sql.Clear(); + sql.Append("delete from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); + dbo.ExecuteSql(sql.ToString()); + //鍚屾椂杩樿鍒犻櫎IOControl琛ㄧ殑浠诲姟淇℃伅 + sql.Clear(); + sql.Append("delete from IO_CONTROL where MANAGE_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); dbo.ExecuteSql(sql.ToString()); wcs_wms_cancel.code = 0; wcs_wms_cancel.msg = ""; wcs_wms_cancel.data = ""; - } - else if (stepOk == 1 && FSTATUS == 0) { - sql.Clear(); - sql.Append("delete from T_Monitor_Task where F_ManageTaskIndex = '").Append(wms_wcs_cancel.taskId).Append("'"); - dbo.ExecuteSql(sql.ToString()); - sql.Clear(); - sql.Append("delete from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); - var count= dbo.ExecuteSql(sql.ToString()); - //鏆備笉鑰冭檻鏁版嵁搴撴墽琛屽垹闄ゆ寚浠ゅけ璐ョ殑鎯呭喌 + } + else if (stepOk == 1 && FSTATUS == 0) { + sql.Clear(); + sql.Append("delete from T_Monitor_Task where F_ManageTaskIndex = '").Append(wms_wcs_cancel.taskId).Append("'"); + dbo.ExecuteSql(sql.ToString()); + sql.Clear(); + sql.Append("delete from t_manage_task where FID = '").Append(wms_wcs_cancel.taskId).Append("'"); + var count = dbo.ExecuteSql(sql.ToString()); + //鏆備笉鑰冭檻鏁版嵁搴撴墽琛屽垹闄ゆ寚浠ゅけ璐ョ殑鎯呭喌 - //鍚屾椂杩樿鍒犻櫎IOControl琛ㄧ殑浠诲姟淇℃伅 - sql.Clear(); - sql.Append("delete from IO_CONTROL where MANAGE_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); - dbo.ExecuteSql(sql.ToString()); + //鍚屾椂杩樿鍒犻櫎IOControl琛ㄧ殑浠诲姟淇℃伅 + sql.Clear(); + sql.Append("delete from IO_CONTROL where MANAGE_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); + dbo.ExecuteSql(sql.ToString()); wcs_wms_cancel.code = 0; wcs_wms_cancel.msg = ""; wcs_wms_cancel.data = ""; - + + } + else + { + + wcs_wms_cancel.code = 1; + wcs_wms_cancel.msg = "鍙栨秷浠诲姟澶辫触锛屼换鍔″凡鎵ц锛"; + wcs_wms_cancel.data = ""; + } } - else + else if (dv.Count == 0) { + wcs_wms_cancel.code = 0; + wcs_wms_cancel.msg = "鍙栨秷浠诲姟鎴愬姛锛學CS涓棤姝や换鍔★紒" + wms_wcs_cancel.taskId; + wcs_wms_cancel.data = ""; + + } + else + { wcs_wms_cancel.code = 1; - wcs_wms_cancel.msg = "鍙栨秷浠诲姟澶辫触锛屼换鍔″凡鎵ц锛"; + wcs_wms_cancel.msg = "鍙栨秷浠诲姟澶辫触锛學CS涓湁澶氭潯鐩稿悓浠诲姟锛"; wcs_wms_cancel.data = ""; } - } - else if (dv.Count == 0) - { - - wcs_wms_cancel.code = 0; - wcs_wms_cancel.msg = "鍙栨秷浠诲姟鎴愬姛锛學CS涓棤姝や换鍔★紒" + wms_wcs_cancel.taskId; - wcs_wms_cancel.data = ""; - - } - else - { - wcs_wms_cancel.code = 1; - wcs_wms_cancel.msg = "鍙栨秷浠诲姟澶辫触锛學CS涓湁澶氭潯鐩稿悓浠诲姟锛"; - wcs_wms_cancel.data = ""; - } - if (wcs_wms_cancel.code == 0) {//鍒犻櫎鎴愬姛 - sql.Clear(); - sql.Append("select * from IO_CONTROL where CONTROL_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); - dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; - if (dv1.Count > 0) { + if (wcs_wms_cancel.code == 0) {//鍒犻櫎鎴愬姛 sql.Clear(); - sql.Append("delete from IO_CONTROL where CONTROL_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); - dbo.ExceSQL(sql.ToString()); + sql.Append("select * from IO_CONTROL where CONTROL_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); + dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; + if (dv1.Count > 0) { + sql.Clear(); + sql.Append("delete from IO_CONTROL where CONTROL_ID = '").Append(wms_wcs_cancel.taskId).Append("'"); + dbo.ExceSQL(sql.ToString()); + } } } - } - returnJson = Model.JsonHelper.Serializer(wcs_wms_cancel); - CommonClassLib.CCarryConvert.WriteLog("WEBAPI", "杩斿洖鎶ユ枃", returnJson, ""); - dbo.TransCommit(); - return returnJson; + returnJson = Model.JsonHelper.Serializer(wcs_wms_cancel); + CommonClassLib.CCarryConvert.WriteLog("WEBAPI", "杩斿洖鎶ユ枃", returnJson, ""); + dbo.TransCommit(); + return returnJson; } catch (Exception ex) { @@ -484,14 +488,14 @@ namespace WindowsFormsApp1 } else if (wms_wcs.agvTaskStatus == 22)//寮濮嬫斁璐 { - status = 3; + status = 4; } else if (wms_wcs.agvTaskStatus == 23)//鏀捐揣瀹屾垚 { - status = 4; + status = 5; } else { - status = 0; + status = 3; } wcs_wms.code = 0; wcs_wms.msg = "";