master
lxw 3 months ago
parent fd6c19067f
commit d91f797991

@ -0,0 +1,27 @@
using SqlSugar;
namespace Entity.DbModel.Station;
[SugarTable("charge_water_cooler_relation")]
public class ChargeWaterCoolerRelation
{
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// 充电机编码
/// </summary>
[SugarColumn(ColumnName = "charge_code")]
public string ChargeCode { get; set; }
/// <summary>
/// 水冷机编码
/// </summary>
[SugarColumn(ColumnName = "water_cooler_code")]
public string WaterCoolerCode { get; set; }
}

@ -295,6 +295,7 @@ public abstract class BaseRepository<T> where T : class, new()
.ToListAsync();
}
public async Task<List<T>> QueryListByOrderClauseAsync(Expression<Func<T, object>> expression)
{
return await DbBaseClient
@ -614,6 +615,7 @@ public abstract class BaseRepository<T> where T : class, new()
.Select(expression2)
.ToListAsync();
}
public async Task<List<long>> QueryByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, long>> selectExpression, bool blUseNoLock = false)
{
return await DbBaseClient

@ -0,0 +1,14 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class ChargeWaterCoolerRelationRepository: BaseRepository<ChargeWaterCoolerRelation>
{
public ChargeWaterCoolerRelationRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}

@ -7,6 +7,7 @@ using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Host.Req;
using Service.Init;
using Service.WaterCool.Client;
using SqlSugar;
namespace Service.Charger;
@ -50,7 +51,7 @@ public class ChargerService
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.ChargerNo);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
return chargerClient.StartCharge(chargeSoc,(float)power, 1);
return chargerClient.StartCharge(chargeSoc, (float)power, 1);
}
/// <summary>
@ -77,6 +78,21 @@ public class ChargerService
return Result<bool>.Fail(@"充电机未连接");
}
//
WaterCoolClientMgr.Dictionary.TryGetValue(StaticStationInfo.RelationMap[chargerClient.Sn].WaterCoolerCode,
out WaterCoolClient client);
if (client == null)
{
return Result<bool>.Fail("未初始化液冷");
}
if (!client.HeartManageStop())
{
return Result<bool>.Fail("液冷系统断开失败");
}
client.StopFlag = true;
chargerClient.SendRemoteStopCharging();
return Result<bool>.Success(true, "发送停止命令成功");
@ -114,30 +130,78 @@ public class ChargerService
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{
NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
StartHH1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartHour) :0),
StartHH2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartHour) : 0),
StartHH3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartHour):0),
StartHH4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartHour):0),
StartHH5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartHour):0),
StartHH6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartHour):0),
StartHH7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartHour):0),
StartHH8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].StartHour) : 0),
StartMM1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute):0),
StartMM2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute):0),
StartMM3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute):0),
StartMM4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute):0),
StartMM5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute):0),
StartMM6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute):0),
StartMM7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute) : 0),
StartMM8 = (byte)(elecPriceModelVersionDetails.Count > 7 ? Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute) : 0),
TimePeak1 = (byte)(elecPriceModelVersionDetails.Count > 0 ? Convert.ToByte(elecPriceModelVersionDetails[0].Type):0),
TimePeak2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].Type):0),
TimePeak3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].Type):0),
TimePeak4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].Type):0),
TimePeak5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].Type):0),
TimePeak6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].Type):0),
TimePeak7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].Type):0),
TimePeak8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].Type):0)
StartHH1 = (byte)(elecPriceModelVersionDetails.Count > 0
? Convert.ToByte(elecPriceModelVersionDetails[0].StartHour)
: 0),
StartHH2 = (byte)(elecPriceModelVersionDetails.Count > 1
? Convert.ToByte(elecPriceModelVersionDetails[1].StartHour)
: 0),
StartHH3 = (byte)(elecPriceModelVersionDetails.Count > 2
? Convert.ToByte(elecPriceModelVersionDetails[2].StartHour)
: 0),
StartHH4 = (byte)(elecPriceModelVersionDetails.Count > 3
? Convert.ToByte(elecPriceModelVersionDetails[3].StartHour)
: 0),
StartHH5 = (byte)(elecPriceModelVersionDetails.Count > 4
? Convert.ToByte(elecPriceModelVersionDetails[4].StartHour)
: 0),
StartHH6 = (byte)(elecPriceModelVersionDetails.Count > 5
? Convert.ToByte(elecPriceModelVersionDetails[5].StartHour)
: 0),
StartHH7 = (byte)(elecPriceModelVersionDetails.Count > 6
? Convert.ToByte(elecPriceModelVersionDetails[6].StartHour)
: 0),
StartHH8 = (byte)(elecPriceModelVersionDetails.Count > 7
? Convert.ToByte(elecPriceModelVersionDetails[7].StartHour)
: 0),
StartMM1 = (byte)(elecPriceModelVersionDetails.Count > 0
? Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute)
: 0),
StartMM2 = (byte)(elecPriceModelVersionDetails.Count > 1
? Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute)
: 0),
StartMM3 = (byte)(elecPriceModelVersionDetails.Count > 2
? Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute)
: 0),
StartMM4 = (byte)(elecPriceModelVersionDetails.Count > 3
? Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute)
: 0),
StartMM5 = (byte)(elecPriceModelVersionDetails.Count > 4
? Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute)
: 0),
StartMM6 = (byte)(elecPriceModelVersionDetails.Count > 5
? Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute)
: 0),
StartMM7 = (byte)(elecPriceModelVersionDetails.Count > 6
? Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute)
: 0),
StartMM8 = (byte)(elecPriceModelVersionDetails.Count > 7
? Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute)
: 0),
TimePeak1 = (byte)(elecPriceModelVersionDetails.Count > 0
? Convert.ToByte(elecPriceModelVersionDetails[0].Type)
: 0),
TimePeak2 = (byte)(elecPriceModelVersionDetails.Count > 1
? Convert.ToByte(elecPriceModelVersionDetails[1].Type)
: 0),
TimePeak3 = (byte)(elecPriceModelVersionDetails.Count > 2
? Convert.ToByte(elecPriceModelVersionDetails[2].Type)
: 0),
TimePeak4 = (byte)(elecPriceModelVersionDetails.Count > 3
? Convert.ToByte(elecPriceModelVersionDetails[3].Type)
: 0),
TimePeak5 = (byte)(elecPriceModelVersionDetails.Count > 4
? Convert.ToByte(elecPriceModelVersionDetails[4].Type)
: 0),
TimePeak6 = (byte)(elecPriceModelVersionDetails.Count > 5
? Convert.ToByte(elecPriceModelVersionDetails[5].Type)
: 0),
TimePeak7 = (byte)(elecPriceModelVersionDetails.Count > 6
? Convert.ToByte(elecPriceModelVersionDetails[6].Type)
: 0),
TimePeak8 = (byte)(elecPriceModelVersionDetails.Count > 7
? Convert.ToByte(elecPriceModelVersionDetails[7].Type)
: 0)
};
return setPeakValleyTime;
}
@ -153,7 +217,8 @@ public class ChargerService
if (binInfos.Count > 0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count();
List<BinInfo> canSwapCounts = BinInfoRepository.QueryListByClause(i =>
i.Exists == 1 && i.Status == 1 && i.Soc >= Convert.ToDecimal(StaticStationInfo.SwapSoc) && i.ChargeStatus!=1);
i.Exists == 1 && i.Status == 1 && i.Soc >= Convert.ToDecimal(StaticStationInfo.SwapSoc) &&
i.ChargeStatus != 1);
if (canSwapCounts.Count > 0)
batteryStatusInfoResp.canSwapCount = canSwapCounts.Count();
List<BinInfo> chargingCounts =
@ -162,4 +227,4 @@ public class ChargerService
batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);
}
}
}

