Browse Source

修改AGV信号的PLC协议,将3置为无意义,防止客户单显示不正确。修改由于掉线导致AGV对接站台信息的状态不变更的情况

master
志铭 吕 2 weeks ago
parent
commit
63330540fb
  1. 7
      ControlMonitorClient/FrmDeviceStatus.cs
  2. 31
      WcfControlMonitorHost/FrmHost.Designer.cs
  3. 55
      WcfControlMonitorHost/FrmHost.cs
  4. 17
      WcfControlMonitorLib/SControlMonitor.cs
  5. 166
      webapi/WindowsFormsApp1/APIChannel.cs

7
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:

31
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;

55
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;
//}
}
/// <summary>
/// 定时器:定时发送出入库模式

17
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
/// <summary>
/// 构造函数
@ -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());
}
}
}
}

166
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<CCallService.WMS_WCS_PARAM_Priority>(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<CCallService.WMS_WCS_PARAM_Priority>(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 = "取消任务成功,WCS中无此任务!" + wms_wcs_cancel.taskId;
wcs_wms_cancel.data = "";
}
else
{
wcs_wms_cancel.code = 1;
wcs_wms_cancel.msg = "取消任务失败,任务已执行!";
wcs_wms_cancel.msg = "取消任务失败,WCS中有多条相同任务!";
wcs_wms_cancel.data = "";
}
}
else if (dv.Count == 0)
{
wcs_wms_cancel.code = 0;
wcs_wms_cancel.msg = "取消任务成功,WCS中无此任务!" + wms_wcs_cancel.taskId;
wcs_wms_cancel.data = "";
}
else
{
wcs_wms_cancel.code = 1;
wcs_wms_cancel.msg = "取消任务失败,WCS中有多条相同任务!";
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 = "";

Loading…
Cancel
Save