|
|
@@ -1,10 +1,6 @@
|
|
|
using DBHelper_SqlSugar;
|
|
|
using Logs;
|
|
|
-using System;
|
|
|
using System.Collections.Concurrent;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Threading.Tasks;
|
|
|
using WCS.Core;
|
|
|
using WCS.Entity;
|
|
|
using WCS.Entity.Protocol;
|
|
|
@@ -100,6 +96,129 @@ namespace WCS.Service.Extensions
|
|
|
return source.WakeupOn(sec, "");
|
|
|
}
|
|
|
|
|
|
+ public static IBCR80 BCR(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ var dev = Device.Find("BCR" + source.CODE);
|
|
|
+ return dev.DEVICEPROTOCOLS.First().Data<IBCR80>();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static short PalletType(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return (short)source.Get<int>("PalletType");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static short ProductLine(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return (short)source.Get<int>("ProductLine");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static short WorkShop(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return (short)source.Get<int>("WorkShop");
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取从source到endaddr的路径中的所有位置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">起始位置</param>
|
|
|
+ /// <param name="endAddr">目标位置</param>
|
|
|
+ /// <param name="condition">路径筛选条件</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static List<WCS_DEVICE> GetPath(this WCS_DEVICE source, string endAddr, Func<List<WCS_DEVICE>, bool> condition = null)
|
|
|
+ {
|
|
|
+ var q = source.PATHS.Where(v => v.START == source & v.END.CODE.Contains(endAddr.ToUpper()))
|
|
|
+ .Select(v => v.PATH.Split('-').Select(v => Device.Find(v)).ToList());
|
|
|
+
|
|
|
+ if (condition != null)
|
|
|
+ q = q.Where(condition);
|
|
|
+
|
|
|
+ return q.FirstOrDefault();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取从source到endaddr的路径中的第一个位置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">起始位置</param>
|
|
|
+ /// <param name="endAddr">目标位置</param>
|
|
|
+ /// <param name="condition">路径筛选条件</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static WCS_DEVICE GetPath(this WCS_DEVICE source, string endAddr)
|
|
|
+ {
|
|
|
+ var q = source.PATHS.Where(v => v.START == source && v.END.CODE.Contains(endAddr.ToUpper()))
|
|
|
+ .Select(v => v.PATH.Split('-').Select(v => Device.Find(v)).ToList());
|
|
|
+
|
|
|
+ return q.FirstOrDefault().FirstOrDefault();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static WCS_DEVICE GetNext(this WCS_DEVICE source, string endAddr)
|
|
|
+ {
|
|
|
+ return source.GetNext(endAddr, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取从source到endaddr的路径中的下一个位置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source">起始位置</param>
|
|
|
+ /// <param name="endAddr">目标位置</param>
|
|
|
+ /// <param name="condition">路径筛选条件</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static WCS_DEVICE GetNext(this WCS_DEVICE source, string endAddr, Func<List<WCS_DEVICE>, bool> condition)
|
|
|
+ {
|
|
|
+ var path = source.GetPath(endAddr, condition);
|
|
|
+ if (Ltc.Do(path, v => v == null || v.Count == 0))
|
|
|
+ return null;
|
|
|
+
|
|
|
+ if (source.IsConv())
|
|
|
+ {
|
|
|
+ var obj = path.FirstOrDefault(v => !v.IsConv());
|
|
|
+ if (obj == null)
|
|
|
+ {
|
|
|
+ return path.Last();
|
|
|
+ }
|
|
|
+ else if (obj.IsRGV())
|
|
|
+ {
|
|
|
+ var target = path.Skip(path.IndexOf(obj) + 1).FirstOrDefault();
|
|
|
+ return target;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return path.First();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool IsDevGroup(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return source.CODE.Contains("G");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool IsRGV(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return source.DEVICEPROTOCOLS.Any(v => v.DB.PROTOCOL == typeof(IRGV520).AssemblyQualifiedName);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool IsConv(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return source.DEVICEPROTOCOLS.Any(v => v.DB.PROTOCOL == typeof(IStation521).AssemblyQualifiedName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 是否堆垛机
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="source"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static bool IsSC(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return source.DEVICEPROTOCOLS.Any(v => v.DB.PROTOCOL == typeof(ISRM520).AssemblyQualifiedName);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool IsTunnel(this WCS_DEVICE source)
|
|
|
+ {
|
|
|
+ return source.DEVICEPROTOCOLS.Count == 0 && source.CODE.StartsWith("T");
|
|
|
+ }
|
|
|
+
|
|
|
public static void AddFlag(DF flag, params string[] devices)
|
|
|
{
|
|
|
var arr = LogicHandler.AllObjects.OfType<WCS_DEVICE>().Where(v => devices.Contains(v.CODE)).ToArray();
|