|
|
@@ -25,7 +25,6 @@ public class plc_led_goodslogo_dj2 : IHttpHandler
|
|
|
|
|
|
//输入参数 【条码】
|
|
|
public string barCode = "";
|
|
|
- public S7 s7 = new S7() ;
|
|
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
|
{
|
|
|
@@ -38,7 +37,7 @@ public class plc_led_goodslogo_dj2 : IHttpHandler
|
|
|
DataTable infoDt = new DataTable();
|
|
|
//写入PLC
|
|
|
//正式
|
|
|
- s7.Open("172.19.26.237", 102);
|
|
|
+ SiemensS7.Open("172.19.26.237", 102);
|
|
|
|
|
|
if (context.Request["barcode"] is object)
|
|
|
{
|
|
|
@@ -67,44 +66,44 @@ public class plc_led_goodslogo_dj2 : IHttpHandler
|
|
|
);
|
|
|
if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
|
|
|
{
|
|
|
- s7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
- s7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
- s7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
+ SiemensS7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
+ SiemensS7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
+ SiemensS7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
|
|
|
//写标识位-扫描结果
|
|
|
- s7.Write<short>("101.0", Convert.ToInt16(1));
|
|
|
+ SiemensS7.Write<short>("101.0", Convert.ToInt16(1));
|
|
|
}
|
|
|
|
|
|
- context.Response.Write(s7.Read<short>("101.0"));
|
|
|
- context.Response.Write(s7.Read<short>("101.2"));
|
|
|
- context.Response.Write(s7.Read<string>("101.6",11));
|
|
|
- context.Response.Write(s7.Read<string>("101.20",11));
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("101.0"));
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("101.2"));
|
|
|
+ context.Response.Write(SiemensS7.Read<string>("101.6",11));
|
|
|
+ context.Response.Write(SiemensS7.Read<string>("101.20",11));
|
|
|
|
|
|
|
|
|
- if (Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(s7.Read<short>("101.2"))
|
|
|
- || Convert.ToInt16(1) != Convert.ToInt16(s7.Read<short>("101.0")))
|
|
|
+ if (Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(SiemensS7.Read<short>("101.2"))
|
|
|
+ || Convert.ToInt16(1) != Convert.ToInt16(SiemensS7.Read<short>("101.0")))
|
|
|
{
|
|
|
- s7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
- s7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
- s7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
+ SiemensS7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
+ SiemensS7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
+ SiemensS7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
|
|
|
//写标识位-扫描结果
|
|
|
- s7.Write<short>("101.0", Convert.ToInt16(1));
|
|
|
+ SiemensS7.Write<short>("101.0", Convert.ToInt16(1));
|
|
|
}
|
|
|
- Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "4位数据位:" + s7.Read<short>("101.0") + ",辅件编码:" + s7.Read<short>("101.2")
|
|
|
- + ",条码:" + s7.Read<string>("101.6",11)+ ",产品编码:" + s7.Read<string>("101.20",11) + ";数据:" + new JsonResult(infoDt).ToJson());
|
|
|
+ Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "4位数据位:" + SiemensS7.Read<short>("101.0") + ",辅件编码:" + SiemensS7.Read<short>("101.2")
|
|
|
+ + ",条码:" + SiemensS7.Read<string>("101.6",11)+ ",产品编码:" + SiemensS7.Read<string>("101.20",11) + ";数据:" + new JsonResult(infoDt).ToJson());
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//写标识位-扫描结果
|
|
|
- //s7.Write<short>("400.0", Convert.ToInt16(2));
|
|
|
- //context.Response.Write(s7.Read<short>("400.0"));
|
|
|
- //Logger.Info("无条码!");
|
|
|
+ SiemensS7.Write<short>("101.0", Convert.ToInt16(2));
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("101.0"));
|
|
|
+ Logger.Info("无条码!");
|
|
|
}
|
|
|
|
|
|
context.Response.Write(new JsonResult(infoDt).ToJson());
|
|
|
- s7.Close();
|
|
|
+ SiemensS7.Close();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|