212 lines
5.7 KiB
C#
212 lines
5.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Runtime.Serialization;
|
|||
|
using System.ServiceModel;
|
|||
|
using System.Text;
|
|||
|
using DeiNiu.Utils;
|
|||
|
|
|||
|
namespace DeiNiu.wms.win
|
|||
|
{
|
|||
|
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“ServiceLight”。
|
|||
|
|
|||
|
public delegate bool turnOnLights(int portNo, List<ELight> lights);
|
|||
|
public delegate bool turnOffLights(int portNo, List<ELight> lights);
|
|||
|
|
|||
|
public delegate bool lightLable(List<ELabel> lables);
|
|||
|
public delegate bool turnOffLable(List<ELabel> lables);
|
|||
|
public delegate bool resetLights(int port);
|
|||
|
|
|||
|
|
|||
|
public delegate Cart getCarIp(string carNo);
|
|||
|
public delegate void clearLablesByPortOrder(int port,int order);
|
|||
|
public delegate void logMsg(string msg);
|
|||
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
|
|||
|
public class ServiceLight : IServiceLight
|
|||
|
{
|
|||
|
|
|||
|
public turnOffLights turnOffLts = null;
|
|||
|
public turnOnLights turnOnLts = null;
|
|||
|
public turnOffLable turnOffLb = null;
|
|||
|
|
|||
|
public string turnOnLightById(int lightId)
|
|||
|
{
|
|||
|
return turnOnLight(lightId,0,0);
|
|||
|
|
|||
|
}
|
|||
|
public string turnOffLightById(int lightId)
|
|||
|
{
|
|||
|
return turnOffLight(lightId,0, 0);
|
|||
|
}
|
|||
|
public string turnOnLight (int lightId, byte which, int portNo)
|
|||
|
{
|
|||
|
|
|||
|
List<ELight> els = new List<ELight>();
|
|||
|
ELight el = new ELight();
|
|||
|
el.port =portNo;
|
|||
|
el.which = which;
|
|||
|
el.lightId=lightId;
|
|||
|
els.Add(el);
|
|||
|
bool rt = true;
|
|||
|
if (turnOnLts != null)
|
|||
|
{
|
|||
|
rt= turnOnLts(portNo,els);
|
|||
|
|
|||
|
}
|
|||
|
if (rt)
|
|||
|
return "亮灯请求成功";
|
|||
|
else
|
|||
|
return "亮灯失败";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public string turnOffLight(int lightId, byte which, int portNo)
|
|||
|
{
|
|||
|
List<ELight> els = new List<ELight>();
|
|||
|
ELight el = new ELight();
|
|||
|
el.port = portNo;
|
|||
|
el.which = which;
|
|||
|
el.lightId = lightId;
|
|||
|
els.Add(el);
|
|||
|
|
|||
|
bool rt = true;
|
|||
|
if (turnOffLts != null)
|
|||
|
{
|
|||
|
rt = turnOffLts(portNo, els);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (rt)
|
|||
|
return "灭灯成功";
|
|||
|
else
|
|||
|
return "灭灯失败";
|
|||
|
|
|||
|
}
|
|||
|
public clearLablesByPortOrder clearLablesByPortOrder = null;
|
|||
|
public void clearLables(int port, int order)
|
|||
|
{
|
|||
|
if (clearLablesByPortOrder != null)
|
|||
|
{
|
|||
|
clearLablesByPortOrder(port, order);
|
|||
|
}
|
|||
|
}
|
|||
|
public void showLableId(int port)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
//点亮标签
|
|||
|
public lightLable lightUp = null;
|
|||
|
public string lightLabels(List<ELabel> labels)
|
|||
|
{
|
|||
|
//labelPool.Concat(labels);
|
|||
|
if (null != lightUp)
|
|||
|
{
|
|||
|
if( lightUp(labels))
|
|||
|
return "succeed";
|
|||
|
}
|
|||
|
|
|||
|
return "failed";
|
|||
|
}
|
|||
|
public resetLights resetPort = null;
|
|||
|
public string resetLabels(int port)
|
|||
|
{
|
|||
|
if (null != resetPort)
|
|||
|
{
|
|||
|
if (resetPort(port))
|
|||
|
{
|
|||
|
return "success";
|
|||
|
}
|
|||
|
}
|
|||
|
return "failed";
|
|||
|
}
|
|||
|
public ELabel testPost(ELabel label)
|
|||
|
{
|
|||
|
// string json = getJson(label);
|
|||
|
// Console.Write("get the lable: " + json );
|
|||
|
|
|||
|
return label;// "succeed";
|
|||
|
}
|
|||
|
public string getJson(ELabel label)
|
|||
|
{
|
|||
|
// string json = String.Format("\"labelId\":{0},\"address\":{1},\"count\":{2},\"color\":{3},\"port\":{4},\"orderNo\":{5}"
|
|||
|
// , label.labelId, label.address, label.count, label.color, label.port, label.orderNo);
|
|||
|
// string json = String.Format("\"labelId\":{0},\"num1\":{1},\"num2\":{2},\"color\":{3},\"orderNo\":{4}"
|
|||
|
// , label.labelId, label.num1, label.num2, label.color, label.orderNo);
|
|||
|
// Console.Write("get the lable: " + json);
|
|||
|
// Console.Write("get the lable: " + json);
|
|||
|
|
|||
|
return Util.getLbJson(label);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public getCarIp getCarIpAddress = null;
|
|||
|
public Cart getCarUrl(string carNo)
|
|||
|
{
|
|||
|
if (getCarIpAddress != null)
|
|||
|
{
|
|||
|
return(getCarIpAddress(carNo));
|
|||
|
}
|
|||
|
return new Cart();
|
|||
|
}
|
|||
|
|
|||
|
public logMsg outMsg=null;
|
|||
|
public void printMsg(string msg)
|
|||
|
{
|
|||
|
if (outMsg != null)
|
|||
|
{
|
|||
|
outMsg(msg);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public string lightOn(List<ELight> lights)
|
|||
|
{
|
|||
|
|
|||
|
bool rt = true;
|
|||
|
if (turnOnLts != null)
|
|||
|
{
|
|||
|
rt = turnOnLts(0, lights);
|
|||
|
}
|
|||
|
|
|||
|
if (rt)
|
|||
|
return "亮灯成功";
|
|||
|
else
|
|||
|
return "亮灯失败";
|
|||
|
}
|
|||
|
|
|||
|
public string lightOff(List<ELight> lights)
|
|||
|
{
|
|||
|
|
|||
|
bool rt = true;
|
|||
|
if (turnOffLts != null)
|
|||
|
{
|
|||
|
rt = turnOffLts(0, lights);
|
|||
|
}
|
|||
|
|
|||
|
if (rt)
|
|||
|
return "灭灯成功";
|
|||
|
else
|
|||
|
return "灭灯失败";
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public string labelOff(List<ELabel> labels)
|
|||
|
{
|
|||
|
|
|||
|
bool rt = true;
|
|||
|
if (turnOffLb != null)
|
|||
|
{
|
|||
|
rt = turnOffLb(labels);
|
|||
|
}
|
|||
|
|
|||
|
if (rt)
|
|||
|
return "灭灯成功";
|
|||
|
else
|
|||
|
return "灭灯失败";
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|