12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using PlcSiemens.Core.Extension;
- using ServiceCenter.Logs;
- using WCS.Core;
- using WCS.Entity.Protocol.BCR;
- namespace WCS.WorkEngineering.Extensions
- {
- /// <summary>
- /// BCR扩展
- /// </summary>
- public class BCR : Device<IBCR81>
- {
- /// <summary>
- /// BCR扩展
- /// </summary>
- /// <param name="device"></param>
- /// <param name="world"></param>
- public BCR(Device device, World world) : base(device, world)
- {
- }
- /// <summary>
- /// 获取BCR码
- /// </summary>
- /// <returns></returns>
- public string GetBCRCode()
- {
- var barcode = Data.Content.RemoveEscapeCharacters();
- if (barcode.IsNullOrWhiteSpace()) throw new KnownException($"{Entity.Code}--扫码失败,内容为空", LogLevelEnum.High);
- return barcode;
- }
- }
- /// <summary>
- /// BCR83
- /// </summary>
- public class BCR83 : Device<IBCR83>
- {
- /// <summary>
- /// BCR扩展
- /// </summary>
- /// <param name="device"></param>
- /// <param name="world"></param>
- public BCR83(Device device, World world) : base(device, world)
- {
- }
- /// <summary>
- /// 获取BCR码
- /// </summary>
- /// <returns></returns>
- public string GetBCRCode()
- {
- var barcode = Data.BcrCode.RemoveEscapeCharacters();
- if (barcode.IsNullOrWhiteSpace()) throw new KnownException($"{Entity.Code}--扫码失败,内容为空", LogLevelEnum.High);
- return barcode;
- }
- }
- /// <summary>
- /// BCR扩展
- /// </summary>
- public static class BCRExtension
- {
- /// <summary>
- /// 获取BCR码
- /// </summary>
- /// <param name="bs"></param>
- /// <param name="code">BCR对应站点设备号</param>
- /// <returns></returns>
- public static string GetBCRCode(this List<BCR> bc, string code)
- {
- code = "BCR" + code;
- var bcr = bc.FirstOrDefault(p => p.Entity.Code == code) ?? throw new KnownException($"未找到扫码器{code}", LogLevelEnum.High);
- return bcr.GetBCRCode();
- }
- ///// <summary>
- ///// 获取BCR83码集合
- ///// </summary>
- ///// <param name="bc"></param>
- ///// <returns></returns>
- //public static string GetBCRCodeList(this BCR83 bc)
- //{
- //}
- }
- }
|