电池包数据显示更改

master
CZ 3 months ago
parent 5589c8e388
commit 2bd33abb54

@ -0,0 +1,95 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 电池包基本参数2
/// </summary>
public class BasicParameterResp
{
/// <summary>
/// 记录类型
/// </summary>
public byte RecordType { get; set; }
/// <summary>
/// PGN 码
/// </summary>
public byte Pgn1 { get; set; }
public byte Pgn2 { get; set; }
public byte Pgn3 { get; set; }
/// <summary>
/// 电池编码
/// </summary>
public byte[] BatteryCode { get; set; }
/// <summary>
/// 产权标识
/// </summary>
public byte TitleMarke { get; set; }
/// <summary>
/// 电池成组厂商
/// </summary>
public string Batterymanufacturers { get; set; }
/// <summary>
/// 电池成组生产日期:年
/// </summary>
public byte GroupYear { get; set; }
/// <summary>
/// 电池成组生产日期:月
/// </summary>
public byte GroupMonth { get; set; }
/// <summary>
/// 电池成组生产日期:日
/// </summary>
public byte GroupDay { get; set; }
/// <summary>
/// 电池电芯生产厂商
/// </summary>
public byte[] BatteryManufacturer { get; set; }
/// <summary>
/// 电池电芯生产日期:年
/// </summary>
public byte CellYear { get; set; }
/// <summary>
/// 电池电芯生产日期:月
/// </summary>
public byte CellMonth { get; set; }
/// <summary>
/// 电池电芯生产日期:日
/// </summary>
public byte CellDay { get; set; }
/// <summary>
/// 电池箱电子控制单元生产厂商
/// </summary>
public byte[] Manufacturer { get; set; }
/// <summary>
/// 电池箱电子控制单元硬件版本
/// </summary>
public byte HardwareVersion { get; set; }
/// <summary>
/// 电池箱电子控制单元软件版本
/// </summary>
public byte SoftwareVersion { get; set; }
/// <summary>
/// 电池包序列号
/// </summary>
public byte[] SerialNumber { get; set; }
/// <summary>
/// 电池包型号
/// </summary>
public byte[] ModelNumber { get; set; }
}

@ -0,0 +1,42 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 3.6.2.4 充放电机上传电池包基本信息PGN:0x00F882
/// </summary>
public class BatteryBaseInfoResp
{
public string Pgn { get; set; }
/// <summary>
/// 电池包额定量度
/// </summary>
public byte RatedMeasurement{get;set;}
/// <summary>
/// 电池包额定电压
/// </summary>
public byte PackVoltage{get;set;}
/// <summary>
/// 电池包额定总能量
/// </summary>
public byte RatedBatteryPack{get;set;}
/// <summary>
/// 电池冷却方式
/// </summary>
public byte BatteryCoolingSystem{get;set;}
/// <summary>
/// 电池类型
/// </summary>
public byte BatteryType{get;set;}
/// <summary>
/// 电池系统中 CSC总的数目电池监控单元数目
/// </summary>
public byte BatteryCSCSNumber{get;set;}
/// <summary>
/// PACK 中单体电芯的总数目
/// </summary>
public byte PACKNumber{get;set;}
/// <summary>
/// PACK 中电芯温度点(探针)的总数目
/// </summary>
public byte PACKTemperatureNumber{get;set;}
}

@ -0,0 +1,54 @@
namespace Entity.Dto.Resp;
public class BatteryInfoResp
{
/// <summary>
/// 仓位编码
/// </summary>
public string code { get; set; }
/// <summary>
/// 仓位名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 充电机编号
/// </summary>
public string charger_no { get; set; }
/// <summary>
/// 遥测数据
/// </summary>
public UploadTelemetryDataResp UploadTelemetryDataResp { get; set; }
/// <summary>
/// 电池包基本信息
/// </summary>
public BatteryBaseInfoResp BatteryBaseInfoResp { get; set; }
/// <summary>
/// 电池包基本参数2
/// </summary>
public BasicParameterResp BasicParameterResp { get; set; }
/// <summary>
/// 电池包基本状态
/// </summary>
public UpBmsResp UpBmsResp { get; set; }
/// <summary>
/// 电池包报警状态
/// </summary>
public UpAlarmResp UpAlarmResp { get; set; }
/// <summary>
/// 电池包编码和SOC数据
/// </summary>
public VoltageCurrentSocResp VoltageCurrentSocResp { get; set; }
/// <summary>
/// 电压温度极值统计
/// </summary>
public VoltageExtremumStatisticsResp VoltageExtremumStatisticsResp { get; set; }
}

