using PlcSiemens.Core.Extension; using ServiceCenter.Logs; using WCS.Core; using WCS.WorkEngineering.Protocol.BCR; namespace WCS.WorkEngineering.Extensions { /// /// BCR扩展 /// public class BCR : Device { /// /// BCR扩展 /// /// /// public BCR(Device device, World world) : base(device, world) { } /// /// 获取BCR码 /// /// public string GetBCRCode() { var barcode = Data.Content.Trim().Split('\0')[0]; if (barcode.IsNullOrWhiteSpace()) throw new KnownException($"{Entity.Code}--扫码失败,内容为空", LogLevelEnum.High); return barcode; } } /// /// BCR扩展 /// public static class BCRExtension { /// /// 获取BCR码 /// /// /// BCR对应站点设备号 /// public static string GetBCRCode(this List bs, string code) { code = "BCR" + code; var bcr = bs.FirstOrDefault(p => p.Entity.Code == code) ?? throw new KnownException($"未找到扫码器{code}", LogLevelEnum.High); return bcr.GetBCRCode(); } } }