diff --git a/Entity/Dto/Resp/BasicParameterResp.cs b/Entity/Dto/Resp/BasicParameterResp.cs new file mode 100644 index 0000000..e7cfae0 --- /dev/null +++ b/Entity/Dto/Resp/BasicParameterResp.cs @@ -0,0 +1,95 @@ +namespace Entity.Dto.Resp; + +/// +/// 电池包基本参数2 +/// +public class BasicParameterResp +{ + /// + /// 记录类型 + /// + public byte RecordType { get; set; } + + /// + /// PGN 码 + /// + public byte Pgn1 { get; set; } + + public byte Pgn2 { get; set; } + public byte Pgn3 { get; set; } + + /// + /// 电池编码 + /// + public byte[] BatteryCode { get; set; } + + /// + /// 产权标识 + /// + public byte TitleMarke { get; set; } + + /// + /// 电池成组厂商 + /// + public string Batterymanufacturers { get; set; } + + /// + /// 电池成组生产日期:年 + /// + public byte GroupYear { get; set; } + + /// + /// 电池成组生产日期:月 + /// + public byte GroupMonth { get; set; } + + /// + /// 电池成组生产日期:日 + /// + public byte GroupDay { get; set; } + + /// + /// 电池电芯生产厂商 + /// + public byte[] BatteryManufacturer { get; set; } + + /// + /// 电池电芯生产日期:年 + /// + public byte CellYear { get; set; } + + /// + /// 电池电芯生产日期:月 + /// + public byte CellMonth { get; set; } + + /// + /// 电池电芯生产日期:日 + /// + public byte CellDay { get; set; } + + /// + /// 电池箱电子控制单元生产厂商 + /// + public byte[] Manufacturer { get; set; } + + /// + /// 电池箱电子控制单元硬件版本 + /// + public byte HardwareVersion { get; set; } + + /// + /// 电池箱电子控制单元软件版本 + /// + public byte SoftwareVersion { get; set; } + + /// + /// 电池包序列号 + /// + public byte[] SerialNumber { get; set; } + + /// + /// 电池包型号 + /// + public byte[] ModelNumber { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/BatteryBaseInfoResp.cs b/Entity/Dto/Resp/BatteryBaseInfoResp.cs new file mode 100644 index 0000000..d2ad9a6 --- /dev/null +++ b/Entity/Dto/Resp/BatteryBaseInfoResp.cs @@ -0,0 +1,42 @@ +namespace Entity.Dto.Resp; + +/// +/// 3.6.2.4 充放电机上传电池包基本信息(PGN:0x00F882) +/// +public class BatteryBaseInfoResp +{ + public string Pgn { get; set; } + + /// + /// 电池包额定量度 + /// + public byte RatedMeasurement{get;set;} + /// + /// 电池包额定电压 + /// + public byte PackVoltage{get;set;} + /// + /// 电池包额定总能量 + /// + public byte RatedBatteryPack{get;set;} + /// + /// 电池冷却方式 + /// + public byte BatteryCoolingSystem{get;set;} + /// + /// 电池类型 + /// + public byte BatteryType{get;set;} + /// + /// 电池系统中 CSC总的数目(电池监控单元数目) + /// + public byte BatteryCSCSNumber{get;set;} + /// + /// PACK 中单体电芯的总数目 + /// + public byte PACKNumber{get;set;} + /// + /// PACK 中电芯温度点(探针)的总数目 + /// + public byte PACKTemperatureNumber{get;set;} +} \ No newline at end of file diff --git a/Entity/Dto/Resp/BatteryInfoResp.cs b/Entity/Dto/Resp/BatteryInfoResp.cs new file mode 100644 index 0000000..1d0d4ba --- /dev/null +++ b/Entity/Dto/Resp/BatteryInfoResp.cs @@ -0,0 +1,54 @@ +namespace Entity.Dto.Resp; + +public class BatteryInfoResp +{ + /// + /// 仓位编码 + /// + public string code { get; set; } + + /// + /// 仓位名称 + /// + public string name { get; set; } + + /// + /// 充电机编号 + /// + public string charger_no { get; set; } + + /// + /// 遥测数据 + /// + public UploadTelemetryDataResp UploadTelemetryDataResp { get; set; } + + /// + /// 电池包基本信息 + /// + public BatteryBaseInfoResp BatteryBaseInfoResp { get; set; } + + /// + /// 电池包基本参数2 + /// + public BasicParameterResp BasicParameterResp { get; set; } + + /// + /// 电池包基本状态 + /// + public UpBmsResp UpBmsResp { get; set; } + + /// + /// 电池包报警状态 + /// + public UpAlarmResp UpAlarmResp { get; set; } + + /// + /// 电池包编码和SOC数据 + /// + public VoltageCurrentSocResp VoltageCurrentSocResp { get; set; } + + /// + /// 电压温度极值统计 + /// + public VoltageExtremumStatisticsResp VoltageExtremumStatisticsResp { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/UpAlarmResp.cs b/Entity/Dto/Resp/UpAlarmResp.cs new file mode 100644 index 0000000..74898a9 --- /dev/null +++ b/Entity/Dto/Resp/UpAlarmResp.cs @@ -0,0 +1,199 @@ +namespace Entity.Dto.Resp; + +/// +/// 电池包报警状态 +/// +public class UpAlarmResp +{ + /// + /// 记录类型 + /// + public byte RecordType { get; set; } + + /// + /// PGN 码 + /// + public byte Pgn1 { get; set; } + + public byte Pgn2 { get; set; } + public byte Pgn3 { get; set; } + + /// + /// 单体蓄电池或蓄电池模块电压越限 + /// + public byte SingleBattery { get; set; } + + /// + /// 电压偏差越限 + /// + public byte VoltageOvershoot { get; set; } + + /// + /// 温度越限 + /// + public byte TemperatureExceedance { get; set; } + + /// + /// 温度偏差越限 + /// + public byte TemperatureDifference { get; set; } + + /// + /// SOC 低 + /// + public byte LowSOC { get; set; } + + /// + /// 放电电流越限 + /// + public byte DischargeCurrent { get; set; } + + /// + /// 充电电流限 + /// + public byte ChargingCurrentLimit { get; set; } + + /// + /// 总正负极柱温度越限 + /// + public byte TotalTemp { get; set; } + + /// + /// 电池系统故障码 + /// + /// 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 电池温度采样异常 + /// + public short BatteryFaultCode { get; set; } + + /// + /// 高压绝缘低 + /// + public byte HighVoltageLow { get; set; } + + /// + /// 单体蓄电池或蓄电池模块电压越极限 + /// + public byte MonomerLimit { get; set; } + + /// + /// 电压偏差越极限 + /// + public byte VoltageDifference { get; set; } + + /// + /// 温度越极限 + /// + public byte TemperatureOvershoot { get; set; } + + /// + /// 温度偏差越极限 + /// + public byte TempDifference { get; set; } + + /// + /// SOC 极低 + /// + public byte VeryLowSoc { get; set; } + + /// + /// 放电电流越极限 + /// + public byte DischargeCurrentLimit { get; set; } + + /// + /// 充电电流越极限 + /// + public byte ChargingCurrent { get; set; } + + /// + /// 总正负极柱温度越极限 + /// + public byte TotalTempLimit { get; set; } + + /// + /// 高压绝缘极低 + /// + public byte HighVoltageInsulation { get; set; } + + /// + /// 硬件故障 + /// + public byte HardwareFailure { get; set; } + + /// + /// 保留 + /// + public byte Reserve { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/UpBmsResp.cs b/Entity/Dto/Resp/UpBmsResp.cs new file mode 100644 index 0000000..6d9d41f --- /dev/null +++ b/Entity/Dto/Resp/UpBmsResp.cs @@ -0,0 +1,64 @@ +namespace Entity.Dto.Resp; + +/// +/// 电池包基本状态 +/// +public class UpBmsResp +{ + /// + /// 记录类型 + /// + public byte RecordType { get; set; } + + /// + ///PGN码 + /// + public string Pgn { get; set; } + + /// + /// 报警级别 + /// 0:正常 + /// 1:1 级报警 3:3 级报警 5:5 级报警 其余保留 + /// + public short AlarmLevel { get; set; } + + /// + /// 电池箱所在位置编号 分辨率:1/位,偏移量:0,数值范围:1~250 + /// + public short BatteryBoxLocationNumber { get; set; } + + /// + /// 电池箱能输出的最大电流值 分辨率:0.05A/位,偏移量:-1600A,数值范围:-1600A ~ 1612.75A + /// + public short BatteryBoxMaximumCurrentOutput { get; set; } + + /// + /// 电池箱能承受最大反馈电流值 分辨率:0.05A/位,偏移量:-1600A,数值范围:-1600A~1612.75A + /// + public short BatteryMaximumFeedback { get; set; } + + /// + /// 电池箱风扇状态 0:关闭1:开启 2:不可用 3:不可用 + /// + public byte BatteryBoxFanStatus { get; set; } + + /// + /// 加热装置状态 0:关闭1:开启 2:不可用 3:不可用 + /// + public byte HeaterCondition { get; set; } + + /// + /// 均衡状态 0:关闭1:开启 2:不可用 3:不可用 + /// + public byte EquilibriumState { get; set; } + + /// + /// 高压互锁状态 0 断开 1 连接 + /// + public byte HighVoltageInterlockState { get; set; } + + /// + /// 保留 + /// + public short Reserve { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/UploadTelemetryDataResp.cs b/Entity/Dto/Resp/UploadTelemetryDataResp.cs new file mode 100644 index 0000000..07986f8 --- /dev/null +++ b/Entity/Dto/Resp/UploadTelemetryDataResp.cs @@ -0,0 +1,168 @@ +namespace Entity.Dto.Resp; + +/// +/// 遥测数据 +/// +public class UploadTelemetryDataResp +{ + /// + /// 当前 SOC + /// + public byte CurrentSoc { get; set; } + + /// + /// 最高蓄电池温度 + /// + public Int16 MaxBatteryTemp { get; set; } + + /// + /// 最高温度检测点编号 + /// + public ushort MaxTempDetectionPointNo { get; set; } + + /// + /// 最低蓄电池温度数据分辨率:1ºC/位,-50 ºC 偏移量;数据范围:-50ºC ~+200ºC; + /// + public Int16 MinBatteryTemp { get; set; } + + /// + /// 最低温度检测点编号 + /// + public ushort MinTempDetectionPointNo { get; set; } + + /// + /// 单体电池最高电压 + /// + public float SingleBatteryMaxVoltage { get; set; } + + /// + /// 单体电池最低压 + /// + public float SingleBatteryMinVoltage { get; set; } + + /// + /// 充电机环境温度 + /// + public Int16 ChargerEnvTemp { get; set; } + + /// + /// 充电导引电压 + /// + public float ChargingPilotVoltage { get; set; } + + /// + /// BMS 需求电压 + /// + public float BmsNeedVoltage { get; set; } + + /// + /// BMS 需求电流 + /// + public float BmsNeedCurrent { get; set; } + + /// + /// 充电模式 01H:恒压充电、02H恒流充电 + /// + public byte ChargeMode { get; set; } + + /// + /// BMS 充电电压测量值 + /// + public float BmsChargingVoltage { get; set; } + + /// + /// BMS 充电电流测量值 + /// + public float BmsChargingCurrent { get; set; } + + /// + /// 估算剩余充电时间 + /// + public ushort EstimatedRemainingTime { get; set; } + + /// + /// 充电接口温度探头 1 + /// + public Int16 ChargingInterfaceDetectionOneTemp { get; set; } + + /// + /// 充电接口温度探头 2 + /// + public Int16 ChargingInterfaceDetectionTwoTemp { get; set; } + + /// + /// 充电接口温度探头 3 + /// + public Int16 ChargingInterfaceDetectionTheTemp { get; set; } + + /// + /// 充电接口温度探头 4 + /// + public Int16 ChargingInterfaceDetectionFourTemp { get; set; } + + /// + /// 直流电表当前电量 + /// + public float DcMeterCurrentPower { get; set; } + + /// + /// 充电电压(直流电表电压) + /// + public float DcMeterVoltage { get; set; } + + /// + /// 充电电流(直流电表电流) + /// + public float DcMeterCurrent { get; set; } + + /// + /// 高压采集电压 + /// + public float HighVoltageAcquisitionVoltage { get; set; } + + /// + /// 高压采集电流 + /// + public float HighVoltageAcquisitionCurrent { get; set; } + + /// + /// 桩内部温度 + /// + public byte ChargerInsideTemp { get; set; } + + /// + /// 本次充电时间 + /// + public ushort ChargingTime { get; set; } + + /// + /// 模块进风口温度 + /// + public byte ModuleOneAirInletTemp { get; set; } + + /// + /// 模块出风口温度 + /// + public byte ModuleTwoAirInletTemp { get; set; } + + /// + /// 充电模式 0:站内充电 1:站外充电 + /// + public byte ChargeModel { get; set; } + + /// + /// 充电启动方式 1:站控启动 2:本地充电 + /// + + public byte ChargingStartMethod { get; set; } + + /// + /// 交流电表当前电量 + /// + public float ACMeterCurrentBatteryValue { get; set; } + + /// + /// 设备编号 + /// + public string ChargerNo { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/VoltageCurrentSocResp.cs b/Entity/Dto/Resp/VoltageCurrentSocResp.cs new file mode 100644 index 0000000..7074e2c --- /dev/null +++ b/Entity/Dto/Resp/VoltageCurrentSocResp.cs @@ -0,0 +1,34 @@ +namespace Entity.Dto.Resp; + +/// +/// 电池包编码和SOC数据 +/// +public class VoltageCurrentSocResp +{ + /// + /// 记录类型 + /// + public byte RecordType { get; set; } + /// + /// PGN 码 + /// + public byte Pgn1 { get; set; } + public byte Pgn2 { get; set; } + public byte Pgn3 { get; set; } + /// + /// 电压测量值 分辨率:0.1V/位,偏移量:0V,数值范围:0V ~750V + /// + public float Voltage { get; set; } + /// + /// 电流测量值 分辨率:0.05A/位,偏移量:-1600A,数值范围:-1600A~1612.75A + /// + public float Current { get; set; } + /// + /// 当前SOC 分辨率:0.1%/位,偏移量:0%,数值范围 0%~100% + /// + public float SOC { get; set; } + /// + /// 当前SOH 分辨率:1%/位,偏移量:0%,数值范围 0%~100% + /// + public float SOH { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/VoltageExtremumStatisticsResp.cs b/Entity/Dto/Resp/VoltageExtremumStatisticsResp.cs new file mode 100644 index 0000000..d470a2f --- /dev/null +++ b/Entity/Dto/Resp/VoltageExtremumStatisticsResp.cs @@ -0,0 +1,49 @@ +namespace Entity.Dto.Resp; + +/// +/// 电压温度极值统计 +/// +public class VoltageExtremumStatisticsResp +{ + /// + /// 记录类型 + /// + public byte RecordType { get; set; } + + /// + /// PGN 码 + /// + public byte Pgn1 { get; set; } + public byte Pgn2 { get; set; } + public byte Pgn3 { get; set; } + + /// + /// 单体蓄电池或蓄电池模块最高电压 + /// 分辨率:0.01V/位,偏移量:0V,数值范围:0V ~24V + /// + public float MaximumVoltage { get; set; } + + /// + /// 最高电压单体蓄电池或蓄电池模块的编号 + /// 分辨率:1/位,偏移量:0,数值范围: + /// + public float MaximumVoltageNum { get; set; } + + /// + /// 单体蓄电池或蓄电池模块最低电压 + /// 分辨率:0.01V/位,偏移量:0V,数值范围:0V ~24V + /// + public float MinimumVoltage { get; set; } + + /// + /// 最低电压单体蓄电池或蓄电池模块的编号 + /// 分辨率:1/位,偏移量:0,数值范围:1~250 + /// + public float MinimumVoltageNum { get; set; } + + /// + /// 单体平均电压 + /// 分辨率:0.01V/位,偏移量:0V,数值范围:0V ~24V + /// + public float CellAverageVoltage { get; set; } +} \ No newline at end of file diff --git a/Service/Charger/ChargerService.cs b/Service/Charger/ChargerService.cs index 778d7db..6273e8c 100644 --- a/Service/Charger/ChargerService.cs +++ b/Service/Charger/ChargerService.cs @@ -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.Success(batteryStatusInfoResp); } + + public Result> BatteryInfo() + { + List lstBatteryInfoResp = new(); + List 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().ReverseMap(); + cfg.CreateMap().ReverseMap(); + cfg.CreateMap().ReverseMap(); + cfg.CreateMap().ReverseMap(); + cfg.CreateMap().ReverseMap(); + cfg.CreateMap().ReverseMap(); + cfg.CreateMap().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(chargerClient.UploadTelemetryData); + BatteryInfoResp.BatteryBaseInfoResp=mapper.Map(chargerClient.BatteryBaseInfo); + BatteryInfoResp.BasicParameterResp=mapper.Map(chargerClient.BasicParameter); + BatteryInfoResp.UpBmsResp=mapper.Map(chargerClient.UpBms); + BatteryInfoResp.UpAlarmResp=mapper.Map(chargerClient.UpAlarm); + BatteryInfoResp.VoltageCurrentSocResp=mapper.Map(chargerClient.VoltageCurrentSoc); + BatteryInfoResp.VoltageExtremumStatisticsResp=mapper.Map(chargerClient.VoltageExtremumStatistics); + lstBatteryInfoResp.Add(BatteryInfoResp); + } + } + + return Result>.Success(lstBatteryInfoResp); + } } diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index 6a26ab2..cf6499e 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -161,6 +161,14 @@ public class ChargerClient : TcpClient /// 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 Vin = new() diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs index 866c84f..f75908c 100644 --- a/Service/Charger/Codec/Decoder.cs +++ b/Service/Charger/Codec/Decoder.cs @@ -232,6 +232,7 @@ public class Decoder : ByteToMessageDecoder 66 => ModelConvert.Decode(bytes), 72 => ModelConvert.Decode(bytes), 81 => ModelConvert.Decode(bytes), + 82 => ModelConvert.Decode(bytes), 142 => ModelConvert.Decode(bytes), 143 => ModelConvert.Decode(bytes), 144 => ModelConvert.Decode(bytes), diff --git a/Service/Charger/Handler/BasicParameterHandler.cs b/Service/Charger/Handler/BasicParameterHandler.cs index f0a3af7..73f0d0c 100644 --- a/Service/Charger/Handler/BasicParameterHandler.cs +++ b/Service/Charger/Handler/BasicParameterHandler.cs @@ -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; } } } diff --git a/Service/Charger/Handler/BatteryBaseInfoHandler.cs b/Service/Charger/Handler/BatteryBaseInfoHandler.cs new file mode 100644 index 0000000..0442f71 --- /dev/null +++ b/Service/Charger/Handler/BatteryBaseInfoHandler.cs @@ -0,0 +1,23 @@ +using DotNetty.Transport.Channels; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Resp; + +namespace Service.Charger.Handler; + +/// +/// 3.6.2.4 充放电机上传电池包基本信息(PGN:0x00F882) +/// +public class BatteryBaseInfoHandler : SimpleChannelInboundHandler, 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; + } + } +} \ No newline at end of file diff --git a/Service/Charger/Handler/UpAlarmHandler.cs b/Service/Charger/Handler/UpAlarmHandler.cs index e6f1ee4..02d391f 100644 --- a/Service/Charger/Handler/UpAlarmHandler.cs +++ b/Service/Charger/Handler/UpAlarmHandler.cs @@ -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"; diff --git a/Service/Charger/Handler/UpBmsHandler.cs b/Service/Charger/Handler/UpBmsHandler.cs new file mode 100644 index 0000000..8d9d333 --- /dev/null +++ b/Service/Charger/Handler/UpBmsHandler.cs @@ -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, 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; + } + } +} \ No newline at end of file diff --git a/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs b/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs index f0b40cc..6a95c52 100644 --- a/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs +++ b/Service/Charger/Handler/UploadRemoteSignalDataHandler.cs @@ -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 lstAlarm = new List(); - - 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 uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList(); - + List uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList(); + // 找出数据库中存在但实时报警中不存在的元素 List 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 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 } } diff --git a/Service/Charger/Handler/VoltageCurrentSocHandler.cs b/Service/Charger/Handler/VoltageCurrentSocHandler.cs index e16f4e7..4f014c4 100644 --- a/Service/Charger/Handler/VoltageCurrentSocHandler.cs +++ b/Service/Charger/Handler/VoltageCurrentSocHandler.cs @@ -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}"); + } } } diff --git a/Service/Charger/Msg/Charger/Resp/BatteryBaseInfo.cs b/Service/Charger/Msg/Charger/Resp/BatteryBaseInfo.cs new file mode 100644 index 0000000..7f8ede9 --- /dev/null +++ b/Service/Charger/Msg/Charger/Resp/BatteryBaseInfo.cs @@ -0,0 +1,53 @@ +using HybirdFrameworkCore.Autofac.Attribute; + +namespace Service.Charger.Msg.Charger.Resp; + +/// +/// 3.6.2.4 充放电机上传电池包基本信息(PGN:0x00F882) +/// +public class BatteryBaseInfo: ASDU +{ + [Property(0, 24)] + public string Pgn { get; set; } + + /// + /// 电池包额定量度 + /// + [Property(0, 16)] + public byte RatedMeasurement{get;set;} + /// + /// 电池包额定电压 + /// + [Property(16, 16)] + public byte PackVoltage{get;set;} + /// + /// 电池包额定总能量 + /// + [Property(32, 16)] + public byte RatedBatteryPack{get;set;} + /// + /// 电池冷却方式 + /// + [Property(48, 8)] + public byte BatteryCoolingSystem{get;set;} + /// + /// 电池类型 + /// + [Property(56, 8)] + public byte BatteryType{get;set;} + /// + /// 电池系统中 CSC总的数目(电池监控单元数目) + /// + [Property(64, 8)] + public byte BatteryCSCSNumber{get;set;} + /// + /// PACK 中单体电芯的总数目 + /// + [Property(72, 16)] + public byte PACKNumber{get;set;} + /// + /// PACK 中电芯温度点(探针)的总数目 + /// + [Property(88, 16)] + public byte PACKTemperatureNumber{get;set;} +} \ No newline at end of file diff --git a/Service/MyTask/BatteryInfoUploadTask.cs b/Service/MyTask/BatteryInfoUploadTask.cs index 21f350d..b4a9b51 100644 --- a/Service/MyTask/BatteryInfoUploadTask.cs +++ b/Service/MyTask/BatteryInfoUploadTask.cs @@ -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] diff --git a/WebStarter/Controllers/ChargeController.cs b/WebStarter/Controllers/ChargeController.cs index deb7b11..15b4c77 100644 --- a/WebStarter/Controllers/ChargeController.cs +++ b/WebStarter/Controllers/ChargeController.cs @@ -185,4 +185,15 @@ public class ChargeController : ControllerBase { return _chargerService.BatteryStatusInfo(); } + + /// + /// 电池数据显示 + /// + /// + [HttpGet] + [Route("BatteryInfo")] + public Result> BatteryInfo() + { + return _chargerService.BatteryInfo(); + } } \ No newline at end of file