| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <%@ WebHandler Language="C#" Class="plc_test" %>
- using System;
- using System.Web;
- using DK.XuWei.WebMes;
- public class plc_test : IHttpHandler
- {
- #region 数据变量
- //条码
- public string barCode = "";
- //读取标识
- public string readFlag = "";
- //扫码结果
- public int scanResult = 0;
- #endregion
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- //允许读取标识【PLC】
- readFlag = context.Request[""] is object ? context.Request[""].ToString() : "";
- //PLC配置
- SiemensS7.Open("", 0);
- //通过读取标识去【PLC】读取条码DB
- barCode = string.Empty;
- //允许读取第一个;
- if (readFlag == "1")
- {
- #region 调取条码校验
- //扫码结果
- if (true)//接口返回值
- {
- scanResult = 1;
- }
- else
- {
- //条码格式错误
- if (true)
- {
- scanResult = 2;
- }
- //产品不可到达
- else if (true)
- {
- scanResult = 3;
- }
- //MES异常
- else if (true)
- {
- scanResult = 4;
- }
- //条码不一致
- else if (true)
- {
- scanResult = 5;
- }
- //绑码完成
- else if (true)
- {
- scanResult = 6;
- }
- }
- #endregion
- #region 在P在LC写入产品型号及数量,返回扫码结果;
- #endregion
- }
- //允许读取全部产品;
- else if (readFlag == "2")
- {
- }
- //允许读取全部产品(带托盘);
- else if (readFlag == "3")
- {
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|