@ -0,0 +1,199 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 电池包报警状态
/// </summary>
public class UpAlarmResp
{
/// <summary>
/// 记录类型
/// </summary>
public byte RecordType { get; set; }
/// <summary>
/// PGN 码
/// </summary>
public byte Pgn1 { get; set; }
public byte Pgn2 { get; set; }
public byte Pgn3 { get; set; }
/// <summary>
/// 单体蓄电池或蓄电池模块电压越限
/// </summary>
public byte SingleBattery { get; set; }
/// <summary>
/// 电压偏差越限
/// </summary>
public byte VoltageOvershoot { get; set; }
/// <summary>
/// 温度越限
/// </summary>
public byte TemperatureExceedance { get; set; }
/// <summary>
/// 温度偏差越限
/// </summary>
public byte TemperatureDifference { get; set; }
/// <summary>
/// SOC 低
/// </summary>
public byte LowSOC { get; set; }
/// <summary>
/// 放电电流越限
/// </summary>
public byte DischargeCurrent { get; set; }
/// <summary>
/// 充电电流限
/// </summary>
public byte ChargingCurrentLimit { get; set; }
/// <summary>
/// 总正负极柱温度越限
/// </summary>
public byte TotalTemp { get; set; }
/// <summary>
/// 电池系统故障码
///
/// 0x1011 单体温度过高一级
/// 0x1012 单体温度过高二级
/// 0x1013 单体温度过高三级
/// 0x1021 单体温度过低一级
/// 0x1022 单体温度过低二级
/// 0x1023 单体温度过低三级
/// 0x1031 单体过压一级
/// 0x1032 单体过压二级
/// 0x1033 单体过压三级
/// 0x1041 单体欠压一级
/// 0x1042 单体欠压二级
/// 0x1043 单体欠压三级
/// 0x10A1 电池包总压过高一级
/// 0x10A2 电池包总压过高二级
/// 0x10A3 电池包总压过高三级
/// 0x10B1 电池包总压过低一级
/// 0x10B2 电池包总压过低二级
/// 0x10B3 电池包总压过低三级
/// 0x1061 放电过流一级
/// 0x1062 放电过流二级
/// 0x1063 放电过流三级
/// 0x1091 充电过流一级
/// 0x1092 充电过流二级
/// 0x1093 充电过流三级
/// 0x10E1 单体压差过大一级
/// 0x10E2 单体压差过大二级
/// 0x10E3 单体压差过大三级
/// 0x10D1 单体温差过大一级
/// 0x10D2 单体温差过大二级
/// 0x10D3 单体温差过大三级
/// 0x10C1 绝缘过低一级
/// 0x10C2 绝缘过低二级
/// 0x10C3 绝缘过低三级
/// 0x10F1 SOC 过低一级
/// 0x10F2 SOC 过低二级
/// 0x10F3 SOC 过低三级
/// 0x1111 供电电压过低一级
/// 0x1112 供电电压过低二级
/// 0x1113 供电电压过低三级
/// 0x1121 供电电压过高一级
/// 0x1122 供电电压过高二级
/// 0x1123 供电电压过高三级
/// 0x1141 电池温升过快一级
/// 0x1142 电池温升过快二级
/// 0x1143 电池温升过快三级
/// 0x1103 Pack 回路断开
/// 0x2013 从板通讯丢失
/// 0x2033 充电机丢失
/// 0x2043 绝缘仪通讯丢失
/// 0x2053 电流传感器通讯丢失
/// 0x2073 热管理机组通讯丢失
/// 0x20E3 电流传感器采样异常
/// 0x20D3 绝缘采样异常
/// 0x4013 主正继电器开路故障
/// 0x4023 主负继电器开路故障
/// 0x40F2 主正继电器粘连故障
/// 0x4102 主负继电器粘连故障
/// 0x5013 外部短路故障
/// 0x5032 高压互锁故障
/// 0x5053 CC2 电压异常
/// 0x5153 充电枪连接故障
/// 0x6033 充电系统不匹配故障
/// 0x6023 充电电流异常
/// 0x7022 均衡故障
/// 0x8023 火灾报警
/// 0x8013 自保护故障
/// 0x8033 电池过放
/// 0x8043 电池过充
/// 0x5123 预充故障
/// 0x90B3 电池电压采样线开路
/// 0x90C3 电池温度采样线开路
/// 0x90E3 电池电压采样异常
/// 0x90F3 电池温度采样异常
/// </summary>
public short BatteryFaultCode { get; set; }
/// <summary>
/// 高压绝缘低
/// </summary>
public byte HighVoltageLow { get; set; }
/// <summary>
/// 单体蓄电池或蓄电池模块电压越极限
/// </summary>
public byte MonomerLimit { get; set; }
/// <summary>
/// 电压偏差越极限
/// </summary>
public byte VoltageDifference { get; set; }
/// <summary>
/// 温度越极限
/// </summary>
public byte TemperatureOvershoot { get; set; }
/// <summary>
/// 温度偏差越极限
/// </summary>
public byte TempDifference { get; set; }
/// <summary>
/// SOC 极低
/// </summary>
public byte VeryLowSoc { get; set; }
/// <summary>
/// 放电电流越极限
/// </summary>
public byte DischargeCurrentLimit { get; set; }
/// <summary>
/// 充电电流越极限
/// </summary>
public byte ChargingCurrent { get; set; }
/// <summary>
/// 总正负极柱温度越极限
/// </summary>
public byte TotalTempLimit { get; set; }
/// <summary>
/// 高压绝缘极低
/// </summary>
public byte HighVoltageInsulation { get; set; }
/// <summary>
/// 硬件故障
/// </summary>
public byte HardwareFailure { get; set; }
/// <summary>
/// 保留
/// </summary>
public byte Reserve { get; set; }
}

