充电机电池包Msg和Handler

master
xjl 6 months ago
parent cd66481c45
commit e43e1c8c0f

@ -1,6 +1,7 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.Session;
using HybirdFrameworkDriver.TcpClient;
using HybirdFrameworkServices.Charger.Handler;
using Service.Charger.Codec;
using Service.Charger.Common;
using Service.Charger.Handler;
@ -28,11 +29,35 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
public bool IsCharged { get; set; } = false;
public bool IsStopped { get; set; } = false;
public bool IsCanSendStopCmd { get; set; } = true;
public DateTime? ChargingStartTime { get; set; }
public DateTime? ChargingStopTime { get; set; }
/// <summary>
/// 电池包实时数据
/// </summary>
public BatteryPackData? BatteryPackData { get; set; }
/// <summary>
/// 电池包实时单体温度&单体电压数据
/// </summary>
public BatteryPackDataVoltage? BatteryPackDataVoltage { get; set; }
/// <summary>
/// 电池包上报累计充放电电量
/// </summary>
public BatteryPackTotalElectricity? BatteryPackTotalElectricity { get; set; }
/// <summary>
/// 电池包上报充放电口温度
/// </summary>
public BatteryPackPortTemperature? BatteryPackPortTemperature { get; set; }
/// <summary>
/// 电池包内部接触器状态和故障上报
/// </summary>
public BatteryPackStateAndFault? BatteryPackStateAndFault { get; set; }
/// <summary>
///充电机遥信数据
/// </summary>

@ -124,12 +124,20 @@ public class Decoder : ByteToMessageDecoder
48 => ModelConvert.Decode<ResponseSetting>(bytes),
50 => ModelConvert.Decode<SdUpPkFtValSet>(bytes),
75 => ModelConvert.Decode<UploadModuleStatus>(bytes),
83 => ModelConvert.Decode<QueryVersionRes>(bytes),
82 => ModelConvert.Decode<BatteryPackData>(bytes),
83 => ModelConvert.Decode<BatteryPackDataVoltage>(bytes),
84 => ModelConvert.Decode<BatteryPackTotalElectricity>(bytes),
85 => ModelConvert.Decode<BatteryPackPortTemperature>(bytes),
86 => ModelConvert.Decode<BatteryPackStateAndFault>(bytes),
//83 => ModelConvert.Decode<QueryVersionRes>(bytes),
87 => ModelConvert.Decode<ElecMeterInfo>(bytes),
49 => ModelConvert.Decode<InquireGatewaySpikesValleys>(bytes),
47 => ModelConvert.Decode<SetPeakValleyTime>(bytes),
86 => ModelConvert.Decode<UploadUpgrade>(bytes),
// 86 => ModelConvert.Decode<UploadUpgrade>(bytes),
_ => throw new InvalidOperationException("This should never be reached"),
},
#endregion

@ -0,0 +1,35 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.5.9 电池包实时数据上报(站内充电模式有电池包时周期性上传)
/// <code>
/// 1保存电池包实时数据
/// 2保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class BatteryPackDataHandler : SimpleChannelInboundHandler<BatteryPackData>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryPackDataHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackData msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryPackData = msg;
}
}
}
}

@ -0,0 +1,35 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.5.10 电池包实时单体温度&单体电压数据(站内充电模式有电池包时周期性上传)
/// <code>
/// 1电池包实时单体温度&单体电压数据
/// 2保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class BatteryPackDataVoltageHandler : SimpleChannelInboundHandler<BatteryPackDataVoltage>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryPackDataVoltageHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackDataVoltage msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryPackDataVoltage = msg;
}
}
}
}

@ -0,0 +1,35 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.5.12 电池包上报充放电口温度(站内充电模式有电池包时周期性上传)
/// <code>
/// 1保存电池包上报充放电口温度
/// 2保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class BatteryPackPortTemperatureHandler : SimpleChannelInboundHandler<BatteryPackPortTemperature>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryPackPortTemperatureHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackPortTemperature msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryPackPortTemperature = msg;
}
}
}
}

@ -0,0 +1,35 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.5.13 电池包内部接触器状态和故障上报(站内充电模式有电池包时周期性上传)
/// <code>
/// 1保存电池包内部接触器状态和故障上报
/// 2保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class BatteryPackStateAndFaultHandler : SimpleChannelInboundHandler<BatteryPackStateAndFault>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryPackStateAndFaultHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackStateAndFault msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryPackStateAndFault = msg;
}
}
}
}