@ -22,6 +22,8 @@ using Service.Charger.Msg.Charger.Resp;
using Service.Charger.Msg.Host.Req;
using Service.Charger.Msg.Host.Req.Bms;
using Service.Charger.Msg.Host.Req.OutCharger.Req;
using Service.Init;
using Service.WaterCool.Client;
namespace Service.Charger.Client;
@ -463,10 +465,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
}
setPeakValleyTime= GetMsgContents(setPeakValleyTime);
setPeakValleyTime = GetMsgContents(setPeakValleyTime);
CurrentCmd = JsonConvert.SerializeObject(setPeakValleyTime, Formatting.Indented) + "\r\n" +
@ -645,6 +644,23 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
return Result<bool>.Fail($"仓-{BinNo} 被禁用");
}
//判断水冷继电器状态为断开
var relation = StaticStationInfo.RelationMap[Sn];
var waterCoolClient = WaterCoolClientMgr.GetBySn(relation.WaterCoolerCode)
;
if (waterCoolClient == null)
{
return Result<bool>.Fail($"液冷机组未初始化");
}
if (!waterCoolClient.WaitIsClose())
{
return Result<bool>.Fail($"继电器未断开");
}
RedisHelper redisHelper = AppInfo.Container.Resolve<RedisHelper>();
string? lockKey = redisHelper.GetStrValue($"chargeNo{BinNo}Start");
@ -716,22 +732,22 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
for (int i = 0; i < timeRng.NumberTime; i++)
{
PropertyInfo propertyStartTimePeriod1 = timeRng.GetType().GetProperty("StartHH" + (i + 1));
propertyStartTimePeriod1.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartHH" + (i + 1)).GetValue(timeRng))));
propertyStartTimePeriod1.SetValue(timeRng,
BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartHH" + (i + 1))
.GetValue(timeRng))));
PropertyInfo propertyStartTimePeriod2 = timeRng.GetType().GetProperty("StartMM" + (i + 1));
propertyStartTimePeriod2.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartMM" + (i + 1)).GetValue(timeRng))));
propertyStartTimePeriod2.SetValue(timeRng,
BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartMM" + (i + 1))
.GetValue(timeRng))));
PropertyInfo propertyTimePeriodPeakIden = timeRng.GetType().GetProperty("TimePeak" + (i + 1));
propertyTimePeriodPeakIden.SetValue(timeRng, timeRng.GetType().GetProperty("TimePeak" + (i + 1)).GetValue(timeRng));
propertyTimePeriodPeakIden.SetValue(timeRng,
timeRng.GetType().GetProperty("TimePeak" + (i + 1)).GetValue(timeRng));
}
return timeRng;
}
}
}

