567 lines
15 KiB
C#
567 lines
15 KiB
C#
using ImTools;
|
|
using OrpaonEMS.App.Models;
|
|
using OrpaonEMS.App.PrismEvent;
|
|
using OrpaonEMS.App.Services;
|
|
using OrpaonEMS.App.Views;
|
|
using OrpaonEMS.Core;
|
|
using OrpaonEMS.Model.Enums;
|
|
using Prism.Commands;
|
|
using Prism.Events;
|
|
using Prism.Regions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OrpaonEMS.App.ViewModels
|
|
{
|
|
/// <summary>
|
|
/// 手自动控制ViewModel
|
|
/// </summary>
|
|
public class AutoHandViewModel : NavigationViewModel
|
|
{
|
|
/// <summary>
|
|
/// 实例化函数
|
|
/// </summary>
|
|
/// <param name="bmsDataService"></param>
|
|
/// <param name="energyStorageService"></param>
|
|
/// <param name="aCService"></param>
|
|
/// <param name="eventAggregator"></param>
|
|
/// <param name="inPowerPCSDataService"></param>
|
|
public AutoHandViewModel(BmsDataService bmsDataService,
|
|
EnergyStorageService energyStorageService,
|
|
ACService aCService,
|
|
ConfigDataService configDataService,
|
|
IEventAggregator eventAggregator,
|
|
IRegionManager regionManager,
|
|
EMSService eMSService,
|
|
YuePuRunModelService yuePuRunModelService,
|
|
InPowerPCSDataService inPowerPCSDataService)
|
|
{
|
|
this.bmsDataService = bmsDataService;
|
|
this.energyStorageService = energyStorageService;
|
|
ACService = aCService;
|
|
ConfigDataService = configDataService;
|
|
EventAggregator = eventAggregator;
|
|
RegionManager = regionManager;
|
|
EMSService = eMSService;
|
|
YuePuRunModelService = yuePuRunModelService;
|
|
InPowerPCSDataService = inPowerPCSDataService;
|
|
|
|
//EventAggregator.GetEvent<PeakValleyTimeEvent>().Subscribe(OnPeakValleyTimeEventMsgReceived);
|
|
SetHeatTemp = (double)ConfigDataService.SetHeadTargetTemp;
|
|
SetCoolTemp = ConfigDataService.SetCoolTargetTemp;
|
|
|
|
//RegionManager.RequestNavigate("UserDefineContentRegion", "YuPuHandView");
|
|
}
|
|
|
|
//private void OnPeakValleyTimeEventMsgReceived(ElePVEnum @enum)
|
|
//{
|
|
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Bms数据服务
|
|
/// </summary>
|
|
public BmsDataService bmsDataService { get; }
|
|
|
|
/// <summary>
|
|
/// 储能的服务
|
|
/// </summary>
|
|
public EnergyStorageService energyStorageService { get; }
|
|
|
|
/// <summary>
|
|
/// 液冷服务
|
|
/// </summary>
|
|
public ACService ACService { get; }
|
|
public ConfigDataService ConfigDataService { get; }
|
|
public IEventAggregator EventAggregator { get; }
|
|
public IRegionManager RegionManager { get; set; }
|
|
public EMSService EMSService { get; }
|
|
public YuePuRunModelService YuePuRunModelService { get; }
|
|
|
|
/// <summary>
|
|
/// 英博PCS服务
|
|
/// </summary>
|
|
public InPowerPCSDataService InPowerPCSDataService { get; }
|
|
|
|
#region PCS 操作
|
|
|
|
private double _PwValue;
|
|
/// <summary>
|
|
/// Pw值信息数据
|
|
/// </summary>
|
|
public double PwValue
|
|
{
|
|
get { return _PwValue; }
|
|
set { _PwValue = value; RaisePropertyChanged(); }
|
|
}
|
|
|
|
private DelegateCommand _PcsStartBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动操作
|
|
/// </summary>
|
|
public DelegateCommand PcsStartBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsStartBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsStartBtnCmd == null)
|
|
{
|
|
_PcsStartBtnCmd = new DelegateCommand(() => PcsStartBtnCmdMethod());
|
|
}
|
|
return _PcsStartBtnCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PCS 手动操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsStartBtnCmdMethod()
|
|
{
|
|
//EventAggregator.GetEvent<PeakValleyTimeEvent>().Publish(ElePVEnum.Peak);
|
|
await InPowerPCSDataService.PCSStartAsync();
|
|
}
|
|
|
|
private DelegateCommand _PcsEndBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动关闭结束操作
|
|
/// </summary>
|
|
public DelegateCommand PcsEndBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsEndBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsEndBtnCmd == null)
|
|
{
|
|
_PcsEndBtnCmd = new DelegateCommand(() => PcsEndBtnCmdMethod());
|
|
}
|
|
return _PcsEndBtnCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PCS 手动关闭结束操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsEndBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PCSStopAsync();
|
|
}
|
|
|
|
private DelegateCommand _PcsResetBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动复位操作
|
|
/// </summary>
|
|
public DelegateCommand PcsResetBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsResetBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsResetBtnCmd == null)
|
|
{
|
|
_PcsResetBtnCmd = new DelegateCommand(() => PcsResetBtnCmdMethod());
|
|
}
|
|
return _PcsResetBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动复位操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsResetBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PCSFaultResetAsync();
|
|
}
|
|
|
|
|
|
private DelegateCommand _PcsRemoteBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动远程操作
|
|
/// </summary>
|
|
public DelegateCommand PcsRemoteBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsRemoteBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsRemoteBtnCmd == null)
|
|
{
|
|
_PcsRemoteBtnCmd = new DelegateCommand(() => PcsRemoteBtnCmdMethod());
|
|
}
|
|
return _PcsRemoteBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动远程操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsRemoteBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PCSRemoteLocationAsync(true);
|
|
}
|
|
|
|
private DelegateCommand _PcsLocationBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动本地操作
|
|
/// </summary>
|
|
public DelegateCommand PcsLocationBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsLocationBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsLocationBtnCmd == null)
|
|
{
|
|
_PcsLocationBtnCmd = new DelegateCommand(() => PcsLocationBtnCmdMethod());
|
|
}
|
|
return _PcsLocationBtnCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PCS 手动本地操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsLocationBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PCSRemoteLocation(false);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DelegateCommand _PcsSendPwBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动发送功率操作
|
|
/// </summary>
|
|
public DelegateCommand PcsSendPwBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsSendPwBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsSendPwBtnCmd == null)
|
|
{
|
|
_PcsSendPwBtnCmd = new DelegateCommand(() => PcsSendPwBtnCmdMethod());
|
|
}
|
|
return _PcsSendPwBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动发送功率操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsSendPwBtnCmdMethod()
|
|
{
|
|
//
|
|
//正是充电,负是放电
|
|
if (PwValue >= 0)
|
|
{
|
|
await InPowerPCSDataService.SendPcsChargCmdAsync(PwValue);
|
|
}
|
|
else
|
|
{
|
|
await InPowerPCSDataService.SendPcsDisChargCmdAsync(PwValue);
|
|
}
|
|
}
|
|
|
|
private DelegateCommand _PcsCloseLinkBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动关闭连接操作
|
|
/// </summary>
|
|
public DelegateCommand PcsCloseLinkBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsCloseLinkBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsCloseLinkBtnCmd == null)
|
|
{
|
|
_PcsCloseLinkBtnCmd = new DelegateCommand(() => PcsCloseLinkBtnCmdMethod());
|
|
}
|
|
return _PcsCloseLinkBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动关闭连接操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsCloseLinkBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.CloseModbusRtuAsync();
|
|
}
|
|
|
|
|
|
|
|
private DelegateCommand _BmsResetBtnCmd;
|
|
/// <summary>
|
|
/// Bms复位操作
|
|
/// </summary>
|
|
public DelegateCommand BmsResetBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_BmsResetBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_BmsResetBtnCmd == null)
|
|
{
|
|
_BmsResetBtnCmd = new DelegateCommand(() => BmsResetBtnCmdMethod());
|
|
}
|
|
return _BmsResetBtnCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bms复位操作 执行方法
|
|
/// </summary>
|
|
private async Task BmsResetBtnCmdMethod()
|
|
{
|
|
bmsDataService.BmsAlarmReset();
|
|
await Task.CompletedTask;
|
|
}
|
|
|
|
|
|
|
|
|
|
private DelegateCommand _PcsGridConBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动并网操作
|
|
/// </summary>
|
|
public DelegateCommand PcsGridConBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsGridConBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsGridConBtnCmd == null)
|
|
{
|
|
_PcsGridConBtnCmd = new DelegateCommand(() => PcsGridConBtnCmdMethod());
|
|
}
|
|
return _PcsGridConBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动并网操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsGridConBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PcsOffLineCmdAsync(Core.Enums.PCSOffLineInfo.OnLine);
|
|
}
|
|
|
|
|
|
|
|
private DelegateCommand _PcsGridOffBtnCmd;
|
|
/// <summary>
|
|
/// PCS 手动离网操作
|
|
/// </summary>
|
|
public DelegateCommand PcsGridOffBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_PcsGridOffBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_PcsGridOffBtnCmd == null)
|
|
{
|
|
_PcsGridOffBtnCmd = new DelegateCommand(() => PcsGridOffBtnCmdMethod());
|
|
}
|
|
return _PcsGridOffBtnCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// PCS 手动离网操作 执行方法
|
|
/// </summary>
|
|
private async Task PcsGridOffBtnCmdMethod()
|
|
{
|
|
//
|
|
await InPowerPCSDataService.PcsOffLineCmdAsync(Core.Enums.PCSOffLineInfo.OffLine);
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 液冷操作
|
|
|
|
private double _SetHeatTemp;
|
|
/// <summary>
|
|
/// 制热设定温度
|
|
/// </summary>
|
|
public double SetHeatTemp
|
|
{
|
|
get { return _SetHeatTemp; }
|
|
set { _SetHeatTemp = value; }
|
|
}
|
|
|
|
private int _SetCoolTemp;
|
|
/// <summary>
|
|
/// 制冷设定温度
|
|
/// </summary>
|
|
public int SetCoolTemp
|
|
{
|
|
get { return _SetCoolTemp; }
|
|
set { _SetCoolTemp = value; }
|
|
}
|
|
|
|
private DelegateCommand<string> _AcRunModelBtnCmd;
|
|
/// <summary>
|
|
/// 液冷 运行模式操作
|
|
/// </summary>
|
|
public DelegateCommand<string> AcRunModelBtnCmd
|
|
{
|
|
set
|
|
{
|
|
_AcRunModelBtnCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_AcRunModelBtnCmd == null)
|
|
{
|
|
_AcRunModelBtnCmd = new DelegateCommand<string>((par) => AcRunModelBtnCmdMethod(par));
|
|
}
|
|
return _AcRunModelBtnCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 液冷 运行模式操作 执行方法
|
|
/// </summary>
|
|
private void AcRunModelBtnCmdMethod(string par)
|
|
{
|
|
//EventAggregator.GetEvent<PeakValleyTimeEvent>().Publish(Model.Enums.ElePVEnum.Peak);
|
|
|
|
switch (par)
|
|
{
|
|
case "Cool":
|
|
ACService.SetCoolCtrModel(Core.Enums.CoolState.Cool);
|
|
break;
|
|
case "Heat":
|
|
ACService.SetCoolCtrModel(Core.Enums.CoolState.Heat);
|
|
break;
|
|
case "Stop":
|
|
ACService.SetCoolCtrModel(Core.Enums.CoolState.Stop);
|
|
break;
|
|
case "AutoCycle":
|
|
ACService.SetCoolCtrModel(Core.Enums.CoolState.AutoCycle);
|
|
break;
|
|
case "Auto":
|
|
ACService.SetCoolCtrModel(Core.Enums.CoolState.Auto);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region BMS操作
|
|
|
|
private DelegateCommand _BMSHandResetCmd;
|
|
/// <summary>
|
|
/// BMS 手动复位操作
|
|
/// </summary>
|
|
public DelegateCommand BMSHandResetCmd
|
|
{
|
|
set
|
|
{
|
|
_BMSHandResetCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_BMSHandResetCmd == null)
|
|
{
|
|
_BMSHandResetCmd = new DelegateCommand(() => BMSHandResetCmdMethod());
|
|
}
|
|
return _BMSHandResetCmd;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// BMS复位操作
|
|
/// </summary>
|
|
private void BMSHandResetCmdMethod()
|
|
{
|
|
bmsDataService.BmsAlarmReset();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 手自动程序
|
|
|
|
|
|
|
|
|
|
private DelegateCommand<object> _AutoHandCmd;
|
|
/// <summary>
|
|
/// 手自动命令
|
|
/// </summary>
|
|
public DelegateCommand<object> AutoHandCmd
|
|
{
|
|
set
|
|
{
|
|
_AutoHandCmd = value;
|
|
}
|
|
get
|
|
{
|
|
if (_AutoHandCmd == null)
|
|
{
|
|
_AutoHandCmd = new DelegateCommand<object>((par) => AutoHandCmdMethod(par));
|
|
}
|
|
return _AutoHandCmd;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 手自动的操作
|
|
/// </summary>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
private void AutoHandCmdMethod(object par)
|
|
{
|
|
if ((bool)par)
|
|
{
|
|
// True 自动模式
|
|
energyStorageService.EnergyStorageStateMachine.Fire(Core.Enums.EnergyStorageStateTrig.StandbyTrig);
|
|
}
|
|
else
|
|
{
|
|
// False 手动模式
|
|
energyStorageService.EnergyStorageStateMachine.Fire(Core.Enums.EnergyStorageStateTrig.HandTrig);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|