using HH.WCS.Hexafluo.api;
using HH.WCS.Hexafluo.device;
using HH.WCS.Hexafluo.dispatch;
using HH.WCS.Hexafluo.util;
using HH.WCS.Hexafluo.wms;
using HH.WCS.SJML.api;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace HH.WCS.Hexafluo.process
{
///
/// 设备信号处理
///
internal class DeviceProcess
{
static DeviceProcess() {
Settings.GetCameraInfoList().ForEach(a => {
cameraStates.Add(a.site, new CameraState { site = a.site, state = -1 });
});
}
// private static Dictionary RainStates = new Dictionary();
///
/// 雨量传感器
///
///
///
internal static void Analysis(string data, string ip) {
if (data != null)
{
}
else
{
}
}
private static Dictionary cameraStates = new Dictionary();
internal static void SetCameraInfo(List models) {
var Open = Settings.CameraOpenKeyList;
if (Open=="Y")
{
models.ForEach(a => {
var info = Settings.GetCameraInfoList().Where(b => b.site == a.site).FirstOrDefault();
if (info != null)
{
if (cameraStates.Keys.Contains(a.site))
{
if (a.state == 0)
{
cameraStates[a.site].state = a.state;
//更新数据库,变空(改当前数量为0)
LocationHelper.BindLoc(info.location,0);
//LocationHelper
}
else
{
if (cameraStates[a.site].state > 0)
{
cameraStates[a.site].state++;
if (cameraStates[a.site].state > 2)
{
//更新数据库(连续两次收到满的信号,才当作是满的),变满(改当前数量为1)
LocationHelper.BindLoc(info.location,1);
}
}
else
{
cameraStates[a.site].state = a.state;
}
}
cameraStates[a.site].modify = DateTime.Now;
}
}
});
}
}
//internal static void CheckCameraTask() {
// Settings.GetCameraInfoList().ForEach(a => {
// var startList = a.Where(b => b.locType == 1).ToList();
// var endList = a.Where(b => b.locType >= 2).OrderBy(b => b.order).ToList();
// //获取一个起点是满的货位
// string startBit = null;
// for (int i = 0; i < startList.Count; i++) {
// if (cameraStates[startList[i].site].state >= 2) {
// startBit = startList[i].location;
// break;
// }
// }
// //判断起点没有任务
// if (startBit != null && LocationHelper.CheckLocFree(startBit)) {
// //调wms获取终点,终点在endList里面,找到之后生成任务
// Console.WriteLine($"相机起点{startBit}有货,查找找到对应终点");
// }
// });
//}
internal static void Traffic(string forkliftNo, string lockNo, bool v) {
throw new NotImplementedException();
}
}
}