@ -0,0 +1,64 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 电池包基本状态
/// </summary>
public class UpBmsResp
{
/// <summary>
/// 记录类型
/// </summary>
public byte RecordType { get; set; }
/// <summary>
///PGN码
/// </summary>
public string Pgn { get; set; }
/// <summary>
/// 报警级别
/// 0正常
/// 1:1 级报警 3:3 级报警 5:5 级报警 其余保留
/// </summary>
public short AlarmLevel { get; set; }
/// <summary>
/// 电池箱所在位置编号 分辨率1/位偏移量0数值范围1~250
/// </summary>
public short BatteryBoxLocationNumber { get; set; }
/// <summary>
/// 电池箱能输出的最大电流值 分辨率0.05A/位,偏移量:-1600A数值范围-1600A ~ 1612.75A
/// </summary>
public short BatteryBoxMaximumCurrentOutput { get; set; }
/// <summary>
/// 电池箱能承受最大反馈电流值 分辨率0.05A/位,偏移量:-1600A数值范围-1600A~1612.75A
/// </summary>
public short BatteryMaximumFeedback { get; set; }
/// <summary>
/// 电池箱风扇状态 0关闭1开启 2不可用 3不可用
/// </summary>
public byte BatteryBoxFanStatus { get; set; }
/// <summary>
/// 加热装置状态 0关闭1开启 2不可用 3不可用
/// </summary>
public byte HeaterCondition { get; set; }
/// <summary>
/// 均衡状态 0关闭1开启 2不可用 3不可用
/// </summary>
public byte EquilibriumState { get; set; }
/// <summary>
/// 高压互锁状态 0 断开 1 连接
/// </summary>
public byte HighVoltageInterlockState { get; set; }
/// <summary>
/// 保留
/// </summary>
public short Reserve { get; set; }
}

