using IStation.Epanet.Enums;
|
using IStation.Epanet;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using IStation.Model;
|
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
|
using SixLabors.ImageSharp.PixelFormats;
|
|
namespace IStation.WinFrmUI
|
{
|
/// <summary>
|
/// 导出 分析系数
|
/// </summary>
|
public partial class AnalysisFactorHelper
|
{
|
#region Model
|
|
public class ScadaDiffViewModel
|
{
|
public DateTime Time { get; set; }
|
public int Flag { get; set; }
|
public double Rpm { get; set; }
|
public double Hz { get; set; }
|
public double Hz0 { get; set; }
|
public double Flow { get; set; }
|
public double Head { get; set; }
|
public double CurveHead { get; set; }
|
public double HeadDiff { get; set; }
|
public double CorrectCurveHead { get; set; }
|
public double CorrectHeadDiff { get; set; }
|
}
|
public class ModelDiffViewMdoel
|
{
|
public string Time { get; set; }
|
public string MonitorID { get; set; }
|
public string ModelID { get; set; }
|
public double ModelValue { get; set; }
|
public double MonitorValue { get; set; }
|
public double DiffVlaue { get; set; }
|
public int? Flag { get; set; }
|
public double? Hz { get; set; }
|
public double? Hz0 { get; set; }
|
}
|
public class AnalysisFactorDto
|
{
|
|
/// <summary>
|
/// 泵标志
|
/// </summary>
|
public int Flag { get; set; }
|
|
/// <summary>
|
/// 频率
|
/// </summary>
|
public double Hz { get; set; }
|
|
/// <summary>
|
/// 扬程标准差
|
/// </summary>
|
public double? HeadSTDP { get; set; }
|
|
/// <summary>
|
/// 扬程偏差
|
/// </summary>
|
public double? HeadDeviation { get; set; }
|
|
/// <summary>
|
/// 准确度
|
/// </summary>
|
public double Accuracy { get; set; }
|
|
|
}
|
|
#endregion
|
|
private static BLL.StationSignalRecordPacket _packet = new BLL.StationSignalRecordPacket();
|
private static string _model_file = System.IO.Path.Combine
|
(Settings.File.RootDirectory,
|
Settings.File.DataFolder,
|
"ch2_v3_20240801(Clear).inp");
|
|
#region Export
|
|
/// <summary>
|
/// 导出Scada分析系数
|
/// </summary>
|
public static bool ExportScadaAnalysis(long monitorDataSourcesId, long stationId, string name)
|
{
|
var packets = _packet.Get(monitorDataSourcesId, stationId);
|
if (packets == null || !packets.Any())
|
return false;
|
|
var eq_list = new BLL.Equipment().GetPumpListByBelongTypeAndBelongID(IStation.ObjectType.Station, stationId);
|
if (eq_list == null || !eq_list.Any())
|
return false;
|
var flag_list = eq_list.Select(x => x.SortCode).OrderBy(x => x).ToList();
|
var flag_pump_dict = eq_list.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 eq_list)
|
{
|
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);
|
}
|
|
var vm_list = new List<ScadaDiffViewModel>();
|
foreach (var packet in packets)
|
{
|
var station_signal_records = packet.StationSignalRecords;
|
if (station_signal_records == null || !station_signal_records.Any())
|
continue;
|
foreach (var record in station_signal_records)
|
{
|
var pump_signal_records = record.PumpSignalRecords;
|
if (pump_signal_records == null || !pump_signal_records.Any())
|
continue;
|
pump_signal_records = pump_signal_records.OrderBy(x => x.Flag).ToList();
|
|
foreach (var pump_record in pump_signal_records)
|
{
|
if (pump_record.Rpm == IStation.Error.Default || pump_record.Head == IStation.Error.Default)
|
{
|
continue;
|
}
|
var flag = pump_record.Flag;
|
var pump = flag_pump_dict[flag];
|
var curve_qh = flag_curve_dict[flag];
|
|
var hz = pump_record.Rpm / pump.Nr * 50;
|
hz = Math.Round(hz, 2);
|
|
var curve_head = GetCurveHead(curve_qh, pump.Nr, pump_record.Rpm, pump_record.FlowRate);
|
curve_head = Math.Round(curve_head, 2);
|
|
var pump_head50hz = Model.CurveCalcuHelper.Calculate50HByHz(pump_record.Head, hz);
|
var curve_head50hz = Model.CurveCalcuHelper.Calculate50HByHz(curve_head, hz);
|
|
var head_diff = pump_head50hz - curve_head50hz;
|
|
var vm_pump = new ScadaDiffViewModel();
|
vm_pump.Time = record.Time;
|
vm_pump.Flag = flag;
|
vm_pump.Rpm = pump_record.Rpm;
|
vm_pump.Hz = hz;
|
vm_pump.Hz0 = Math.Round(hz, 0);
|
vm_pump.Head = pump_record.Head;
|
vm_pump.Flow = pump_record.FlowRate;
|
vm_pump.CurveHead = curve_head;
|
vm_pump.HeadDiff = head_diff;
|
vm_list.Add(vm_pump);
|
}
|
}
|
}
|
|
if (!vm_list.Any())
|
return false;
|
|
var flag_hz_head_diff_list = vm_list.Select(x => new Tuple<int, double, double>(x.Flag, x.Hz0, x.HeadDiff)).ToList();
|
return SaveAnalysisFactorDtoList(name, eq_list, flag_hz_head_diff_list);
|
}
|
|
/// <summary>
|
/// 导出模型分析系数
|
/// </summary>
|
public static bool ExportModelAnalysis(long monitorDataSourcesId, long stationId, int station_index, string name)
|
{
|
var packets = _packet.Get(monitorDataSourcesId, stationId);
|
if (packets == null || !packets.Any())
|
return false;
|
|
var eq_list = new BLL.Equipment().GetPumpListByBelongTypeAndBelongID(IStation.ObjectType.Station, stationId);
|
if (eq_list == null || !eq_list.Any())
|
{
|
return default;
|
}
|
|
var flag_pump_dict = eq_list.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 eq_list)
|
{
|
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 default;
|
}
|
|
|
|
var err = EpanetMethods.ENopen(_model_file, "", "");
|
if (err != ErrorCode.Ok)
|
{
|
return default;
|
}
|
|
err = EpanetMethods.ENopenH();
|
if (err != ErrorCode.Ok)
|
{
|
return default;
|
}
|
|
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 vm_list = new List<ModelDiffViewMdoel>();
|
var model_id_build = new StringBuilder(31);
|
foreach (var packet in packets)
|
{
|
var station_signal_records = packet.StationSignalRecords;
|
if (station_signal_records == null || !station_signal_records.Any())
|
continue;
|
foreach (var record in station_signal_records)
|
{
|
var time = record.Time.ToString("G");
|
Tuple<Dictionary<string, float[]>, Dictionary<string, double>[]> tuple = null;
|
if (station_index == 1)
|
{
|
tuple = GetStation1(record.ModelRecordDict);
|
}
|
else
|
{
|
tuple = GetStation2(record.ModelRecordDict);
|
}
|
|
var pattern_dict = tuple.Item1;
|
var scada_dict = tuple.Item2[0];
|
var pump_dict = tuple.Item2[1];
|
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 ModelDiffViewMdoel();
|
vm.Time = time;
|
vm.MonitorID = scada_id;
|
vm.ModelID = model_id;
|
vm.ModelValue = model_head;
|
vm.MonitorValue = scada_value;
|
vm.DiffVlaue = scada_value - model_head;
|
vm.Hz = hz;
|
vm.Hz0 = hzr;
|
vm.Flag = flag;
|
if (Math.Round(vm.DiffVlaue) > 100)
|
{
|
continue;
|
}
|
vm_list.Add(vm);
|
}
|
}
|
}
|
}
|
|
|
|
EpanetMethods.ENcloseH();
|
EpanetMethods.ENclose();
|
|
if (!vm_list.Any())
|
return default;
|
|
|
var flag_hz_head_diff_list = vm_list.Where(x => x.Flag.HasValue).Select(x => new Tuple<int, double, double>(x.Flag.Value, x.Hz0.Value, x.DiffVlaue)).ToList();
|
return SaveAnalysisFactorDtoList(name, eq_list, flag_hz_head_diff_list);
|
}
|
|
#endregion
|
|
#region Function
|
public static bool SaveAnalysisFactorDtoList(string name, List<Model.Equipment<Model.Pump>> eq_list, List<Tuple<int, double, double>> flag_hz_head_diff_list)
|
{
|
if (eq_list == null || !eq_list.Any())
|
{
|
return default;
|
}
|
if (flag_hz_head_diff_list == null || !flag_hz_head_diff_list.Any())
|
{
|
return default;
|
}
|
|
var flag_pump_dict = eq_list.ToDictionary(x => x.SortCode, x => x.RatedParas);
|
var all_analysis_factor_list = GetAnalysisFactorDtoList(flag_pump_dict, flag_hz_head_diff_list);
|
if (all_analysis_factor_list == null || all_analysis_factor_list.Any())
|
{
|
return default;
|
}
|
var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "分析系数");
|
if (!Directory.Exists(root_folder))
|
{
|
Directory.CreateDirectory(root_folder);
|
}
|
var fileName = root_folder + "\\" + name + ".json";
|
var json = JsonHelper.Object2Json(all_analysis_factor_list);
|
File.WriteAllText(fileName, json);
|
return true;
|
}
|
|
public static List<AnalysisFactorDto> GetAnalysisFactorDtoList(Dictionary<int, Model.Pump> flag_pump_dict , List<Tuple<int, double, double>> flag_hz_head_diff_list)
|
{
|
if (flag_pump_dict == null || !flag_pump_dict.Any())
|
{
|
return default;
|
}
|
if (flag_hz_head_diff_list == null || !flag_hz_head_diff_list.Any())
|
{
|
return default;
|
}
|
|
var exist_data_analysis_factor_list = new List<AnalysisFactorDto>();
|
var opt_std_dev_pop = 0.3;
|
|
//分析5hz范围内的系数
|
var group_by_flag = flag_hz_head_diff_list.GroupBy(x => x.Item1);
|
var flag_range5_hz_factor_dict = new Dictionary<int, Dictionary<double, Tuple<double, double, int>>>();
|
foreach (var flag_item in group_by_flag)
|
{
|
var flag = flag_item.Key;
|
var pump = flag_pump_dict[flag];
|
if (!pump.IsBp)
|
continue;
|
|
for (double i = 20; i <= 50; i += 5)
|
{
|
var min_hz = i - 5;
|
double max_hz = i;
|
|
var list = flag_item.Where(x => x.Item2 >= min_hz && x.Item2 <= max_hz).ToList();
|
if (list == null || list.Count() < 10)
|
continue;
|
|
var head_diff_list = list.Select(x => x.Item3).ToList();
|
|
var filter_tuple = GetFilterBySTDP(head_diff_list.ToArray(), opt_std_dev_pop, 0);
|
var filter_array = filter_tuple.Item1;
|
var std_dev_pop = filter_tuple.Item2;
|
var std_dev_pop_head_avg = filter_array.Average();
|
|
if (!flag_range5_hz_factor_dict.ContainsKey(flag))
|
{
|
flag_range5_hz_factor_dict.Add(flag, new Dictionary<double, Tuple<double, double, int>>());
|
}
|
|
flag_range5_hz_factor_dict[flag].Add(max_hz, new Tuple<double, double, int>(std_dev_pop, std_dev_pop_head_avg, filter_array.Count()));
|
}
|
if (true)
|
{
|
|
}
|
}
|
|
|
//分析1hz范围内的系数
|
var group_by_flag_hz = flag_hz_head_diff_list.GroupBy(x => new { x.Item1, x.Item2 });
|
foreach (var item in group_by_flag_hz)
|
{
|
var hz = item.Key.Item2;
|
if (hz < 20)
|
continue;
|
if (item.Count() < 5)
|
continue;
|
|
var flag = item.Key.Item1;
|
var pump = flag_pump_dict[flag];
|
var head_diff_list = item.Select(x => x.Item3).ToList();
|
var filter_std_dev_pop_tuple = GetFilterBySTDP(head_diff_list.ToArray(), opt_std_dev_pop, 0);
|
var filter_std_dev_pop_array = filter_std_dev_pop_tuple.Item1;
|
var std_dev_pop = filter_std_dev_pop_tuple.Item2;
|
|
var std_dev_pop_head_avg = filter_std_dev_pop_array.Average();
|
var head_diff_avg = std_dev_pop_head_avg;
|
if (Math.Abs(head_diff_avg) > 5)
|
continue;
|
if (Math.Abs(std_dev_pop) > 1)
|
continue;
|
|
if (Math.Abs(std_dev_pop) > 0.5 && item.Count() < 10)
|
continue;
|
|
var analysis_facotr = new AnalysisFactorDto();
|
analysis_facotr.Flag = flag;
|
analysis_facotr.Hz = hz;
|
analysis_facotr.HeadSTDP = std_dev_pop;
|
analysis_facotr.HeadDeviation = std_dev_pop_head_avg;
|
analysis_facotr.Accuracy = 0;
|
exist_data_analysis_factor_list.Add(analysis_facotr);
|
}
|
exist_data_analysis_factor_list = exist_data_analysis_factor_list.OrderBy(x => x.Flag).ThenBy(x => x.Hz).ToList();
|
|
//相似换算修正系数(不存在监测数据的频率)
|
var similar_analysis_factor_list = new List<AnalysisFactorDto>();
|
foreach (var pump_item in flag_pump_dict)
|
{
|
var flag = pump_item.Key;
|
var pump = pump_item.Value;
|
if (!pump.IsBp)
|
continue;
|
if(!flag_range5_hz_factor_dict.ContainsKey(flag))
|
continue;
|
var range5_hz_item = flag_range5_hz_factor_dict[flag];
|
for (int hz = 1; hz <= 50; hz++)
|
{
|
if (exist_data_analysis_factor_list.Exists(x => x.Flag == flag && x.Hz == hz))
|
continue;
|
|
var hz_range_num = hz / 5;
|
var hz_key = (hz_range_num + 1) * 5;
|
if (hz_key > 50)
|
hz_key = 50;
|
if (range5_hz_item.ContainsKey(hz_key))
|
{
|
var item = range5_hz_item[hz_key];
|
var analysis_facotr = new AnalysisFactorDto();
|
analysis_facotr.Flag = flag;
|
analysis_facotr.Hz = hz;
|
analysis_facotr.HeadSTDP = item.Item1;
|
analysis_facotr.HeadDeviation = item.Item2;
|
analysis_facotr.Accuracy = 0;
|
similar_analysis_factor_list.Add(analysis_facotr);
|
}
|
else
|
{
|
var hz_list = range5_hz_item.Select(x => x.Key).ToList();
|
var similar_hz = hz_list.Where(x => x >= hz_key)?.OrderBy(x => x).FirstOrDefault();
|
if (similar_hz == null|| similar_hz.Value==0)
|
{
|
similar_hz = hz_list.OrderByDescending(x => x).FirstOrDefault();
|
}
|
if (similar_hz == null)
|
{
|
throw new Exception("similar_hz error");
|
}
|
var tuple = range5_hz_item[similar_hz.Value];
|
var similar_ratio = hz / similar_hz.Value;
|
var head_dev = tuple.Item2 * similar_ratio;
|
var head_stdp = tuple.Item1 * similar_ratio;
|
|
var analysis_facotr = new AnalysisFactorDto();
|
analysis_facotr.Flag = flag;
|
analysis_facotr.Hz = hz;
|
analysis_facotr.HeadSTDP = head_stdp;
|
analysis_facotr.HeadDeviation = head_dev;
|
analysis_facotr.Accuracy = -1;
|
similar_analysis_factor_list.Add(analysis_facotr);
|
}
|
}
|
}
|
|
var all_analysis_factor_list = new List<AnalysisFactorDto>();
|
all_analysis_factor_list.AddRange(exist_data_analysis_factor_list);
|
all_analysis_factor_list.AddRange(similar_analysis_factor_list);
|
all_analysis_factor_list = all_analysis_factor_list.OrderBy(x => x.Flag).ThenBy(x => x.Hz).ToList();
|
return all_analysis_factor_list;
|
}
|
public static Tuple<double[], double> GetFilterBySTDP(double[] array, double min_dev=0.3, int start_index = 1, int max_iteration_count = 3)
|
{
|
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 (start_index > max_iteration_count)
|
{
|
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;
|
}
|
start_index++;
|
return GetFilterBySTDP(filter_array, min_dev, start_index, max_iteration_count);
|
}
|
|
|
#region Scada
|
private static double GetCurveHead(Model.CurveExpress curve_qh, double nr, double rpm, double flow)
|
{
|
if (curve_qh == null)
|
return default;
|
var similar_qh = Model.CurveCalcuHelper.CalculateSimilarQH(curve_qh, nr, rpm);
|
if (similar_qh == null)
|
return default;
|
var head = similar_qh.GetFitPointY(flow);
|
return head;
|
}
|
#endregion
|
|
#region Model
|
|
public static Tuple<Dictionary<string, float[]>, Dictionary<string, double>[]> GetStation1(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 pump_flag_dict = new Dictionary<string, double>();
|
var pump_flow_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);
|
|
|
|
pump_flag_dict.Add("Pump11", GlobalHelper.Flag11);
|
pump_flag_dict.Add("Pump12", GlobalHelper.Flag12);
|
pump_flag_dict.Add("Pump13", GlobalHelper.Flag13);
|
pump_flag_dict.Add("Pump14", GlobalHelper.Flag14);
|
pump_flag_dict.Add("Pump15", GlobalHelper.Flag15);
|
pump_flag_dict.Add("Pump16", GlobalHelper.Flag16);
|
pump_flag_dict.Add("Pump17", GlobalHelper.Flag17);
|
pump_flag_dict.Add("Pump18", GlobalHelper.Flag18);
|
|
|
|
var dict_array = new Dictionary<string, double>[] { scada_dict, pump_dict, pump_flag_dict };
|
return new Tuple<Dictionary<string, float[]>, Dictionary<string, double>[]>(pattern_dict, dict_array);
|
}
|
|
public static Tuple<Dictionary<string, float[]>, Dictionary<string, double>[]> GetStation2(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 pump_ratio_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)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);
|
|
|
pump_ratio_dict.Add("Pump21", GlobalHelper.Flag21);
|
pump_ratio_dict.Add("Pump22", GlobalHelper.Flag22);
|
pump_ratio_dict.Add("Pump23", GlobalHelper.Flag23);
|
pump_ratio_dict.Add("Pump24", GlobalHelper.Flag24);
|
pump_ratio_dict.Add("Pump25", GlobalHelper.Flag25);
|
pump_ratio_dict.Add("Pump26", GlobalHelper.Flag26);
|
pump_ratio_dict.Add("Pump27", GlobalHelper.Flag27);
|
|
var dict_array = new Dictionary<string, double>[] { scada_dict, pump_dict, pump_ratio_dict };
|
return new Tuple<Dictionary<string, float[]>, Dictionary<string, double>[]>(pattern_dict, dict_array);
|
}
|
|
public static 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;
|
}
|
|
public static 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;
|
}
|
|
public static 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;
|
}
|
|
|
public static Dictionary<string, string> GetModelPressureIdMappingDict()
|
{
|
var 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"},
|
{"Jdn2400","SPDN2400"},
|
{"Jdn2700","SPDN2700"},
|
{"Jpump21","SPPump21"},
|
{"Jpump22","SPPump22"},
|
{"Jpump23","SPPump23"},
|
{"Jpump24","SPPump24"},
|
{"Jpump25","SPPump25"},
|
{"Jpump26","SPPump26"},
|
{"Jpump27","SPPump27"}
|
};
|
|
return dict;
|
}
|
|
public static Dictionary<string, string> GetModelFlowIdMappingDict()
|
{
|
var dict = new Dictionary<string, string>()
|
{
|
{ "Pjd1", "SFJD1"},
|
{ "Pjd2", "SFJD2"},
|
{ "Pjd3", "SFJD3"},
|
|
{ "Pdn2400", "SFDN2400"},
|
{ "Pdn2700", "SFDN2700"},
|
{ "Ppump21", "SFPump21"},
|
{ "Ppump22", "SFPump22"},
|
{ "Ppump23", "SFPump23"},
|
{ "Ppump24", "SFPump24"},
|
{ "Ppump25", "SFPump25"},
|
{ "Ppump26", "SFPump26"},
|
{ "Ppump27", "SFPump27"}
|
};
|
|
return dict;
|
}
|
|
|
public static Dictionary<int, string> GetFlagPumpIdDict()
|
{
|
var dict = new Dictionary<int, string>()
|
{
|
{ GlobalHelper.Flag11,"Pump11" },
|
{ GlobalHelper.Flag12,"Pump12" },
|
{ GlobalHelper.Flag13,"Pump13" },
|
{ GlobalHelper.Flag14,"Pump14" },
|
{ GlobalHelper.Flag15,"Pump15" },
|
{ GlobalHelper.Flag16,"Pump16" },
|
{ GlobalHelper.Flag17,"Pump17" },
|
{ GlobalHelper.Flag18,"Pump18" },
|
{ GlobalHelper.Flag21,"Pump21" },
|
{ GlobalHelper.Flag22,"Pump22" },
|
{ GlobalHelper.Flag23,"Pump23" },
|
{ GlobalHelper.Flag24,"Pump24" },
|
{ GlobalHelper.Flag25,"Pump25" },
|
{ GlobalHelper.Flag26,"Pump26" },
|
{ GlobalHelper.Flag27,"Pump27" }
|
};
|
|
return dict;
|
}
|
|
public static Dictionary<string, int> GetPumpIdFlagDict()
|
{
|
var dict = new Dictionary<string, int>()
|
{
|
{"Pump11",GlobalHelper.Flag11},
|
{"Pump12",GlobalHelper.Flag12},
|
{"Pump13",GlobalHelper.Flag13},
|
{"Pump14",GlobalHelper.Flag14},
|
{"Pump15",GlobalHelper.Flag15},
|
{"Pump16",GlobalHelper.Flag16},
|
{"Pump17",GlobalHelper.Flag17},
|
{"Pump18",GlobalHelper.Flag18},
|
{"Pump21",GlobalHelper.Flag21},
|
{"Pump22",GlobalHelper.Flag22},
|
{"Pump23",GlobalHelper.Flag23},
|
{"Pump24",GlobalHelper.Flag24},
|
{"Pump25",GlobalHelper.Flag25},
|
{"Pump26",GlobalHelper.Flag26},
|
{"Pump27",GlobalHelper.Flag27}
|
};
|
|
return dict;
|
}
|
|
public static Tuple<List<string>, List<string>, List<string>> GetModelIdList()
|
{
|
var flow_id_list = new List<string>();
|
flow_id_list.Add("Pjd1");
|
flow_id_list.Add("Pjd2");
|
flow_id_list.Add("Pjd3");
|
flow_id_list.Add("Pdn2400");
|
flow_id_list.Add("Pdn2700");
|
flow_id_list.Add("Ppump21");
|
flow_id_list.Add("Ppump22");
|
flow_id_list.Add("Ppump23");
|
flow_id_list.Add("Ppump24");
|
flow_id_list.Add("Ppump25");
|
flow_id_list.Add("Ppump26");
|
flow_id_list.Add("Ppump27");
|
|
var pressure_id_list = new List<string>();
|
pressure_id_list.Add("Jjd1");
|
pressure_id_list.Add("Jjd2");
|
pressure_id_list.Add("Jjd3");
|
pressure_id_list.Add("Jpump11");
|
pressure_id_list.Add("Jpump12");
|
pressure_id_list.Add("Jpump13");
|
pressure_id_list.Add("Jpump14");
|
pressure_id_list.Add("Jpump15");
|
pressure_id_list.Add("Jpump16");
|
pressure_id_list.Add("Jpump17");
|
pressure_id_list.Add("Jpump18");
|
pressure_id_list.Add("Jdn2400");
|
pressure_id_list.Add("Jdn2700");
|
pressure_id_list.Add("Jpump21");
|
pressure_id_list.Add("Jpump22");
|
pressure_id_list.Add("Jpump23");
|
pressure_id_list.Add("Jpump24");
|
pressure_id_list.Add("Jpump25");
|
pressure_id_list.Add("Jpump26");
|
pressure_id_list.Add("Jpump27");
|
|
|
var pump_id_list = new List<string>();
|
pump_id_list.Add("Pump11");
|
pump_id_list.Add("Pump12");
|
pump_id_list.Add("Pump13");
|
pump_id_list.Add("Pump14");
|
pump_id_list.Add("Pump15");
|
pump_id_list.Add("Pump16");
|
pump_id_list.Add("Pump17");
|
pump_id_list.Add("Pump18");
|
pump_id_list.Add("Pump21");
|
pump_id_list.Add("Pump22");
|
pump_id_list.Add("Pump23");
|
pump_id_list.Add("Pump24");
|
pump_id_list.Add("Pump25");
|
pump_id_list.Add("Pump26");
|
pump_id_list.Add("Pump27");
|
|
return new Tuple<List<string>, List<string>, List<string>>(flow_id_list,pressure_id_list,pump_id_list);
|
}
|
|
public static Dictionary<string, Tuple<string, int>> GetFlowPumpDict()
|
{
|
var dic = new Dictionary<string, Tuple<string, int>>();
|
dic.Add("Ppump21", new Tuple<string, int>("Pump21", GlobalHelper.Flag21));
|
dic.Add("Ppump22", new Tuple<string, int>("Pump22", GlobalHelper.Flag22));
|
dic.Add("Ppump23", new Tuple<string, int>("Pump23", GlobalHelper.Flag23));
|
dic.Add("Ppump24", new Tuple<string, int>("Pump24", GlobalHelper.Flag24));
|
dic.Add("Ppump25", new Tuple<string, int>("Pump25", GlobalHelper.Flag25));
|
dic.Add("Ppump26", new Tuple<string, int>("Pump26", GlobalHelper.Flag26));
|
dic.Add("Ppump27", new Tuple<string, int>("Pump27", GlobalHelper.Flag27));
|
return dic;
|
}
|
|
public static Dictionary<string, Tuple<string, int>> GetPressurePumpDict()
|
{
|
var dic = new Dictionary<string, Tuple<string, int>>();
|
var pressure_id_list = new List<string>();
|
dic.Add("Jpump11", new Tuple<string, int>("Pump11", GlobalHelper.Flag11));
|
dic.Add("Jpump12", new Tuple<string, int>("Pump12", GlobalHelper.Flag12));
|
dic.Add("Jpump13", new Tuple<string, int>("Pump13", GlobalHelper.Flag13));
|
dic.Add("Jpump14", new Tuple<string, int>("Pump14", GlobalHelper.Flag14));
|
dic.Add("Jpump15", new Tuple<string, int>("Pump15", GlobalHelper.Flag15));
|
dic.Add("Jpump16", new Tuple<string, int>("Pump16", GlobalHelper.Flag16));
|
dic.Add("Jpump17", new Tuple<string, int>("Pump17", GlobalHelper.Flag17));
|
dic.Add("Jpump18", new Tuple<string, int>("Pump18", GlobalHelper.Flag18));
|
|
dic.Add("Jpump21", new Tuple<string, int>("Pump21", GlobalHelper.Flag21));
|
dic.Add("Jpump22", new Tuple<string, int>("Pump22", GlobalHelper.Flag22));
|
dic.Add("Jpump23", new Tuple<string, int>("Pump23", GlobalHelper.Flag23));
|
dic.Add("Jpump24", new Tuple<string, int>("Pump24", GlobalHelper.Flag24));
|
dic.Add("Jpump25", new Tuple<string, int>("Pump25", GlobalHelper.Flag25));
|
dic.Add("Jpump26", new Tuple<string, int>("Pump26", GlobalHelper.Flag26));
|
dic.Add("Jpump27", new Tuple<string, int>("Pump27", GlobalHelper.Flag27));
|
|
return dic;
|
}
|
|
public static List<string> GetPatternIdList()
|
{
|
var list = new List<string>();
|
list.Add("Pump11");
|
list.Add("Pump12");
|
list.Add("Pump13");
|
list.Add("Pump14");
|
list.Add("Pump15");
|
list.Add("Pump16");
|
list.Add("Pump17");
|
list.Add("Pump18");
|
list.Add("R3");
|
list.Add("R2");
|
list.Add("R1");
|
list.Add("SFJD1");
|
list.Add("SFJD2");
|
list.Add("SFJD3");
|
list.Add("RPump21");
|
list.Add("RPump22");
|
list.Add("RPump23");
|
list.Add("RPump24");
|
list.Add("RPump25");
|
list.Add("RPump26");
|
list.Add("RPump27");
|
list.Add("SFPump21");
|
list.Add("SFPump22");
|
list.Add("SFPump23");
|
list.Add("SFPump24");
|
list.Add("SFPump25");
|
list.Add("SFPump26");
|
list.Add("SFPump27");
|
list.Add("Pump21");
|
list.Add("Pump22");
|
list.Add("Pump23");
|
list.Add("Pump24");
|
list.Add("Pump25");
|
list.Add("Pump26");
|
list.Add("Pump27");
|
list.Add("SFDN2400");
|
list.Add("SFDN2700");
|
return list;
|
}
|
|
public static Dictionary<string, int> GetCurveIdDict()
|
{
|
var dict = new Dictionary<string, int>();
|
dict.Add("11", GlobalHelper.Flag11);
|
dict.Add("12", GlobalHelper.Flag12);
|
dict.Add("13", GlobalHelper.Flag13);
|
dict.Add("14", GlobalHelper.Flag14);
|
dict.Add("15", GlobalHelper.Flag15);
|
dict.Add("16", GlobalHelper.Flag16);
|
dict.Add("17", GlobalHelper.Flag17);
|
dict.Add("18", GlobalHelper.Flag18);
|
dict.Add("21", GlobalHelper.Flag21);
|
dict.Add("22", GlobalHelper.Flag22);
|
dict.Add("23", GlobalHelper.Flag23);
|
dict.Add("24", GlobalHelper.Flag24);
|
dict.Add("25", GlobalHelper.Flag25);
|
dict.Add("26", GlobalHelper.Flag26);
|
dict.Add("27", GlobalHelper.Flag27);
|
|
return dict;
|
}
|
|
public static Dictionary<int, string> GetPumpCurveIdDict()
|
{
|
var dict = new Dictionary<int, string>();
|
dict.Add(GlobalHelper.Flag11, "11");
|
dict.Add(GlobalHelper.Flag12, "12");
|
dict.Add(GlobalHelper.Flag13, "13");
|
dict.Add(GlobalHelper.Flag14, "14");
|
dict.Add(GlobalHelper.Flag15, "15");
|
dict.Add(GlobalHelper.Flag16, "16");
|
dict.Add(GlobalHelper.Flag17, "17");
|
dict.Add(GlobalHelper.Flag18, "18");
|
dict.Add(GlobalHelper.Flag21, "21");
|
dict.Add(GlobalHelper.Flag22, "22");
|
dict.Add(GlobalHelper.Flag23, "23");
|
dict.Add(GlobalHelper.Flag24, "24");
|
dict.Add(GlobalHelper.Flag25, "25");
|
dict.Add(GlobalHelper.Flag26, "26");
|
dict.Add(GlobalHelper.Flag27, "27");
|
|
return dict;
|
}
|
|
#endregion
|
|
|
|
|
#endregion
|
|
}
|
}
|