using HH.WCS.JiaTong.api;
using HH.WCS.JiaTong.device;
using HH.WCS.JiaTong.dispatch;
using HH.WCS.JiaTong.util;
using HH.WCS.JiaTong.wms;
using Newtonsoft.Json;
using S7.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using static HH.WCS.JiaTong.LISTA.process.HttpModel;
using static System.Collections.Specialized.BitVector32;
namespace HH.WCS.JiaTong.process
{
///
/// 设备信号处理,主要是tcp信号,我们做server被动接收信号来处理,根据项目定制的
///
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}");
var plc = Settings.deviceInfos.Where(a => a.address == ip && a.enable == 1).FirstOrDefault();
if (plc != null)
{
if (plc.deviceType == 1)
{
if (data == "")
{
// Traystacker(plc);
}
}
}
else
{
Console.WriteLine($"TCP信号处理:未查询到IP为{ip}的数据,请检查deviceInfo配置中心是否存在该IP的数据!");
}
}
}
///
/// 叠盘机空托返回
///
internal static void Traystacker(string loc, int qty, int type)
{
try
{
//上传数据
Traystacker result1 = new Traystacker() { station = loc, taskSource = 1, Qty = qty, dpType = type };
HttpHelper httpHelper = new HttpHelper();
Result result = new Result();
string date = JsonConvert.SerializeObject(result1);
var url = Settings.tableUrls.Find(a => a.id == 3);
if (url != null)
{
LogHelper.Info($"叠盘机空托返回:地址:{url.url},内容:{date}");
var r = httpHelper.WebPost(url.url, date);
result = JsonConvert.DeserializeObject(r);
if (result.code == "0")
{
LogHelper.Info($"叠盘机空托返回请求成功");
}
else
{
LogHelper.Info($"叠盘机空托返回请求失败=>msg:{result.msg}");
}
}
else
{
LogHelper.Info($"叠盘机空托:根据id=3,未找到配置链接,请检查配置文件");
}
}
catch (Exception ex)
{
LogHelper.Error($"叠盘机空托返回 Error=>{ex.ToString()}", ex);
}
}
///
/// 原材料库agv叠盘回库
///
internal static void Traffic()
{
var db = new SqlHelper