@ -10,6 +10,8 @@ using Service.Charger.Common;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
using Service.Init;
using Service.WaterCool.Client;
namespace HybirdFrameworkServices.Charger.Handler
{
@ -31,6 +33,7 @@ namespace HybirdFrameworkServices.Charger.Handler
public SwapOrderBatteryRepository SwapOrderBatteryRepository { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStartChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStartCharging msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
@ -43,13 +46,15 @@ namespace HybirdFrameworkServices.Charger.Handler
client.IsCharged = true;
client.IsStopped = false;
chargeStatus = 1;
SwapOrderBattery? swapOrderBattery = SwapOrderBatteryRepository.QueryLatestOrderNoByBatterySn(client.BatteryNo);
SwapOrderBattery? swapOrderBattery =
SwapOrderBatteryRepository.QueryLatestOrderNoByBatterySn(client.BatteryNo);
if (swapOrderBattery != null)
{
ChargeOrderRepository.Update(it => it.SwapOrderSn == swapOrderBattery.SwapOrderSn,
it => it.Sn == client.ChargeOrderNo);
List<ChargeOrder> orders = ChargeOrderRepository.QueryBySwapOrderAndBatterySn(swapOrderBattery.SwapOrderSn,
List<ChargeOrder> orders = ChargeOrderRepository.QueryBySwapOrderAndBatterySn(
swapOrderBattery.SwapOrderSn,
client.BatteryNo);
if (orders.Count > 0)
{
@ -60,7 +65,6 @@ namespace HybirdFrameworkServices.Charger.Handler
{
cloudChargeOrder = order.CloudChargeOrder;
}
}
if (string.IsNullOrWhiteSpace(cloudChargeOrder))
@ -72,21 +76,28 @@ namespace HybirdFrameworkServices.Charger.Handler
ChargeOrderRepository.Update(it => it.CloudChargeOrder == cloudChargeOrder,
it => hashSet.Contains(it.Id));
}
}
else
{
Log.Error($"can not find swapOrderBattery by {client.BatteryNo}");
}
//闭合继电器状态
var waterCoolClient =
WaterCoolClientMgr.GetBySn(StaticStationInfo.RelationMap[client.Sn].WaterCoolerCode);
if (waterCoolClient != null)
{
//闭合继电器状态-延时300->上高压->按照策略开始液冷模式
waterCoolClient.HeartManageStart();
}
}
else if (msg.Result == 1)
{
client.IsCharged = false;
}
if (ObjUtils.IsNotNullOrWhiteSpace( client.ChargeOrderNo))
if (ObjUtils.IsNotNullOrWhiteSpace(client.ChargeOrderNo))
{
ChargeOrderRepository.Update(it => it.CmdStatus == (msg.Result == 0 ? 1 : 2),
it => it.Sn == client.ChargeOrderNo);
@ -101,4 +112,4 @@ namespace HybirdFrameworkServices.Charger.Handler
}
}
}
}
}

