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.

108 lines
3.5 KiB

using HybirdFrameworkCore.Utils;
using HybirdFrameworkDriver.Session;
using log4net;
using Service.Api.Resp;
using Service.Car.Msg.Car.Req;
using Service.Car.Server;
using Service.TBox.Msg.TBox;
using Service.TBox.Server;
namespace Service.TBox.Service;
public class TBoxService
{
private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxService));
/// <summary>
/// 焕能长治
///
/// </summary>
/// <param name="carNo"></param>
public static CarInfoResp GetHnCZCarInfo(string carNo)
{
IoSession? ioSession = CarServerMgr.CarServer?.SessionMgr.GetSession(carNo);
CarInfoResp carInfoResp = new CarInfoResp()
{
Connected = CarServerMgr.CarServer != null && ioSession != null,
CarNo = carNo,
CarInfo = new()
{
CarNo = carNo,
CarVin = carNo,
BatteryNum = 1,
}
};
if (ObjUtils.IsNotNull(ioSession))
{
ioSession.BusinessMap.TryGetValue("ElecMsg", out var elecMsg);
if (elecMsg != null)
{
carInfoResp.ElecMsg = (ElecMsg)elecMsg;
}
ioSession.BusinessMap.TryGetValue("HeartBeatMsg", out var heartBeatMsg);
if (heartBeatMsg != null)
{
var beatMsg = (HeartBeatMsg)heartBeatMsg;
CarStatus carStatus = new CarStatus();
carStatus.LockStatus = beatMsg.LockStatus;
carStatus.Keys = beatMsg.KeyStatus;
carInfoResp.CarStatus = carStatus;
}
}
return carInfoResp;
}
/// <summary>
/// 焕能阳泉
/// </summary>
/// <returns></returns>
public static CarInfoResp GetHnYQCarInfo(string carNo)
{
var statusMsg = TBoxServerMgr.Server?.StatusMsg;
BatteryInfo1? batteryInfo1 = TBoxServerMgr.Server?.BatteryInfo1;
StatusMsg? serverStatusMsg = TBoxServerMgr.Server?.StatusMsg;
LockStatusMsg? lockStatusMsg = TBoxServerMgr.Server?.LockStatusMsg;
CarInfoResp carInfoResp = new CarInfoResp()
{
CarNo = carNo,
Connected = TBoxServerMgr.Server != null && TBoxServerMgr.Server.Connected,
CarInfo = new()
{
CarNo = carNo,
CarVin = TBoxServerMgr.Server?.ReadVin(),
BatteryNum = 1,
CarType = statusMsg?.CarType,
BatteryInfos = new List<BatteryInfo>()
{
new()
{
BatteryNo = TBoxServerMgr.Server?.BatteryNo(),
Soc = TBoxServerMgr.Server?.SocMsg?.Soc,
Soe = batteryInfo1?.Soe,
Soh = TBoxServerMgr.Server?.SohMsg.Soh,
BatteryType = batteryInfo1?.TypeCode,
BatteryPackageModel = batteryInfo1?.Reserved1
}
}
},
ElecMsg = new()
{
CarNo = carNo,
SubMile = TBoxServerMgr.Server?.SubMileMsg?.SubMile,
TotalMile = TBoxServerMgr.Server?.TotalMileMsg?.TotalMile,
},
CarStatus = new()
{
Keys = serverStatusMsg?.Keys,
LockStatus = lockStatusMsg?.LockStatus,
Break = serverStatusMsg?.Break,
Gear = serverStatusMsg?.Gear
}
};
return carInfoResp;
}
}