using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Windows.Forms;
|
|
|
//编辑原始的性能曲线
|
namespace AStation.WinFrmUI.Chart
|
{
|
public partial class ImportCurveByCurveExpressCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public ImportCurveByCurveExpressCtrl()
|
{
|
InitializeComponent();
|
|
this.imgCmbCurveSourceFrom.Properties.AddEnum(typeof(AStation.Chart.eSourceWay), false);
|
this.imgCmbCurveSourceFrom.EditValue = AStation.Chart.eSourceWay.SCADA数据分析;
|
|
this.imgCmbQHFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQHFitType.EditValue = _qhFitType;
|
|
this.imgCmbQEFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQEFitType.EditValue = _qeFitType;
|
|
this.imgCmbQPFitType.Properties.AddEnum(typeof(AStation.Curve.eFitType), false);
|
this.imgCmbQPFitType.EditValue = _qpFitType;
|
|
this.txtCurveCode.Text = "SCADA数据分析";
|
this.chartFeatCurveViewCtrl1.Enabled = false;
|
}
|
|
|
AStation.Curve.eFitType _qhFitType = AStation.Curve.eFitType.CubicCurve;
|
AStation.Curve.eFitType _qeFitType = AStation.Curve.eFitType.CubicCurve;
|
AStation.Curve.eFitType _qpFitType = AStation.Curve.eFitType.CubicCurve;
|
|
|
private AStation.Curve.CurveExpress QhCurve = null, QeCurve = null, QpCurve = null;
|
List<AStation.Curve.CurvePoint> QhPoints = null, QePoints = null, QpPoints = null;
|
|
private bool initial = false;
|
|
|
//选择文件
|
private void btnFilePath_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
{
|
var dlg = new System.Windows.Forms.OpenFileDialog();
|
dlg.Filter = "EXCEL 文件(*.express)|*.express";
|
dlg.CheckFileExists = true;
|
if (dlg.ShowDialog() != DialogResult.OK)
|
return;
|
initial = false;
|
this.btnFilePath.Text = dlg.FileName;
|
var json = File.ReadAllText(dlg.FileName);
|
var express = JsonHelper.Json2Object<Model.PumpCurveInfo>(json);
|
if (express == null || express.CurveQH == null)
|
{
|
this.QhCurve = null; this.QeCurve = null; this.QpCurve = null;
|
this.QhPoints = null; this.QePoints = null; this.QpPoints = null;
|
this.chartFeatCurveViewCtrl1.Enabled = false;
|
this.chartFeatCurveViewCtrl1.InitialChartData();
|
XtraMessageBox.Show("解析失败!");
|
}
|
else
|
{
|
this.QhPoints = null;
|
this.QePoints = null;
|
this.QpPoints = null;
|
|
if (express.CurveQH.DefinePoints != null)
|
this.QhPoints = express.CurveQH.DefinePoints;
|
else
|
this.QhPoints = express.CurveQH.GetFitPoints(12);
|
|
if (express.CurveQE != null)
|
{
|
if (express.CurveQE.DefinePoints != null)
|
this.QePoints = express.CurveQE.DefinePoints;
|
else
|
this.QePoints = express.CurveQE.GetFitPoints(12);
|
|
}
|
|
if (express.CurveQP != null)
|
{
|
if (express.CurveQP.DefinePoints != null)
|
this.QpPoints = express.CurveQP.DefinePoints;
|
else
|
this.QpPoints = express.CurveQP.GetFitPoints(12);
|
}
|
|
this.txtCurveCode.Text = Path.GetFileNameWithoutExtension(dlg.FileName);
|
this.imgCmbQHFitType.EditValue = express.CurveQH.FitType;
|
this.imgCmbQEFitType.EditValue = express.CurveQE.FitType;
|
this.imgCmbQPFitType.EditValue = express.CurveQP.FitType;
|
initial = true;
|
loadCurve();
|
}
|
}
|
|
|
private void imgCmbQHFitType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
loadCurve();
|
}
|
|
private void imgCmbQEFitType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
loadCurve();
|
}
|
|
private void imgCmbQPFitType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
loadCurve();
|
}
|
|
|
//加载曲线
|
private bool loadCurve()
|
{
|
if (!initial)
|
return false;
|
if (QhPoints == null)
|
{
|
this.chartFeatCurveViewCtrl1.Enabled = false;
|
this.chartFeatCurveViewCtrl1.InitialChartData();
|
return false;
|
}
|
|
this.chartFeatCurveViewCtrl1.Enabled = true;
|
_qhFitType = (AStation.Curve.eFitType)this.imgCmbQHFitType.EditValue;
|
_qeFitType = (AStation.Curve.eFitType)this.imgCmbQEFitType.EditValue;
|
_qpFitType = (AStation.Curve.eFitType)this.imgCmbQPFitType.EditValue;
|
|
|
|
QhCurve = AStation.Curve.FitHelper.BuildCurveExpress(QhPoints, _qhFitType);
|
QeCurve = AStation.Curve.FitHelper.BuildCurveExpress(QePoints, _qeFitType);
|
QpCurve = AStation.Curve.FitHelper.BuildCurveExpress(QpPoints, _qpFitType);
|
|
this.chartFeatCurveViewCtrl1.SetBindingData(QhCurve, QeCurve, QpCurve);
|
|
return true;
|
}
|
|
|
public bool GetCurve(out string curveCode, out AStation.Chart.eSourceWay eCurveSourceFrom, out Model.PumpCurveInfo featCurveExpressGroup)
|
{
|
curveCode = "";
|
eCurveSourceFrom = AStation.Chart.eSourceWay.SCADA数据分析;
|
featCurveExpressGroup = null;
|
if (!loadCurve())
|
return false;
|
curveCode = this.txtCurveCode.Text.Trim();
|
if (string.IsNullOrEmpty(curveCode))
|
{
|
XtraMessageBox.Show("请输入曲线名称!");
|
return false;
|
}
|
eCurveSourceFrom = (AStation.Chart.eSourceWay)this.imgCmbCurveSourceFrom.EditValue;
|
featCurveExpressGroup = new Model.PumpCurveInfo(QhCurve, QeCurve, QpCurve);
|
return true;
|
}
|
}
|
}
|