|
|
@@ -187,6 +187,7 @@ namespace PLC_S.EPTS
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ string msg = null;
|
|
|
// 2. 读取PLC 窑车号
|
|
|
outputMessage = $"[{EPTS_CODE}]GET_KC_Code=[ ]{plc_ini.Add_KC_Code + plc_ini.Add_KC_CodeNum}";
|
|
|
logger_t.OutputTrace(outputMessage);
|
|
|
@@ -197,13 +198,22 @@ namespace PLC_S.EPTS
|
|
|
logger_t.OutputTrace(outputMessage);
|
|
|
FormLogShow?.ShowLog(outputMessage);
|
|
|
FormLogShow?.ShowLog(outputMessage);
|
|
|
+ //if (kc_result.Data <= 0)
|
|
|
+ //{
|
|
|
+ // return;
|
|
|
+ //}
|
|
|
if (kc_result.Data <= 0)
|
|
|
{
|
|
|
+ // 窑车号为空
|
|
|
+ msg = "窑车号为空";
|
|
|
+ SetMSG(plc_ini, plc, msg);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
string kilnCarCode = "TK3" + kc_result.Data.ToString("000");
|
|
|
|
|
|
+ // 0:读取完复位,1:产品类型写入完成,2:窑车产品类型写入错误【产品所在窑车位置错误】
|
|
|
+ short g_flag = 1;
|
|
|
// 卸窑工号
|
|
|
string usercode = "";
|
|
|
using (IDataAccess dataAccess = PLC_S_DataAccess.GetDataAccess())
|
|
|
@@ -227,6 +237,111 @@ namespace PLC_S.EPTS
|
|
|
outputMessage = $"[{EPTS_CODE}]DB_UserCode=[{usercode}]";
|
|
|
logger_t.OutputTrace(outputMessage);
|
|
|
FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ #region 窑车位置对应产品类型
|
|
|
+ sqlString = "select t.barcode\n" +
|
|
|
+ " ,g.goodsid\n" +
|
|
|
+ " ,g.goodscode\n" +
|
|
|
+ " ,g.seatcovercode\n" +
|
|
|
+ " , case\n" +
|
|
|
+ " when g.goodstypeid in (3, 4) then\n" +
|
|
|
+ " 2\n" +
|
|
|
+ " when g.goodstypeid in (18, 19) then\n" +
|
|
|
+ " 1\n" +
|
|
|
+ " else\n" +
|
|
|
+ " 3\n" +
|
|
|
+ " end goodstype\n" +
|
|
|
+ " ,t.kilncarposition - 86 kilncarposition\n" +
|
|
|
+ " from tp_pm_kilncargoods t\n" +
|
|
|
+ " inner join tp_mst_kilncar kc\n" +
|
|
|
+ " on kc.kilncarid = t.kilncarid\n" +
|
|
|
+ " inner join tp_mst_goods g\n" +
|
|
|
+ " on g.goodsid = t.goodsid\n" +
|
|
|
+ " where kc.kilncarcode = @kilncarcode@\n" +
|
|
|
+ " order by t.kilncarposition, t.barcode";
|
|
|
+ ps = new CDAParameter[]
|
|
|
+ {
|
|
|
+ new CDAParameter("kilncarcode", kilnCarCode),
|
|
|
+ };
|
|
|
+
|
|
|
+ dataTable = dataAccess.ExecuteDatatable(sqlString, ps);
|
|
|
+ if (!dataTable.HasData())
|
|
|
+ {
|
|
|
+ outputMessage = $"[{EPTS_CODE}]DB_CarGoods=[此窑车上无产品]";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ msg = $"[{kilnCarCode}]此窑车上无产品";
|
|
|
+ SetMSG(plc_ini, plc, msg);
|
|
|
+
|
|
|
+ outputMessage = $"[{EPTS_CODE}]SET_E_Code=[1]{plc_ini.Add_Error + plc_ini.Add_ErrorNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ PLCResult e1_result = plc.Write<short>(plc_ini.Add_Error, plc_ini.Add_ErrorNum, 1);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_E_Code=[1]{plc_ini.Add_Error + plc_ini.Add_ErrorNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ outputMessage = $"[{EPTS_CODE}]SET_G_FLAG=[2]{plc_ini.Add_G_FLAG + plc_ini.Add_G_FLAGNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ PLCResult e2_result = plc.Write<short>(plc_ini.Add_G_FLAG, plc_ini.Add_G_FLAGNum, 2);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_G_FLAG=[2]{plc_ini.Add_G_FLAG + plc_ini.Add_G_FLAGNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 1; i < 25; i++)
|
|
|
+ {
|
|
|
+ int d_num = (i - 1) * 2;
|
|
|
+
|
|
|
+ string Add_G_TYPENum = plc_ini.Add_G_TYPENum1 + "." + (plc_ini.Add_G_TYPENum2 + d_num);
|
|
|
+ string Add_G_MODENum = plc_ini.Add_G_MODENum1 + "." + (plc_ini.Add_G_MODENum2 + d_num);
|
|
|
+ short gt = 0;
|
|
|
+ short gm = 0;
|
|
|
+ DataRow[] drs = dataTable.Select("kilncarposition=" + i);
|
|
|
+ if (drs == null || drs.Length == 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (drs.Length == 1)
|
|
|
+ {
|
|
|
+ gt = Convert.ToInt16(drs[0]["goodstype"]);
|
|
|
+ gm = Convert.ToInt16(drs[0]["seatcovercode"]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ gm = Convert.ToInt16(drs.Length);
|
|
|
+ g_flag = 2;
|
|
|
+ }
|
|
|
+ // 产品类型 (0:无 1:智能 2:连体 3:其他)
|
|
|
+ outputMessage = $"[{EPTS_CODE}]SET_G_TYPE=[{gt}]{plc_ini.Add_G_TYPE + Add_G_TYPENum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ PLCResult gt_result = plc.Write<short>(plc_ini.Add_G_TYPE, Add_G_TYPENum, gt);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_G_TYPE=[{gt}]{plc_ini.Add_G_TYPE + Add_G_TYPENum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ // 产品型号
|
|
|
+ outputMessage = $"[{EPTS_CODE}]SET_G_MODE=[{gm}]{plc_ini.Add_G_MODE + Add_G_MODENum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ PLCResult gm_result = plc.Write<short>(plc_ini.Add_G_FLAG, Add_G_MODENum, gm);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_G_MODE=[{gm}]{plc_ini.Add_G_MODE + Add_G_MODENum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据状态-窑车产品位置信息(0:读取完复位,1:产品类型写入完成,2:窑车产品类型写入错误【产品所在窑车位置错误】)
|
|
|
+ outputMessage = $"[{EPTS_CODE}]SET_G_FLAG=[{g_flag}]{plc_ini.Add_G_FLAG + plc_ini.Add_G_FLAGNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ PLCResult gf_result = plc.Write<short>(plc_ini.Add_G_FLAG, plc_ini.Add_G_FLAGNum, g_flag);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_G_FLAG=[{g_flag}]{plc_ini.Add_G_FLAG + plc_ini.Add_G_FLAGNum}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ #endregion
|
|
|
}
|
|
|
|
|
|
string result = SmartDeviceProxy.Instance.Invoke<string>(
|
|
|
@@ -240,20 +355,45 @@ namespace PLC_S.EPTS
|
|
|
// 返回状态(成功、失败)
|
|
|
if (result != "OK")
|
|
|
{
|
|
|
+ //if (result == "EE")
|
|
|
+ //{
|
|
|
+ // outputMessage = $"[{EPTS_CODE}]result=[{result}]MES服务端异常(详情参见MES端日志)";
|
|
|
+ //}
|
|
|
+ //else if (result == "EU-01")
|
|
|
+ //{
|
|
|
+ // outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的帐套或工号(详情参见MES端日志)";
|
|
|
+ //}
|
|
|
+ //else if (result == "EU-02")
|
|
|
+ //{
|
|
|
+ // outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的窑车号(详情参见MES端日志)";
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // outputMessage = $"[{EPTS_CODE}]result=[{result}]其他错误(详情参见MES端日志)";
|
|
|
+ //}
|
|
|
if (result == "EE")
|
|
|
{
|
|
|
+ msg = "MES服务端异常";
|
|
|
outputMessage = $"[{EPTS_CODE}]result=[{result}]MES服务端异常(详情参见MES端日志)";
|
|
|
}
|
|
|
else if (result == "EU-01")
|
|
|
{
|
|
|
+ msg = $"[{usercode}]无效的帐套或工号";
|
|
|
outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的帐套或工号(详情参见MES端日志)";
|
|
|
}
|
|
|
else if (result == "EU-02")
|
|
|
{
|
|
|
+ msg = $"[{kilnCarCode}]无效的窑车号";
|
|
|
outputMessage = $"[{EPTS_CODE}]result=[{result}]无效的窑车号(详情参见MES端日志)";
|
|
|
}
|
|
|
+ //else if (result == "EC0")
|
|
|
+ //{
|
|
|
+ // msg = $"[{kilnCarCode}]此窑车无有效产品条码";
|
|
|
+ // outputMessage = $"[{EPTS_CODE}]result=[{result}]此窑车无有效产品条码";
|
|
|
+ //}
|
|
|
else
|
|
|
{
|
|
|
+ msg = $"[{kilnCarCode}]" + result.Replace("EP-00=", "").Replace(System.Environment.NewLine, " ").Replace("\n", " ");
|
|
|
outputMessage = $"[{EPTS_CODE}]result=[{result}]其他错误(详情参见MES端日志)";
|
|
|
}
|
|
|
logger_e_out.OutputError(null, outputMessage);
|
|
|
@@ -270,6 +410,12 @@ namespace PLC_S.EPTS
|
|
|
//logger_t.OutputTrace(outputMessage);
|
|
|
//FormLogShow?.ShowLog(outputMessage);
|
|
|
|
|
|
+ if (g_flag == 2)
|
|
|
+ {
|
|
|
+ msg = "【窑车位置错误】" + msg;
|
|
|
+ }
|
|
|
+ SetMSG(plc_ini, plc, msg);
|
|
|
+
|
|
|
// 7. 写入PLC ERROR标识 = 1
|
|
|
outputMessage = $"[{EPTS_CODE}]SET_E_Code=[1]{plc_ini.Add_Error + plc_ini.Add_ErrorNum}";
|
|
|
logger_t.OutputTrace(outputMessage);
|
|
|
@@ -298,6 +444,13 @@ namespace PLC_S.EPTS
|
|
|
outputMessage = $"[{EPTS_CODE}]END_E_Code=[0]{plc_ini.Add_Error + plc_ini.Add_ErrorNum}";
|
|
|
logger_t.OutputTrace(outputMessage);
|
|
|
FormLogShow?.ShowLog(outputMessage);
|
|
|
+
|
|
|
+ msg = $"[{kilnCarCode}]窑车已放行";
|
|
|
+ if (g_flag == 2)
|
|
|
+ {
|
|
|
+ msg = "【窑车位置错误】" + msg;
|
|
|
+ }
|
|
|
+ SetMSG(plc_ini, plc, msg);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
@@ -313,6 +466,21 @@ namespace PLC_S.EPTS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void SetMSG(INI_KUL plc_ini, SocketClient<SiemensS7_1200Model> plc, string msg)
|
|
|
+ {
|
|
|
+ string outputMessage = $"[{EPTS_CODE}]SET_MSG=[{msg}]{plc_ini.Add_MSG_CODE}{plc_ini.Add_MSG_NUM1}.{plc_ini.Add_MSG_NUM2}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ string num = plc_ini.Add_MSG_NUM1 + "." + (plc_ini.Add_MSG_NUM2 + 2);
|
|
|
+ PLCResult msg_result = plc.Write<short>(plc_ini.Add_MSG_CODE, num, (short)msg.Length);
|
|
|
+ num = plc_ini.Add_MSG_NUM1 + "." + (plc_ini.Add_MSG_NUM2 + 4);
|
|
|
+ msg_result = plc.Write(plc_ini.Add_MSG_CODE, num, msg, System.Text.Encoding.Unicode);
|
|
|
+ outputMessage = $"[{EPTS_CODE}]END_MSG=[{msg}]{plc_ini.Add_MSG_CODE}{plc_ini.Add_MSG_NUM1}.{plc_ini.Add_MSG_NUM2}";
|
|
|
+ logger_t.OutputTrace(outputMessage);
|
|
|
+ FormLogShow?.ShowLog(outputMessage);
|
|
|
+ //return outputMessage;
|
|
|
+ }
|
|
|
+
|
|
|
public void Stop()
|
|
|
{
|
|
|
try
|