using DevExpress.XtraCharts;
|
using IStation.Epanet;
|
using IStation.Epanet.Enums;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel.DataAnnotations;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
public partial class ModelCorrectionPage : DocumentPage
|
{
|
public ModelCorrectionPage()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "模型修正";
|
|
this.gridView1.SetNormalView();
|
this.gridView2.SetNormalView();
|
|
|
|
this.repositoryItemDateEdit1.SetOnlyShowYearMonth();
|
this.repositoryItemDateEdit2.SetOnlyShowYearMonth();
|
this.barEditDateStart.EditValue = new DateTime(2024, 9, 1);
|
this.barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
|
|
this.cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
|
|
this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
|
this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
|
|
InitialDiagarm();
|
}
|
|
|
private SwiftPlotDiagram _diagram;//图表
|
private Series _series_default_head; //
|
private Series _series_curve_head; //
|
private Series _series_correct_curve_head; //
|
private void InitialDiagarm()
|
{
|
this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;//是否在图表上显示图例
|
|
_diagram = (SwiftPlotDiagram)this.chartControl1.Diagram;
|
_diagram.EnableAxisXScrolling = true;//X轴是否允许滚动
|
_diagram.EnableAxisXZooming = true;//X轴是否允许缩放
|
_diagram.PaneLayout.Direction = PaneLayoutDirection.Vertical;//窗格的对齐方式
|
|
_diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Minute;
|
|
|
_series_default_head = chartControl1.GetSeriesByName("SeriesDefaultHead");
|
_series_curve_head = chartControl1.GetSeriesByName("SeriesCurveHead");
|
_series_correct_curve_head = chartControl1.GetSeriesByName("SeriesCorrectCurveHead");
|
|
_series_default_head.CrosshairLabelPattern = "监测扬程:{V}";
|
_series_curve_head.CrosshairLabelPattern = "模型扬程:{V}";
|
_series_correct_curve_head.CrosshairLabelPattern = "扬程偏差:{V}";
|
|
//定制窗格的滚动条的外观
|
ScrollBarOptions scrollBarOptions = _diagram.DefaultPane.ScrollBarOptions;
|
scrollBarOptions.BackColor = Color.White;
|
scrollBarOptions.BarColor = Color.LightSlateGray;
|
scrollBarOptions.BorderColor = Color.DarkGray;
|
scrollBarOptions.BarThickness = 15;
|
scrollBarOptions.XAxisScrollBarAlignment = ScrollBarAlignment.Far;
|
scrollBarOptions.XAxisScrollBarVisible = true;
|
|
}
|
|
|
#region ViewModel
|
|
public class PumpFactorViewModel
|
{
|
[Display(Name = "泵")]
|
public int Flag { get; set; }
|
|
[Display(Name = "频率")]
|
public double Hz { get; set; }
|
|
[Display(Name = "总体标准差")]
|
public double STDP { get; set; }
|
|
[Display(Name = "扬程(STDP)")]
|
public double STDPHead { get; set; }
|
|
[Display(Name = "备注")]
|
public string Note { get; set; }
|
|
public void Round()
|
{
|
this.STDP = Math.Round(this.STDP, 5);
|
this.STDPHead = Math.Round(this.STDPHead, 5);
|
}
|
|
}
|
|
public class ModelDiffViewModel
|
{
|
[Display(Name = "时间")]
|
public string Time { get; set; }
|
|
[Display(Name = "监测标识")]
|
public string MonitorID { get; set; }
|
|
[Display(Name = "模型标识")]
|
public string ModelID { get; set; }
|
|
[Display(Name = "类型")]
|
public string Type { get; set; }
|
|
[Display(Name = "模型值")]
|
public double ModelValue { get; set; }
|
|
[Display(Name = "监测值")]
|
public double MonitorValue { get; set; }
|
|
[Display(Name = "偏差值")]
|
public double DiffVlaue { get; set; }
|
|
[Display(Name = "泵")]
|
public bool IsPump { get; set; }
|
|
[Display(Name = "泵")]
|
public int?Flag { get; set; }
|
|
[Display(Name = "频率")]
|
public double? Hz { get; set; }
|
public double? HzRound { get; set; }
|
|
}
|
|
#endregion
|
|
private BLL.StationSignalRecordPacket _bll = new BLL.StationSignalRecordPacket();
|
private Model.Station _station = null;
|
private Model.MonitorDataSources _monitorDataSources = null;
|
|
private List<ModelDiffViewModel> _model_diff_vm_list = null;
|
|
private string _model_file = System.IO.Path.Combine
|
(Settings.File.RootDirectory, Settings.File.DataFolder, "ch2_v3_20240801(Clear).inp");
|
|
/// <summary>
|
/// 清空数据
|
/// </summary>
|
public void Clear()
|
{
|
_model_diff_vm_list=new List<ModelDiffViewModel>();
|
this.cmbFlag.SelectedItem = null;
|
this.cmbFlag.Properties.Items.Clear();
|
this.modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>();
|
this.pumpFactorViewModelBindingSource.DataSource = new List<PumpFactorViewModel>();
|
|
|
ClearChart();
|
}
|
|
private void ClearChart()
|
{
|
|
this.chartControl1.BeginInit();
|
_series_default_head.Points.Clear();
|
_series_curve_head.Points.Clear();
|
_series_correct_curve_head.Points.Clear();
|
this.chartControl1.EndInit();
|
}
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
this.stationListCtrl1.SetBindingData();
|
this.monitorDataSourcesTreeList1.SetBindingData();
|
}
|
|
//泵站变换
|
private void StationListCtrl1_FocusedChangedEvent(Model.Station obj)
|
{
|
_station = obj;
|
WaitFrmHelper.ShowWaitForm();
|
SetBindingData(_monitorDataSources, _station);
|
WaitFrmHelper.HideWaitForm();
|
|
}
|
|
//来源变换
|
private void MonitorDataSourcesListCtrl1_FocusedChangedEvent(Model.MonitorDataSources obj)
|
{
|
_monitorDataSources = obj;
|
WaitFrmHelper.ShowWaitForm();
|
SetBindingData(_monitorDataSources, _station);
|
WaitFrmHelper.HideWaitForm();
|
}
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Model.MonitorDataSources monitorDataSources, Model.Station station)
|
{
|
Clear();
|
if (monitorDataSources == null || station == null)
|
{
|
return;
|
}
|
if (this.barCekLoad.Checked)
|
{
|
return;
|
}
|
|
var pumps = new BLL.Equipment().GetPumpListByBelongTypeAndBelongID(IStation.ObjectType.Station, station.ID);
|
if (pumps == null || !pumps.Any())
|
{
|
return;
|
}
|
|
var flag_pump_dict = pumps.ToDictionary(x => x.SortCode, x => x.RatedParas);
|
var flag_curve_dict = new Dictionary<int, Model.CurveExpress>();
|
var bll_curve = new BLL.PumpCurve();
|
foreach (var pump in pumps)
|
{
|
Model.CurveExpress qh = null;
|
var curve_info = bll_curve.GetDefaultWorkingByPumpID(pump.ID)?.CurveInfo;
|
if (curve_info != null)
|
{
|
qh = curve_info.CurveQH;
|
}
|
flag_curve_dict.Add(pump.SortCode, qh);
|
}
|
if (flag_curve_dict == null || !flag_curve_dict.Any())
|
{
|
return;
|
}
|
|
var flag_list = pumps.Select(x => x.SortCode).OrderBy(x => x).ToList();
|
this.cmbFlag.Properties.Items.AddRange(flag_list);
|
|
|
var station_index = station.SortCode;
|
var dt_start = Convert.ToDateTime(this.barEditDateStart.EditValue);
|
var dt_end = Convert.ToDateTime(this.barEditDateEnd.EditValue);
|
var list = Get(monitorDataSources.ID, station.ID, station.SortCode, dt_start, dt_end, 300);
|
if (list == null || !list.Any())
|
{
|
return;
|
}
|
|
|
var pressure_id_mapping_dict = GetPumpPressureIdMappingDict(station_index);
|
var flow_id_mapping_dict = GetPumpFlowIdMappingDict(station_index);
|
var pump_id_mapping_dict = GetPumpIdMappingDict(station_index);
|
|
|
var err = EpanetMethods.ENopen(_model_file, "", "");
|
if (err != ErrorCode.Ok)
|
{
|
return;
|
}
|
|
err = EpanetMethods.ENopenH();
|
if (err != ErrorCode.Ok)
|
{
|
return;
|
}
|
|
var multi_tag_head_diff_list = new List<Tuple<string, double>>();
|
var vm_list = new List<ModelDiffViewModel>();
|
var model_id_build = new StringBuilder(31);
|
foreach (var tuple in list)
|
{
|
var time = tuple.Item1.ToString("G");
|
var pattern_dict = tuple.Item2;
|
var scada_dict = tuple.Item3;
|
var pump_dict = tuple.Item4;
|
var pattern_init = true;
|
|
foreach (var pattern in pattern_dict)
|
{
|
var pattern_id = pattern.Key;
|
var pattern_factor_array = pattern.Value;
|
var pattern_factor_array_count = pattern_factor_array.Length == 0 ? 1 : pattern_factor_array.Length;
|
err = EpanetMethods.ENgetpatternindex(pattern_id, out int pattern_index);
|
if (err != ErrorCode.Ok)
|
{
|
pattern_init = false;
|
continue;
|
}
|
err = EpanetMethods.ENsetpattern(pattern_index, pattern_factor_array, pattern_factor_array_count);
|
if (err != ErrorCode.Ok)
|
{
|
pattern_init = false;
|
continue;
|
}
|
}
|
if (!pattern_init)
|
continue;
|
|
|
EpanetMethods.ENinitH(0);
|
EpanetMethods.ENrunH(out _);
|
EpanetMethods.ENgetcount(CountType.Node, out int node_count);
|
EpanetMethods.ENgetcount(CountType.Link, out int link_count);
|
|
for (int node_index = 1; node_index <= node_count; node_index++)
|
{
|
if (EpanetMethods.ENgetnodeid(node_index, model_id_build) != ErrorCode.Ok)
|
continue;
|
var model_id = model_id_build.ToString();
|
if (pressure_id_mapping_dict.ContainsKey(model_id))
|
{
|
var scada_id = pressure_id_mapping_dict[model_id];
|
|
double? hz = null, hzr = null;
|
int? flag = null;
|
if (pump_dict.ContainsKey(scada_id))
|
{
|
if (!(pump_dict[scada_id] > 0))
|
{
|
continue;
|
}
|
hz = pump_dict[scada_id] * 50;
|
hz = Math.Round(hz.Value, 2);
|
hzr = Math.Round(hz.Value);
|
flag = pump_id_mapping_dict[model_id];
|
}
|
EpanetMethods.ENgetnodevalue(node_index, NodeValue.Head, out float model_head);
|
var scada_value = scada_dict[scada_id];
|
var vm = new ModelDiffViewModel();
|
vm.Time = time;
|
vm.MonitorID = scada_id;
|
vm.ModelID = model_id;
|
vm.ModelValue = model_head;
|
vm.MonitorValue = scada_value;
|
vm.DiffVlaue = model_head - scada_value;
|
vm.Type = "压力";
|
vm.Hz = hz;
|
vm.HzRound = hzr;
|
vm.Flag = flag;
|
if (Math.Round(vm.DiffVlaue) > 100)
|
{
|
continue;
|
}
|
vm_list.Add(vm);
|
}
|
}
|
|
for (int link_index = 1; link_index <= link_count; link_index++)
|
{
|
if (EpanetMethods.ENgetlinkid(link_index, model_id_build) != ErrorCode.Ok)
|
continue;
|
var model_id = model_id_build.ToString();
|
|
if (flow_id_mapping_dict.ContainsKey(model_id))
|
{
|
var scada_id = flow_id_mapping_dict[model_id];
|
double? hz = null, hzr = null;
|
int? flag = null;
|
if (pump_dict.ContainsKey(scada_id))
|
{
|
if (!(pump_dict[scada_id] > 0))
|
{
|
continue;
|
}
|
hz = pump_dict[scada_id] * 50;
|
hz = Math.Round(hz.Value, 2);
|
hzr = Math.Round(hz.Value);
|
flag = pump_id_mapping_dict[model_id];
|
}
|
EpanetMethods.ENgetlinkvalue(link_index, LinkValue.Flow, out float model_value);
|
model_value = Math.Abs(model_value);
|
var scada_value = scada_dict[scada_id];
|
var vm = new ModelDiffViewModel();
|
vm.Time = time;
|
vm.MonitorID = scada_id;
|
vm.ModelID = model_id;
|
vm.ModelValue = model_value;
|
vm.MonitorValue = scada_value;
|
vm.DiffVlaue = model_value - scada_value;
|
vm.Type = "流量";
|
vm.Hz = hz;
|
vm.HzRound = hzr;
|
vm.Flag = flag;
|
vm_list.Add(vm);
|
}
|
|
EpanetMethods.ENgetlinktype(link_index, out LinkType linkType);
|
if (linkType == LinkType.Pump)
|
{
|
EpanetMethods.ENgetlinkvalue(link_index, LinkValue.InitStatus, out float on_off);
|
}
|
}
|
}
|
EpanetMethods.ENcloseH();
|
EpanetMethods.ENclose();
|
|
var vm_pump_facotr_list = new List<PumpFactorViewModel>();
|
var group_by_flag = vm_list.Where(x => x.Type == "压力" && x.Flag.HasValue).GroupBy(x => new { x.Flag, x.HzRound });
|
foreach (var flag_item in group_by_flag)
|
{
|
var flag = flag_item.Key.Flag.Value;
|
var pump = flag_pump_dict[flag];
|
var qh = flag_curve_dict[flag];
|
var hz = flag_item.Key.HzRound.Value;
|
|
if (hz < 20)
|
{
|
continue;
|
}
|
|
var head_diff_list = flag_item.Select(x => x.DiffVlaue).ToList();
|
double head_diff_avg = 0d, std_dev_pop = 0d, std_dev_pop_head_avg = 0d;
|
|
var filter_std_dev_pop_tuple = FilterBySTDP(head_diff_list.ToArray(), 0.3, 0);
|
var filter_std_dev_pop_array = filter_std_dev_pop_tuple.Item1;
|
std_dev_pop = filter_std_dev_pop_tuple.Item2;
|
|
std_dev_pop_head_avg = filter_std_dev_pop_array.Average();
|
|
head_diff_avg = std_dev_pop_head_avg;
|
if (Math.Abs(head_diff_avg) > 5)
|
{
|
continue;
|
}
|
|
if (std_dev_pop > 1 && flag_item.Count() < 5)
|
{
|
continue;
|
}
|
|
var vm_pump_facotr = new PumpFactorViewModel();
|
vm_pump_facotr.Flag = flag;
|
vm_pump_facotr.Hz = hz;
|
vm_pump_facotr.STDP = std_dev_pop;
|
vm_pump_facotr.STDPHead = std_dev_pop_head_avg;
|
vm_pump_facotr.Note = $"{flag_item.Count()}-{filter_std_dev_pop_array.Count()}={flag_item.Count() - filter_std_dev_pop_array.Count()}";
|
vm_pump_facotr.Round();
|
vm_pump_facotr_list.Add(vm_pump_facotr);
|
}
|
|
|
_model_diff_vm_list = vm_list;
|
this.modelTimeViewModelBindingSource.DataSource = vm_list;
|
this.modelTimeViewModelBindingSource.ResetBindings(false);
|
this.gridView1.BestFitColumns();
|
|
|
this.pumpFactorViewModelBindingSource.DataSource = vm_pump_facotr_list;
|
this.pumpFactorViewModelBindingSource.ResetBindings(false);
|
this.gridView2.BestFitColumns();
|
|
|
AlertTool.ShowInfo(System.Windows.Forms.Application.OpenForms[0], "提示", "分析完成!");
|
}
|
|
|
public List<Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>>> Get(long monitorDataSourcesId, long stationId, int station_index,DateTime dt_start, DateTime dt_end, int timeStep = 300)
|
{
|
|
var bllSummary = new BLL.MonitorDataSetSummary();
|
var yearMonths = bllSummary.GetYearMonth(monitorDataSourcesId);
|
yearMonths= yearMonths?.Where(x => (x.Year >= dt_start.Year && x.Year <= dt_end.Year) && (x.Month >= dt_start.Month && x.Month <= dt_end.Month)).ToList();
|
if (yearMonths==null|| !yearMonths.Any())
|
{
|
return default;
|
}
|
|
var bllEquipment = new BLL.Equipment();
|
var enginePumps = bllEquipment.GetEnginePumpListByBelongTypeAndBelongID(IStation.ObjectType.Station, stationId);
|
if (enginePumps == null || !enginePumps.Any())
|
return default;
|
|
var bllMonitorPoint = new BLL.MonitorPoint();
|
var bllEquipmentMonitorMapping = new BLL.EquipmentMonitorMapping();
|
var bllMonitorDataSet = new BLL.MonitorDataSet();
|
|
|
var pumpParasDict = new Dictionary<int, Model.Pump>();
|
var pumpMonitorPointDict = new Dictionary<int, List<Model.MonitorPointExSignalWithSignalType>>();
|
var stationMonitorPointList = new List<Model.MonitorPointExSignalWithSignalType>();
|
var signalIds = new List<long>();
|
foreach (var enginePump in enginePumps)
|
{
|
var pump = bllEquipment.GetChildPumpByEnginePumpID(enginePump.ID);
|
if (pump == null)
|
continue;
|
var equipmentMonitorMappings = bllEquipmentMonitorMapping.GetByEquipmentID(enginePump.ID);
|
if (equipmentMonitorMappings == null || !equipmentMonitorMappings.Any())
|
continue;
|
var monitorPointIds = equipmentMonitorMappings.Select(x => x.MonitorPointID).ToList();
|
var monitorPoints = bllMonitorPoint.GetExSignalWithSignalTypeByIds(monitorPointIds);
|
monitorPoints = monitorPoints?.Where(x => !string.IsNullOrEmpty(x.TagName)).ToList();
|
monitorPoints = monitorPoints?.Where(x => x.SignalType != IStation.SignalType.频率).ToList();
|
monitorPoints = monitorPoints?.Where(x => x.Flags != null && !x.Flags.Contains(Flags.总站)).ToList();
|
if (monitorPoints == null || !monitorPoints.Any())
|
continue;
|
pumpParasDict.Add(enginePump.SortCode, pump.RatedParas);
|
pumpMonitorPointDict.Add(enginePump.SortCode, monitorPoints);
|
signalIds.AddRange(monitorPoints.Select(x => x.SignalID));
|
}
|
|
var monitorPoints_station = bllMonitorPoint.GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.ObjectType.Station, stationId);
|
monitorPoints_station = monitorPoints_station?.Where(x => !string.IsNullOrEmpty(x.TagName)).ToList();
|
stationMonitorPointList = monitorPoints_station?
|
.Where(x => x.Flags != null && x.Flags.Contains(IStation.Flags.总站)).ToList();
|
if (stationMonitorPointList != null && stationMonitorPointList.Any())
|
{
|
signalIds.AddRange(stationMonitorPointList.Select(x => x.SignalID));
|
}
|
|
signalIds = signalIds.Distinct().ToList();
|
|
|
var pressure_monitor_points = monitorPoints_station.Where(x => x.SignalType == IStation.SignalType.压力).ToList();
|
var flow_monitor_points = monitorPoints_station.Where(x => x.SignalType == IStation.SignalType.瞬时流量).ToList();
|
|
var list = new List<Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>>>();
|
foreach (var yearMonth in yearMonths)
|
{
|
var year = yearMonth.Year;
|
var month = yearMonth.Month;
|
|
var summaries = bllSummary.GetAllByDate(monitorDataSourcesId, year, month);
|
if (summaries == null || !summaries.Any())
|
return default;
|
|
var minTime = summaries.Min(x => x.MinTime);
|
var maxTime = summaries.Max(x => x.MaxTime);
|
var totalSeconds = (int)(maxTime - minTime).TotalSeconds;
|
|
var startDay = minTime;//.AddDays(1);
|
var days = (maxTime - minTime).Days;
|
var capacity = _bll.CalcuCapacity(days, timeStep);// 每个月的数据量
|
|
|
var findIndexDict = new Dictionary<long, int>();// 查找数据下标
|
var recordDict = new Dictionary<long, double>();// 数据字典
|
signalIds.ForEach(x =>
|
{
|
findIndexDict.Add(x, 0);
|
recordDict.Add(x, IStation.Error.Default);
|
});
|
|
var signalRecordPackets = bllMonitorDataSet.GetSignalRecordPacket(monitorDataSourcesId, signalIds, year, month);
|
if (signalRecordPackets == null || !signalRecordPackets.Any())
|
return default;
|
|
//按天整理数据
|
for (int i = 0; i <= days; i++)
|
{
|
var day = startDay.AddDays(i);
|
|
//分割步长
|
for (int seconds = 0; seconds < _bll.TotalSecondsOfDay; seconds += timeStep) //00点的数据不要
|
{
|
var realTime = day.AddSeconds(seconds);
|
_bll.GetRecordDict(realTime, signalRecordPackets, findIndexDict, recordDict, timeStep, out bool existRecord);
|
if (!existRecord)
|
continue;
|
|
var timeValue = new ExportEpanetHelper.TimeValue
|
{
|
Time = realTime,
|
Value = new Dictionary<string, double>()
|
};
|
|
if (stationMonitorPointList != null && stationMonitorPointList.Any())
|
{
|
foreach (var stationMonitorPoint in stationMonitorPointList)
|
{
|
var time = realTime;
|
var value = recordDict[stationMonitorPoint.SignalID];
|
if (stationMonitorPoint.SignalType == IStation.SignalType.压力)
|
{
|
value = Model.CurveCalcuHelper.Mpa2M(value);
|
}
|
else if (stationMonitorPoint.SignalType == IStation.SignalType.瞬时流量)
|
{
|
value = value < 0 ? 0 : value;
|
}
|
timeValue.Value.Add(stationMonitorPoint.TagName, value);
|
}
|
}
|
|
foreach (var pumpMonitorPointItem in pumpMonitorPointDict)
|
{
|
var key = pumpMonitorPointItem.Key;
|
var pumpParas = pumpParasDict[key];
|
var pumpMonitorPointList = pumpMonitorPointItem.Value;
|
foreach (var pumpMonitorPoint in pumpMonitorPointList)
|
{
|
var time = realTime;
|
var value = recordDict[pumpMonitorPoint.SignalID];
|
if (pumpMonitorPoint.SignalType == IStation.SignalType.转速)
|
{
|
value = value / pumpParas.Nr;
|
value = value < 0 ? 0 : value;
|
value = value > 1 ? 1 : value;
|
}
|
else if (pumpMonitorPoint.SignalType == IStation.SignalType.频率)
|
{
|
value = value / 50;
|
value = value < 0 ? 0 : value;
|
value = value > 1 ? 1 : value;
|
}
|
else if (pumpMonitorPoint.SignalType == IStation.SignalType.压力)
|
{
|
value = Model.CurveCalcuHelper.Mpa2M(value);
|
}
|
else if (pumpMonitorPoint.SignalType == IStation.SignalType.瞬时流量)
|
{
|
value = value < 0 ? 0 : value;
|
}
|
timeValue.Value.Add(pumpMonitorPoint.TagName, value);
|
}
|
}
|
|
if (station_index == 1)
|
{
|
list.Add(GetStation1(realTime, timeValue.Value));
|
}
|
else
|
{
|
list.Add(GetStation2(realTime, timeValue.Value));
|
}
|
|
}
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
private Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>> GetStation1(DateTime dateTime, Dictionary<string, double> time_dict)
|
{
|
var pattern_dict = new Dictionary<string, float[]>();
|
var scada_dict = new Dictionary<string, double>();
|
var pump_dict = new Dictionary<string, double>();
|
var limited_speed_ratio = 0.1;
|
|
var Pump11 = time_dict["Pump11"];
|
var Pump12 = time_dict["Pump12"];
|
var Pump13 = time_dict["Pump13"];
|
var Pump14 = time_dict["Pump14"];
|
var Pump15 = time_dict["Pump15"];
|
var Pump16 = time_dict["Pump16"];
|
var Pump17 = time_dict["Pump17"];
|
var Pump18 = time_dict["Pump18"];
|
|
Pump11 = Pump11 < limited_speed_ratio ? 0 : Pump11;
|
Pump12 = Pump12 < limited_speed_ratio ? 0 : Pump12;
|
Pump13 = Pump13 < limited_speed_ratio ? 0 : Pump13;
|
Pump14 = Pump14 < limited_speed_ratio ? 0 : Pump14;
|
Pump15 = Pump15 < limited_speed_ratio ? 0 : Pump15;
|
Pump16 = Pump16 < limited_speed_ratio ? 0 : Pump16;
|
Pump17 = Pump17 < limited_speed_ratio ? 0 : Pump17;
|
Pump18 = Pump18 < limited_speed_ratio ? 0 : Pump18;
|
|
|
pattern_dict.Add("R1", new float[] { (float)time_dict["R1"] });
|
pattern_dict.Add("R2", new float[] { (float)time_dict["R2"] });
|
pattern_dict.Add("R3", new float[] { (float)time_dict["R3"] });
|
pattern_dict.Add("SFJD1", new float[] { (float)time_dict["SFJD1"] });
|
pattern_dict.Add("SFJD2", new float[] { (float)time_dict["SFJD2"] });
|
pattern_dict.Add("SFJD3", new float[] { (float)time_dict["SFJD3"] });
|
pattern_dict.Add("Pump11", new float[] { (float)Pump11 });
|
pattern_dict.Add("Pump12", new float[] { (float)Pump12 });
|
pattern_dict.Add("Pump13", new float[] { (float)Pump13 });
|
pattern_dict.Add("Pump14", new float[] { (float)Pump14 });
|
pattern_dict.Add("Pump15", new float[] { (float)Pump15 });
|
pattern_dict.Add("Pump16", new float[] { (float)Pump16 });
|
pattern_dict.Add("Pump17", new float[] { (float)Pump17 });
|
pattern_dict.Add("Pump18", new float[] { (float)Pump18 });
|
|
scada_dict.Add("SPJD1", time_dict["SPJD1"]);
|
scada_dict.Add("SPJD2", time_dict["SPJD2"]);
|
scada_dict.Add("SPJD3", time_dict["SPJD3"]);
|
scada_dict.Add("SFJD1", time_dict["SFJD1"]);
|
scada_dict.Add("SFJD2", time_dict["SFJD2"]);
|
scada_dict.Add("SFJD3", time_dict["SFJD3"]);
|
scada_dict.Add("SPPump11", time_dict["SPPump11"]);
|
scada_dict.Add("SPPump12", time_dict["SPPump12"]);
|
scada_dict.Add("SPPump13", time_dict["SPPump13"]);
|
scada_dict.Add("SPPump14", time_dict["SPPump14"]);
|
scada_dict.Add("SPPump15", time_dict["SPPump15"]);
|
scada_dict.Add("SPPump16", time_dict["SPPump16"]);
|
scada_dict.Add("SPPump17", time_dict["SPPump17"]);
|
scada_dict.Add("SPPump18", time_dict["SPPump18"]);
|
|
pump_dict.Add("SPPump11", Pump11);
|
pump_dict.Add("SPPump12", Pump12);
|
pump_dict.Add("SPPump13", Pump13);
|
pump_dict.Add("SPPump14", Pump14);
|
pump_dict.Add("SPPump15", Pump15);
|
pump_dict.Add("SPPump16", Pump16);
|
pump_dict.Add("SPPump17", Pump17);
|
pump_dict.Add("SPPump18", Pump18);
|
|
|
return new Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>>(dateTime, pattern_dict, scada_dict, pump_dict);
|
}
|
|
private Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>> GetStation2(DateTime dateTime, Dictionary<string, double> time_dict)
|
{
|
var pattern_dict = new Dictionary<string, float[]>();
|
var scada_dict = new Dictionary<string, double>();
|
var pump_dict = new Dictionary<string, double>();
|
var limited_speed_ratio = 0.1;
|
|
|
var Pump21 = time_dict["Pump21"];
|
var Pump22 = time_dict["Pump22"];
|
var Pump23 = time_dict["Pump23"];
|
var Pump24 = time_dict["Pump24"];
|
var Pump25 = time_dict["Pump25"];
|
var Pump26 = time_dict["Pump26"];
|
var Pump27 = time_dict["Pump27"];
|
|
|
Pump21 = Pump21 < limited_speed_ratio ? 0 :Pump21;
|
Pump22 = Pump22 < limited_speed_ratio ? 0 :Pump22;
|
Pump23 = Pump23 < limited_speed_ratio ? 0 :Pump23;
|
Pump24 = Pump24 < limited_speed_ratio ? 0 :Pump24;
|
Pump25 = Pump25 < limited_speed_ratio ? 0 :Pump25;
|
Pump26 = Pump26 < limited_speed_ratio ? 0 :Pump26;
|
Pump27 = Pump27 < limited_speed_ratio ? 0 :Pump27;
|
|
|
pattern_dict.Add("RPump21", new float[] { (float)time_dict["RPump21"] });
|
pattern_dict.Add("RPump22", new float[] { (float)time_dict["RPump22"] });
|
pattern_dict.Add("RPump23", new float[] { (float)time_dict["RPump23"] });
|
pattern_dict.Add("RPump24", new float[] { (float)time_dict["RPump24"] });
|
pattern_dict.Add("RPump25", new float[] { (float)time_dict["RPump25"] });
|
pattern_dict.Add("RPump26", new float[] { (float)time_dict["RPump26"] });
|
pattern_dict.Add("RPump27", new float[] { (float)time_dict["RPump27"] });
|
|
|
pattern_dict.Add("SFDN2400", new float[] { (float)time_dict["SFDN2400"] });
|
pattern_dict.Add("SFDN2700", new float[] { (float)time_dict["SFDN2700"] });
|
pattern_dict.Add("SFPump21", new float[] { (float)time_dict["SFPump21"] });
|
pattern_dict.Add("SFPump22", new float[] { (float)time_dict["SFPump22"] });
|
pattern_dict.Add("SFPump23", new float[] { (float)time_dict["SFPump23"] });
|
pattern_dict.Add("SFPump24", new float[] { (float)time_dict["SFPump24"] });
|
pattern_dict.Add("SFPump25", new float[] { (float)time_dict["SFPump25"] });
|
pattern_dict.Add("SFPump26", new float[] { (float)time_dict["SFPump26"] });
|
pattern_dict.Add("SFPump27", new float[] { (float)time_dict["SFPump27"] });
|
|
|
pattern_dict.Add("Pump21", new float[] { (float)Pump21 });
|
pattern_dict.Add("Pump22", new float[] { (float)Pump22 });
|
pattern_dict.Add("Pump23", new float[] { (float)Pump23 });
|
pattern_dict.Add("Pump24", new float[] { (float)Pump24 });
|
pattern_dict.Add("Pump25", new float[] { (float)Pump25 });
|
pattern_dict.Add("Pump26", new float[] { (float)Pump26 });
|
pattern_dict.Add("Pump27", new float[] { (float)(double)time_dict["Pump27"] });
|
|
|
|
scada_dict.Add("SPDN2400", time_dict["SPDN2400"]);
|
scada_dict.Add("SPDN2700", time_dict["SPDN2700"]);
|
scada_dict.Add("SPPump21", time_dict["SPPump21"]);
|
scada_dict.Add("SPPump22", time_dict["SPPump22"]);
|
scada_dict.Add("SPPump23", time_dict["SPPump23"]);
|
scada_dict.Add("SPPump24", time_dict["SPPump24"]);
|
scada_dict.Add("SPPump25", time_dict["SPPump25"]);
|
scada_dict.Add("SPPump26", time_dict["SPPump26"]);
|
scada_dict.Add("SPPump27", time_dict["SPPump27"]);
|
|
scada_dict.Add("SFDN2400", time_dict["SFDN2400"]);
|
scada_dict.Add("SFDN2700", time_dict["SFDN2700"]);
|
//scada_dict.Add("SFPump21", time_dict["SFPump21"]);
|
//scada_dict.Add("SFPump22", time_dict["SFPump22"]);
|
//scada_dict.Add("SFPump23", time_dict["SFPump23"]);
|
//scada_dict.Add("SFPump24", time_dict["SFPump24"]);
|
//scada_dict.Add("SFPump25", time_dict["SFPump25"]);
|
//scada_dict.Add("SFPump26", time_dict["SFPump26"]);
|
//scada_dict.Add("SFPump27", time_dict["SFPump27"]);
|
|
|
pump_dict.Add("SPPump21", Pump21);
|
pump_dict.Add("SPPump22", Pump22);
|
pump_dict.Add("SPPump23", Pump23);
|
pump_dict.Add("SPPump24", Pump24);
|
pump_dict.Add("SPPump25", Pump25);
|
pump_dict.Add("SPPump26", Pump26);
|
pump_dict.Add("SPPump27", Pump27);
|
|
|
pump_dict.Add("SFPump21", Pump21);
|
pump_dict.Add("SFPump22", Pump22);
|
pump_dict.Add("SFPump23", Pump23);
|
pump_dict.Add("SFPump24", Pump24);
|
pump_dict.Add("SFPump25", Pump25);
|
pump_dict.Add("SFPump26", Pump26);
|
pump_dict.Add("SFPump27", Pump27 );
|
|
return new Tuple<DateTime, Dictionary<string, float[]>, Dictionary<string, double>, Dictionary<string, double>>(dateTime, pattern_dict, scada_dict, pump_dict);
|
}
|
|
private Dictionary<string, string> GetPumpPressureIdMappingDict(int station_index)
|
{
|
var dict = new Dictionary<string, string>();
|
if (station_index == 1)
|
{
|
dict = new Dictionary<string, string>()
|
{
|
{ "Jjd1", "SPJD1"},
|
{ "Jjd2", "SPJD2"},
|
{ "Jjd3", "SPJD3"},
|
{"Jpump11","SPPump11"},
|
{"Jpump12","SPPump12"},
|
{"Jpump13","SPPump13"},
|
{"Jpump14","SPPump14"},
|
{"Jpump15","SPPump15"},
|
{"Jpump16","SPPump16"},
|
{"Jpump17","SPPump17"},
|
{"Jpump18","SPPump18"},
|
};
|
|
}
|
else
|
{
|
dict = new Dictionary<string, string>()
|
{
|
{"Jdn2400","SPDN2400"},
|
{"Jdn2700","SPDN2700"},
|
{"Jpump21","SPPump21"},
|
{"Jpump22","SPPump22"},
|
{"Jpump23","SPPump23"},
|
{"Jpump24","SPPump24"},
|
{"Jpump25","SPPump25"},
|
{"Jpump26","SPPump26"},
|
{"Jpump27","SPPump27"}
|
};
|
}
|
return dict;
|
}
|
|
private Dictionary<string, string> GetPumpFlowIdMappingDict(int station_index)
|
{
|
var dict = new Dictionary<string, string>();
|
if (station_index == 1)
|
{
|
dict = new Dictionary<string, string>()
|
{
|
{ "Pjd1", "SFJD1"},
|
{ "Pjd2", "SFJD2"},
|
{ "Pjd3", "SFJD3"},
|
};
|
}
|
else
|
{
|
dict = new Dictionary<string, string>()
|
{
|
{ "Pdn2400", "SFDN2400"},
|
{ "Pdn2700", "SFDN2700"},
|
//{ "Ppump21", "SFPump21"},
|
//{ "Ppump22", "SFPump22"},
|
//{ "Ppump23", "SFPump23"},
|
//{ "Ppump24", "SFPump24"},
|
//{ "Ppump25", "SFPump25"},
|
//{ "Ppump26", "SFPump26"},
|
//{ "Ppump27", "SFPump27"}
|
};
|
}
|
return dict;
|
}
|
|
private Dictionary<string, int> GetPumpIdMappingDict(int station_index)
|
{
|
var dict = new Dictionary<string, int>();
|
if (station_index == 1)
|
{
|
dict = new Dictionary<string, int>()
|
{
|
{"Jpump11",GlobalHelper.Flag11},
|
{"Jpump12",GlobalHelper.Flag12},
|
{"Jpump13",GlobalHelper.Flag13},
|
{"Jpump14",GlobalHelper.Flag14},
|
{"Jpump15",GlobalHelper.Flag15},
|
{"Jpump16",GlobalHelper.Flag16},
|
{"Jpump17",GlobalHelper.Flag17},
|
{"Jpump18",GlobalHelper.Flag18},
|
};
|
}
|
else
|
{
|
dict = new Dictionary<string, int>()
|
{
|
{ "Ppump21", GlobalHelper.Flag21},
|
{ "Ppump22", GlobalHelper.Flag22},
|
{ "Ppump23", GlobalHelper.Flag23},
|
{ "Ppump24", GlobalHelper.Flag24},
|
{ "Ppump25", GlobalHelper.Flag25},
|
{ "Ppump26", GlobalHelper.Flag26},
|
{ "Ppump27", GlobalHelper.Flag27},
|
{"Jpump21",GlobalHelper.Flag21},
|
{"Jpump22",GlobalHelper.Flag22},
|
{"Jpump23",GlobalHelper.Flag23},
|
{"Jpump24",GlobalHelper.Flag24},
|
{"Jpump25",GlobalHelper.Flag25},
|
{"Jpump26",GlobalHelper.Flag26},
|
{"Jpump27",GlobalHelper.Flag27}
|
};
|
}
|
return dict;
|
}
|
|
private Tuple<double[], double> FilterBySTDP(double[] array, double min_dev, int count)
|
{
|
if (array == null || !array.Any())
|
{
|
return default;
|
}
|
var array_avg = array.Average();
|
var array_count = array.Count();
|
|
|
FilterOutliersHelper.STDEV(array, out double std_dev, out double std_dev_pop);
|
if (Math.Abs(std_dev_pop) < min_dev)
|
{
|
return new Tuple<double[], double>(array, std_dev_pop);
|
}
|
if (count > 3)
|
{
|
return new Tuple<double[], double>(array, std_dev_pop);
|
}
|
var filter_array = array.Where(x => !(Math.Abs(x - array_avg) > Math.Abs(std_dev_pop * 2))).ToArray();
|
if (filter_array == null || !filter_array.Any())
|
{
|
return default;
|
}
|
count++;
|
return FilterBySTDP(filter_array, min_dev, count);
|
}
|
|
|
private void cmbFlag_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
ClearChart();
|
if (_model_diff_vm_list == null || !_model_diff_vm_list.Any())
|
{
|
return;
|
}
|
if (!int.TryParse(this.cmbFlag.Text, out int flag))
|
{
|
return;
|
}
|
var vm_list = _model_diff_vm_list.Where(x => x.Type == "压力" && x.Flag == flag).ToList();
|
if (vm_list == null || !vm_list.Any())
|
{
|
return;
|
}
|
this.chartControl1.BeginInit();
|
foreach (var vm in vm_list)
|
{
|
var time = vm.Time;
|
_series_default_head.Points.Add(new SeriesPoint(time, vm.MonitorValue));
|
_series_curve_head.Points.Add(new SeriesPoint(time, vm.ModelValue));
|
_series_correct_curve_head.Points.Add(new SeriesPoint(time, vm.DiffVlaue));
|
}
|
|
this.chartControl1.EndInit();
|
}
|
|
|
//加载
|
private void barCekLoad_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
WaitFrmHelper.ShowWaitForm();
|
SetBindingData(_monitorDataSources, _station);
|
WaitFrmHelper.HideWaitForm();
|
}
|
|
|
// 刷新数据
|
private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
InitialDataSource();
|
}
|
|
private void barBtnExportAnalysisFactor_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_monitorDataSources == null || _station == null)
|
{
|
return;
|
}
|
WaitFrmHelper.ShowWaitForm("正在导出");
|
ExportModelAnalysisFactorHelper.Export(_monitorDataSources.ID, _station.ID,_station.SortCode, _station.Name);
|
WaitFrmHelper.HideWaitForm();
|
AlertTool.ShowInfo(System.Windows.Forms.Application.OpenForms[0], "提示", "导出完成!");
|
|
}
|
}
|
}
|