Files
YuPu-OrpaonEMS/OrpaonEMS.App/ViewModels/YuPuHandViewModel.cs
2025-02-28 22:23:13 +08:00

255 lines
7.4 KiB
C#

using OrpaonEMS.App.Models;
using OrpaonEMS.App.Services;
using OrpaonEMS.Core;
using Prism.Commands;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrpaonEMS.App.ViewModels
{
public class YuPuHandViewModel : NavigationViewModel
{
public YuPuHandViewModel(YuePuRunModelService yuePuRunModelService,IDialogService dialogService)
{
YuePuRunModelService = yuePuRunModelService;
this.DialogService = dialogService;
}
private DelegateCommand<string> _QFSwitchCmd;
/// <summary>
/// 电操 手动操作
/// </summary>
public DelegateCommand<string> QFSwitchCmd
{
set
{
_QFSwitchCmd = value;
}
get
{
if (_QFSwitchCmd == null)
{
_QFSwitchCmd = new DelegateCommand<string>((par) => QFSwitchCmdMethod(par));
}
return _QFSwitchCmd;
}
}
public YuePuRunModelService YuePuRunModelService { get; }
/// <summary>
/// 执行方法
/// </summary>
/// <param name="par"></param>
private void QFSwitchCmdMethod(string par)
{
switch (par)
{
case "QFSwitch1开":
YuePuRunModelService.QFSwitch1.SetRtSwitch(Model.Enums.SwitchEm.On);
break;
case "QFSwitch1关":
YuePuRunModelService.QFSwitch1.SetRtSwitch(Model.Enums.SwitchEm.Off);
break;
case "QFSwitch2开":
YuePuRunModelService.QFSwitch2.SetRtSwitch(Model.Enums.SwitchEm.On);
break;
case "QFSwitch2关":
YuePuRunModelService.QFSwitch2.SetRtSwitch(Model.Enums.SwitchEm.Off);
break;
case "QFSwitch3开":
YuePuRunModelService.QFSwitch3.SetRtSwitch(Model.Enums.SwitchEm.On);
break;
case "QFSwitch3关":
YuePuRunModelService.QFSwitch3.SetRtSwitch(Model.Enums.SwitchEm.Off);
break;
case "QFSwitch4开":
YuePuRunModelService.QFSwitch4.SetRtSwitch(Model.Enums.SwitchEm.On);
break;
case "QFSwitch4关":
YuePuRunModelService.QFSwitch4.SetRtSwitch(Model.Enums.SwitchEm.Off);
break;
default:
break;
}
}
//ControlModelCmd
private DelegateCommand<string> _ControlModelCmd;
/// <summary>
/// 电操 手动操作
/// </summary>
public DelegateCommand<string> ControlModelCmd
{
set
{
_ControlModelCmd = value;
}
get
{
if (_ControlModelCmd == null)
{
_ControlModelCmd = new DelegateCommand<string>((par) => ControlModelCmdMethod(par));
}
return _ControlModelCmd;
}
}
/// <summary>
/// 控制模式
/// </summary>
/// <param name="par"></param>
private void ControlModelCmdMethod(string par)
{
switch (par)
{
case "Master":
YuePuRunModelService.SetControlModel(ESChargInfo.Master);
break;
case "Slaver":
YuePuRunModelService.SetControlModel(ESChargInfo.Slave);
break;
case "Night_Master":
YuePuRunModelService.SetControlModel(ESChargInfo.Night_Master);
break;
default:
break;
}
}
//SolarHandCmd
private DelegateCommand<string> _SolarHandCmd;
/// <summary>
/// 光伏 手动操作
/// </summary>
public DelegateCommand<string> SolarHandCmd
{
set
{
_SolarHandCmd = value;
}
get
{
if (_SolarHandCmd == null)
{
_SolarHandCmd = new DelegateCommand<string>((par) => SolarHandCmdMethod(par));
}
return _SolarHandCmd;
}
}
/// <summary>
/// 光伏操作
/// </summary>
/// <param name="par"></param>
/// <exception cref="NotImplementedException"></exception>
private void SolarHandCmdMethod(string par)
{
switch (par)
{
case "Open":
YuePuRunModelService.OpenSolar();
break;
case "Close":
YuePuRunModelService.CloseSolar();
break;
default:
break;
}
}
//YuPuRunModelHandCmd
private DelegateCommand<string> _YuPuRunModelHandCmd;
/// <summary>
/// 运行模式 手动操作
/// </summary>
public DelegateCommand<string> YuPuRunModelHandCmd
{
set
{
_YuPuRunModelHandCmd = value;
}
get
{
if (_YuPuRunModelHandCmd == null)
{
_YuPuRunModelHandCmd = new DelegateCommand<string>((par) => YuPuRunModelHandCmdMethod(par));
}
return _YuPuRunModelHandCmd;
}
}
private void YuPuRunModelHandCmdMethod(string par)
{
switch (par)
{
case "Master":
YuePuRunModelService.HandRunModel(ESChargInfo.Master);
break;
case "Slave":
YuePuRunModelService.HandRunModel(ESChargInfo.Slave);
break;
case "Night_Master":
YuePuRunModelService.HandRunModel(ESChargInfo.Night_Master);
break;
default:
break;
}
}
private DelegateCommand _YuPuReportCmd;
private readonly IDialogService DialogService;
/// <summary>
/// 统计分析 手动操作
/// </summary>
public DelegateCommand YuPuReportCmd
{
set
{
_YuPuReportCmd = value;
}
get
{
if (_YuPuReportCmd == null)
{
_YuPuReportCmd = new DelegateCommand(() => YuPuReportCmdMethod());
}
return _YuPuReportCmd;
}
}
private void YuPuReportCmdMethod()
{
//弹窗
DialogService.ShowDialog("YuPuReportView", new DialogParameters() { { "Data", null } }, (par) =>
{
if (par.Result == ButtonResult.OK)
{
//程序名称
//var ReturnValue = par.Parameters.GetValue<BmsRwCell>("Model");
}
else if (par.Result == ButtonResult.Cancel)
{
//取消
}
});
}
}
}