using DevExpress.XtraBars;
|
using System.Data;
|
using Yw.Pump;
|
using Yw.Vmo;
|
using Yw.WinFrmUI.Phart;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class SimulationEnergyAnalyChartCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SimulationEnergyAnalyChartCtrl()
|
{
|
InitializeComponent();
|
this.pumpWorkingViewChart1.RunPointSelectedEvent += PumpWorkingViewChart1_RunPointSelectedEvent;
|
}
|
|
private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
|
private HydroWorkingVmo _working = null;//工况
|
private HydroEnergyAnalyViewModel _vm = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData
|
(
|
Yw.Model.HydroModelInfo hydroInfo,
|
HydroWorkingVmo working,
|
HydroEnergyAnalyViewModel vm
|
)
|
{
|
if (hydroInfo == null)
|
{
|
return;
|
}
|
if (working == null)
|
{
|
return;
|
}
|
if (vm == null)
|
{
|
return;
|
}
|
_hydroInfo = hydroInfo;
|
_working = working;
|
_vm = vm;
|
InitialGroups();
|
}
|
|
//初始化所有分组
|
private void InitialGroups()
|
{
|
if (_vm == null)
|
{
|
return;
|
}
|
var groups = _vm.Items?.Select(x => x.BeginGroup).Distinct().ToList();
|
this.barCmbGroup.Visibility = groups != null && groups.Count > 1 ? BarItemVisibility.Always : BarItemVisibility.Never;
|
this.repositoryItemImageComboBox1.Items.BeginUpdate();
|
this.repositoryItemImageComboBox1.Items.Clear();
|
this.barCmbGroup.EditValue = null;
|
groups?.ForEach(x =>
|
{
|
this.repositoryItemImageComboBox1.Items.Add(x, x, -1);
|
});
|
this.barCmbGroup.EditValue = groups != null && groups.Count > 0 ? groups[0] : null;
|
this.repositoryItemImageComboBox1.Items.EndUpdate();
|
}
|
|
//初始化图表
|
private void InitialChart(PumpWorkingViewViewModel vm)
|
{
|
this.pumpWorkingViewChart1.SetBindingData(vm);
|
if (vm != null && vm.Items != null)
|
{
|
var item = vm.Items.FirstOrDefault();
|
SetCurrent(item);
|
}
|
this.barCkE.Checked = this.pumpWorkingViewChart1.QEVisible;
|
}
|
|
//分组值改变
|
private void barCmbGroup_EditValueChanged(object sender, EventArgs e)
|
{
|
var group = this.barCmbGroup.EditValue?.ToString();
|
if (group == null)
|
{
|
return;
|
}
|
var vm = CreateViewModel(group);
|
InitialChart(vm);
|
}
|
|
//创建
|
private PumpWorkingViewViewModel CreateViewModel(string group)
|
{
|
if (_hydroInfo == null)
|
{
|
return default;
|
}
|
if (_working == null)
|
{
|
return default;
|
}
|
if (_vm == null)
|
{
|
return default;
|
}
|
var pipe = _vm.Pipe?.Items?.Find(x => x.BeginGroup == group);
|
|
var vm = new PumpWorkingViewViewModel();
|
vm.Id = _working.ID.ToString();
|
vm.Name = _working.Name;
|
vm.CurveName = $"装置线";
|
vm.Color = Color.Black;
|
vm.StartH = pipe?.StartH ?? 0;
|
vm.PipeQ = pipe?.PipeQ ?? 0;
|
vm.PipeH = pipe?.PipeH ?? 0;
|
|
if (_vm.Items != null && _vm.Items.Count > 0)
|
{
|
var items = _vm.Items.Where(x => x.BeginGroup == group && x.LinkStatus == Yw.Hydro.LinkStatus.Open).ToList();
|
if (items != null && items.Count > 0)
|
{
|
vm.Items = new List<PumpWorkingViewItemViewModel>();
|
foreach (var item in items)
|
{
|
var vmItem = new PumpWorkingViewItemViewModel();
|
vm.Items.Add(vmItem);
|
vmItem.Id = item.Code;
|
vmItem.Name = item.Name;
|
vmItem.CurveName = item.Name;
|
vmItem.Color = HydroPumpCurveColorHelper.GetRandomColor(items.IndexOf(item));
|
vmItem.Q = item.CurrentQ ?? 0;
|
vmItem.H = item.CurrentH ?? 0;
|
vmItem.P = item.CurrentP;
|
vmItem.E = item.CurrentE;
|
vmItem.Hz = item.CurrentHz;
|
vmItem.N = item.CurrentN;
|
vmItem.CurveQH = item.CurrentCurveQH;
|
vmItem.CurveQP = item.CurrentCurveQP;
|
vmItem.CurveQE = item.CurrentCurveQE;
|
}
|
}
|
}
|
|
return vm;
|
}
|
|
//设置当前
|
private void SetCurrent(PumpWorkingViewItemViewModel item)
|
{
|
if (item != null)
|
{
|
this.barTxtPump.EditValue = item.Name;
|
this.barTxtQ.EditValue = $"{Math.Round(item.Q, 1)}m³/h";
|
this.barTxtH.EditValue = $"{Math.Round(item.H, 2)}m";
|
this.barTxtP.EditValue = $"{Math.Round(item.P ?? 0, 1)}kW";
|
this.barTxtE.EditValue = $"{Math.Round(item.E ?? 0, 1)}%";
|
}
|
}
|
|
private void PumpWorkingViewChart1_RunPointSelectedEvent(PumpWorkingViewItemViewModel obj)
|
{
|
SetCurrent(obj);
|
}
|
|
private void barCkE_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.pumpWorkingViewChart1.QEVisible = this.barCkE.Checked;
|
}
|
|
private void barBtnCoord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.pumpWorkingViewChart1.SetChartAxis();
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public void ExportToImage(string fileName)
|
{
|
this.pumpWorkingViewChart1.ExportToImage(fileName);
|
}
|
|
|
|
|
}
|
}
|