diff --git a/Entity/Dto/Resp/WaterCoolStatusResp.cs b/Entity/Dto/Resp/WaterCoolStatusResp.cs new file mode 100644 index 0000000..99991c6 --- /dev/null +++ b/Entity/Dto/Resp/WaterCoolStatusResp.cs @@ -0,0 +1,63 @@ +namespace Entity.Dto.Resp; + +public class WaterCoolStatusResp +{ + public string Sn { get; set; } + + /// + /// TMS 工作状态 + /// 0关机模式,1制冷模式,2制热模式,3自循环模式 + /// + public byte TmsStatus { get; set; } + + /// + /// TMS 高压继电器状态 + /// 0 断开状态,1 闭合状态,2~3 无效 + /// + public byte TmsHighStatus { get; set; } + + /// + /// 出水温度(机组到电池) + /// 分辨率:1 ℃/bit 偏移量:-40℃范围:-40℃~210℃ 类型:测量255:无效 + /// + public sbyte GetOutTemperature { get; set; } + + /// + /// 回水温度(电池到机组) + /// 分辨率:1 ℃/bit 偏移量:-40℃范围:-40℃~210℃ 类型:测量255:无效 + /// + public sbyte ComeBackTemperature { get; set; } + + /// + /// 供应商编号 + /// + public byte SupplierNumber { get; set; } + + /// + /// 软件版本 + /// + public byte SoftwareVersion { get; set; } + + /// + /// TMS 需求功率高字节 + /// 分辨率:0.1 Kw/bit 偏移量:0范围:0Kw~100.0Kw 类型:测量65535:无效(按照实时发送) + /// + public byte TmsHighPower { get; set; } + + /// + /// TMS 需求功率低字节 + /// 分辨率:0.1 Kw/bit 偏移量:0范围:0Kw~100.0Kw 类型:测量65535:无效(按照实时发送) + /// + public byte TmsLowPower { get; set; } + + /// + /// TMS 故障码 + /// 0:无故障; 出现 1 种以上循环发送 + /// + public byte TmsTroubleCode { get; set; } + + /// + /// crc校验帧 + /// + public byte CrcCheckValue { get; set; } +} \ No newline at end of file diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index 2c3fc23..399b58c 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -10,6 +10,7 @@ using HybirdFrameworkCore.Utils; using HybirdFrameworkDriver.Session; using HybirdFrameworkDriver.TcpClient; using log4net; +using Microsoft.AspNetCore.Routing.Matching; using Newtonsoft.Json; using Repository.Station; using Service.Charger.Codec; @@ -320,8 +321,11 @@ public class ChargerClient : TcpClient CurrentCmd = JsonConvert.SerializeObject(remoteStartCharging, Formatting.Indented) + "\r\n" + BitUtls.BytesToHexStr(remoteStartCharging.ToBytes()); - AuxiliaryPower auxiliaryPower = new AuxiliaryPower(1); - this.Channel.WriteAndFlushAsync(auxiliaryPower); + AuxiliaryPower auxiliaryPower0 = new AuxiliaryPower(0); + AuxiliaryPower auxiliaryPower1 = new AuxiliaryPower(1); + this.Channel.WriteAndFlushAsync(auxiliaryPower0); + Thread.Sleep(3000); + this.Channel.WriteAndFlushAsync(auxiliaryPower1); this.Channel.WriteAndFlushAsync(remoteStartCharging); return Result.Success(chargeOrderNo); } @@ -666,7 +670,7 @@ public class ChargerClient : TcpClient RedisHelper redisHelper = AppInfo.Container.Resolve(); string? lockKey = redisHelper.GetStrValue($"chargeNo{BinNo}Start"); - if (!string.IsNullOrWhiteSpace(lockKey)) + if (!string.IsNullOrEmpty(lockKey)) { return Result.Success(true, $"charger-{BinNo} is starting"); } diff --git a/Service/Charger/Handler/UploadTelemetryDataHandler.cs b/Service/Charger/Handler/UploadTelemetryDataHandler.cs index 39f0f60..c74a34d 100644 --- a/Service/Charger/Handler/UploadTelemetryDataHandler.cs +++ b/Service/Charger/Handler/UploadTelemetryDataHandler.cs @@ -27,10 +27,10 @@ namespace Service.Charger.Handler msg.ChargerNo = sn; Log.Info($"receive {msg} from {sn}"); - if (!AppSettingsConstVars.DisabledTask.Contains("UploadTelemetryData")) + /*if (!AppSettingsConstVars.DisabledTask.Contains("UploadTelemetryData")) { RedisHelper.PublishAsync("UploadTelemetryData", JsonConvert.SerializeObject(msg)); - } + }*/ client.UploadTelemetryData = msg; //充电机实时充电功率 diff --git a/Service/WaterCool/Client/WaterCoolClient.cs b/Service/WaterCool/Client/WaterCoolClient.cs index 3e606bb..ecc2b92 100644 --- a/Service/WaterCool/Client/WaterCoolClient.cs +++ b/Service/WaterCool/Client/WaterCoolClient.cs @@ -129,7 +129,7 @@ public class WaterCoolClient : TcpClient /// - /// 热管理策略 + /// 热管理策略(开始充电调用) /// 闭合继电器状态-延时300->上高压->按照策略开始液冷模式 /// public void HeartManageStart() @@ -157,9 +157,8 @@ public class WaterCoolClient : TcpClient PowerOperate(0); } - /// - /// 热管理策略 + /// 热管理策略(停止充电调用) /// 下高压->监测继电器状态(5s)->断开继电器 (停止失败做报警,手动处理报警) /// public bool HeartManageStop() @@ -191,8 +190,11 @@ public class WaterCoolClient : TcpClient Thread.Sleep(300); return IsClose; } - - //上高压 + + /// + /// 高压请求 + /// + /// public void PowerOperate(byte value) { if (msg.HighTension == value) @@ -214,17 +216,6 @@ public class WaterCoolClient : TcpClient msg.HighTension = value; } - /// - /// Tmax>=28℃且Tmean>=24℃ - /// 进水口温度>=10℃,则请求 TMS进行冷却。 - /// 7℃<进水口温度<10℃,若前一个模式为关机模式或制热模式或自循环模式,则请求TMS进行自循环模式;若前一个模式为制冷模式,则请求TMS进行制冷模式 - ///进水口温度<=7℃,则请求TMS进行自循环 - /// Tmax<=24℃或Tmean<=22℃ - /// - public void Strategy() - { - } - public bool Connect() { base.BaseConnect(); diff --git a/WebStarter/Controllers/WaterCoolControlller.cs b/WebStarter/Controllers/WaterCoolControlller.cs new file mode 100644 index 0000000..2363af2 --- /dev/null +++ b/WebStarter/Controllers/WaterCoolControlller.cs @@ -0,0 +1,70 @@ +using AutoMapper; +using Entity.DbModel.Station; +using Entity.Dto.Resp; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Service.Charger.Client; +using Service.WaterCool.Client; +using Service.WaterCool.Msg.WaterCool; + +namespace WebStarter.Controllers; + +[Produces("application/json")] +[ApiController] +[Route("api/[controller]")] +public class WaterCoolControlller: ControllerBase +{ + /// + /// 获取水冷机列表信息 + /// + /// 充电机code列表返回 + [HttpGet] + [Route("GetWhaterCoolList")] + public async Task>> GetWhaterCoolList() + { + var vv = WaterCoolClientMgr.Dictionary.Values; + List coolStatusResps = new(); + + var configuration = new MapperConfiguration(cfg => cfg.CreateMap()); + var mapper = configuration.CreateMapper(); + + foreach (var VARIABLE in vv) + { + if (VARIABLE != null && VARIABLE.WaterCoolStatus != null) + { + WaterCoolStatusResp coolStatusResp = new(); + coolStatusResp=mapper.Map(VARIABLE.WaterCoolStatus); + coolStatusResp.Sn = VARIABLE.Sn; + coolStatusResps.Add(coolStatusResp); + } + } + return Result>.Success(coolStatusResps); + } + + /*/// + /// 水冷机发送指令 + /// + /// 充电机code列表返回 + [HttpGet] + [Route("SendModeMsg")] + public async Task>> SendModeMsg() + { + var vv = WaterCoolClientMgr.Dictionary.Values; + List coolStatusResps = new(); + + var configuration = new MapperConfiguration(cfg => cfg.CreateMap()); + var mapper = configuration.CreateMapper(); + + foreach (var VARIABLE in vv) + { + if (VARIABLE != null && VARIABLE.WaterCoolStatus != null) + { + WaterCoolStatusResp coolStatusResp = new(); + coolStatusResp=mapper.Map(VARIABLE.WaterCoolStatus); + coolStatusResp.Sn = VARIABLE.Sn; + coolStatusResps.Add(coolStatusResp); + } + } + return Result>.Success(coolStatusResps); + }*/ +} \ No newline at end of file