using System.Threading.Tasks;
using WCS.Core;
using WCS.WorkEngineering.Extensions;
using WCS.WorkEngineering.Protocol.BCR;
using WCS.WorkEngineering.Protocol.SRM;
using WCS.WorkEngineering.Protocol.Station;
using WCS.WorkEngineering.Worlds;
using static Dm.net.buffer.ByteArrayBuffer;
namespace WCS.WorkEngineering.Systems
{
///
/// 设备信息读取接口
///
[BelongTo(typeof(MainWorld))]
public class GetDeviceSystem : ServiceSystem, object>
{
///
/// 所有的站台
///
private List Convs;
private List Srms;
private List Bcrs;
private List> Device91;
///
/// 构造函数
///
public GetDeviceSystem()
{
//Convs = Device.All.Where(v => v.HasProtocol()).Select(v => new Station(v, this.World)).ToList();
Srms = Device.All.Where(v => v.HasProtocol()).Select(v => new SRM(v, this.World)).ToList();
Bcrs = Device.All.Where(v => v.HasProtocol()).Select(v => new BCR(v, this.World)).ToList();
Device91 = Device.All.Where(v => v.HasProtocol()).Select(v => new Device(v, this.World)).ToList();
}
protected override object Do(Tuple tuple)
{
switch (tuple.Item1)
{
case "堆垛机":
return Srms;
case "输送机":
return Convs;
case "读码器":
var b = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).Data.Content;
var a = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
return Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
case "Disassemble":
List deviceInfos = new List();
var deviceInfo = Device.All.Where(v => v.Code == "8003" || v.Code == "8011" || v.Code == "8019").Select(v => new Station(v, this.World)).ToList();
foreach (dynamic i in deviceInfo)
{
deviceInfos.Add(new DeviceInfo { DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
}
return deviceInfos;
case "PalletizingEquip":
List deviceInfos1 = new List();
var equlist = new List() { "8090", "8089", "8156", "8092", "8091", "8157", "8096", "8095", "8159", "8098", "8097", "8160", "8307", "8306" };
var deviceInfo1 = Device.All.Where(v => equlist.Contains(v.Code)).Select(v => new Station(v, this.World)).ToList();
foreach (dynamic i in deviceInfo1)
{
deviceInfos1.Add(new DeviceInfo1 { TaskCode = i.Data2.TaskNumber, DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
}
return deviceInfos1;
case "外检":
return Device91;
default: return "未知设备类型";
}
//if (code.Contains("SRM")) return Device.All.Where(v => v.Code == code).Select(v => new SRM(v, this.World)).ToList();
//else if (code.Contains("BCR")) return Device.All.Where(v => v.Code == code).Select(v => new BCR(v, this.World)).ToList();
//else if (code.Contains("D91")) return Device.All.Where(v => v.Code == code).Select(v => new Device(v, this.World)).ToList();
//return Device.All.Where(v => v.Code == code).Select(v => new Station(v, this.World)).ToList();
}
}
public class DeviceInfo
{
public string DeviceCode { get; set; }
public bool PH_STATUS { get; set; }
}
public class DeviceInfo1 : DeviceInfo
{
public int TaskCode { get; set; }
}
}