@ -0,0 +1,35 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.5.11 电池包上报累计充放电电量(站内充电模式有电池包时周期性上传
/// <code>
/// 1保存电池包上报累计充放电电量数据
/// 2保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class BatteryPackTotalElectricityHandler : SimpleChannelInboundHandler<BatteryPackTotalElectricity>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryPackTotalElectricityHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryPackTotalElectricity msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryPackTotalElectricity = msg;
}
}
}
}

@ -0,0 +1,63 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.Req
{
/// <summary>
/// 3.5.9 电池包实时数据上报(站内充电模式有电池包时周期性上传)
/// </summary>
public class BatteryPackData : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 电池包 SOC
/// </summary>
[Property(8, 8, PropertyReadConstant.Bit, 0.4, 1)]
public float SOC { get; set; }
/// <summary>
/// 电池包 SOH
/// </summary>
[Property(16, 8, PropertyReadConstant.Bit, 0.4, 1)]
public float SOH { get; set; }
/// <summary>
/// 电池包总电流,充电为负值,放电为正
/// </summary>
[Property(24, 16, PropertyReadConstant.Bit, 0.1, 1, 1000)]
public float TotalCurrent { get; set; }
/// <summary>
/// 电池包允许最大回充电电流值(脉冲)
/// </summary>
[Property(40, 16, PropertyReadConstant.Bit, 0.1, 1)]
public float AllowableMaxBackCurrent { get; set; }
/// <summary>
/// 电池包允许最大放电电流值(脉冲)
/// </summary>
[Property(56, 16, PropertyReadConstant.Bit, 0.1, 1)]
public float AllowableMaxPutCurrent { get; set; }
/// <summary>
/// 电池包正极绝缘值
/// </summary>
[Property(72, 16)]
public UInt16 PositiveInsulationValue { get; set; }
/// <summary>
/// 电池包负极绝缘值
/// </summary>
[Property(88, 16)]
public UInt16 NegativeInsulationValue { get; set; }
/// <summary>
/// 电池端高压(主继电器内侧)
/// </summary>
[Property(104, 16)]
public UInt16 BatteryHighVoltage { get; set; }
/// <summary>
/// 母线端高压(主继电器外侧) Busbar
/// </summary>
[Property(120, 16)]
public UInt16 BusbarHighVoltage { get; set; }
}
}

