using Entity.Constant; using HybirdFrameworkCore.Configuration; using Service.Execute.Model; namespace Service.Execute { /// /// 软件管理类 /// public class StationSoftMgr { public static readonly SwappingStateMachine SwappingStateMachine = SwappingStateMachine.GetInstance(); public static Dictionary> DeviceLogs = new () { [(int)StationConstant.DeviceCode.Radar] = new (), [(int)StationConstant.DeviceCode.Rfid] = new (), [(int)StationConstant.DeviceCode.Tbox] = new (), [(int)StationConstant.DeviceCode.Plc] = new(), }; public static readonly string addr1 = AppSettingsHelper.GetContent("SoundAddr", "Address1"); #region 换电流程 /// /// 换电流程启动 /// public static void SwappingStateMachineStart() { SwappingStateMachine.Start(); } /// /// 换电流程重置 /// public static void SwappingStateMachineCancel() { SwappingStateMachine.Cancel(); } /// /// 换电流程收栋操作 /// public static void SwappingStateMachineManual() { SwappingStateMachine.Manual(); } #endregion 换电流程启动 #region 设备业务数据日志 public static void PutDeviceLog(int key, Enum @enum,string data,int type) { SwapDeviceLog deviceLog = BuildDeviceLog(@enum, data,key, type); DeviceLogs.TryGetValue(key, out var value); if (value == null) { List list = new List() { deviceLog }; DeviceLogs[key] = list; } else { value.Add(deviceLog); if (value.Count > 10) { var swapDeviceLogs = value.OrderByDescending(i => i.Time).ToList(); var deviceLogs = swapDeviceLogs.Take(10).ToList(); value = deviceLogs.OrderBy(i => i.Time).ToList(); } DeviceLogs[key] = value; } } public static SwapDeviceLog BuildDeviceLog(Enum @enum,string data,int device,int type) { return new() { Time = DateTime.Now, desc = BaseEnumExtensions.GetDescription(@enum), Data = data, Device = device, Type = type }; } #endregion } }