@ -0,0 +1,168 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 遥测数据
/// </summary>
public class UploadTelemetryDataResp
{
/// <summary>
/// 当前 SOC
/// </summary>
public byte CurrentSoc { get; set; }
/// <summary>
/// 最高蓄电池温度
/// </summary>
public Int16 MaxBatteryTemp { get; set; }
/// <summary>
/// 最高温度检测点编号
/// </summary>
public ushort MaxTempDetectionPointNo { get; set; }
/// <summary>
/// 最低蓄电池温度数据分辨率1ºC/位,-50 ºC 偏移量;数据范围:-50ºC ~+200ºC
/// </summary>
public Int16 MinBatteryTemp { get; set; }
/// <summary>
/// 最低温度检测点编号
/// </summary>
public ushort MinTempDetectionPointNo { get; set; }
/// <summary>
/// 单体电池最高电压
/// </summary>
public float SingleBatteryMaxVoltage { get; set; }
/// <summary>
/// 单体电池最低压
/// </summary>
public float SingleBatteryMinVoltage { get; set; }
/// <summary>
/// 充电机环境温度
/// </summary>
public Int16 ChargerEnvTemp { get; set; }
/// <summary>
/// 充电导引电压
/// </summary>
public float ChargingPilotVoltage { get; set; }
/// <summary>
/// BMS 需求电压
/// </summary>
public float BmsNeedVoltage { get; set; }
/// <summary>
/// BMS 需求电流
/// </summary>
public float BmsNeedCurrent { get; set; }
/// <summary>
/// 充电模式 01H:恒压充电、02H恒流充电
/// </summary>
public byte ChargeMode { get; set; }
/// <summary>
/// BMS 充电电压测量值
/// </summary>
public float BmsChargingVoltage { get; set; }
/// <summary>
/// BMS 充电电流测量值
/// </summary>
public float BmsChargingCurrent { get; set; }
/// <summary>
/// 估算剩余充电时间
/// </summary>
public ushort EstimatedRemainingTime { get; set; }
/// <summary>
/// 充电接口温度探头 1
/// </summary>
public Int16 ChargingInterfaceDetectionOneTemp { get; set; }
/// <summary>
/// 充电接口温度探头 2
/// </summary>
public Int16 ChargingInterfaceDetectionTwoTemp { get; set; }
/// <summary>
/// 充电接口温度探头 3
/// </summary>
public Int16 ChargingInterfaceDetectionTheTemp { get; set; }
/// <summary>
/// 充电接口温度探头 4
/// </summary>
public Int16 ChargingInterfaceDetectionFourTemp { get; set; }
/// <summary>
/// 直流电表当前电量
/// </summary>
public float DcMeterCurrentPower { get; set; }
/// <summary>
/// 充电电压(直流电表电压)
/// </summary>
public float DcMeterVoltage { get; set; }
/// <summary>
/// 充电电流(直流电表电流)
/// </summary>
public float DcMeterCurrent { get; set; }
/// <summary>
/// 高压采集电压
/// </summary>
public float HighVoltageAcquisitionVoltage { get; set; }
/// <summary>
/// 高压采集电流
/// </summary>
public float HighVoltageAcquisitionCurrent { get; set; }
/// <summary>
/// 桩内部温度
/// </summary>
public byte ChargerInsideTemp { get; set; }
/// <summary>
/// 本次充电时间
/// </summary>
public ushort ChargingTime { get; set; }
/// <summary>
/// 模块进风口温度
/// </summary>
public byte ModuleOneAirInletTemp { get; set; }
/// <summary>
/// 模块出风口温度
/// </summary>
public byte ModuleTwoAirInletTemp { get; set; }
/// <summary>
/// 充电模式 0站内充电 1站外充电
/// </summary>
public byte ChargeModel { get; set; }
/// <summary>
/// 充电启动方式 1站控启动 2本地充电
/// </summary>
public byte ChargingStartMethod { get; set; }
/// <summary>
/// 交流电表当前电量
/// </summary>
public float ACMeterCurrentBatteryValue { get; set; }
/// <summary>
/// 设备编号
/// </summary>
public string ChargerNo { get; set; }
}

@ -0,0 +1,34 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 电池包编码和SOC数据
/// </summary>
public class VoltageCurrentSocResp
{
/// <summary>
/// 记录类型
/// </summary>
public byte RecordType { get; set; }
/// <summary>
/// PGN 码
/// </summary>
public byte Pgn1 { get; set; }
public byte Pgn2 { get; set; }
public byte Pgn3 { get; set; }
/// <summary>
/// 电压测量值 分辨率0.1V/位偏移量0V数值范围0V ~750V
/// </summary>
public float Voltage { get; set; }
/// <summary>
/// 电流测量值 分辨率0.05A/位,偏移量:-1600A数值范围-1600A~1612.75A
/// </summary>
public float Current { get; set; }
/// <summary>
/// 当前SOC 分辨率0.1%/位偏移量0%,数值范围 0%~100%
/// </summary>
public float SOC { get; set; }
/// <summary>
/// 当前SOH 分辨率1%/位偏移量0%,数值范围 0%~100%
/// </summary>
public float SOH { get; set; }
}