@ -0,0 +1,89 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.Req
{
/// <summary>
/// 3.5.10 电池包实时单体温度&单体电压数据(站内充电模式有电池包时周期性上传)
/// </summary>
public class BatteryPackDataVoltage : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 电芯温度最大值
/// </summary>
[Property(8, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 CellTemperatureMax { get; set; }
/// <summary>
/// 电芯温度最小值
/// </summary>
[Property(16, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 CellTemperatureMin { get; set; }
/// <summary>
/// 电芯温度平均值
/// </summary>
[Property(24, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 CellTemperatureAverage { get; set; }
/// <summary>
/// 电芯温度最大值所在 CSC 编号
/// </summary>
[Property(32, 8 )]
public byte CellTemperatureCSCNumber { get; set; }
/// <summary>
/// 电芯温度最大值所在 CSC 内温度探针编号
/// </summary>
[Property(40, 8 )]
public byte CellTemperatureCSCProbeNumber { get; set; }
/// <summary>
/// 电芯温度最小值所在 CSC 编号
/// </summary>
[Property(48, 8)]
public byte CellTemperatureMinCSCNumber { get; set; }
/// <summary>
/// 电芯温度最小值所在 CSC 内温度探针编号
/// </summary>
[Property(56, 8)]
public byte CellTemperatureMinCSCProbeNumber { get; set; }
/// <summary>
/// 电芯电压最大值
/// </summary>
[Property(64, 16, PropertyReadConstant.Bit, 0.001, 3)]
public float CellVoltageMax { get; set; }
/// <summary>
/// 电芯电压最大值所在 CSC 编号
/// </summary>
[Property(80, 8)]
public byte CellVoltageCSCNumber { get; set; }
/// <summary>
/// 电芯电压最大值所在 CSC 内的单体编号
/// </summary>
[Property(88, 8)]
public byte CellVoltageCSCProbeNumber { get; set; }
/// <summary>
/// 电芯电压平均值
/// </summary>
[Property(96, 16, PropertyReadConstant.Bit, 0.001, 3)]
public float CellVoltageAverage { get; set; }
/// <summary>
/// 电芯电压最小值
/// </summary>
[Property(112, 8, PropertyReadConstant.Bit, 0.001, 3)]
public float CellVoltageMin { get; set; }
/// <summary>
/// 电芯电压最小值所在 CSC 编号
/// </summary>
[Property(128, 8)]
public byte CellVoltageMinCSCNumber { get; set; }
/// <summary>
/// 电芯电压最小值所在 CSC 内的单体编号
/// </summary>
[Property(136, 8)]
public byte CellVoltageMinCSCProbeNumber { get; set; }
}
}

@ -0,0 +1,38 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.Req
{
/// <summary>
/// 3.5.12 电池包上报充放电口温度(站内充电模式有电池包时周期性上传)
/// </summary>
public class BatteryPackPortTemperature : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// A 枪温度 1/充电连接器1 温度 1
/// </summary>
[Property(8, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 AGunTemperature1 { get; set; }
/// <summary>
/// A 枪温度 2/充电连接器1 温度2
/// </summary>
[Property(16, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 AGunTemperature2 { get; set; }
/// <summary>
/// B 枪温度 1/充电连接器2 温度 1
/// </summary>
[Property(24, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 BGunTemperature1 { get; set; }
/// <summary>
/// B 枪温度 2/充电连接器2 温度2
/// </summary>
[Property(32, 8, PropertyReadConstant.Bit, 1, 0, 50)]
public Int16 BGunTemperature2 { get; set; }
}
}

@ -0,0 +1,178 @@
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar.DistributedSystem.Snowflake;
namespace Service.Charger.Msg.Charger.Req
{
/// <summary>
/// 3.5.13 电池包内部接触器状态和故障上报(站内充电模式有电池包时周期性上传)
/// </summary>
public class BatteryPackStateAndFault : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 充负 1 继电器粘连故障
/// </summary>
[Property(8, 8)]
public byte ChargingNegativeOneAdhesionFault { get; set; }
/// <summary>
/// 充正 1 继电器粘连故 障
/// </summary>
[Property(16, 8)]
public byte ChargingCorrectOneAdhesionFault { get; set; }
/// <summary>
/// 主负继电器粘连故障
/// </summary>
[Property(24, 8)]
public byte MainNegativeAdhesionFault { get; set; }
/// <summary>
/// 主正继电器粘连故障
/// </summary>
[Property(32, 8)]
public byte MainCorrectAdhesionFault { get; set; }
/// <summary>
/// 主负继电器状态(如继 电器状态由 BMS检测)
/// </summary>
[Property(40, 8)]
public byte MainNegativeState { get; set; }
/// <summary>
/// 主正继电器状态(如继 电器状态由 BMS检测)
/// </summary>
[Property(48, 8)]
public byte MainCorrectState { get; set; }
/// <summary>
/// 加热 2 继电器粘连故障
/// </summary>
[Property(56, 8)]
public byte HeatingTwoAdhesionFault { get; set; }
/// <summary>
/// 加热 1 继电器粘连故障
/// </summary>
[Property(64, 8)]
public byte HeatingOneAdhesionFault { get; set; }
/// <summary>
/// 充负 2 继电器粘连故障
/// </summary>
[Property(72, 8)]
public byte ChargingNegativeTwoAdhesionFault { get; set; }
/// <summary>
/// 充正 2 继电器粘连故障
/// </summary>
[Property(80, 8)]
public byte ChargingCorrectTwoAdhesionFault { get; set; }
/// <summary>
/// 充正继电器 2状态(如 继电器状态由 BMS检测)
/// </summary>
[Property(88, 8)]
public byte ChargingCorrectTwoState { get; set; }
/// <summary>
/// 充负继电器 2状态(如 继电器状态由 BMS检 测)
/// </summary>
[Property(96, 8)]
public byte ChargingNegativeTwoState { get; set; }
/// <summary>
/// 充负继电器 1状态(如 继电器状态由 BMS检 测)
/// </summary>
[Property(104, 8)]
public byte ChargingNegativeOneState { get; set; }
/// <summary>
/// 充正继电器 1状态(如 继电器状态由 BMS检 测
/// </summary>
[Property(112, 8)]
public byte ChargingCorrectOneState { get; set; }
/// <summary>
/// 预充继电器状态(如继电器状态由 BMS 检测)
/// </summary>
[Property(120, 8)]
public byte PreChargingState { get; set; }
/// <summary>
/// 主负继电器无法闭合 报警
/// </summary>
[Property(128, 8)]
public byte MainNegativeNotCloseFault { get; set; }
/// <summary>
/// 主正继电器无法闭合 报警
/// </summary>
[Property(136, 8)]
public byte MainCorrectNotCloseFault { get; set; }
/// <summary>
/// 支路断路故障
/// </summary>
[Property(144, 8)]
public byte BranchBrokenFault { get; set; }
/// <summary>
/// 附件继电器粘连故障(保留)
/// </summary>
[Property(152, 8)]
public byte AnnexAdhesionFault { get; set; }
/// <summary>
/// BMS 24V 供电异常报 警
/// </summary>
[Property(160, 8)]
public byte BMSPowerSupplyFault { get; set; }
/// <summary>
/// BMS 24V 供电异常报 警
/// </summary>
[Property(168, 8)]
public byte BMSPowerSupplyFault2 { get; set; }//协议里两个字段一样
/// <summary>
/// 热管理系统故障
/// </summary>
[Property(176, 8)]
public byte ThermalManagementFault { get; set; }
/// <summary>
/// 加热膜或 TMS接触器 无法闭合故障
/// </summary>
[Property(184, 8)]
public byte HeatingFilmNotCloseFault { get; set; }
/// <summary>
/// 加热膜或 TMS接触器 无法闭合故障
/// </summary>
[Property(192, 8)]
public byte HeatingFilmNotCloseFault2 { get; set; }////协议里两个字段一样
/// <summary>
/// 加热膜或 TMS接触器 无法断开报警
/// </summary>
[Property(200, 8)]
public byte HeatingFilmNotDisconnectFault { get; set; }
/// <summary>
/// 直流充电 2 负继电器 无法闭合报警
/// </summary>
[Property(208, 8)]
public byte DcTwoNegativeNotCloseFault { get; set; }
/// <summary>
/// 直流充电 2 正继电器 无法闭合报警
/// </summary>
[Property(216, 8)]
public byte DcTwoCorrectNotCloseFault { get; set; }
/// <summary>
/// 直流充电 1 负继电器 无法闭合报警
/// </summary>
[Property(224, 8)]
public byte DcOneNegativeNotCloseFault { get; set; }
/// <summary>
/// 直流充电 1 正继电器 无法闭合报警
/// </summary>
[Property(232, 8)]
public byte DcOneCorrectNotCloseFault { get; set; }
/// <summary>
/// 充电插座过温报警
/// </summary>
[Property(240, 8)]
public byte ChargingSocketOverheatedFault { get; set; }
/// <summary>
/// 电池包自保护报警
/// </summary>
[Property(248, 8)]
public byte SelfProtectionFault { get; set; }
/// <summary>
/// 电池系统故障码
/// </summary>
[Property(256, 8)]
public byte BatterySystemFaultCode { get; set; }
}
}

@ -0,0 +1,48 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.Req
{
/// <summary>
/// 3.5.11 电池包上报累计充放电电量(站内充电模式有电池包时周期性上传
/// </summary>
public class BatteryPackTotalElectricity : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 累计充电电量
/// </summary>
[Property(8, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float TotalElectricCharge { get; set; }
/// <summary>
/// 累计放电电量
/// </summary>
[Property(40, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float TotalElectricDischarge { get; set; }
/// <summary>
/// 单次充电电量
/// </summary>
[Property(72, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float OnceElectricCharge { get; set; }
/// <summary>
/// 累计动能回馈充电电量
/// </summary>
[Property(88, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float TotalFeedbackElectricCharge { get; set; }
/// <summary>
/// 累计换电电量
/// </summary>
[Property(120, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float TotalElectricSwap { get; set; }
/// <summary>
/// 累计插枪充电电量
/// </summary>
[Property(152, 32, PropertyReadConstant.Bit, 0.1, 1, 0)]
public float TotalElectricInsertCharge { get; set; }
}
}
Loading…
Cancel
Save