using HH.WCS.JunzhouNongfu.device;
|
using HH.WCS.Mobox3.DoubleCoin.device;
|
using HH.WCS.Mobox3.DoubleCoin.dispatch;
|
using HH.WCS.Mobox3.DoubleCoin.util;
|
using HH.WCS.Mobox3.DoubleCoin.wms;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Threading;
|
|
namespace HH.WCS.Mobox3.DoubleCoin.process
|
{
|
/// <summary>
|
/// 设备信号处理,主要是tcp信号,我们做server被动接收信号来处理,根据项目定制的
|
/// </summary>
|
internal class DeviceProcess
|
{
|
internal static void Analysis(string data, string ip) {
|
if (data.Length >= 6) {
|
//去掉消息头3F 00
|
data = data.Substring(4);
|
//Console.WriteLine($"{ip}-{data}");
|
}
|
}
|
|
internal static bool OpenOrCloseDoor(string doorCode, int state)
|
{
|
var plc = Settings.SafeDoorDevices.FirstOrDefault(a=>a.DeviceCode == doorCode);
|
if (plc != null)
|
{
|
if (state == 1023)//进入安全门
|
{
|
byte[] its = new byte[] {0x3F, 0x00, 0x11, 0x0d, 0x0a };
|
if (!TcpServer.isSend.ContainsKey(plc.IPAddress))
|
{
|
TcpServer.isSend.Add(plc.IPAddress, true);
|
}
|
else
|
{
|
TcpServer.isSend[plc.IPAddress] = true;
|
}
|
return TcpServer.TcpServerSend( plc.IPAddress, its);
|
}
|
|
if (state == 1025)//离开安全门
|
{
|
byte[] its = new byte[] { 0x3F, 0x00, 0x10, 0x0d, 0x0a };
|
if (!TcpServer.isSend.ContainsKey(plc.IPAddress))
|
{
|
TcpServer.isSend.Add(plc.IPAddress, true);
|
}
|
else
|
{
|
TcpServer.isSend[plc.IPAddress] = true;
|
}
|
return TcpServer.TcpServerSend(plc.IPAddress, its);
|
}
|
}
|
return false;
|
}
|
}
|
}
|