@ -0,0 +1,49 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 电压温度极值统计
/// </summary>
public class VoltageExtremumStatisticsResp
{
/// <summary>
/// 记录类型
/// </summary>
public byte RecordType { get; set; }
/// <summary>
/// PGN 码
/// </summary>
public byte Pgn1 { get; set; }
public byte Pgn2 { get; set; }
public byte Pgn3 { get; set; }
/// <summary>
/// 单体蓄电池或蓄电池模块最高电压
/// 分辨率0.01V/位偏移量0V数值范围0V ~24V
/// </summary>
public float MaximumVoltage { get; set; }
/// <summary>
/// 最高电压单体蓄电池或蓄电池模块的编号
/// 分辨率1/位偏移量0数值范围
/// </summary>
public float MaximumVoltageNum { get; set; }
/// <summary>
/// 单体蓄电池或蓄电池模块最低电压
/// 分辨率0.01V/位偏移量0V数值范围0V ~24V
/// </summary>
public float MinimumVoltage { get; set; }
/// <summary>
/// 最低电压单体蓄电池或蓄电池模块的编号
/// 分辨率1/位偏移量0数值范围1~250
/// </summary>
public float MinimumVoltageNum { get; set; }
/// <summary>
/// 单体平均电压
/// 分辨率0.01V/位偏移量0V数值范围0V ~24V
/// </summary>
public float CellAverageVoltage { get; set; }
}

@ -1,10 +1,13 @@
using System.Collections.Concurrent;
using AutoMapper;
using Entity.DbModel.Station;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Charger.Resp;
using Service.Charger.Msg.Host.Req;
using Service.Init;
using SqlSugar;
@ -182,4 +185,44 @@ public class ChargerService
batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);
}
public Result<List<BatteryInfoResp>> BatteryInfo()
{
List<BatteryInfoResp> lstBatteryInfoResp = new();
List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.CacheBinFlag == 0);
foreach (var binInfo in binInfos)
{
ChargerClient? chargerClient = ClientMgr.GetBySn(binInfo.ChargerNo);
if (chargerClient != null)
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<UploadTelemetryDataResp , UploadTelemetryData>().ReverseMap();
cfg.CreateMap<BatteryBaseInfoResp, BatteryBaseInfo>().ReverseMap();
cfg.CreateMap<BasicParameterResp, BasicParameter>().ReverseMap();
cfg.CreateMap<UpBmsResp, UpBms>().ReverseMap();
cfg.CreateMap<UpAlarmResp, UpAlarm>().ReverseMap();
cfg.CreateMap<VoltageCurrentSocResp, VoltageCurrentSoc>().ReverseMap();
cfg.CreateMap<VoltageExtremumStatisticsResp, VoltageExtremumStatistics>().ReverseMap();
});
IMapper mapper = config.CreateMapper();
BatteryInfoResp BatteryInfoResp = new();
BatteryInfoResp.code = binInfo.Code;
BatteryInfoResp.name = binInfo.Name;
BatteryInfoResp.charger_no = binInfo.ChargerNo;
BatteryInfoResp.UploadTelemetryDataResp=mapper.Map<UploadTelemetryDataResp>(chargerClient.UploadTelemetryData);
BatteryInfoResp.BatteryBaseInfoResp=mapper.Map<BatteryBaseInfoResp>(chargerClient.BatteryBaseInfo);
BatteryInfoResp.BasicParameterResp=mapper.Map<BasicParameterResp>(chargerClient.BasicParameter);
BatteryInfoResp.UpBmsResp=mapper.Map<UpBmsResp>(chargerClient.UpBms);
BatteryInfoResp.UpAlarmResp=mapper.Map<UpAlarmResp>(chargerClient.UpAlarm);
BatteryInfoResp.VoltageCurrentSocResp=mapper.Map<VoltageCurrentSocResp>(chargerClient.VoltageCurrentSoc);
BatteryInfoResp.VoltageExtremumStatisticsResp=mapper.Map<VoltageExtremumStatisticsResp>(chargerClient.VoltageExtremumStatistics);
lstBatteryInfoResp.Add(BatteryInfoResp);
}
}
return Result<List<BatteryInfoResp>>.Success(lstBatteryInfoResp);
}
}

@ -161,6 +161,14 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// </summary>
public VoltageExtremumStatistics? VoltageExtremumStatistics = new VoltageExtremumStatistics();
public BatteryBaseInfo? BatteryBaseInfo = new();
public VoltageCurrentSoc? VoltageCurrentSoc = new();
public UpAlarm? UpAlarm = new();
public UpBms? UpBms = new();
public BasicParameter? BasicParameter = new();
#region 充电桩数据
public ConcurrentDictionary<byte, string> Vin = new()

