From e903270fa1c104a61fedf9668ef0a4b758110e27 Mon Sep 17 00:00:00 2001 From: smartwyy <645583145@qq.com> Date: Thu, 30 May 2024 15:50:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E6=9C=BA=E9=81=A5=E6=B5=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Constant/StationParamConst.cs | 1 + Service/Cloud/Client/CloudClientMgr.cs | 60 +++++++- Service/Cloud/Msg/UploadTelemetryData.cs | 169 +++++++++++++++++++++++ Service/Init/StaticStationInfo.cs | 6 + 4 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 Service/Cloud/Msg/UploadTelemetryData.cs diff --git a/Entity/Constant/StationParamConst.cs b/Entity/Constant/StationParamConst.cs index 6750f1a..35921d5 100644 --- a/Entity/Constant/StationParamConst.cs +++ b/Entity/Constant/StationParamConst.cs @@ -209,6 +209,7 @@ public class StationParamConst //充电soc public static readonly string ChargeSoc = "Station.ChargeSoc"; + public static readonly string ChargePower = "Station.ChargePower"; public static readonly string AutoChargeEnabled = "Station.AutoChargeEnabled"; public static readonly string Eid = "Station.Eid"; public static readonly string Oid = "Station.Oid"; diff --git a/Service/Cloud/Client/CloudClientMgr.cs b/Service/Cloud/Client/CloudClientMgr.cs index 9c7ef41..f255fa9 100644 --- a/Service/Cloud/Client/CloudClientMgr.cs +++ b/Service/Cloud/Client/CloudClientMgr.cs @@ -1,14 +1,21 @@ using Autofac; +using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Redis; +using log4net; +using Newtonsoft.Json; +using Repository.Station; +using Service.Cloud.Msg; +using Service.Cloud.Msg.Host.Req; using Service.Init; -using Service.System; namespace Service.Cloud.Client; [Scope("SingleInstance")] public class CloudClientMgr { + private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClientMgr)); public static CloudClient? CloudClient { get; set; } public static void Init() @@ -28,6 +35,55 @@ public class CloudClientMgr CloudClient.InitHandler(); - Task.Run(() => CloudClient.Connect()); + Task.Run(() => CloudClient.Connect()); + + RedisHelper? redisHelper = AppInfo.Container.Resolve(); + BinInfoRepository binInfoRepository = AppInfo.Container.Resolve(); + redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) => + { + Log.Info($"receive UploadTelemetryData={value}"); + if (value.HasValue) + { + UploadTelemetryData? data = JsonConvert.DeserializeObject(value.ToString()); + if (data != null) + { + BinInfo? binInfo = binInfoRepository.QueryByClause(it => it.ChargerNo == data.ChargerNo); + ChargeDevDataInfo req = new ChargeDevDataInfo() + { + sn = StaticStationInfo.StationNo, + en = data.ChargerNo, + sd = "A"+int.Parse(data.ChargerNo), + mtp = StaticStationInfo.ChargePower, + mcr = 1, + hb = binInfo?.Exists??0, + el = 0, + cno = int.Parse(data.ChargerNo), + cs = binInfo.ChargeStatus??0, + fs = 0, + @as = 0, + //fc = data., + //st = data., + ct = data.ChargingTime, + //ssoc = data., + csoc = data.CurrentSoc, + //ssoe = data., + //csoe = data., + cvot = data.BmsChargingVoltage, + ccur = data.BmsChargingCurrent, + nvot = data.BmsNeedVoltage, + ncur = data.BmsNeedCurrent, + lsv = data.SingleBatteryMinVoltage, + hsv = data.SingleBatteryMaxVoltage, + lst = data.MinBatteryTemp, + hst = data.MaxBatteryTemp, + ws = 0xFF, + it = 0xFF, + ot = 0xFF, + bt = DateTime.Now + }; + CloudClient?.SendChargeDevDataInfo(req); + } + } + }); } } \ No newline at end of file diff --git a/Service/Cloud/Msg/UploadTelemetryData.cs b/Service/Cloud/Msg/UploadTelemetryData.cs new file mode 100644 index 0000000..b4e0e4a --- /dev/null +++ b/Service/Cloud/Msg/UploadTelemetryData.cs @@ -0,0 +1,169 @@ +namespace Service.Cloud.Msg +{ + /// + /// 3.5.4 遥测数据上报 + /// + public class UploadTelemetryData + { + /// + /// 当前 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/Service/Init/StaticStationInfo.cs b/Service/Init/StaticStationInfo.cs index 7848311..af82bea 100644 --- a/Service/Init/StaticStationInfo.cs +++ b/Service/Init/StaticStationInfo.cs @@ -95,6 +95,12 @@ public class StaticStationInfo get => byte.Parse(Resolve(StationParamConst.ChargeSoc)); set => Set(StationParamConst.ChargeSoc, value); } + + public static float ChargePower + { + get => float.Parse(Resolve(StationParamConst.ChargePower)); + set => Set(StationParamConst.ChargeSoc, value); + } /// /// 0-关闭 1-开启