|
@@ -1,5 +1,9 @@
|
|
|
-using WCS.Core;
|
|
|
-using PLCType = WCS.Core.PLCType;
|
|
|
+using PlcSiemens.Core.Extension;
|
|
|
+using ServiceCenter.Logs;
|
|
|
+using ServiceCenter.Redis;
|
|
|
+using WCS.Core;
|
|
|
+using WCS.WorkEngineering.Protocol.BCR;
|
|
|
+using WCS.WorkEngineering.Protocol.Station;
|
|
|
|
|
|
namespace WCS.WorkEngineering.Extensions
|
|
|
{
|
|
@@ -54,7 +58,7 @@ namespace WCS.WorkEngineering.Extensions
|
|
|
Port = 102,
|
|
|
Rack = 0,
|
|
|
Slot = 1,
|
|
|
- Type = PLCType.Siemens
|
|
|
+ //Type = PLCType.Siemens
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -63,6 +67,93 @@ namespace WCS.WorkEngineering.Extensions
|
|
|
}
|
|
|
|
|
|
#endregion 协议操作扩展
|
|
|
+
|
|
|
+ #region 设备扩展方法
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否被禁止
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否被禁止(this Device<IStation520, IStation521, IStation523, IStation91> device)
|
|
|
+ {
|
|
|
+ var config = RedisHub.Default.Check("ForbidTubuEnter") ?? throw new Exception("请在Redis中配置入库口禁用");
|
|
|
+ var configs = config.Split(",");
|
|
|
+ if (configs.Contains(device.Entity.Code)) throw new KnownException("当前入库口已被禁用,请联系运维人员了解具体情况", LogLevelEnum.High);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否被禁止
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否被禁止(this Device<IStation520, IStation521, IStation523, IBCR81> device)
|
|
|
+ {
|
|
|
+ var config = RedisHub.Default.Check("ForbidTubuEnter") ?? throw new Exception("请在Redis中配置入库口禁用");
|
|
|
+ var configs = config.Split(",");
|
|
|
+ if (configs.Contains(device.Entity.Code)) throw new KnownException("当前入库口已被禁用,请联系运维人员了解具体情况", LogLevelEnum.High);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否被禁止
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否被禁止(this Device<IStation520, IStation521, IStation523, IStation91, IBCR81> device)
|
|
|
+ {
|
|
|
+ var config = RedisHub.Default.Check("ForbidTubuEnter") ?? throw new Exception("请在Redis中配置入库口禁用");
|
|
|
+ var configs = config.Split(",");
|
|
|
+ if (configs.Contains(device.Entity.Code)) throw new KnownException("当前入库口已被禁用,请联系运维人员了解具体情况", LogLevelEnum.High);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否满足执行条件
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否满足执行条件(this Device<IStation520, IStation521, IStation523, IStation91> device)
|
|
|
+ {
|
|
|
+ if (device.Data.VoucherNo != device.Data2.VoucherNo) throw new KnownException($"凭证号不一致,DB520:{device.Data.VoucherNo}-DB521:{device.Data2.VoucherNo}", LogLevelEnum.High);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.Run)) throw new KnownException("设备运行中", LogLevelEnum.Low);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 0) throw new KnownException("有光电无请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 1) throw new KnownException("无光电有请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.OT_Status)) throw new KnownException("站台货物信息与实际占用不一致", LogLevelEnum.Low);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否满足执行条件
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否满足执行条件(this Device<IStation520, IStation521, IStation523, IBCR81> device)
|
|
|
+ {
|
|
|
+ if (device.Data.VoucherNo != device.Data2.VoucherNo) throw new KnownException($"凭证号不一致,DB520:{device.Data.VoucherNo}-DB521:{device.Data2.VoucherNo}", LogLevelEnum.High);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.Run)) throw new KnownException("设备运行中", LogLevelEnum.Low);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 0) throw new KnownException("有光电无请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 1) throw new KnownException("无光电有请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.OT_Status)) throw new KnownException("站台货物信息与实际占用不一致", LogLevelEnum.Low);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 入库站点是否满足执行条件
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static void 入库站点是否满足执行条件(this Device<IStation520, IStation521, IStation523, IStation91, IBCR81> device)
|
|
|
+ {
|
|
|
+ if (device.Data.VoucherNo != device.Data2.VoucherNo) throw new KnownException($"凭证号不一致,DB520:{device.Data.VoucherNo}-DB521:{device.Data2.VoucherNo}", LogLevelEnum.High);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.Run)) throw new KnownException("设备运行中", LogLevelEnum.Low);
|
|
|
+ if (device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 0) throw new KnownException("有光电无请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.PH_Status) && device.Data2.Request == 1) throw new KnownException("无光电有请求", LogLevelEnum.Mid);
|
|
|
+ if (!device.Data3.Status.HasFlag(StationStatus.OT_Status)) throw new KnownException("站台货物信息与实际占用不一致", LogLevelEnum.Low);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取BCR码
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static string GetBCRCode(this IBCR81 bCR)
|
|
|
+ {
|
|
|
+ var barcode = bCR.Content.Trim('\0');
|
|
|
+ if (barcode.IsNullOrWhiteSpace()) throw new KnownException($"扫码失败,内容为空", LogLevelEnum.High);
|
|
|
+ return barcode;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 设备扩展方法
|
|
|
}
|
|
|
|
|
|
/// <summary>
|