@ -232,6 +232,7 @@ public class Decoder : ByteToMessageDecoder
66 => ModelConvert.Decode<Detectionpointextremumdata>(bytes),
72 => ModelConvert.Decode<BasicParameter>(bytes),
81 => ModelConvert.Decode<QueryBatterySnRes>(bytes),
82 => ModelConvert.Decode<BatteryBaseInfo>(bytes),
142 => ModelConvert.Decode<BattenergyInfo1>(bytes),
143 => ModelConvert.Decode<BattenergyInfo2>(bytes),
144 => ModelConvert.Decode<BattenergyInfo3>(bytes),

@ -22,6 +22,7 @@ namespace Service.Charger.Handler
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BasicParameter = msg;
}
}
}

@ -0,0 +1,23 @@
using DotNetty.Transport.Channels;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Resp;
namespace Service.Charger.Handler;
/// <summary>
/// 3.6.2.4 充放电机上传电池包基本信息PGN:0x00F882
/// </summary>
public class BatteryBaseInfoHandler : SimpleChannelInboundHandler<BatteryBaseInfo>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryBaseInfoHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryBaseInfo msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.BatteryBaseInfo = msg;
}
}
}

@ -94,7 +94,7 @@ namespace Service.Charger.Handler
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.UpAlarm = msg;
#region 故障处理
string bms = "bms";

@ -0,0 +1,20 @@
using DotNetty.Transport.Channels;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Resp;
namespace Service.Charger.Handler;
public class UpBmsHandler: SimpleChannelInboundHandler<UpBms>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UpBmsHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, UpBms msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.UpBms = msg;
}
}
}

