diff --git a/OrpaonEMS.App/Services/YuePuRunModelService.cs b/OrpaonEMS.App/Services/YuePuRunModelService.cs index 906e4e6..5c445ba 100644 --- a/OrpaonEMS.App/Services/YuePuRunModelService.cs +++ b/OrpaonEMS.App/Services/YuePuRunModelService.cs @@ -732,6 +732,10 @@ namespace OrpaonEMS.App.Services Task.Run(() => { + double? lastSlaveNightTargetSoc = null; + bool? lastSlaveShouldCharge = null; + bool? lastSlaveInWeekendTime = null; + //判断状态是否正确 while (CurESChargInfo == ESChargInfo.Night_Slave) { @@ -759,7 +763,34 @@ namespace OrpaonEMS.App.Services // OpenSolar(); //} - if (!IsInWeekendTime()) + bool inWeekendTime = IsInWeekendTime(); + var slaveNightTargetSoc = Math.Min(NightSlave_ToSlaveFullSoc, ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue); + bool shouldCharge = !inWeekendTime && SlaveClient.ClientInfo!.SOC < slaveNightTargetSoc; + + if (lastSlaveNightTargetSoc == null + || Math.Abs(lastSlaveNightTargetSoc.Value - slaveNightTargetSoc) > 0.0001 + || lastSlaveInWeekendTime == null + || lastSlaveInWeekendTime.Value != inWeekendTime) + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电目标】-模式:Night_Slave,从储能SOC:{SlaveClient.ClientInfo!.SOC:0.##},配置目标SOC:{NightSlave_ToSlaveFullSoc:0.##},BMS上限:{ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue:0.##},采用目标SOC:{slaveNightTargetSoc:0.##},是否周末禁充:{inWeekendTime}"); + lastSlaveNightTargetSoc = slaveNightTargetSoc; + lastSlaveInWeekendTime = inWeekendTime; + } + + if (lastSlaveShouldCharge == null || lastSlaveShouldCharge.Value != shouldCharge) + { + if (shouldCharge) + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电开始】-模式:Night_Slave,从储能SOC:{SlaveClient.ClientInfo!.SOC:0.##},目标SOC:{slaveNightTargetSoc:0.##}"); + } + else + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电停止】-模式:Night_Slave,从储能SOC:{SlaveClient.ClientInfo!.SOC:0.##},目标SOC:{slaveNightTargetSoc:0.##},是否周末禁充:{inWeekendTime}"); + } + lastSlaveShouldCharge = shouldCharge; + } + + if (!inWeekendTime) { //展示用 ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw; @@ -767,7 +798,7 @@ namespace OrpaonEMS.App.Services //循环执行方法 //从储能箱充满为止 - if (SlaveClient.ClientInfo!.SOC < 90) + if (SlaveClient.ClientInfo!.SOC < slaveNightTargetSoc) { //主储能箱充电 SlaveClient.ServerCmd.CmdType = "Charg"; @@ -841,6 +872,10 @@ namespace OrpaonEMS.App.Services Task.Run(() => { + double? lastMasterNightTargetSoc = null; + bool? lastMasterShouldCharge = null; + bool? lastMasterInWeekendTime = null; + //判断状态是否正确 while (CurESChargInfo == ESChargInfo.Night_Master) { @@ -868,7 +903,34 @@ namespace OrpaonEMS.App.Services // OpenSolar(); //} - if (!IsInWeekendTime()) + bool inWeekendTime = IsInWeekendTime(); + var masterNightTargetSoc = Math.Min(NightMaster_ToMasterFullSoc, ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue); + bool shouldCharge = !inWeekendTime && MasterClient.ClientInfo!.SOC < masterNightTargetSoc; + + if (lastMasterNightTargetSoc == null + || Math.Abs(lastMasterNightTargetSoc.Value - masterNightTargetSoc) > 0.0001 + || lastMasterInWeekendTime == null + || lastMasterInWeekendTime.Value != inWeekendTime) + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电目标】-模式:Night_Master,主储能SOC:{MasterClient.ClientInfo!.SOC:0.##},配置目标SOC:{NightMaster_ToMasterFullSoc:0.##},BMS上限:{ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue:0.##},采用目标SOC:{masterNightTargetSoc:0.##},是否周末禁充:{inWeekendTime}"); + lastMasterNightTargetSoc = masterNightTargetSoc; + lastMasterInWeekendTime = inWeekendTime; + } + + if (lastMasterShouldCharge == null || lastMasterShouldCharge.Value != shouldCharge) + { + if (shouldCharge) + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电开始】-模式:Night_Master,主储能SOC:{MasterClient.ClientInfo!.SOC:0.##},目标SOC:{masterNightTargetSoc:0.##}"); + } + else + { + LogService.Info($"时间:{DateTime.Now}-【夜间充电停止】-模式:Night_Master,主储能SOC:{MasterClient.ClientInfo!.SOC:0.##},目标SOC:{masterNightTargetSoc:0.##},是否周末禁充:{inWeekendTime}"); + } + lastMasterShouldCharge = shouldCharge; + } + + if (!inWeekendTime) { //展示用 ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw; @@ -876,7 +938,7 @@ namespace OrpaonEMS.App.Services //循环执行方法 //主储能箱充满为止 - if (MasterClient.ClientInfo!.SOC < ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue) + if (MasterClient.ClientInfo!.SOC < masterNightTargetSoc) { //主储能箱充电 MasterClient.ServerCmd.CmdType = "Charg"; @@ -2838,7 +2900,8 @@ namespace OrpaonEMS.App.Services //SetControlModel(ESChargInfo.Night_Master); //主储能箱充满为止 - if (MasterClient.ClientInfo!.SOC < ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue) + var masterNightTargetSoc = Math.Min(NightMaster_ToMasterFullSoc, ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue); + if (MasterClient.ClientInfo!.SOC < masterNightTargetSoc) { //主储能箱充电 MasterClient.ServerCmd.CmdType = "Charg";