更改了周五和周六晚上不充电
关闭后进程不关闭的操作 Mqtt的发布,关闭这个功能
This commit is contained in:
@@ -184,6 +184,10 @@ namespace OrpaonEMS.App
|
|||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
protected override void OnExit(ExitEventArgs e)
|
||||||
{
|
{
|
||||||
|
ContainerLocator.Container.Resolve<YuePuRunModelService>().ThreadEnable = false;
|
||||||
|
ContainerLocator.Container.Resolve<EnergyStorageService>().WebSocketThreadEnable = false;
|
||||||
|
ContainerLocator.Container.Resolve<EMSService>().ThreadEnable = false;
|
||||||
|
|
||||||
energyStorageService.EnergyStorageStateMachine.Fire(Core.Enums.EnergyStorageStateTrig.HandTrig);
|
energyStorageService.EnergyStorageStateMachine.Fire(Core.Enums.EnergyStorageStateTrig.HandTrig);
|
||||||
base.OnExit(e);
|
base.OnExit(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ namespace OrpaonEMS.App.Services
|
|||||||
|
|
||||||
ListDistClient.Find(a => a.ServerCmd.Station == 0)!.EMSSocketServerConState.ServerSendState = true;
|
ListDistClient.Find(a => a.ServerCmd.Station == 0)!.EMSSocketServerConState.ServerSendState = true;
|
||||||
ListDistClient.Find(a => a.ServerCmd.Station == 1)!.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()));
|
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);
|
var Data = Encoding.UTF8.GetString(message.Payload);
|
||||||
//反序列化数据
|
//反序列化数据
|
||||||
ClientInfo data = JsonSerializer.Deserialize<ClientInfo>(Data);
|
ClientInfo data = JsonSerializer.Deserialize<ClientInfo>(Data);
|
||||||
if (data.Station == 1)
|
//if (data.Station == 1)
|
||||||
{
|
//{
|
||||||
var dd = 1;
|
// var dd = 1;
|
||||||
}
|
//}
|
||||||
|
|
||||||
foreach (var item in ListDistClient)
|
foreach (var item in ListDistClient)
|
||||||
{
|
{
|
||||||
if (item.ClientInfo!.Station == data.Station)
|
if (item.ClientInfo!.Station == data.Station)
|
||||||
{
|
{
|
||||||
if (data.Station == 1)
|
//if (data.Station == 1)
|
||||||
{
|
//{
|
||||||
var dd = 1;
|
// var dd = 1;
|
||||||
}
|
//}
|
||||||
item.ClientInfo = data;
|
item.ClientInfo = data;
|
||||||
item.EMSSocketServerConState.ServerRecvState = true;
|
item.EMSSocketServerConState.ServerRecvState = true;
|
||||||
break;
|
break;
|
||||||
@@ -1294,7 +1294,7 @@ namespace OrpaonEMS.App.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool WebSocketServerState { get; set; } = false;
|
private bool WebSocketServerState { get; set; } = false;
|
||||||
|
|
||||||
private bool ThreadEnable = true;
|
public bool ThreadEnable = true;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -1363,7 +1363,7 @@ namespace OrpaonEMS.App.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 线程使能
|
/// 线程使能
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool WebSocketThreadEnable { get; set; } = true;
|
public bool WebSocketThreadEnable { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前的客户端状态指令内容
|
/// 当前的客户端状态指令内容
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace OrpaonEMS.App.Services
|
|||||||
InPowerPCSDataService = inPowerPCSDataService;
|
InPowerPCSDataService = inPowerPCSDataService;
|
||||||
if (ConfigDataService.IsMaster)
|
if (ConfigDataService.IsMaster)
|
||||||
{
|
{
|
||||||
MqttClientInit();
|
//MqttClientInit();
|
||||||
|
|
||||||
CycleSendStart();
|
//CycleSendStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OrpaonEMS.App.Services
|
|||||||
{
|
{
|
||||||
///////
|
///////
|
||||||
/////怎么认定为晚上,光伏发电功率低于一个阈值时可认为是晚上
|
/////怎么认定为晚上,光伏发电功率低于一个阈值时可认为是晚上
|
||||||
public YuePuRunModelService(ILogService logService, ConfigDataService configDataService,
|
public YuePuRunModelService(ILogService logService, ConfigDataService configDataService,
|
||||||
IEventAggregator eventAggregator)
|
IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
ConfigDataService = configDataService;
|
ConfigDataService = configDataService;
|
||||||
@@ -514,7 +514,6 @@ namespace OrpaonEMS.App.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
|
||||||
if (WaitTokenSource.IsCancellationRequested)
|
if (WaitTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -532,6 +531,7 @@ namespace OrpaonEMS.App.Services
|
|||||||
SlaveClient.ServerCmd.CoolOnOffCmd = false;
|
SlaveClient.ServerCmd.CoolOnOffCmd = false;
|
||||||
MasterClient.ServerCmd.CoolOnOffCmd = false;
|
MasterClient.ServerCmd.CoolOnOffCmd = false;
|
||||||
|
|
||||||
|
Thread.Sleep(30000);
|
||||||
|
|
||||||
//WaitEnvActionResult
|
//WaitEnvActionResult
|
||||||
|
|
||||||
@@ -695,48 +695,47 @@ namespace OrpaonEMS.App.Services
|
|||||||
// OpenSolar();
|
// OpenSolar();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//if (!IsSpecialWeekDay())
|
if (!IsInWeekendTime())
|
||||||
//{
|
|
||||||
|
|
||||||
//展示用
|
|
||||||
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
|
|
||||||
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
|
|
||||||
|
|
||||||
//循环执行方法
|
|
||||||
//从储能箱充满为止
|
|
||||||
if (SlaveClient.ClientInfo!.SOC < 90)
|
|
||||||
{
|
{
|
||||||
//主储能箱充电
|
//展示用
|
||||||
SlaveClient.ServerCmd.CmdType = "Charg";
|
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
|
||||||
SlaveClient.ServerCmd.CmdPw = SlaveClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
|
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
|
else
|
||||||
{
|
{
|
||||||
//从储能箱充电
|
//周五或者周六
|
||||||
|
//主从都不充电
|
||||||
|
MasterClient.ServerCmd.CmdType = "Charg";
|
||||||
|
MasterClient.ServerCmd.CmdPw = 0;
|
||||||
|
//MasterControlMsg = "【主储能】周五周六晚上不充电,【主储能】不动作";
|
||||||
|
|
||||||
SlaveClient.ServerCmd.CmdType = "Charg";
|
SlaveClient.ServerCmd.CmdType = "Charg";
|
||||||
SlaveClient.ServerCmd.CmdPw = 0;
|
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)
|
catch (Exception ex)
|
||||||
@@ -805,48 +804,46 @@ namespace OrpaonEMS.App.Services
|
|||||||
// OpenSolar();
|
// OpenSolar();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//if (!IsSpecialWeekDay())
|
if (!IsInWeekendTime())
|
||||||
//{
|
|
||||||
|
|
||||||
//展示用
|
|
||||||
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
|
|
||||||
TaxRealPw = SolarEleMeter5.AvePw - SolarEleMeter3.AvePw;//光伏和市电供应给税务大楼的负载
|
|
||||||
|
|
||||||
//循环执行方法
|
|
||||||
//主储能箱充满为止
|
|
||||||
if (MasterClient.ClientInfo!.SOC < ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue)
|
|
||||||
{
|
{
|
||||||
//主储能箱充电
|
//展示用
|
||||||
MasterClient.ServerCmd.CmdType = "Charg";
|
ManageRealPw = EsEleMeter4.AvePw - EsEleMeter1.AvePw;
|
||||||
MasterClient.ServerCmd.CmdPw = MasterClient.ClientInfo!.MaxDisChargPw * ConfigDataService.energyStorageRunConfig.MaxBatDisChargRatio;
|
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
|
else
|
||||||
{
|
{
|
||||||
//主储能箱充电
|
//周五或者周六
|
||||||
|
//主从都不充电
|
||||||
MasterClient.ServerCmd.CmdType = "Charg";
|
MasterClient.ServerCmd.CmdType = "Charg";
|
||||||
MasterClient.ServerCmd.CmdPw = 0;
|
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)
|
catch (Exception ex)
|
||||||
@@ -3275,13 +3272,43 @@ namespace OrpaonEMS.App.Services
|
|||||||
return (DateTime.Now.DayOfWeek == DayOfWeek.Friday && IsPm()) || (DateTime.Now.DayOfWeek == DayOfWeek.Saturday && IsPm());
|
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>
|
||||||
/// 是否时下午
|
/// 是否时下午
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool IsPm()
|
private bool IsPm()
|
||||||
{
|
{
|
||||||
return DateTime.Now.Hour > 18;
|
return DateTime.Now.Hour >= 23;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user