@ -63,74 +63,124 @@ namespace Service.Charger.Handler
}
#region 充电机故障显示
//不准确,注释
//if(sn=="C2008")
//if (msg.TotalWarning||msg.TotalError)
{
var lstEquipAlarmDefine = EquipAlarmDefineRepository.QueryListByClause(i => i.EquipCode == "充电机");
List<string> lstAlarm = new List<string>();
if (msg.EmergencyStop)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="1").ToList()[0].ErrorCode);
if (msg.SmokeFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="2").ToList()[0].ErrorCode);
if (msg.ChargeACInputCircuitBreakerFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="3").ToList()[0].ErrorCode);
if (msg.DcBusPositElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="4").ToList()[0].ErrorCode);
if (msg.DcBusNegatElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="5").ToList()[0].ErrorCode);
if (msg.DcBusPositElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="6").ToList()[0].ErrorCode);
if (msg.DDcBusNegatElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="7").ToList()[0].ErrorCode);
if (msg.ChargingInterfaceLockError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="8").ToList()[0].ErrorCode);
if (msg.ChargerFanError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="9").ToList()[0].ErrorCode);
if (msg.ArresterError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="10").ToList()[0].ErrorCode);
if (msg.InsulationDetectionAlarm)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="11").ToList()[0].ErrorCode);
if (msg.InsulationDetectionError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="12").ToList()[0].ErrorCode);
if (msg.BatteryPolarityReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="13").ToList()[0].ErrorCode);
if (msg.VeConGuidanceFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="14").ToList()[0].ErrorCode);
if (msg.ChargingOverTempError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="15").ToList()[0].ErrorCode);
if (msg.InterfaceOverFaulty)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="16").ToList()[0].ErrorCode);
if (msg.ChargingGunNotHomingError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="17").ToList()[0].ErrorCode);
if (msg.BmsConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="18").ToList()[0].ErrorCode);
if (msg.ChargerInputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="19").ToList()[0].ErrorCode);
if (msg.ChargerInputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="20").ToList()[0].ErrorCode);
if (msg.DcBusOutputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="21").ToList()[0].ErrorCode);
if (msg.DcBusOutputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="22").ToList()[0].ErrorCode);
if (msg.DcBusOutputOverCurrentError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="23").ToList()[0].ErrorCode);
if (!msg.VehicleConnStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="24").ToList()[0].ErrorCode);
if (!msg.ChargeStationGunHolderStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="25").ToList()[0].ErrorCode);
if (!msg.ChargingInterfaceLockStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="26").ToList()[0].ErrorCode);
if (msg.PositiveDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="27").ToList()[0].ErrorCode);
if (msg.NegativeDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="28").ToList()[0].ErrorCode);
if (msg.EntranceGuardError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="29").ToList()[0].ErrorCode);
if (msg.PConA3dhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="30").ToList()[0].ErrorCode);
if (msg.NConadhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="31").ToList()[0].ErrorCode);
if (msg.ReliefCircuitError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="32").ToList()[0].ErrorCode);
if (msg.ConActivated)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="33").ToList()[0].ErrorCode);
if (msg.ConAdhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="34").ToList()[0].ErrorCode);
if (msg.AuxiliaryPowerError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="35").ToList()[0].ErrorCode);
if (msg.ModuleOutputReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="36").ToList()[0].ErrorCode);
if (msg.AcContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="37").ToList()[0].ErrorCode);
if (msg.ChargingGunOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="38").ToList()[0].ErrorCode);
if (msg.ChargerOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="39").ToList()[0].ErrorCode);
if (msg.MeterConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="40").ToList()[0].ErrorCode);
if (msg.MeterDataError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="41").ToList()[0].ErrorCode);
if (msg.WaterloggingWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="42").ToList()[0].ErrorCode);
if (msg.ReversePowerWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="43").ToList()[0].ErrorCode);
if (msg.BatteryPackAuxiliaryPowerStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="44").ToList()[0].ErrorCode);
void Alarm(string number)
{
var alarm = lstEquipAlarmDefine.Where(i => i.ErrorCode == number);
if (alarm.Count() > 0)
lstAlarm.Add(sn + alarm.ToList()[0].ErrorCode);
}
if (msg.EmergencyStop)
Alarm("1");
if (msg.SmokeFault)
Alarm("2");
if (msg.ChargeACInputCircuitBreakerFault)
Alarm("3");
if (msg.DcBusPositElecContactorRefuFault)
Alarm("4");
if (msg.DcBusNegatElecContactorRefuFault)
Alarm("5");
if (msg.DcBusPositElecFusesFault)
Alarm("6");
if (msg.DDcBusNegatElecFusesFault)
Alarm("7");
if (msg.ChargingInterfaceLockError)
Alarm("8");
if (msg.ChargerFanError)
Alarm("9");
if (msg.ArresterError)
Alarm("10");
if (msg.InsulationDetectionAlarm)
Alarm("11");
if (msg.InsulationDetectionError)
Alarm("12");
if (msg.BatteryPolarityReverseError)
Alarm("13");
if (msg.VeConGuidanceFailure)
Alarm("14");
if (msg.ChargingOverTempError)
Alarm("15");
if (msg.InterfaceOverFaulty)
Alarm("16");
if (msg.ChargingGunNotHomingError)
Alarm("17");
if (msg.BmsConnError)
Alarm("18");
if (msg.ChargerInputOverVoltageError)
Alarm("19");
if (msg.ChargerInputUnderVoltageError)
Alarm("20");
if (msg.DcBusOutputOverVoltageError)
Alarm("21");
if (msg.DcBusOutputUnderVoltageError)
Alarm("22");
if (msg.DcBusOutputOverCurrentError)
Alarm("23");
if (!msg.VehicleConnStatus)
Alarm("24");
if (!msg.ChargeStationGunHolderStatus)Alarm("25");
if (!msg.ChargingInterfaceLockStatus)Alarm("26");
if (msg.PositiveDcTransmissionContactorStatus)
Alarm("27");
if (msg.NegativeDcTransmissionContactorStatus)
Alarm("28");
if (msg.EntranceGuardError)
Alarm("29");
if (msg.PConA3dhesionFailure)
Alarm("30");
if (msg.NConadhesionFailure)
Alarm("31");
if (msg.ReliefCircuitError)
Alarm("32");
if (msg.ConActivated)
Alarm("33");
if (msg.ConAdhesionFailure)
Alarm("34");
if (msg.AuxiliaryPowerError)
Alarm("35");
if (msg.ModuleOutputReverseError)
Alarm("36");
if (msg.AcContactorStatus)
Alarm("37");
if (msg.ChargingGunOverTempWarning)
Alarm("38");
if (msg.ChargerOverTempWarning)
Alarm("39");
if (msg.MeterConnError)
Alarm("40");
if (msg.MeterDataError)
Alarm("41");
if (msg.WaterloggingWarning)
Alarm("42");
if (msg.ReversePowerWarning)
Alarm("43");
if (msg.BatteryPackAuxiliaryPowerStatus)
Alarm("44");
//查询当前充电机的实时报警信息
var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn);
var sqllstAlarm=lstNowEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();//当前报警列表
var sqllstAlarm = lstNowEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList(); //当前报警列表
// 找出实时报警中存在但数据库中不存在的元素
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
// 找出数据库中存在但实时报警中不存在的元素
List<string> uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList();
if (uniqueToList1.Count > 0)
{//这里要添加新的报警数据
{
//这里要添加新的报警数据
foreach (var errorCode in uniqueToList1)
{
EquipAlarmDefine? alarmDefine = EquipAlarmDefineRepository.QueryByClause(i=>i.ErrorCode==errorCode.Replace(sn,""));
EquipAlarmDefine? alarmDefine =
EquipAlarmDefineRepository.QueryByClause(i => i.ErrorCode == errorCode.Replace(sn, ""));
if (alarmDefine != null)
{
EquipAlarmRecord record = new EquipAlarmRecord()
@ -141,8 +191,8 @@ namespace Service.Charger.Handler
ErrorLevel = alarmDefine.ErrorLevel,
ErrorMsg = alarmDefine.ErrorMsg,
ProcessMethod = alarmDefine.ProcessMethod,
StartTime= DateTime.Now
};
StartTime = DateTime.Now
};
EquipAlarmRecordRepository.Insert(record);
}
}
@ -152,7 +202,7 @@ namespace Service.Charger.Handler
//这些是要清除实时报警,并且处理记录的。
// 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象
List<EquipAlarmRecord> filteredObjectList = lstNowEquipAlarmRecord
.Where(obj => uniqueToList2.Contains(obj.ErrorCode))
.Where(obj => uniqueToList2.Contains(obj.ErrorCode))
.ToList();
foreach (var VARIABLE in filteredObjectList)
{
@ -164,13 +214,37 @@ namespace Service.Charger.Handler
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime=DateTime.Now;
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
EquipAlarmRecordRepository.Delete(filteredObjectList);
}
}
//else
//{
/*var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn);
if (lstNowEquipAlarmRecord.Count > 0)
{
foreach (var VARIABLE in lstNowEquipAlarmRecord)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime=DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
}
EquipAlarmRecordRepository.Delete(i=>i.Id>0);*/
//}
#endregion
}
}

