namespace HStation.WinFrmUI.PhartRelation
|
{
|
public partial class XhsPumpMainPhartPanel : DocumentPage
|
{
|
public XhsPumpMainPhartPanel()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "泵型号曲线";
|
|
this.xhsPumpMainPhartListCtrl1.FocusedChangedEvent += XhsPumpMainPhartListCtrl1_FocusedChangedEvent;
|
|
}
|
|
private long _pump_main_id;
|
private Vmo.AssetsPumpMainVmo _pump_main;
|
private Vmo.PhartDiagramRelationExtensionsVmo _xhs_phart_diagram_ex_std_dto = null;
|
private readonly BLL.PhartDiagramRelation _bll = new();
|
|
private Yw.Geometry.Point2d _design_pt;
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public async void InitialDataSource(long pump_main_id)
|
{
|
_pump_main_id = pump_main_id;
|
if (_pump_main_id < 1)
|
{
|
this.xhsPumpMainPhartListCtrl1.Clear();
|
return;
|
}
|
_pump_main = await new BLL.AssetsPumpMain().GetByID(_pump_main_id);
|
if (_pump_main == null)
|
{
|
this.xhsPumpMainPhartListCtrl1.Clear();
|
return;
|
}
|
this.xhsPumpMainPhartListCtrl1.SetBindingData(pump_main_id);
|
}
|
|
//选择曲线变换事件
|
private void XhsPumpMainPhartListCtrl1_FocusedChangedEvent(Vmo.PhartDiagramRelationExtensionsVmo obj)
|
{
|
_design_pt = null;
|
_xhs_phart_diagram_ex_std_dto = obj;
|
InitChart(_pump_main, _xhs_phart_diagram_ex_std_dto);
|
}
|
|
private Tuple<Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d> Get(Vmo.PhartDiagramRelationExtensionsVmo dto)
|
{
|
if (dto == null)
|
{
|
return default;
|
}
|
var diagram = dto.Diagram;
|
if (diagram == null)
|
{
|
return default;
|
}
|
var graph_list = diagram.GraphList;
|
if (graph_list == null || !graph_list.Any())
|
{
|
return default;
|
}
|
|
var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QH);
|
var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QE);
|
var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QP);
|
|
if (graph_qh == null)
|
{
|
return default;
|
}
|
|
List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
|
points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
|
if (graph_qe != null)
|
points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
|
if (graph_qp != null)
|
points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
|
|
var cubic_spline_qh = new Yw.Geometry.CubicSpline2d(points_qh);
|
var cubic_spline_qe = new Yw.Geometry.CubicSpline2d(points_qe);
|
var cubic_spline_qp = new Yw.Geometry.CubicSpline2d(points_qp);
|
|
return new Tuple<Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d>(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp);
|
}
|
|
#region 图表
|
|
//初始化图表数据
|
private void InitChart(Vmo.AssetsPumpMainVmo pump_main, Vmo.PhartDiagramRelationExtensionsVmo dto)
|
{
|
if (pump_main == null)
|
{
|
return;
|
}
|
if (dto == null)
|
{
|
return;
|
}
|
var diagram = dto.Diagram;
|
if (diagram == null)
|
{
|
return;
|
}
|
var tuple = Get(dto);
|
if (tuple == null)
|
{
|
return;
|
}
|
var cubic_spline_qh = tuple.Item1;
|
var cubic_spline_qe = tuple.Item2;
|
var cubic_spline_qp = tuple.Item3;
|
if (_design_pt == null)
|
{
|
_design_pt = new Yw.Geometry.Point2d();
|
_design_pt.X = Math.Round(cubic_spline_qh.MaxX / 2);
|
_design_pt.Y = Math.Round(cubic_spline_qh.GetPointY(_design_pt.X), 1);
|
}
|
|
var disp_paras = diagram.DispParas;
|
var is_calc_disp_paras = string.IsNullOrWhiteSpace(disp_paras);
|
// this.pumpViewChartCtrl1.SetBindingData(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp, disp_paras, is_calc_disp_paras);
|
this.pumpViewChartCtrl1.SetBindingData(pump_main.RatedSpeed, dto);
|
// this.pumpPerformInfoCtrl1.SetDesignPoint(_design_pt);
|
}
|
|
//清空图表数据
|
private void ClearChart()
|
{
|
// this.xtrPerform2dChart1.InitialChartData();
|
}
|
|
#endregion 图表
|
|
#region 导入
|
|
//Excel 导入
|
private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new Yw.WinFrmUI.Phart.PumpImportByExcelDlg();
|
dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
|
{
|
var bol = await Import(other_name, qh, qe, qp);
|
return bol;
|
};
|
dlg.ShowDialog();
|
}
|
|
//图片 导入
|
private void barBtnImportByPicture_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new Yw.WinFrmUI.Phart.ImportPumpPerform2dByPictureDlg();
|
dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
|
{
|
var bol = await Import(other_name, qh, qe, qp);
|
return bol;
|
};
|
dlg.ShowDialog();
|
}
|
|
//单点 导入
|
private void barBtnImportByOnePoint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new Yw.WinFrmUI.Phart.PumpImportByOnePointDlg();
|
if (_pump_main != null)
|
{
|
dlg.Set(_pump_main.RatedFlow, _pump_main.RatedHead, _pump_main.RatedSpeed, _pump_main.RatedEfficiency);
|
}
|
|
dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
|
{
|
var bol = await Import(other_name, qh, qe, qp);
|
return bol;
|
};
|
dlg.ShowDialog();
|
}
|
|
// 导入
|
private async Task<bool> Import(string other_name, Yw.Pump.CurveQH qh, Yw.Pump.CurveQE qe, Yw.Pump.CurveQP qp)
|
{
|
if (_pump_main_id < 1)
|
{
|
XtraMessageBox.Show("PumpMain is null!");
|
return false;
|
}
|
|
var input = new Vmo.PhartDiagramRelationExtensionsVmo();
|
input.ObjectType = HStation.Assets.DataType.PumpMain;
|
input.ObjectID = _pump_main_id;
|
input.Importance = 0;
|
input.OtherName = other_name;
|
input.Diagram = new Vmo.PhartDiagramExGraphListVmo()
|
{
|
DiagramType = HStation.PhartRelation.eDiagramType.Feat,
|
Name = other_name,
|
GraphList = new List<Vmo.PhartGraphVmo>()
|
{
|
new ()
|
{
|
Name = other_name+"-QH",
|
GeometryStyle= HStation.PhartRelation.eGeometryStyle.FeatCurve,
|
GraphType= HStation.PhartRelation.eGraphType.QH,
|
GraphParas=new HStation.Model.QHGraphParasModel()
|
{
|
Hz=50,
|
N=_pump_main.RatedSpeed
|
}.ToJson(),
|
GeometryInfo=qh.ToDbString()
|
},
|
new ()
|
{
|
Name = other_name+"-QE",
|
GeometryStyle= HStation.PhartRelation.eGeometryStyle.FeatCurve,
|
GraphType= HStation.PhartRelation.eGraphType.QE,
|
GraphParas=new HStation.Model.QEGraphParasModel()
|
{
|
Hz=50,
|
N=_pump_main.RatedSpeed
|
}.ToJson(),
|
GeometryInfo=qe.ToDbString()
|
},
|
new ()
|
{
|
Name = other_name+"-QP",
|
GeometryStyle= HStation.PhartRelation.eGeometryStyle.FeatCurve,
|
GraphType= HStation.PhartRelation.eGraphType.QP,
|
GraphParas=new HStation.Model.QPGraphParasModel()
|
{
|
Hz=50,
|
N=_pump_main.RatedSpeed
|
}.ToJson(),
|
GeometryInfo=qp.ToDbString()
|
},
|
}
|
};
|
|
var mapping_id = await _bll.InsertEx(input);
|
if (mapping_id < 1)
|
{
|
return false;
|
}
|
var xhs_phart_diagram_ex_std_dto = await _bll.GetExByID(mapping_id);
|
this.xhsPumpMainPhartListCtrl1.Add(xhs_phart_diagram_ex_std_dto);
|
return true;
|
}
|
|
#endregion 导入
|
|
#region 操作
|
|
//编辑
|
private void barBtnEditChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_xhs_phart_diagram_ex_std_dto == null)
|
{
|
return;
|
}
|
var diagram = _xhs_phart_diagram_ex_std_dto.Diagram;
|
if (diagram == null)
|
{
|
return;
|
}
|
var graph_list = diagram.GraphList;
|
if (graph_list == null || !graph_list.Any())
|
{
|
return;
|
}
|
|
var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QH);
|
var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QE);
|
var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QP);
|
|
if (graph_qh == null)
|
{
|
return;
|
}
|
Yw.Pump.CurveQH qh = null;
|
Yw.Pump.CurveQE qe = null;
|
Yw.Pump.CurveQP qp = null;
|
List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
|
points_qh = PhartPerformCurveHelper.GetFeatPointList((HStation.PhartRelation.eGraphType)graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
|
qh = new Yw.Pump.CurveQH(Yw.Ahart.eFeatType.Cubic, points_qh);
|
if (graph_qe != null)
|
{
|
points_qe = PhartPerformCurveHelper.GetFeatPointList((HStation.PhartRelation.eGraphType)graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
|
qe = new Yw.Pump.CurveQE(Yw.Ahart.eFeatType.Cubic, points_qe);
|
}
|
if (graph_qp != null)
|
{
|
points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
|
qp = new Yw.Pump.CurveQP(Yw.Ahart.eFeatType.Cubic, points_qp);
|
}
|
|
var dlg = new Yw.WinFrmUI.Phart.PumpEditChartDlg();
|
dlg.SetBindingData(qh, qe, qp);
|
dlg.ReloadDataEvent += async (new_qh, new_qe, new_qp) =>
|
{
|
var new_points_qh = new_qh.GetPointList();
|
var new_points_qe = new_qe.GetPointList();
|
var new_points_qp = new_qp.GetPointList();
|
|
graph_qh.GeometryInfo = new Yw.Pump.CurveQH(Yw.Ahart.eFeatType.Cubic, new_points_qh).ToDbString();
|
graph_qe.GeometryInfo = new Yw.Pump.CurveQE(Yw.Ahart.eFeatType.Cubic, new_points_qe).ToDbString();
|
graph_qp.GeometryInfo = new Yw.Pump.CurveQP(Yw.Ahart.eFeatType.Cubic, new_points_qp).ToDbString();
|
|
_xhs_phart_diagram_ex_std_dto.Diagram.GraphList = new List<Vmo.PhartGraphVmo>()
|
{
|
graph_qh,
|
graph_qe,
|
graph_qp,
|
};
|
var bol = await _bll.UpdateEx(_xhs_phart_diagram_ex_std_dto);
|
if (bol)
|
{
|
InitChart(_pump_main, _xhs_phart_diagram_ex_std_dto);
|
}
|
return bol;
|
};
|
dlg.ShowDialog();
|
}
|
|
//别名
|
private void barBtnOtherName_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_xhs_phart_diagram_ex_std_dto == null)
|
{
|
return;
|
}
|
var dlg = new SetOtherNameDlg();
|
dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.OtherName);
|
dlg.VerifyValueChanged += async (value) =>
|
{
|
_xhs_phart_diagram_ex_std_dto.OtherName = value;
|
var bol = await _bll.UpdateEx(_xhs_phart_diagram_ex_std_dto);
|
if (!bol)
|
{
|
XtraMessageBox.Show("更新失败!");
|
return false;
|
}
|
this.xhsPumpMainPhartListCtrl1.UpdateOtherName(_xhs_phart_diagram_ex_std_dto.ID, value);
|
XtraMessageBox.Show("更新成功!");
|
return true;
|
};
|
|
dlg.ShowDialog();
|
}
|
|
//重要度
|
private void barBtnUpdateimportance_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new SetImportanceDlg();
|
dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.Importance);
|
dlg.VerifyValueChanged += async (value) =>
|
{
|
_xhs_phart_diagram_ex_std_dto.Importance = value;
|
var bol = await _bll.UpdateEx(_xhs_phart_diagram_ex_std_dto);
|
if (!bol)
|
{
|
XtraMessageBox.Show("更新失败!");
|
return false;
|
}
|
this.xhsPumpMainPhartListCtrl1.UpdateImportance(_xhs_phart_diagram_ex_std_dto.ID, value);
|
XtraMessageBox.Show("更新成功!");
|
return true;
|
};
|
|
dlg.ShowDialog();
|
}
|
|
//变速
|
private void barBtnVariableSpeed_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_xhs_phart_diagram_ex_std_dto == null)
|
{
|
return;
|
}
|
|
if (_pump_main == null)
|
{
|
return;
|
}
|
|
var tuple = Get(_xhs_phart_diagram_ex_std_dto);
|
if (tuple == null)
|
{
|
return;
|
}
|
|
//var vm = new Yw.WinFrmUI.Phart.PumpVariableSpeedViewModel();
|
//vm.Id = _xhs_phart_diagram_ex_std_dto.ID.ToString();
|
//vm.Name = $"{_pump_main.RatedSpeed}";
|
//vm.RatedSpeed = _pump_main.RatedSpeed;
|
//vm.CurrentSpeed = _pump_main.RatedSpeed;
|
//vm.CurrentHz = 50;
|
//vm.Qh = tuple.Item1;
|
//vm.Qe = tuple.Item2;
|
//vm.Qp = tuple.Item3;
|
|
|
//var dlg = new PumpVariableSpeedChartDlg();
|
//dlg.SetBindingData(vm, null);
|
//dlg.ShowDialog();
|
|
|
//var vm = new Yw.WinFrmUI.Phart.PumpWorkViewModel();
|
//vm.Id = _xhs_phart_diagram_ex_std_dto.ID.ToString();
|
//vm.Name = $"{_pump_main.RatedSpeed}";
|
//vm.RatedSpeed = _pump_main.RatedSpeed;
|
//vm.CurrentSpeed = _pump_main.RatedSpeed/2;
|
//vm.CurrentHz = 50/2;
|
//vm.Qh = tuple.Item1;
|
//vm.Qe = tuple.Item2;
|
//vm.Qp = tuple.Item3;
|
//vm.WorkPoint = new Yw.Geometry.Point2d(15,16);
|
|
//var vm1 = new Yw.WinFrmUI.Phart.PumpWorkViewModel();
|
//vm1.Id = _xhs_phart_diagram_ex_std_dto.ID.ToString()+"1";
|
//vm1.Name = $"{_pump_main.RatedSpeed}";
|
//vm1.RatedSpeed = _pump_main.RatedSpeed;
|
//vm1.CurrentSpeed = _pump_main.RatedSpeed / 1.6;
|
//vm1.CurrentHz = 50 /1.6;
|
//vm1.Qh = tuple.Item1;
|
//vm1.Qe = tuple.Item2;
|
//vm1.Qp = tuple.Item3;
|
//vm1.WorkPoint = new Yw.Geometry.Point2d(12, 19);
|
|
//var dlg = new PumpWorkComparisonChartDlg();
|
//dlg.SetBindingData(new List<Yw.WinFrmUI.Phart.PumpWorkViewModel>() { vm,vm1});
|
//dlg.ShowDialog();
|
|
|
|
//var vm = new Yw.WinFrmUI.Phart.PumpWorkViewModel();
|
//vm.Id = _xhs_phart_diagram_ex_std_dto.ID.ToString();
|
//vm.Name = $"{_pump_main.RatedSpeed}";
|
//vm.RatedSpeed = _pump_main.RatedSpeed;
|
//vm.CurrentSpeed = _pump_main.RatedSpeed / 2;
|
//vm.CurrentHz = 50 / 2;
|
//vm.Qh = tuple.Item1;
|
//vm.Qe = tuple.Item2;
|
//vm.Qp = tuple.Item3;
|
//vm.RunStatus = true;
|
//vm.WorkPoint = new Yw.Geometry.Point2d(15, 16);
|
|
//var dlg = new PumpWorkChartDlg();
|
//dlg.SetBindingData(vm);
|
//dlg.ShowDialog();
|
}
|
|
//复制并延长
|
private void barBtnCopyAndExpand_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_xhs_phart_diagram_ex_std_dto == null)
|
{
|
return;
|
}
|
var diagram = _xhs_phart_diagram_ex_std_dto.Diagram;
|
if (diagram == null)
|
{
|
return;
|
}
|
var graph_list = diagram.GraphList;
|
if (graph_list == null || !graph_list.Any())
|
{
|
return;
|
}
|
|
var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QH);
|
var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QE);
|
var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QP);
|
|
if (graph_qh == null)
|
{
|
return;
|
}
|
Yw.Pump.CurveQH qh = null;
|
Yw.Pump.CurveQE qe = null;
|
Yw.Pump.CurveQP qp = null;
|
List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
|
points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
|
qh = new Yw.Pump.CurveQH(Yw.Ahart.eFeatType.Cubic, points_qh);
|
if (graph_qe != null)
|
{
|
points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
|
qe = new Yw.Pump.CurveQE(Yw.Ahart.eFeatType.Cubic, points_qe);
|
}
|
if (graph_qp != null)
|
{
|
points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
|
qp = new Yw.Pump.CurveQP(Yw.Ahart.eFeatType.Cubic, points_qp);
|
}
|
|
var dlg = new PumpCurveExpandDlg();
|
dlg.SetBindingData(qh, qe, qp);
|
dlg.ReloadDataEvent += async (new_qh, new_qe, new_qp) =>
|
{
|
var other_name = $"{_xhs_phart_diagram_ex_std_dto.OtherName}-复制延长";
|
var bol = await Import(other_name, new_qh, new_qe, new_qp);
|
return bol;
|
};
|
|
dlg.ShowDialog();
|
}
|
|
#region 删除
|
|
//删除
|
private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
await Delete();
|
}
|
|
//删除
|
private async Task<bool> Delete()
|
{
|
if (_xhs_phart_diagram_ex_std_dto == null)
|
{
|
return false;
|
}
|
var diagramId = _xhs_phart_diagram_ex_std_dto.Diagram.ID;
|
var bol = await _bll.DeleteByDiagramID(diagramId);
|
if (!bol)
|
{
|
XtraMessageBox.Show("删除失败!");
|
return false;
|
}
|
XtraMessageBox.Show("删除成功!");
|
ClearChart();
|
this.xhsPumpMainPhartListCtrl1.Delete(_xhs_phart_diagram_ex_std_dto.ID);
|
|
return true;
|
}
|
|
#endregion 删除
|
|
#endregion 操作
|
|
|
}
|
}
|