You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.7 KiB
106 lines
2.7 KiB
|
|
using Entity.Constant;
|
|
using HybirdFrameworkCore.Configuration;
|
|
using Service.Execute.Model;
|
|
|
|
namespace Service.Execute
|
|
{
|
|
/// <summary>
|
|
/// 软件管理类
|
|
/// </summary>
|
|
public class StationSoftMgr
|
|
{
|
|
public static readonly SwappingStateMachine SwappingStateMachine = SwappingStateMachine.GetInstance();
|
|
|
|
|
|
public static Dictionary<int, List<SwapDeviceLog>> 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 换电流程
|
|
|
|
/// <summary>
|
|
/// 换电流程启动
|
|
/// </summary>
|
|
public static void SwappingStateMachineStart()
|
|
{
|
|
SwappingStateMachine.Start();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 换电流程重置
|
|
/// </summary>
|
|
public static void SwappingStateMachineCancel()
|
|
{
|
|
SwappingStateMachine.Cancel();
|
|
}
|
|
/// <summary>
|
|
/// 换电流程收栋操作
|
|
/// </summary>
|
|
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<SwapDeviceLog> list = new List<SwapDeviceLog>() { 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
|
|
}
|
|
}
|