|
@@ -36,9 +36,8 @@ public class plc_led_goodslogo : IHttpHandler
|
|
|
|
|
|
|
|
DataTable infoDt = new DataTable();
|
|
DataTable infoDt = new DataTable();
|
|
|
//写入PLC
|
|
//写入PLC
|
|
|
- //SiemensS7.Open("172.19.26.244", 102);
|
|
|
|
|
//正式
|
|
//正式
|
|
|
- SiemensS7.Open("172.19.26.152", 102);
|
|
|
|
|
|
|
+ SiemensS7.Open("172.19.26.240", 102);
|
|
|
|
|
|
|
|
if (context.Request["barcode"] is object)
|
|
if (context.Request["barcode"] is object)
|
|
|
{
|
|
{
|
|
@@ -47,6 +46,7 @@ public class plc_led_goodslogo : IHttpHandler
|
|
|
infoDt = conn.ExecuteDatatable(@"
|
|
infoDt = conn.ExecuteDatatable(@"
|
|
|
SELECT
|
|
SELECT
|
|
|
TPGL.BARCODE,
|
|
TPGL.BARCODE,
|
|
|
|
|
+ TPGL.GOODSCODE,
|
|
|
TMA.GOODSID,
|
|
TMA.GOODSID,
|
|
|
TMA.LOGOID,
|
|
TMA.LOGOID,
|
|
|
TMA.ACCESSORIESNAME,
|
|
TMA.ACCESSORIESNAME,
|
|
@@ -68,39 +68,32 @@ public class plc_led_goodslogo : IHttpHandler
|
|
|
);
|
|
);
|
|
|
if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
|
|
if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
|
|
|
{
|
|
{
|
|
|
- SiemensS7.Write<short>("400.2", Convert.ToInt16(infoDt.Rows[0]["GOODSID"]));
|
|
|
|
|
- SiemensS7.Write<short>("400.4", Convert.ToInt16(infoDt.Rows[0]["LOGOID"]));
|
|
|
|
|
- SiemensS7.Write<short>("400.6", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
|
|
- SiemensS7.Write<string>("400.10", infoDt.Rows[0]["ACCESSORIESNAME"].ToString());
|
|
|
|
|
- SiemensS7.Write<string>("400.24", infoDt.Rows[0]["DICTIONARYVALUE"].ToString());
|
|
|
|
|
|
|
+ SiemensS7.Write<short>("100.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
|
|
+ SiemensS7.Write<string>("100.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
|
|
+ SiemensS7.Write<string>("100.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
|
|
|
|
|
//写标识位-扫描结果
|
|
//写标识位-扫描结果
|
|
|
- SiemensS7.Write<short>("400.0", Convert.ToInt16(1));
|
|
|
|
|
|
|
+ SiemensS7.Write<short>("100.0", Convert.ToInt16(1));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- context.Response.Write(SiemensS7.Read<short>("400.0"));
|
|
|
|
|
- context.Response.Write(SiemensS7.Read<short>("400.2"));
|
|
|
|
|
- context.Response.Write(SiemensS7.Read<short>("400.4"));
|
|
|
|
|
- context.Response.Write(SiemensS7.Read<short>("400.6"));
|
|
|
|
|
- context.Response.Write(SiemensS7.Read<string>("400.24", 11));
|
|
|
|
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("100.0"));
|
|
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("100.2"));
|
|
|
|
|
+ context.Response.Write(SiemensS7.Read<string>("100.6",11));
|
|
|
|
|
+ context.Response.Write(SiemensS7.Read<string>("100.20",11));
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (Convert.ToInt16(infoDt.Rows[0]["GOODSID"]) != Convert.ToInt16(SiemensS7.Read<short>("400.2"))
|
|
|
|
|
- || Convert.ToInt16(infoDt.Rows[0]["LOGOID"]) != Convert.ToInt16(SiemensS7.Read<short>("400.4"))
|
|
|
|
|
- || Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(SiemensS7.Read<short>("400.6"))
|
|
|
|
|
- || Convert.ToInt16(1) != Convert.ToInt16(SiemensS7.Read<short>("400.0")))
|
|
|
|
|
|
|
+ if (Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(SiemensS7.Read<short>("100.2"))
|
|
|
|
|
+ || Convert.ToInt16(1) != Convert.ToInt16(SiemensS7.Read<short>("100.0")))
|
|
|
{
|
|
{
|
|
|
- SiemensS7.Write<short>("400.2", Convert.ToInt16(infoDt.Rows[0]["GOODSID"]));
|
|
|
|
|
- SiemensS7.Write<short>("400.4", Convert.ToInt16(infoDt.Rows[0]["LOGOID"]));
|
|
|
|
|
- SiemensS7.Write<short>("400.6", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
|
|
- SiemensS7.Write<string>("400.10", infoDt.Rows[0]["ACCESSORIESNAME"].ToString());
|
|
|
|
|
- SiemensS7.Write<string>("400.24", infoDt.Rows[0]["DICTIONARYVALUE"].ToString());
|
|
|
|
|
|
|
+ SiemensS7.Write<short>("100.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]));
|
|
|
|
|
+ SiemensS7.Write<string>("100.6", infoDt.Rows[0]["BARCODE"].ToString());
|
|
|
|
|
+ SiemensS7.Write<string>("100.20", infoDt.Rows[0]["GOODSCODE"].ToString());
|
|
|
|
|
|
|
|
//写标识位-扫描结果
|
|
//写标识位-扫描结果
|
|
|
- SiemensS7.Write<short>("400.0", Convert.ToInt16(1));
|
|
|
|
|
|
|
+ SiemensS7.Write<short>("100.0", Convert.ToInt16(1));
|
|
|
}
|
|
}
|
|
|
- Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "五位数据位:" + SiemensS7.Read<short>("400.0") + "," + SiemensS7.Read<short>("400.2")
|
|
|
|
|
- + "," + SiemensS7.Read<short>("400.4") + "," + SiemensS7.Read<short>("400.6") + "," + SiemensS7.Read<short>("400.10") + "," + SiemensS7.Read<string>("400.24", 11) + ";数据:" + new JsonResult(infoDt).ToJson());
|
|
|
|
|
|
|
+ Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "三位数据位:" + SiemensS7.Read<short>("100.0") + "," + SiemensS7.Read<short>("100.2")
|
|
|
|
|
+ + "," + SiemensS7.Read<short>("100.6") + "," + SiemensS7.Read<string>("100.6",11)+ "," + SiemensS7.Read<string>("100.20",11) + ";数据:" + new JsonResult(infoDt).ToJson());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|