diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index 2c2b3b9..96869a1 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -6,6 +6,7 @@ using Service.Charger.Codec; using Service.Charger.Common; using Service.Charger.Handler; using Service.Charger.Msg.Charger.Req; +using Service.Charger.Msg.Charger.Resp; using Service.Charger.Msg.Host.Req; namespace Service.Charger.Client; @@ -55,9 +56,26 @@ public class ChargerClient : TcpClient /// public BatteryPackStateAndFault? BatteryPackStateAndFault { get; set; } - - - + /// + /// 充放电设备应答站功率调节指令 + /// + public PowerRegulationRes PowerRegulationRes { get; set; } + /// + /// 电池包实时遥信上报(站内充电模式有电池包时周期性上传) + /// + public RemoteSignaling RemoteSignaling { get; set; } + /// + /// 充电机上报车辆 VIN + /// + public VehicleVIN VehicleVIN { get; set; } + /// + /// 充放电机应答辅助控制 + /// + public AuxiliaryPowerRes AuxiliaryPowerRes { get; set; } + /// + /// 充放电上报交流电表数据(交流电表接到充电机上的情况) + /// + public AcMeter AcMeter { get; set; } /// ///充电机遥信数据 /// @@ -94,7 +112,10 @@ public class ChargerClient : TcpClient /// 电池编码 /// public string BatterSn { get; set; } - + /// + /// 远程升级-监控网关上送升级完成确认帧 + /// + public UplinkUpgrade UplinkUpgrade { get; set; } #region 发送指令 private ushort IncreAuthTimes() @@ -161,6 +182,66 @@ public class ChargerClient : TcpClient return Connected; } + /// + /// 监控平台发送功率调节指令 + /// + /// 期望运行功率 + public void SendPowerRegulation(ushort expectedOperatingPower) + { + PowerRegulation powerRegulation = new PowerRegulation(expectedOperatingPower); + this.Channel.WriteAndFlushAsync(powerRegulation); + } + + /// + /// 监控平台下发辅源控制指令 + /// + /// 打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开 + public void SendAuxiliaryPower(byte openFlag) + { + AuxiliaryPower auxiliaryPower = new AuxiliaryPower(openFlag); + this.Channel.WriteAndFlushAsync(auxiliaryPower); + } + + /// + /// 监控平台下发电池仓的状态 + /// + /// 是否有电池 0:无电池 1:有电池 + /// 电接头连接状态 0:未连接 1: 已连接 + /// 水接头状态 0:未连接 1: 已连接 + public void SendBatteryHolderStatus(byte battery, byte connectionState, byte waterCondition) + { + BatteryHolderStatus batteryHolderStatus = new BatteryHolderStatus(battery, connectionState, waterCondition); + this.Channel.WriteAndFlushAsync(batteryHolderStatus); + } + + + + /// + /// 站控下发 VIN 鉴权的结果 + /// + /// VIN 鉴权结果 1:通过 2 不通过 + public void SendAuthenticationVIN(byte vinresult) + { + AuthenticationVIN authenticationVIN = new AuthenticationVIN(vinresult); + this.Channel.WriteAndFlushAsync(authenticationVIN); + } + /// + /// 远程升级-站级监控升级请求下发 + /// + /// 执行控制 0x01:立即执行 0x02:空闲执行 + /// 下载超时时间 + /// 版本号 + /// 文件名称 + /// 文件大小 + /// MD5校验值 + /// URL(文件路径) + public void SendUpgradeRequest(byte executionControl, byte downloadTimeout, string versionNumber, + string fileName, uint fileSize, string mD5Verification, string url) + { + UpgradeRequest upgradeRequest=new UpgradeRequest(executionControl, downloadTimeout, versionNumber, fileName, fileSize, mD5Verification, url); + this.Channel.WriteAndFlushAsync(upgradeRequest); + } + #endregion public void SessionAttr(int sn, int eqmTypeNo, string eqmCode, string destAddr) diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs index e743e90..e78ef22 100644 --- a/Service/Charger/Codec/Decoder.cs +++ b/Service/Charger/Codec/Decoder.cs @@ -112,33 +112,31 @@ public class Decoder : ByteToMessageDecoder { 1 => ModelConvert.Decode(bytes), 3 => ModelConvert.Decode(bytes), - 6 => ModelConvert.Decode(bytes), + 6 => ModelConvert.Decode(bytes), 10 => ModelConvert.Decode(bytes), 11 => ModelConvert.Decode(bytes), 13 => ModelConvert.Decode(bytes), 21 => ModelConvert.Decode(bytes), 25 => ModelConvert.Decode(bytes), - //40 => ModelConvert.Decode(bytes), - //41 => ModelConvert.Decode(bytes), + 34 => ModelConvert.Decode(bytes), + 35 => ModelConvert.Decode(bytes), + 41 => ModelConvert.Decode(bytes), 44 => ModelConvert.Decode(bytes), //46 => ModelConvert.Decode(bytes), - 48 => ModelConvert.Decode(bytes), - 50 => ModelConvert.Decode(bytes), + 48 => ModelConvert.Decode(bytes), + 47 => ModelConvert.Decode(bytes), + 49 => ModelConvert.Decode(bytes), + 50 => ModelConvert.Decode(bytes), + 52 => ModelConvert.Decode(bytes), 75 => ModelConvert.Decode(bytes), - + 81 => ModelConvert.Decode(bytes), 82 => ModelConvert.Decode(bytes), 83 => ModelConvert.Decode(bytes), 84 => ModelConvert.Decode(bytes), 85 => ModelConvert.Decode(bytes), 86 => ModelConvert.Decode(bytes), + 87 => ModelConvert.Decode(bytes), - - //83 => ModelConvert.Decode(bytes), - 87 => ModelConvert.Decode(bytes), - - 49 => ModelConvert.Decode(bytes), - 47 => ModelConvert.Decode(bytes), - // 86 => ModelConvert.Decode(bytes), _ => throw new InvalidOperationException("This should never be reached"), }, #endregion diff --git a/Service/Charger/Handler/AcMeterHandler.cs b/Service/Charger/Handler/AcMeterHandler.cs new file mode 100644 index 0000000..c28f789 --- /dev/null +++ b/Service/Charger/Handler/AcMeterHandler.cs @@ -0,0 +1,31 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Req; +using Service.Charger.Msg.Charger.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.5.19 充放电上报交流电表数据(交流电表接到充电机上的情况) + /// + public class AcMeterHandler: SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(AcMeterHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, AcMeter msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.AcMeter = msg; + } + } + } +} diff --git a/Service/Charger/Handler/AuthVINResHandler.cs b/Service/Charger/Handler/AuthVINResHandler.cs new file mode 100644 index 0000000..59629d7 --- /dev/null +++ b/Service/Charger/Handler/AuthVINResHandler.cs @@ -0,0 +1,32 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.5.17 充电机应答 VIN 鉴权结果 + /// + [Order(8)] + [Scope("InstancePerDependency")] + internal class AuthVINResHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(AuthVINResHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, AuthVINRes msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + + } + } + } +} diff --git a/Service/Charger/Handler/AuxiliaryPowerResHandler.cs b/Service/Charger/Handler/AuxiliaryPowerResHandler.cs new file mode 100644 index 0000000..3d07fe1 --- /dev/null +++ b/Service/Charger/Handler/AuxiliaryPowerResHandler.cs @@ -0,0 +1,32 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.4.4 充放电设备应答辅助控制 + /// + [Order(8)] + [Scope("InstancePerDependency")] + public class AuxiliaryPowerResHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(AuxiliaryPowerResHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, AuxiliaryPowerRes msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.AuxiliaryPowerRes = msg; + } + } + } +} diff --git a/Service/Charger/Handler/PowerRegulationHandler.cs b/Service/Charger/Handler/PowerRegulationHandler.cs new file mode 100644 index 0000000..45e4629 --- /dev/null +++ b/Service/Charger/Handler/PowerRegulationHandler.cs @@ -0,0 +1,34 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Common; +using Service.Charger.Msg.Charger.Resp; +using Service.Charger.Msg.Host.Req; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.4.2 充放电设备应答站功率调节指令 + /// + [Order(8)] + [Scope("InstancePerDependency")] + public class PowerRegulationHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(PowerRegulationHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, PowerRegulationRes msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.PowerRegulationRes = msg; + } + } + } +} diff --git a/Service/Charger/Handler/RemoteSignalingHandler.cs b/Service/Charger/Handler/RemoteSignalingHandler.cs new file mode 100644 index 0000000..7785b36 --- /dev/null +++ b/Service/Charger/Handler/RemoteSignalingHandler.cs @@ -0,0 +1,34 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Common; +using Service.Charger.Msg.Charger.Req; +using Service.Charger.Msg.Charger.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 电池包实时遥信上报(站内充电模式有电池包时周期性上传) + /// + [Order(8)] + [Scope("InstancePerDependency")] + public class RemoteSignalingHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(RemoteSignalingHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, RemoteSignaling msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.RemoteSignaling = msg; + } + } + } +} diff --git a/Service/Charger/Handler/UplinkUpgradeHandler.cs b/Service/Charger/Handler/UplinkUpgradeHandler.cs new file mode 100644 index 0000000..e137ada --- /dev/null +++ b/Service/Charger/Handler/UplinkUpgradeHandler.cs @@ -0,0 +1,37 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Req; +using Service.Charger.Msg.Charger.Resp; +using Service.Charger.Msg.Host.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.7 远程升级-监控网关上送升级完成确认帧 + /// + [Order(8)] + [Scope("InstancePerDependency")] + public class UplinkUpgradeHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(UplinkUpgradeHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, UplinkUpgrade msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.UplinkUpgrade = msg; + + UplinkUpgradeRes uplinkUpgrade=new UplinkUpgradeRes(); + ctx.Channel.WriteAsync(uplinkUpgrade); + } + } + } +} diff --git a/Service/Charger/Handler/VehicleVINHandler.cs b/Service/Charger/Handler/VehicleVINHandler.cs new file mode 100644 index 0000000..6b83eb4 --- /dev/null +++ b/Service/Charger/Handler/VehicleVINHandler.cs @@ -0,0 +1,33 @@ +using DotNetty.Transport.Channels; +using HybirdFrameworkCore.Autofac.Attribute; +using log4net; +using Service.Charger.Client; +using Service.Charger.Msg.Charger.Req; +using Service.Charger.Msg.Charger.Resp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Handler +{ + /// + /// 3.5.14 充电机上报车辆 VIN + /// + [Order(8)] + [Scope("InstancePerDependency")] + public class VehicleVINHandler : SimpleChannelInboundHandler, IBaseHandler + { + private static readonly ILog Log = LogManager.GetLogger(typeof(VehicleVINHandler)); + + protected override void ChannelRead0(IChannelHandlerContext ctx, VehicleVIN msg) + { + if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) + { + Log.Info($"receive {msg} from {sn}"); + client.VehicleVIN = msg; + } + } + } +} diff --git a/Service/Charger/Msg/Charger/Req/AcMeter.cs b/Service/Charger/Msg/Charger/Req/AcMeter.cs new file mode 100644 index 0000000..519721e --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/AcMeter.cs @@ -0,0 +1,57 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Formats.Asn1.AsnWriter; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.19 充放电上报交流电表数据(交流电表接到充电机上的情况) + /// + public class AcMeter : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 交流进线 A 相电压 + /// + [Property(8, 16, scale: 0.1)] + public float PhaseVoltageA { get; set; } + /// + /// 交流进线 B 相电压 + /// + [Property(24, 16, scale: 0.1)] + public float PhaseVoltageB { get; set; } + /// + /// 交流进线 C 相电压 + /// + [Property(40, 16, scale: 0.1)] + public float PhaseVoltageC { get; set; } + /// + /// 交流进线 A 相电流 + /// + [Property(56, 16, scale: 0.1)] + public float PhaseCurrentA { get; set; } + /// + /// 交流进线 B 相电流 + /// + [Property(72, 16, scale: 0.1)] + public float PhaseCurrentB { get; set; } + /// + /// 交流进线 C 相电流 + /// + [Property(88, 16, scale: 0.1)] + public float PhaseCurrentC { get; set; } + /// + /// 交流表总电量 + /// + [Property(104, 32, scale: 0.1)] + public float AcMeterTotalPower { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/AcMeter.cs~handler b/Service/Charger/Msg/Charger/Req/AcMeter.cs~handler new file mode 100644 index 0000000..519721e --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/AcMeter.cs~handler @@ -0,0 +1,57 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Formats.Asn1.AsnWriter; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.19 充放电上报交流电表数据(交流电表接到充电机上的情况) + /// + public class AcMeter : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 交流进线 A 相电压 + /// + [Property(8, 16, scale: 0.1)] + public float PhaseVoltageA { get; set; } + /// + /// 交流进线 B 相电压 + /// + [Property(24, 16, scale: 0.1)] + public float PhaseVoltageB { get; set; } + /// + /// 交流进线 C 相电压 + /// + [Property(40, 16, scale: 0.1)] + public float PhaseVoltageC { get; set; } + /// + /// 交流进线 A 相电流 + /// + [Property(56, 16, scale: 0.1)] + public float PhaseCurrentA { get; set; } + /// + /// 交流进线 B 相电流 + /// + [Property(72, 16, scale: 0.1)] + public float PhaseCurrentB { get; set; } + /// + /// 交流进线 C 相电流 + /// + [Property(88, 16, scale: 0.1)] + public float PhaseCurrentC { get; set; } + /// + /// 交流表总电量 + /// + [Property(104, 32, scale: 0.1)] + public float AcMeterTotalPower { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs b/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs new file mode 100644 index 0000000..b0e7bb2 --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs @@ -0,0 +1,252 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Charger.Common; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static StackExchange.Redis.LCSMatchResult; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.8 电池包实时遥信上报(站内充电模式有电池包时周期性上传) + /// + public class RemoteSignaling : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// BMS 当前均衡状态 0:不平衡 1:平衡 + /// + [Property(15, 1)] + public byte CurrentBMS { get; set; } + /// + /// 附件继电器状态 0:开启 1:闭合 + /// + [Property(14, 1)] + public byte AttachmentRelayStatus { get; set; } + /// + /// BMS 当前状态 + /// 0:高压开启 + /// 1:预先充电 + /// 2 高压关断 + /// 3 高压上电故障 + /// + [Property(12, 2)] + public byte CurrentStatusBMS { get; set; } + /// + /// B2V_ST1 的生命信 0~14 循环,15:信号无效 + /// + [Property(8, 4)] + public byte B2VST1Msg { get; set; } + /// + /// 保留 + /// + [Property(23, 1)] + public byte Hold { get; set; } + /// + /// 最高报警等级 + /// 0:无故障 + /// 1:一级报警故障 + /// 2: 二级普通故障 + /// 3:三级严重故障 + /// + /// + [Property(21, 2)] + public byte MaximumAlarmLevel { get; set; } + /// + /// 充电状态 + /// 0:可以充电 + /// 1:正在充电 + /// 2:充电结束 + /// 3:充电故障 + /// + [Property(19, 2)] + public byte ChargingState { get; set; } + /// + /// 充电模式 + /// 0:预留 + /// 1:直流充电 + /// 2:交流充电 + /// 3:其他充电 + /// + [Property(17, 2)] + public byte ChargingMode { get; set; } + /// + /// 充电枪连接状态 0: 未连接 1:连接 + /// + [Property(16, 1)] + public byte ConnectionStatus { get; set; } + /// + /// PACK 欠压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(30, 2)] + public byte PackUndervoltage { get; set; } + /// + /// PACK 过压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(28, 2)] + public byte PackOvervoltage { get; set; } + /// + /// 电芯温度过高报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(26, 2)] + public byte ExcessiveTemperature { get; set; } + /// + /// 电芯温差异常报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(24, 2)] + public byte AbnormalTemperatureDifference { get; set; } + /// + /// 绝缘报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(38, 2)] + public byte InsulationAlarm { get; set; } + /// + /// 单体电压欠压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(36, 2)] + public byte UndervoltageAlarm { get; set; } + /// + /// 单体电压过高报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(34, 2)] + public byte VoltageTooHigh { get; set; } + /// + /// SOC过低报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(32, 2)] + public byte LowSOCAlarm { get; set; } + /// + /// 电芯温度过低报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(46, 2)] + public byte LowTemperature { get; set; } + /// + /// 放电电流过大报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(44, 2)] + public byte ExcessiveDischargeCurrent { get; set; } + /// + /// 充电电流过大报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(42, 2)] + public byte ExcessiveChargingCurrent { get; set; } + /// + /// 单体压差过大 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(40, 2)] + public byte IndividualPressureDifference { get; set; } + /// + /// BMS 系统不匹配报警 0:正 常 1:故障 + /// + [Property(55, 1)] + public byte BMSSystemMismatchAlarm { get; set; } + /// + /// BMS 内部通讯故障 0:正 常 1:故障 + /// + [Property(54, 1)] + public byte BMSCommunicationFailure { get; set; } + /// + /// SOC 跳变报警 0:正 常 1:故障 + /// + [Property(53, 1)] + public byte SOCJumpAlarm { get; set; } + /// + /// SOC 过高报警 + /// + [Property(52, 1)] + public byte SOCHighAlarm { get; set; } + /// + /// BMS 硬件故障 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(50, 2)] + public byte BMSHardwareFailure { get; set; } + /// + /// 支路压差过大报警(存在并联支路的系统) + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(48, 2)] + public byte BranchPressureDifference { get; set; } + /// + /// GBT32960.3 中规定的故障数目(当前时刻发生的) 0:正常 1:故障 + /// + [Property(59, 5)] + public byte CurrentTimeOccurrence { get; set; } + /// + /// 火灾报警 0:正常 1:故障 + /// + [Property(58, 1)] + public byte FireAlarm { get; set; } + /// + /// 烟雾报警 0:正常 1:故障 + /// + [Property(57, 1)] + public byte SmokeAlarm { get; set; } + /// + /// 高压互锁报警 0:正常 1:故障 + /// + [Property(56, 1)] + public byte HighVoltageInterlockAlarm { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs~handler b/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs~handler new file mode 100644 index 0000000..b0e7bb2 --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/RemoteSignaling.cs~handler @@ -0,0 +1,252 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Charger.Common; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static StackExchange.Redis.LCSMatchResult; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.8 电池包实时遥信上报(站内充电模式有电池包时周期性上传) + /// + public class RemoteSignaling : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// BMS 当前均衡状态 0:不平衡 1:平衡 + /// + [Property(15, 1)] + public byte CurrentBMS { get; set; } + /// + /// 附件继电器状态 0:开启 1:闭合 + /// + [Property(14, 1)] + public byte AttachmentRelayStatus { get; set; } + /// + /// BMS 当前状态 + /// 0:高压开启 + /// 1:预先充电 + /// 2 高压关断 + /// 3 高压上电故障 + /// + [Property(12, 2)] + public byte CurrentStatusBMS { get; set; } + /// + /// B2V_ST1 的生命信 0~14 循环,15:信号无效 + /// + [Property(8, 4)] + public byte B2VST1Msg { get; set; } + /// + /// 保留 + /// + [Property(23, 1)] + public byte Hold { get; set; } + /// + /// 最高报警等级 + /// 0:无故障 + /// 1:一级报警故障 + /// 2: 二级普通故障 + /// 3:三级严重故障 + /// + /// + [Property(21, 2)] + public byte MaximumAlarmLevel { get; set; } + /// + /// 充电状态 + /// 0:可以充电 + /// 1:正在充电 + /// 2:充电结束 + /// 3:充电故障 + /// + [Property(19, 2)] + public byte ChargingState { get; set; } + /// + /// 充电模式 + /// 0:预留 + /// 1:直流充电 + /// 2:交流充电 + /// 3:其他充电 + /// + [Property(17, 2)] + public byte ChargingMode { get; set; } + /// + /// 充电枪连接状态 0: 未连接 1:连接 + /// + [Property(16, 1)] + public byte ConnectionStatus { get; set; } + /// + /// PACK 欠压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(30, 2)] + public byte PackUndervoltage { get; set; } + /// + /// PACK 过压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(28, 2)] + public byte PackOvervoltage { get; set; } + /// + /// 电芯温度过高报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(26, 2)] + public byte ExcessiveTemperature { get; set; } + /// + /// 电芯温差异常报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(24, 2)] + public byte AbnormalTemperatureDifference { get; set; } + /// + /// 绝缘报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(38, 2)] + public byte InsulationAlarm { get; set; } + /// + /// 单体电压欠压报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(36, 2)] + public byte UndervoltageAlarm { get; set; } + /// + /// 单体电压过高报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(34, 2)] + public byte VoltageTooHigh { get; set; } + /// + /// SOC过低报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(32, 2)] + public byte LowSOCAlarm { get; set; } + /// + /// 电芯温度过低报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(46, 2)] + public byte LowTemperature { get; set; } + /// + /// 放电电流过大报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(44, 2)] + public byte ExcessiveDischargeCurrent { get; set; } + /// + /// 充电电流过大报警 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(42, 2)] + public byte ExcessiveChargingCurrent { get; set; } + /// + /// 单体压差过大 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(40, 2)] + public byte IndividualPressureDifference { get; set; } + /// + /// BMS 系统不匹配报警 0:正 常 1:故障 + /// + [Property(55, 1)] + public byte BMSSystemMismatchAlarm { get; set; } + /// + /// BMS 内部通讯故障 0:正 常 1:故障 + /// + [Property(54, 1)] + public byte BMSCommunicationFailure { get; set; } + /// + /// SOC 跳变报警 0:正 常 1:故障 + /// + [Property(53, 1)] + public byte SOCJumpAlarm { get; set; } + /// + /// SOC 过高报警 + /// + [Property(52, 1)] + public byte SOCHighAlarm { get; set; } + /// + /// BMS 硬件故障 + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(50, 2)] + public byte BMSHardwareFailure { get; set; } + /// + /// 支路压差过大报警(存在并联支路的系统) + /// 0:无故障 + /// 1:一级报警故障 + /// 2:二级普通故障 + /// 3:三级严重故障 + /// + [Property(48, 2)] + public byte BranchPressureDifference { get; set; } + /// + /// GBT32960.3 中规定的故障数目(当前时刻发生的) 0:正常 1:故障 + /// + [Property(59, 5)] + public byte CurrentTimeOccurrence { get; set; } + /// + /// 火灾报警 0:正常 1:故障 + /// + [Property(58, 1)] + public byte FireAlarm { get; set; } + /// + /// 烟雾报警 0:正常 1:故障 + /// + [Property(57, 1)] + public byte SmokeAlarm { get; set; } + /// + /// 高压互锁报警 0:正常 1:故障 + /// + [Property(56, 1)] + public byte HighVoltageInterlockAlarm { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/UplinkUpgrade.cs b/Service/Charger/Msg/Charger/Req/UplinkUpgrade.cs new file mode 100644 index 0000000..3ab284f --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/UplinkUpgrade.cs @@ -0,0 +1,61 @@ +using AutoMapper.Execution; +using HybirdFrameworkCore.Autofac.Attribute; +using Service.Charger.Msg.Host.Req; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.7 远程升级-监控网关上送升级完成确认帧 + /// + public class UplinkUpgrade : ASDU + { /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 当前版本号 + /// + [Property(8, 8)] + public byte CurrentVersionNumberByte1 { get; set; } + [Property(16, 8)] + public byte CurrentVersionNumberByte2 { get; set; } + [Property(24, 8)] + public byte CurrentVersionNumberByte3 { get; set; } + public string CurrentVersionNumber + { + get + { + return CurrentVersionNumberByte1 + "." + CurrentVersionNumberByte2 + "." + CurrentVersionNumberByte3; + } + set { } + } + /// + /// 原来版本号 + /// + [Property(32, 8)] + public byte OriginalVersionNumberByte1 { get; set; } + [Property(40, 8)] + public byte OriginalVersionNumberByte2 { get; set; } + [Property(48, 8)] + public byte OriginalVersionNumberByte3 { get; set; } + public string OriginalVersionNumber + { + get + { + return OriginalVersionNumberByte1 + "." + OriginalVersionNumberByte2 + "." + OriginalVersionNumberByte3; + } + set { } + } + /// + /// 升级结果 0: 成功; 1: 失败 + /// + [Property(56, 32)] + public uint UpgradeResultByte { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/VehicleVIN.cs b/Service/Charger/Msg/Charger/Req/VehicleVIN.cs new file mode 100644 index 0000000..db95860 --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/VehicleVIN.cs @@ -0,0 +1,26 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.14 充电机上报车辆 VIN + /// + public class VehicleVIN : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// VIN + /// + [Property(8, 17, type: PropertyReadConstant.Byte)] + public string vin { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Req/VehicleVIN.cs~handler b/Service/Charger/Msg/Charger/Req/VehicleVIN.cs~handler new file mode 100644 index 0000000..db95860 --- /dev/null +++ b/Service/Charger/Msg/Charger/Req/VehicleVIN.cs~handler @@ -0,0 +1,26 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Req +{ + /// + /// 3.5.14 充电机上报车辆 VIN + /// + public class VehicleVIN : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// VIN + /// + [Property(8, 17, type: PropertyReadConstant.Byte)] + public string vin { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Resp/AuthVINRes.cs b/Service/Charger/Msg/Charger/Resp/AuthVINRes.cs new file mode 100644 index 0000000..3e8cf82 --- /dev/null +++ b/Service/Charger/Msg/Charger/Resp/AuthVINRes.cs @@ -0,0 +1,22 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Resp +{ + /// + /// 3.5.17 充电机应答 VIN 鉴权结果 + /// + public class AuthVINRes : ASDU + { + + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Resp/ChargingSOC.cs b/Service/Charger/Msg/Charger/Resp/ChargingSOC.cs deleted file mode 100644 index d174f86..0000000 --- a/Service/Charger/Msg/Charger/Resp/ChargingSOC.cs +++ /dev/null @@ -1,16 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Charger.Resp -{ - /// - /// 3.4.8 充放电机应答监控平台下发站外允许充电 SOC - /// - public class ChargingSOC - { - /// - /// 0 成功 1 失败 - /// - [Property(0, 8)] - public byte Result { get; set; } - } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Charger/Resp/ChargingStartFsdRes.cs b/Service/Charger/Msg/Charger/Resp/ChargingStartFsdRes.cs deleted file mode 100644 index 3ddfd7c..0000000 --- a/Service/Charger/Msg/Charger/Resp/ChargingStartFsdRes.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Charger.Resp -{ - /// - /// 3.4.2 充放电机应答站功率调节指令 - /// - public class ChargingPowerRegulationRes : ASDU - { - /// - /// 记录类型 - /// - [Property(0, 8)] - public byte RecordType { get; set; } - - /// - ///应答结果 0: 成功 1:失败 - /// - [Property(8, 8)] - public byte Result { get; set; } - - /// - ///失败原因 0:正常 1:参数非法 2:双向充电设备放电中 0xFF:其他原因 - /// - [Property(16, 8)] - public byte FailReason { get; set; } - } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs b/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs new file mode 100644 index 0000000..c1ad0b6 --- /dev/null +++ b/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs @@ -0,0 +1,36 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Resp +{ + /// + /// 3.4.2 充放电设备应答站功率调节指令 + /// + public class PowerRegulationRes : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 应答结果 0: 成功 1:失败 + /// + [Property(8, 8)] + public byte ResponseResult { get; set; } + /// + /// 失败原因 + /// 0:正常 + /// 1:参数非法 + /// 2:双向充电设备放电中 + /// 0xFF:其他原因 + /// + [Property(16, 8)] + public ushort CauseFailure { get; set; } + + } +} diff --git a/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs~handler b/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs~handler new file mode 100644 index 0000000..7383e2a --- /dev/null +++ b/Service/Charger/Msg/Charger/Resp/PowerRegulationRes.cs~handler @@ -0,0 +1,35 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Resp +{ + /// + /// 3.4.2 充放电设备应答站功率调节指令 + /// + public class PowerRegulationRes : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 应答结果 0: 成功 1:失败 + /// + [Property(8, 8)] + public byte ResponseResult { get; set; } + /// + /// 失败原因 + /// 0:正常 + /// 1:参数非法 + /// 2:双向充电设备放电中 + /// 0xFF:其他原因 + /// + [Property(16, 8)] + public ushort CauseFailure { get; set; } + } +} diff --git a/Service/Charger/Msg/Charger/Resp/UpgradeRequestRes.cs b/Service/Charger/Msg/Charger/Resp/UpgradeRequestRes.cs new file mode 100644 index 0000000..ab5d73d --- /dev/null +++ b/Service/Charger/Msg/Charger/Resp/UpgradeRequestRes.cs @@ -0,0 +1,31 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Charger.Resp +{ + /// + /// 3.7 远程升级-监控网关响应升级请求 + /// + public class UpgradeRequestRes : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + + /// + /// 应答结果 + /// + public byte ResponseResult { get; set; } + + /// + /// 失败原因 + /// + public byte CauseFailure { get; set; } + } +} diff --git a/Service/Charger/Msg/Host/Req/AdjustChargeRate.cs b/Service/Charger/Msg/Host/Req/AdjustChargeRate.cs index 42a4f65..6ff2277 100644 --- a/Service/Charger/Msg/Host/Req/AdjustChargeRate.cs +++ b/Service/Charger/Msg/Host/Req/AdjustChargeRate.cs @@ -16,10 +16,10 @@ namespace Service.Charger.Msg.Host.Req /// ///期望运行 功率 /// - [Property(8, 16, PropertyReadConstant.Bit, 0.1, 1)] - public float ChargeRate { get; set; } + [Property(8, 16, scale: 0.1)] + public float ExpectedOperatingPower { get; set; } - public AdjustChargeRate(float chargeRate) + public AdjustChargeRate(float expectedOperatingPower) { FrameTypeNo = 45; MsgBodyCount = 1; @@ -28,7 +28,7 @@ namespace Service.Charger.Msg.Host.Req MsgBodyAddr = new byte[] { 0, 0, 0 }; RecordType = 20; - ChargeRate = chargeRate; + ExpectedOperatingPower = expectedOperatingPower; } } } \ No newline at end of file diff --git a/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs b/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs new file mode 100644 index 0000000..7fe6883 --- /dev/null +++ b/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs @@ -0,0 +1,44 @@ +using DotNetty.Codecs.Mqtt.Packets; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.5.16 站控下发 VIN 鉴权的结果 + /// + public class AuthenticationVIN:ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// VIN 鉴权结果 1:通过 2 不通过 + /// + [Property(8, 8)] + public byte VINResult { get; set; } + + public AuthenticationVIN(byte vinresult) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 4; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 51; + + VINResult = vinresult; + } + } +} diff --git a/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs~handler b/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs~handler new file mode 100644 index 0000000..494ba06 --- /dev/null +++ b/Service/Charger/Msg/Host/Req/AuthenticationVIN.cs~handler @@ -0,0 +1,48 @@ +using DotNetty.Codecs.Mqtt.Packets; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.5.16 站控下发 VIN 鉴权的结果 + /// + public class AuthenticationVIN:ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// VIN 鉴权结果 1:通过 2 不通过 + /// + [Property(8, 8)] + public byte VINResult { get; set; } + + /// + /// 站控下发 VIN 鉴权的结果 + /// + /// VIN 鉴权结果 1:通过 2 不通过 + public AuthenticationVIN(byte vinresult) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 4; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 51; + + VINResult = vinresult; + } + } +} diff --git a/Service/Charger/Msg/Host/Req/AuxiliaryPower.cs b/Service/Charger/Msg/Host/Req/AuxiliaryPower.cs index 539d624..7fb9433 100644 --- a/Service/Charger/Msg/Host/Req/AuxiliaryPower.cs +++ b/Service/Charger/Msg/Host/Req/AuxiliaryPower.cs @@ -8,9 +8,31 @@ namespace Service.Charger.Msg.Host.Req public class AuxiliaryPower : ASDU { /// - ///打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开 + /// 记录类型 /// [Property(0, 8)] + public byte RecordType { get; set; } + /// + ///打开辅助电源标志 1:电池包辅助电源导通 0:电池包辅助电源断开 + /// + [Property(8, 8)] public byte OpenFlag { get; set; } + + public AuxiliaryPower(byte openFlag) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 9; + + OpenFlag = openFlag; + } } } \ No newline at end of file diff --git a/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs b/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs new file mode 100644 index 0000000..f581d7a --- /dev/null +++ b/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs @@ -0,0 +1,62 @@ +using DotNetty.Codecs.Mqtt.Packets; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.5.5 监控平台下发电池仓的状态 + /// + public class BatteryHolderStatus:ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 是否有电池 0:无电池 1:有电池 + /// + [Property(8, 8)] + public byte Battery { get; set; } + /// + /// 电接头连接状态 0:未连接 1: 已连接 + /// + [Property(16, 8)] + public byte ConnectionState { get; set; } + /// + /// 水接头状态 0:未连接 1: 已连接 + /// + [Property(24, 8)] + public byte WaterCondition { get; set; } + + /// + /// + /// + /// + /// + /// + public BatteryHolderStatus(byte battery, byte connectionState, byte waterCondition) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 15; + + Battery = battery; + ConnectionState = connectionState; + WaterCondition = waterCondition; + } + } +} diff --git a/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs~handler b/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs~handler new file mode 100644 index 0000000..3fad3d7 --- /dev/null +++ b/Service/Charger/Msg/Host/Req/BatteryHolderStatus.cs~handler @@ -0,0 +1,62 @@ +using DotNetty.Codecs.Mqtt.Packets; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.5.5 监控平台下发电池仓的状态 + /// + public class BatteryHolderStatus:ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 是否有电池 0:无电池 1:有电池 + /// + [Property(8, 8)] + public byte Battery { get; set; } + /// + /// 电接头连接状态 0:未连接 1: 已连接 + /// + [Property(16, 8)] + public byte ConnectionState { get; set; } + /// + /// 水接头状态 0:未连接 1: 已连接 + /// + [Property(24, 8)] + public byte WaterCondition { get; set; } + + /// + /// + /// + /// 是否有电池 0:无电池 1:有电池 + /// 电接头连接状态 0:未连接 1: 已连接 + /// 水接头状态 0:未连接 1: 已连接 + public BatteryHolderStatus(byte battery, byte connectionState, byte waterCondition) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 15; + + Battery = battery; + ConnectionState = connectionState; + WaterCondition = waterCondition; + } + } +} diff --git a/Service/Charger/Msg/Host/Req/Bms/QueryBattery.cs b/Service/Charger/Msg/Host/Req/Bms/QueryBattery.cs deleted file mode 100644 index dd13770..0000000 --- a/Service/Charger/Msg/Host/Req/Bms/QueryBattery.cs +++ /dev/null @@ -1,40 +0,0 @@ -using HybirdFrameworkCore.Autofac.Attribute; - -namespace Service.Charger.Msg.Host.Req.Bms -{ - /// - /// 3.4.1 监控平台发送功率调节指令 - /// - public class QueryBattery : ASDU - { - /// - /// 记录类型 - /// - [Property(0, 8)] - public byte RecordType { get; set; } - - /// - /// 记录类型 - /// - [Property(8, 3, PropertyReadConstant.Byte)] - public byte[] Pgn { get; set; } = { 0x00, 0xf8, 0x2c }; - - /// - /// 记录类型 - /// - [Property(32, 3, PropertyReadConstant.Byte)] - public byte[] QueryPgn { get; set; } - - public QueryBattery(byte[] queryPgn) - { - FrameTypeNo = 46; - MsgBodyCount = 1; - TransReason = 3; - PublicAddr = 0; - MsgBodyAddr = new byte[] { 0, 0, 0 }; - - RecordType = 80; - QueryPgn = queryPgn; - } - } -} \ No newline at end of file diff --git a/Service/Charger/Msg/Host/Req/PowerRegulation.cs b/Service/Charger/Msg/Host/Req/PowerRegulation.cs new file mode 100644 index 0000000..82fceae --- /dev/null +++ b/Service/Charger/Msg/Host/Req/PowerRegulation.cs @@ -0,0 +1,44 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.4.1 监控平台发送功率调节指令 + /// + public class PowerRegulation : ASDU + { + + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 期望运行功率 + /// + [Property(8, 16, scale: 0.1)] + public ushort ExpectedOperatingPower { get; set; } + + public PowerRegulation(ushort expectedOperatingPower) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 5; + + ExpectedOperatingPower = expectedOperatingPower; + } + } +} diff --git a/Service/Charger/Msg/Host/Req/Upgrade request.cs b/Service/Charger/Msg/Host/Req/Upgrade request.cs new file mode 100644 index 0000000..4833b3e --- /dev/null +++ b/Service/Charger/Msg/Host/Req/Upgrade request.cs @@ -0,0 +1,45 @@ +using HslCommunication.BasicFramework; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.7 远程升级-站级监控升级请求下发 + /// + public class Upgrade_request : ASDU + { + /// + /// 执行控制 0x01:立即执行 0x02:空闲执行 + /// + public byte ExecutionControl { get; set; } + /// + /// 下 载 超 时时间 + /// + public byte DownloadTimeout { get; set; } + /// + /// 版本号 ASCII 码 + /// + public string VersionNumber { get; set; } + /// + /// 文件名称 HEX + /// + public string FileName { get; set; } + /// + /// 文件大小 HEX + /// + public string fileSize { get; set; } + /// + /// MD5 校验值 HEX + /// + public string MD5Verification { get; set; } + /// + /// URL(文件路径)ASCII码 + /// + public string URL { get; set; } + } +} diff --git a/Service/Charger/Msg/Host/Req/UpgradeRequest.cs b/Service/Charger/Msg/Host/Req/UpgradeRequest.cs new file mode 100644 index 0000000..fab16dd --- /dev/null +++ b/Service/Charger/Msg/Host/Req/UpgradeRequest.cs @@ -0,0 +1,115 @@ +using HslCommunication.BasicFramework; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Req +{ + /// + /// 3.7 远程升级-站级监控升级请求下发 + /// + public class UpgradeRequest : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + /// + /// 执行控制 0x01:立即执行 0x02:空闲执行 + /// + [Property(8, 8)] + public byte ExecutionControl { get; set; } + /// + /// 下载超时时间 + /// + [Property(16, 16)] + public byte DownloadTimeout { get; set; } + /// + /// 版本号 ASCII 码 + /// + [Property(32, 24)] + public string VersionNumber { get; set; } + /// + /// 文件名称 HEX + /// + [Property(56, 160)] + public byte[] FileNameByte + { + get + { + return Enumerable.Range(0, FileName.Length / 2) + .Select(i => Convert.ToByte(FileName.Substring(i * 2, 2), 16)) + .ToArray(); + } + set { } + } + /// + /// 文件名称 HEX + /// + public string FileName { get; set; } + /// + /// 文件大小 HEX + /// + [Property(216, 32)] + public uint FileSize { get; set; } + /// + /// MD5校验值 HEX + /// + [Property(248, 128)] + public byte[] MD5VerificationByte + { + get + { + return Enumerable.Range(0, MD5Verification.Length / 2) + .Select(i => Convert.ToByte(MD5Verification.Substring(i * 2, 2), 16)) + .ToArray(); + } + set { } + } + public string MD5Verification { get; set; } + /// + /// URL(文件路径)ASCII码 + /// + [Property(376, 1600)] + public string URL { get; set; } + + /// + /// + /// + /// 执行控制 0x01:立即执行 0x02:空闲执行 + /// 下载超时时间 + /// 版本号 + /// 文件名称 + /// 文件大小 + /// MD5校验值 + /// URL(文件路径) + public UpgradeRequest(byte executionControl, byte downloadTimeout, string versionNumber, + string fileName, uint fileSize, string mD5Verification, string url) + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 33; + + ExecutionControl = executionControl; + DownloadTimeout = downloadTimeout; + VersionNumber = versionNumber; + FileName = fileName; + FileSize = fileSize; + MD5Verification = mD5Verification; + URL = url; + } + } +} diff --git a/Service/Charger/Msg/Host/Resp/UplinkUpgradeRes.cs b/Service/Charger/Msg/Host/Resp/UplinkUpgradeRes.cs new file mode 100644 index 0000000..d5138c2 --- /dev/null +++ b/Service/Charger/Msg/Host/Resp/UplinkUpgradeRes.cs @@ -0,0 +1,44 @@ +using DotNetty.Codecs.Mqtt.Packets; +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Resp +{ + /// + /// 3.7 远程升级-站级监控响应升级完成确认帧 + /// + public class UplinkUpgradeRes : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + + /// + /// 应答结果 默认 0 + /// + public byte ResponseResult { get; set; } + + public UplinkUpgradeRes() + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 36; + + RecordType = 0; + } + } +} diff --git a/Service/Charger/Msg/Host/Resp/VehicleVINRes.cs b/Service/Charger/Msg/Host/Resp/VehicleVINRes.cs new file mode 100644 index 0000000..61375f2 --- /dev/null +++ b/Service/Charger/Msg/Host/Resp/VehicleVINRes.cs @@ -0,0 +1,36 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Charger.Msg.Host.Resp +{ + /// + /// 3.5.15 站控应该充电机 VIN 上报响应 + /// + public class VehicleVINRes : ASDU + { + /// + /// 记录类型 + /// + [Property(0, 8)] + public byte RecordType { get; set; } + + public VehicleVINRes() + { + PackLen = 0; + CtlArea = 0; + SrcAddr = 0; + + FrameTypeNo = 45; + MsgBodyCount = 1; + TransReason = 3; + PublicAddr = 0; + MsgBodyAddr = new byte[] { 0, 0, 0 }; + + RecordType = 41; + } + } +} diff --git a/Service/Service.csproj b/Service/Service.csproj index 433e1ae..2a621c7 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -7,21 +7,21 @@ - - - - - - - - + + + + + + + + - - - - + + + +