更改了周五和周六晚上不充电

关闭后进程不关闭的操作
Mqtt的发布,关闭这个功能
This commit is contained in:
2025-03-01 00:19:51 +08:00
parent 547a1b3bf6
commit 325b24c99f
5 changed files with 114 additions and 83 deletions

View File

@@ -185,7 +185,7 @@ namespace OrpaonEMS.App.Services
ListDistClient.Find(a => a.ServerCmd.Station == 0)!.EMSSocketServerConState.ServerSendState = true;
ListDistClient.Find(a => a.ServerCmd.Station == 1)!.EMSSocketServerConState.ServerSendState = true;
//发布消息
wsServer.PublishAllClientPayload(JsonSerializer.Serialize<List<ServerCmd>>(ListDistClient.Select(a => a.ServerCmd).ToList()));
}
@@ -1235,19 +1235,19 @@ namespace OrpaonEMS.App.Services
var Data = Encoding.UTF8.GetString(message.Payload);
//反序列化数据
ClientInfo data = JsonSerializer.Deserialize<ClientInfo>(Data);
if (data.Station == 1)
{
var dd = 1;
}
//if (data.Station == 1)
//{
// var dd = 1;
//}
foreach (var item in ListDistClient)
{
if (item.ClientInfo!.Station == data.Station)
{
if (data.Station == 1)
{
var dd = 1;
}
//if (data.Station == 1)
//{
// var dd = 1;
//}
item.ClientInfo = data;
item.EMSSocketServerConState.ServerRecvState = true;
break;
@@ -1294,7 +1294,7 @@ namespace OrpaonEMS.App.Services
/// </summary>
private bool WebSocketServerState { get; set; } = false;
private bool ThreadEnable = true;
public bool ThreadEnable = true;
#endregion

View File

@@ -1363,7 +1363,7 @@ namespace OrpaonEMS.App.Services
/// <summary>
/// 线程使能
/// </summary>
private bool WebSocketThreadEnable { get; set; } = true;
public bool WebSocketThreadEnable { get; set; } = true;
/// <summary>
/// 当前的客户端状态指令内容

View File

@@ -32,9 +32,9 @@ namespace OrpaonEMS.App.Services
InPowerPCSDataService = inPowerPCSDataService;
if (ConfigDataService.IsMaster)
{
MqttClientInit();
//MqttClientInit();
CycleSendStart();
//CycleSendStart();
}
}

View File

@@ -26,7 +26,7 @@ namespace OrpaonEMS.App.Services
{
///////
/////怎么认定为晚上,光伏发电功率低于一个阈值时可认为是晚上
public YuePuRunModelService(ILogService logService, ConfigDataService configDataService,
public YuePuRunModelService(ILogService logService, ConfigDataService configDataService,
IEventAggregator eventAggregator)
{
ConfigDataService = configDataService;
@@ -140,7 +140,7 @@ namespace OrpaonEMS.App.Services
}
}
/// <summary>
@@ -514,7 +514,6 @@ namespace OrpaonEMS.App.Services
{
try
{
Thread.Sleep(1000);
if (WaitTokenSource.IsCancellationRequested)
{
break;
@@ -532,6 +531,7 @@ namespace OrpaonEMS.App.Services
SlaveClient.ServerCmd.CoolOnOffCmd = false;
MasterClient.ServerCmd.CoolOnOffCmd = false;
Thread.Sleep(30000);
//WaitEnvActionResult
@@ -695,48 +695,47 @@ namespace OrpaonEMS.App.Services
// OpenSolar();
//}
//if (!IsSpecialWeekDay())
//{
//展示用
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
//循环执行方法
//从储能箱充满为止
if (SlaveClient.ClientInfo!.SOC < 90)
if (!IsInWeekendTime())
{
//主储能箱充电
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = SlaveClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
//展示用
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
//循环执行方法
//从储能箱充满为止
if (SlaveClient.ClientInfo!.SOC < 90)
{
//主储能箱充电
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = SlaveClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
}
else
{
//从储能箱充电
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = 0;
}
//主储能箱不运行
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = 0;
}
else
{
//从储能箱充电
//周五或者周六
//主从都不充电
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = 0;
//MasterControlMsg = "【主储能】周五周六晚上不充电,【主储能】不动作";
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = 0;
//SlaveControlMsg = "【从储能】周五周六晚上不充电,【从储能】不动作";
}
//主储能箱不运行
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = 0;
//}
//else
//{
// //周五或者周六
// //主从都不充电
// MasterClient.ServerCmd.CmdType = "Charg";
// MasterClient.ServerCmd.CmdPw = 0;
// MasterControlMsg = "【主储能】周五周六晚上不充电,【主储能】不动作";
// SlaveClient.ServerCmd.CmdType = "Charg";
// SlaveClient.ServerCmd.CmdPw = 0;
// SlaveControlMsg = "【从储能】周五周六晚上不充电,【从储能】不动作";
//}
}
catch (Exception ex)
@@ -805,48 +804,46 @@ namespace OrpaonEMS.App.Services
// OpenSolar();
//}
//if (!IsSpecialWeekDay())
//{
//展示用
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
//循环执行方法
//主储能箱充满为止
if (MasterClient.ClientInfo!.SOC < ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue)
if (!IsInWeekendTime())
{
//主储能箱充电
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = MasterClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
//展示用
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
//循环执行方法
//主储能箱充满为止
if (MasterClient.ClientInfo!.SOC < ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue)
{
//主储能箱充电
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = MasterClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
}
else
{
//主储能箱充电
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = 0;
}
//从储能箱不运行
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = 0;
}
else
{
//主储能箱充电
//周五或者周六
//主从都不充电
MasterClient.ServerCmd.CmdType = "Charg";
MasterClient.ServerCmd.CmdPw = 0;
//MasterControlMsg = "【主储能】周五周六晚上不充电,【主储能】不动作";
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = 0;
//SlaveControlMsg = "【从储能】周五周六晚上不充电,【从储能】不动作";
}
//从储能箱不运行
SlaveClient.ServerCmd.CmdType = "Charg";
SlaveClient.ServerCmd.CmdPw = 0;
//}
//else
//{
// //周五或者周六
// //主从都不充电
// MasterClient.ServerCmd.CmdType = "Charg";
// MasterClient.ServerCmd.CmdPw = 0;
// MasterControlMsg = "【主储能】周五周六晚上不充电,【主储能】不动作";
// SlaveClient.ServerCmd.CmdType = "Charg";
// SlaveClient.ServerCmd.CmdPw = 0;
// SlaveControlMsg = "【从储能】周五周六晚上不充电,【从储能】不动作";
//}
}
catch (Exception ex)
@@ -3275,13 +3272,43 @@ namespace OrpaonEMS.App.Services
return (DateTime.Now.DayOfWeek == DayOfWeek.Friday && IsPm()) || (DateTime.Now.DayOfWeek == DayOfWeek.Saturday && IsPm());
}
/// <summary>
/// 是周五还是周六
/// 在晚上判断是周五晚上还是周六晚上,腾出储能给光伏充电用
/// </summary>
/// <returns></returns>
public bool IsInWeekendTime()
{
DateTime now = DateTime.Now;
DayOfWeek currentDay = now.DayOfWeek;
TimeSpan currentTime = now.TimeOfDay;
// 周五情况:时间 >= 23:00
if (currentDay == DayOfWeek.Friday && currentTime.Hours >= 23)
{
return true;
}
// 周六情况:全天有效
else if (currentDay == DayOfWeek.Saturday)
{
return true;
}
// 周日情况:时间 < 07:00
else if (currentDay == DayOfWeek.Sunday && currentTime.Hours < 7)
{
return true;
}
return false;
}
/// <summary>
/// 是否时下午
/// </summary>
/// <returns></returns>
private bool IsPm()
{
return DateTime.Now.Hour > 18;
return DateTime.Now.Hour >= 23;
}
/// <summary>