@ -36,6 +36,7 @@ namespace Service.Charger.Handler
Log.Info(update
? $"succeed update battery soc {msg.SOC} for {client.BinNo}"
: $"fail update battery soc {msg.SOC} for {client.BinNo}");
}
}
}

@ -0,0 +1,53 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.Resp;
/// <summary>
/// 3.6.2.4 充放电机上传电池包基本信息PGN:0x00F882
/// </summary>
public class BatteryBaseInfo: ASDU
{
[Property(0, 24)]
public string Pgn { get; set; }
/// <summary>
/// 电池包额定量度
/// </summary>
[Property(0, 16)]
public byte RatedMeasurement{get;set;}
/// <summary>
/// 电池包额定电压
/// </summary>
[Property(16, 16)]
public byte PackVoltage{get;set;}
/// <summary>
/// 电池包额定总能量
/// </summary>
[Property(32, 16)]
public byte RatedBatteryPack{get;set;}
/// <summary>
/// 电池冷却方式
/// </summary>
[Property(48, 8)]
public byte BatteryCoolingSystem{get;set;}
/// <summary>
/// 电池类型
/// </summary>
[Property(56, 8)]
public byte BatteryType{get;set;}
/// <summary>
/// 电池系统中 CSC总的数目电池监控单元数目
/// </summary>
[Property(64, 8)]
public byte BatteryCSCSNumber{get;set;}
/// <summary>
/// PACK 中单体电芯的总数目
/// </summary>
[Property(72, 16)]
public byte PACKNumber{get;set;}
/// <summary>
/// PACK 中电芯温度点(探针)的总数目
/// </summary>
[Property(88, 16)]
public byte PACKTemperatureNumber{get;set;}
}

@ -10,6 +10,8 @@ using Repository.Station;
using Service.Charger.Client;
using Service.Init;
using Service.Swap.Dto;
using SqlSugar;
using SqlSugar.Extensions;
namespace Service.MyTask;
[Scope]

@ -185,4 +185,15 @@ public class ChargeController : ControllerBase
{
return _chargerService.BatteryStatusInfo();
}
/// <summary>
/// 电池数据显示
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("BatteryInfo")]
public Result<List<BatteryInfoResp>> BatteryInfo()
{
return _chargerService.BatteryInfo();
}
}
Loading…
Cancel
Save