@ -9,6 +9,7 @@ using Newtonsoft.Json;
using Repository.Station;
using Service.Charger.Client;
using Service.Init;
using Service.WaterCool.Client;
namespace Service.Charger.MyTask;
@ -200,7 +201,26 @@ public class AutoChargeTask : ITask
foreach (var binInfo in stopList)
{
Log.Info($"auto stop charge {binInfo.No} soc:{binInfo.Soc}");
ClientMgr.GetBySn(binInfo.ChargerNo)?.SendRemoteStopCharging();
var chargerClient = ClientMgr.GetBySn(binInfo.ChargerNo);
WaterCoolClientMgr.Dictionary.TryGetValue(
StaticStationInfo.RelationMap[chargerClient?.Sn].WaterCoolerCode,
out WaterCoolClient client);
if (client == null)
{
Log.Info("stop charge fail -- not init watercooler");
continue;
}
if (!client.HeartManageStop())
{
Log.Info("stop charge fail -- watercooler execute stop fail");
continue;
}
client.StopFlag = true;
chargerClient?.SendRemoteStopCharging();
}
#endregion
@ -227,4 +247,4 @@ public class AutoChargeTask : ITask
{
_stop = false;
}
}
}

@ -1,6 +1,8 @@
using Autofac;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using Repository.Station;
using Service.System;
namespace Service.Init;
@ -8,61 +10,77 @@ namespace Service.Init;
/// <summary>
/// 换电站基本信息静态数据
/// </summary>
public class StaticStationInfo
public abstract class StaticStationInfo
{
/// <summary>
/// 水冷/充电机关联关系
/// </summary>
public static Dictionary<string, ChargeWaterCoolerRelation> RelationMap { get; set; }
public static void Init()
{
List<ChargeWaterCoolerRelation> coolerRelations =
AppInfo.Container.Resolve<ChargeWaterCoolerRelationRepository>().Query();
RelationMap = coolerRelations.ToDictionary(i => i.ChargeCode, i => i);
}
public static int StationStatus
{
get => int.Parse(Resolve(StationParamConst.StationStatus));
set => Set(StationParamConst.StationStatus, value);
}
public static string OperationStartTime
{
get => Resolve(StationParamConst.OperationStartTime);
set => Set(StationParamConst.OperationStartTime, value);
}
public static string OperationEndTime
{
get => Resolve(StationParamConst.OperationEndTime);
set => Set(StationParamConst.OperationEndTime, value);
}
public static string StationWay
{
get => Resolve(StationParamConst.StationWay);
set => Set(StationParamConst.StationWay, value);
}
public static string StationModel
{
get => Resolve(StationParamConst.StationModel);
set => Set(StationParamConst.StationModel, value);
}
public static string StationName
{
get => Resolve(StationParamConst.StationName);
set => Set(StationParamConst.StationName, value);
}
public static string StationNo
{
get => Resolve(StationParamConst.StationNo);
set => Set(StationParamConst.StationNo, value);
}
public static string StationSn
{
get => Resolve(StationParamConst.StationSn);
set => Set(StationParamConst.StationSn, value);
}
public static string SwapFinishChargeTime
{
get => Resolve(StationParamConst.SwapFinishChargeTime);
set => Set(StationParamConst.SwapFinishChargeTime, value);
}
public static float SwapSoc
{
get => float.Parse(Resolve(StationParamConst.SwapSoc));
@ -71,7 +89,7 @@ public class StaticStationInfo
#region 充电相关
public static int Eid
public static int Eid
{
get => int.Parse(Resolve(StationParamConst.Eid));
set => Set(StationParamConst.Eid, value);
@ -94,7 +112,7 @@ public class StaticStationInfo
get => byte.Parse(Resolve(StationParamConst.ChargeSoc));
set => Set(StationParamConst.ChargeSoc, value);
}
public static float ChargePower
{
get => float.Parse(Resolve(StationParamConst.ChargePower));
@ -109,10 +127,8 @@ public class StaticStationInfo
get => byte.Parse(Resolve(StationParamConst.AutoChargeEnabled));
set => Set(StationParamConst.AutoChargeEnabled, value);
}
#endregion
#region cloud
@ -124,7 +140,7 @@ public class StaticStationInfo
}
public static int CloudServerPort
{
{
get
{
string port = Resolve(StationParamConst.CloudServerPort);
@ -132,6 +148,7 @@ public class StaticStationInfo
{
return 33000;
}
return int.Parse(port);
}
set => Set(StationParamConst.CloudServerPort, value);

@ -0,0 +1,163 @@
using Autofac;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Redis;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Charger.Client;
using Service.Init;
using Service.Swap.Dto;
using Service.WaterCool.Client;
namespace Service.MyTask;
[Scope]
public class HeartManagementTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(HeartManagementTask));
private static bool _stop;
public string Name()
{
return nameof(HeartManagementTask);
}
public int Interval()
{
return 1000 * 3;
}
public void Handle()
{
var waterCoolClients = WaterCoolClientMgr.Dictionary;
if (waterCoolClients.Count <= 0)
{
return;
}
foreach (var waterCoolClient in waterCoolClients.Values)
{
if (waterCoolClient.Connected)
{
while (true)
{
if (string.IsNullOrWhiteSpace(waterCoolClient.ChargeSn))
{
var dictionary =
StaticStationInfo.RelationMap.Values.ToDictionary(i => i.WaterCoolerCode,
i => i.ChargeCode);
waterCoolClient.ChargeSn = dictionary[waterCoolClient.Sn];
}
var chargerClient = ClientMgr.GetBySn(waterCoolClient.ChargeSn);
if (chargerClient == null)
{
return;
}
if (!waterCoolClient.StopFlag)
{
//Tmin<=12℃且Tmean<=15℃
if (!waterCoolClient.HortStrategyFlag && chargerClient.BatteryPackDataVoltage
?.CellTemperatureMax <=
15
&& chargerClient.BatteryPackDataVoltage
?.CellTemperatureMin <=
12)
{
waterCoolClient.HortStrategyFlag = true;
}
if (waterCoolClient.HortStrategyFlag && (chargerClient.BatteryPackDataVoltage?.CellTemperatureMax >= 20
|| chargerClient.BatteryPackDataVoltage?.CellTemperatureMin >= 17))
{
waterCoolClient.HortStrategyFlag = false;
waterCoolClient.msg.SetTemperature = 0;
waterCoolClient.msg.Mode = 0;
}
//开启制冷策略
if (!waterCoolClient.ColdStrategyFlag && chargerClient.BatteryPackDataVoltage?.CellTemperatureMax >=
28
&& chargerClient.BatteryPackDataVoltage?.CellTemperatureMin >=
24)
{
waterCoolClient.ColdStrategyFlag = true;
}
if (waterCoolClient.ColdStrategyFlag &&
(chargerClient.BatteryPackDataVoltage?.CellTemperatureMax <= 28
|| chargerClient.BatteryPackDataVoltage?.CellTemperatureMin <= 22))
{
waterCoolClient.msg.SetTemperature = 0;
waterCoolClient.msg.Mode = 0;
waterCoolClient.ColdStrategyFlag = false;
}
//加热模式
if (waterCoolClient.HortStrategyFlag)
{
waterCoolClient.msg.Mode = 2;
waterCoolClient.msg.SetTemperature = 45;
}
if (waterCoolClient.ColdStrategyFlag)
{
//若前一个模式为关机模式或制热模式或自循环模式则请求TMS进行自循环模式若前一个模式为制冷模式则请求TMS进行制冷模式
if (waterCoolClient.WaterCoolStatus?.ComeBackTemperature > 7 &&
waterCoolClient.WaterCoolStatus?.ComeBackTemperature < 10)
{
Log.Info("7< <10");
if (waterCoolClient.WaterCoolStatus?.TmsStatus != 1)
{
waterCoolClient.msg.Mode = 3;
}
else
{
waterCoolClient.msg.Mode = 1;
waterCoolClient.msg.SetTemperature = 10;
}
}
else if (waterCoolClient.WaterCoolStatus?.ComeBackTemperature >= 10)
{
Log.Info(">= 10");
// 进水口温度>=10℃则请求 TMS进行冷却
waterCoolClient.msg.Mode = 1;
waterCoolClient.msg.SetTemperature = 10;
}
else if (waterCoolClient.WaterCoolStatus?.ComeBackTemperature <= 7)
{
Log.Info("<=7");
waterCoolClient.msg.Mode = 3;
}
}
}
else
{
//TODO:: 停止需要干什么事情
}
}
}
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -2,14 +2,18 @@
using HybirdFrameworkDriver.Session;
using HybirdFrameworkDriver.TcpClient;
using log4net;
using Service.Charger.Client;
using Service.Charger.Common;
using Service.Charger.Handler;
using Service.Init;
using Service.MyTask;
using Service.WaterCool.Msg.Host;
using Service.WaterCool.Msg.WaterCool;
using Decoder = Service.Charger.Codec.Decoder;
using Encoder = Service.Charger.Codec.Encoder;
namespace Service.WaterCool.Client;
/// <summary>
/// 水冷客户端
/// </summary>
@ -30,12 +34,33 @@ public class WaterCoolClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 是否发送水冷固定帧
/// </summary>
public bool IsWaterCoolSend { get; set; } = true;
//上下电的时间
/// <summary>
///
/// </summary>
public DateTime? PowerChangeTime { get; set; }
//上下电的时间间隔(单位/s)
public int Interval = 15;
//停止标识
public bool StopFlag = true;
//制冷策略
public bool ColdStrategyFlag = false;
//制热策略
public bool HortStrategyFlag = false;
/// <summary>
/// 消息
/// </summary>
public ModeMsg msg{ get; set; }= new ModeMsg();
public ModeMsg msg { get; set; } = new ModeMsg();
//充电机sn
public string ChargeSn { get; set; }
private ILog Log()
{
var name = "WaterCool" + this.Sn;
@ -45,11 +70,42 @@ public class WaterCoolClient : TcpClient<IBaseHandler, Decoder, Encoder>
return logger;
}
//闭合
public bool IsOpen()
{
return WaterCoolStatus?.TmsHighStatus == 1;
}
public bool WaitIsClose()
{
int count = 0;
bool IsClose = this.IsClose();
while (!IsClose)
{
if (count > 5)
{
break;
}
IsClose = this.IsClose();
Thread.Sleep(1000);
count++;
}
return IsClose;
}
public bool IsClose()
{
return WaterCoolStatus?.TmsHighStatus == 0;
}
/// <summary>
/// 水冷机编号
/// </summary>
public string Sn { get; set; }
/// <summary>
/// 水冷发送
/// </summary>
@ -71,6 +127,104 @@ public class WaterCoolClient : TcpClient<IBaseHandler, Decoder, Encoder>
ChannelUtils.AddAttr(Channel, ChargerConst.DestAddr, destAddr);
}
/// <summary>
/// 热管理策略
/// 闭合继电器状态-延时300->上高压->按照策略开始液冷模式
/// </summary>
public void HeartManageStart()
{
Thread.Sleep(100);
int count = 0;
while (!IsOpen())
{
if (count > 5)
{
Log().Info("water Client Open err");
return;
}
Thread.Sleep(1000);
Log().Info("wait waterClient Open");
msg.BMSState = 1;
msg.ChargState = 1;
count++;
}
Thread.Sleep(300);
//上高压
PowerOperate(0);
}
/// <summary>
/// 热管理策略
/// 下高压->监测继电器状态(5s)->断开继电器 (停止失败做报警,手动处理报警)
/// </summary>
public bool HeartManageStop()
{
Thread.Sleep(100);
//下高压
PowerOperate(1);
int count = 0;
bool IsClose = this.IsClose();
while (!IsClose)
{
if (count > 5)
{
Log().Info("water Client Open err");
return IsClose;
}
IsClose = this.IsClose();
Thread.Sleep(1000);
Log().Info("wait waterClient Open");
msg.BMSState = 0;
msg.ChargState = 0;
count++;
}
Thread.Sleep(300);
return IsClose;
}
//上高压
public void PowerOperate(byte value)
{
if (msg.HighTension == value)
{
return;
}
var dateTime = DateTime.Now;
if (PowerChangeTime != null)
{
while ((dateTime - PowerChangeTime).Value.Seconds < Interval)
{
Thread.Sleep(1000);
dateTime = DateTime.Now;
}
}
PowerChangeTime = dateTime;
msg.HighTension = value;
}
/// <summary>
/// Tmax>=28℃且Tmean>=24℃
/// 进水口温度>=10℃则请求 TMS进行冷却。
/// 7℃进水口温度10℃若前一个模式为关机模式或制热模式或自循环模式则请求TMS进行自循环模式若前一个模式为制冷模式则请求TMS进行制冷模式
///进水口温度<=7℃则请求TMS进行自循环
/// Tmax<=24℃或Tmean<=22℃
/// </summary>
public void Strategy()
{
}
public bool Connect()
{
base.BaseConnect();

@ -8,6 +8,7 @@ using HybirdFrameworkCore.Job;
using HybirdFrameworkCore.Redis;
using log4net;
using Service.Charger.Client;
using Service.Init;
using Service.RealTime;
using Service.WaterCool.Client;
using SqlSugar;
@ -114,6 +115,8 @@ if (signalrEnabled)
RealtimeClient.Init();
}
StaticStationInfo.Init();
// 水冷连接
WaterCoolClientMgr.InitClient();

Loading…
Cancel
Save