|
@@ -13,6 +13,8 @@ namespace WCS.Service.Extensions
|
|
|
/// </summary>
|
|
|
public class StationDeviceGroup : DeviceGroup<IStation520, IStation521, IStation523>
|
|
|
{
|
|
|
+ private List<RGVDevice> RGVs;
|
|
|
+
|
|
|
public StationDeviceGroup(WCS_DEVICE entity) : base(entity)
|
|
|
{
|
|
|
}
|
|
@@ -29,12 +31,12 @@ namespace WCS.Service.Extensions
|
|
|
if (Items.Any(v => v.Data3.Status.HasFlag(StationStatus.运行状态位))) return true;
|
|
|
//设备组中没有设备有光带信息
|
|
|
if (!Items.Any(v => v.Data2.Status.HasFlag(IstationStatus.光电状态))) return true;
|
|
|
- //有光电无任务
|
|
|
- if (Items.Any(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum < 10000))
|
|
|
- throw new Exception(LogHelper.SpliceLogMessage("有光电无任务", Entity.CODE, WCS_EXCEPTIONTYPE.设备异常));
|
|
|
- //有光电有任务无请求
|
|
|
- if (Items.Any(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum < 10000 && (type != IstationRequest.无 && v.Data2.Request != type)))
|
|
|
- throw new Exception(LogHelper.SpliceLogMessage("有光电有任务分配目标地址请求请求", Entity.CODE, WCS_EXCEPTIONTYPE.设备异常));
|
|
|
+ ////有光电无任务
|
|
|
+ //if (Items.Any(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum < 10000))
|
|
|
+ // throw new Exception(LogHelper.SpliceLogMessage("有光电无任务", Entity.CODE, WCS_EXCEPTIONTYPE.设备异常));
|
|
|
+ ////有光电有任务无请求
|
|
|
+ //if (Items.Any(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum < 10000 && (type != IstationRequest.无 && v.Data2.Request != type)))
|
|
|
+ // throw new Exception(LogHelper.SpliceLogMessage($"有光电有任务无 {type} 请求", Entity.CODE, WCS_EXCEPTIONTYPE.设备异常));
|
|
|
|
|
|
return false;
|
|
|
}
|
|
@@ -46,9 +48,10 @@ namespace WCS.Service.Extensions
|
|
|
/// <returns></returns>
|
|
|
public List<Device<IStation520, IStation521, IStation523>> RGVGetTaskedDevice()
|
|
|
{
|
|
|
- return Items.Where(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum > 10000)
|
|
|
+ var a = Items.Where(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum > 10000)
|
|
|
.Where(v => v.Entity.CODE.ToShort() != v.Data2.Goodsend && v.Data2.Goodsend != 0)
|
|
|
.ToList();
|
|
|
+ return a.Count == 0 ? null : a;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -58,9 +61,37 @@ namespace WCS.Service.Extensions
|
|
|
/// <returns></returns>
|
|
|
public List<Device<IStation520, IStation521, IStation523>> TaskedDeviceGetNextAddress()
|
|
|
{
|
|
|
- return Items.Where(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum > 10000)
|
|
|
+ var a = Items.Where(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum > 10000)
|
|
|
.Where(v => v.Data2.Goodsend.ToString() == v.Entity.CODE && v.Data2.Goodsend != 0)
|
|
|
.ToList();
|
|
|
+ return a.Count == 0 ? null : a;
|
|
|
+ }
|
|
|
+
|
|
|
+ public float Position { get; }
|
|
|
+ public float Length { get; }
|
|
|
+
|
|
|
+ public RGVDevice NextRGV()
|
|
|
+ {
|
|
|
+ return new RGVDevice(new WCS_DEVICE());
|
|
|
+ }
|
|
|
+
|
|
|
+ public float Distance(RGVDevice rgv)
|
|
|
+ {
|
|
|
+ return Math.Abs((Position - rgv.Position + Length) % Length);
|
|
|
+ }
|
|
|
+
|
|
|
+ public RGVDevice CurrentRGV()
|
|
|
+ {
|
|
|
+ return new RGVDevice(new WCS_DEVICE());
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool NeedRgv()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -88,9 +119,29 @@ namespace WCS.Service.Extensions
|
|
|
throw new Exception(LogHelper.SpliceLogMessage($"等待任务[{Data2.Tasknum}]执行", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
//没有光电
|
|
|
if (!Data2.Status.HasFlag(IstationStatus.光电状态)) return true;
|
|
|
- ////没有任务号
|
|
|
- //if (Data2.Tasknum > 10000)
|
|
|
- // throw new Exception(LogHelper.SpliceLogMessage($"已生成", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
+ //没有任务号
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case IstationRequest.无:
|
|
|
+ if (Data2.Tasknum > 10000)
|
|
|
+ throw new Exception(LogHelper.SpliceLogMessage($"设备已有任务任务", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case IstationRequest.扫码入库:
|
|
|
+ if (Data2.Tasknum > 10000)
|
|
|
+ throw new Exception(LogHelper.SpliceLogMessage($"设备已有任务任务", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case IstationRequest.堆垛机放货完成请求目标地址:
|
|
|
+ if (Data2.Tasknum < 10000)
|
|
|
+ throw new Exception(LogHelper.SpliceLogMessage($"设备无任务信息", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
+ break;
|
|
|
+
|
|
|
+ case IstationRequest.请求分配目标地址:
|
|
|
+ if (Data2.Tasknum < 10000)
|
|
|
+ throw new Exception(LogHelper.SpliceLogMessage($"设备无任务信息", Entity.CODE, WCS_EXCEPTIONTYPE.逻辑异常));
|
|
|
+ break;
|
|
|
+ }
|
|
|
//没有请求
|
|
|
if (type != IstationRequest.无 && Data2.Request != type)
|
|
|
throw new Exception(LogHelper.SpliceLogMessage($"有光电有任务无 {type}", Entity.CODE, WCS_EXCEPTIONTYPE.设备异常));
|
|
@@ -116,9 +167,116 @@ namespace WCS.Service.Extensions
|
|
|
/// </summary>
|
|
|
private static List<RGVStationLocation> PullFilm = new List<RGVStationLocation>();
|
|
|
|
|
|
+ public float Position
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return Data2.Position;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<RGVDevice> AllRGVList
|
|
|
+ {
|
|
|
+ get; set;
|
|
|
+ }
|
|
|
+
|
|
|
+ static RGVDevice()
|
|
|
+ {
|
|
|
+ AllRGVList = Device.Where(v => v.IsRGV() && v.CODE != "RGV8").Select(v => v.Create<RGVDevice>()).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
+ public float Length { get; }
|
|
|
+
|
|
|
+ public List<RGVDevice> RGVList
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return AllRGVList.Where(v => v.Entity.PROTOCOLS.Any(d => Entity.PROTOCOLS.Any(e => e.DB.ID == d.DB.ID)))
|
|
|
+ .Where(v => v.Entity.CODE != Entity.CODE).ToList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public RGVDevice(WCS_DEVICE entity) : base(entity)
|
|
|
{
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 前一个RGV
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public RGVDevice Before()
|
|
|
+ {
|
|
|
+ var arr = AllRGVList.OrderBy(v => v.Position);
|
|
|
+ var rgv = arr.FirstOrDefault(v => v.Position > Position);
|
|
|
+ if (rgv == null)
|
|
|
+ rgv = arr.LastOrDefault(v => v.Position < Position);
|
|
|
+ return rgv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 后一个RGV
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public RGVDevice After()
|
|
|
+ {
|
|
|
+ return new RGVDevice(new WCS_DEVICE());
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 两个RGV之间的距离
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="after"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public float Distance(RGVDevice after)
|
|
|
+ {
|
|
|
+ return Math.Abs((Position - after.Position + Length) % Length);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 是否可用
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool Valid()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 移动
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="addr"></param>
|
|
|
+ public void Move(StationDeviceGroup addr)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 选择出库
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="addr"></param>
|
|
|
+ public void Pick(StationDeviceGroup addr)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Put()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public RGVDevice[] RgvAfter(float distance)
|
|
|
+ {
|
|
|
+ return AllRGVList.Where(v => Distance(v) < distance).ToArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool StopedByMe(RGVDevice rgv)
|
|
|
+ {
|
|
|
+ var target = rgv.Data2.DestPosition_1;
|
|
|
+ var station = Device.Find($"G{target}").Create<StationDeviceGroup>();
|
|
|
+ return station.Distance(this) < station.Distance(rgv);
|
|
|
+ }
|
|
|
+
|
|
|
+ public StationDeviceGroup NextStation()
|
|
|
+ {
|
|
|
+ return new StationDeviceGroup(new WCS_DEVICE());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -144,21 +302,21 @@ namespace WCS.Service.Extensions
|
|
|
|
|
|
public class RGVStationLocation
|
|
|
{
|
|
|
- public RGVStationLocation(string a, string b, string c, string d)
|
|
|
+ public RGVStationLocation(string station, string stationLocation, string startingPoint, string endPoint)
|
|
|
{
|
|
|
- Station = a;
|
|
|
- StationLocation = b;
|
|
|
- StartingPoint = c;
|
|
|
- EndPoint = d;
|
|
|
+ Station = station;
|
|
|
+ StationLocation = stationLocation;
|
|
|
+ StartingPoint = startingPoint;
|
|
|
+ EndPoint = endPoint;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 输送机设备号
|
|
|
+ /// 输送机设备组编号
|
|
|
/// </summary>
|
|
|
public string Station { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 输送机位置表
|
|
|
+ /// 输送机在环轨中的位置
|
|
|
/// </summary>
|
|
|
public string StationLocation { get; set; }
|
|
|
|