using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Numerics;
|
using System.Text;
|
using System.Threading.Tasks;
|
using IStation.Calculation.DispatchAna.Model;
|
|
namespace IStation.Calculation.DispatchAna
|
{
|
/// <summary>
|
/// 松浦大桥调度方案计算器(最优方案)
|
/// </summary>
|
public class Calculator_OptAna_SHYS_松浦大桥: CalculatorBase_SHYS_松浦大桥, IOptAnaCalc
|
{
|
/// <summary>
|
/// /
|
/// </summary>
|
public Calculator_OptAna_SHYS_松浦大桥()
|
{
|
|
}
|
List<Model.MachineDetail> _allMachineList = null;
|
|
#region 计算 最优方案
|
/// <summary>
|
/// 计算 最优方案
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="eta_ana_records"></param>
|
/// <param name="machine_run_status"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public List<IStation.Calculation.DispatchAna.Model.AnaScheme> CalcSchemes(
|
IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras,
|
IStation.Calculation.DispatchAna.Model.EtaAnaRecord4Station eta_ana_records,
|
IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status,
|
out string error_info)
|
{
|
this._corpID = complex_request_paras.CorpID;
|
this._stationID = complex_request_paras.StationID;
|
|
var isUsePress = complex_request_paras.PressValueType == Model.RequestParasComplex.ePressValueType.压力 ? true : false;
|
|
if (isUsePress)
|
return CalcSchemes压力(complex_request_paras, machine_run_status, out error_info);
|
else
|
return CalcSchemes扬程(complex_request_paras, machine_run_status, out error_info);
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="machine_run_status"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
protected override List<IStation.Calculation.DispatchAna.Model.AnaScheme> CalcSchemes压力(
|
IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras,
|
IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status,
|
out string error_info)
|
{
|
error_info = "";
|
if (complex_request_paras == null)
|
{
|
error_info = "ERROR 30";
|
return null;
|
}
|
if (complex_request_paras.OutletPipePara == null ||
|
complex_request_paras.OutletPipePara.Count < 1)
|
{
|
error_info = "ERROR 35,松浦大桥需要出口管路的流量";
|
return null;
|
}
|
if (complex_request_paras.InletPipePara == null ||
|
complex_request_paras.InletPipePara.Count < 4)
|
{
|
error_info = "ERROR 35,松浦大桥需要4个进水液位参数";
|
return null;
|
}
|
double inlet_wl1 = complex_request_paras.InletPipePara[0].Value;
|
double inlet_wl2 = complex_request_paras.InletPipePara[1].Value;
|
double inlet_wl3 = complex_request_paras.InletPipePara[2].Value;
|
double inlet_wl4 = complex_request_paras.InletPipePara[3].Value;
|
|
|
|
double pipe1_TargetFlow = complex_request_paras.OutletPipePara[0].TargetFlow;
|
double pipe2_TargetFlow = 0;
|
double outlet_wl1 = complex_request_paras.OutletPipePara[0].TargetPress;
|
if (outlet_wl1 < -100)
|
{
|
error_info = "ERROR 35,松浦大桥需要 调压池液位数据不合理,数据值为:"+ outlet_wl1;
|
return default;
|
}
|
double outlet_wl2 = outlet_wl1;//没有就认为两边液位一样
|
if (complex_request_paras.OutletPipePara.Count() >= 2)
|
{
|
pipe2_TargetFlow = complex_request_paras.OutletPipePara[1].TargetFlow;
|
outlet_wl2 = complex_request_paras.OutletPipePara[1].TargetPress;
|
if (outlet_wl2 < -100)
|
{
|
error_info = "ERROR 35,松浦大桥需要 调压池液位数据不合理,数据值为:" + outlet_wl2;
|
return default;
|
}
|
}
|
else
|
{
|
if (pipe1_TargetFlow < 50)
|
{//都关机
|
error_info = "ERROR 35,松浦大桥需要 管路的流量 ";
|
return null;
|
}
|
pipe1_TargetFlow = pipe1_TargetFlow / 2;
|
pipe2_TargetFlow = pipe1_TargetFlow;
|
}
|
|
|
|
|
//机泵信息
|
if (_allMachineList == null)
|
{
|
if (!BuildMachineList(
|
out _allMachineList,
|
out error_info))
|
{
|
error_info = "机泵组无法构建,ERROR 70,错误信息:" + error_info;
|
return null;
|
}
|
}
|
|
|
|
|
#region
|
|
|
|
|
|
|
double totalQ = 0, totalH = 0, totalP = 0;
|
int pipe_count = 0;
|
|
int ResultStatus = 1;
|
string ResultStatusInfo = null;
|
|
List<IStation.Calculation.DispatchAna.Model.AnaScheme> pipe1_results = null;
|
AnaScheme pipe1_result = null;
|
if (pipe1_TargetFlow > 100)
|
{
|
double outlet_wl_calc = outlet_wl1;
|
//if (pipe1_TargetFlow < 12000)
|
//{
|
// //至少5米的扬程
|
// if (outlet_wl1 < 6 + (inlet_wl1 + inlet_wl2) / 2)
|
// {
|
// outlet_wl_calc = 6 + (inlet_wl1 + inlet_wl2) / 2;
|
// }
|
//}
|
//else if (pipe1_TargetFlow < 20000)
|
//{
|
// //至少5米的扬程
|
// if (outlet_wl1 < 4 + (inlet_wl1 + inlet_wl2) / 2)
|
// {
|
// outlet_wl_calc = 4 + (inlet_wl1 + inlet_wl2) / 2;
|
// }
|
//}
|
//else
|
{
|
//至少2米的扬程
|
if (outlet_wl1 < 2.5 + (inlet_wl1 + inlet_wl2) / 2)
|
{
|
outlet_wl_calc = 2.5 + (inlet_wl1 + inlet_wl2) / 2;
|
}
|
}
|
|
Common.DispatchAnaGeneralHelper压力 calc_pipe1_helper = new Common.DispatchAnaGeneralHelper压力();
|
|
for (int i = 0; i <= 10; i++)
|
{//扬程过低,算不出来就增加出口压力
|
|
calc_pipe1_helper.InitialParas(
|
pipe1_TargetFlow,//假设一边输出一半
|
(inlet_wl1 + inlet_wl2) / 2, true,
|
outlet_wl_calc, true,
|
null, null,
|
(from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter, out error_info);
|
pipe1_results = calc_pipe1_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
if (pipe1_results != null && pipe1_results.Count > 0)
|
{
|
break;
|
}
|
outlet_wl_calc = outlet_wl_calc * 1.03;
|
ResultStatus = 2;
|
ResultStatusInfo = "提高了一号出口管液位参数";
|
}
|
if (pipe1_results == null || pipe1_results.Count() == 0)
|
{
|
error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,进口液位:{0}m {1}m,出口液位:{2}m,流量要求:{3}",
|
inlet_wl1, inlet_wl2, outlet_wl1, pipe1_TargetFlow);
|
return null;
|
}
|
pipe1_result = pipe1_results.First();
|
|
totalQ += pipe1_result.TotalWrkQ;
|
totalP += pipe1_result.TotalWrkP;
|
totalH += pipe1_result.TotalWrkH;
|
pipe_count++;
|
}
|
|
IStation.Calculation.DispatchAna.Model.AnaScheme pipe2_result = null;
|
List<IStation.Calculation.DispatchAna.Model.AnaScheme> pipe2_results = null;
|
|
if (pipe2_TargetFlow > 100)
|
{
|
double outlet_wl_calc = outlet_wl2;
|
//if (pipe1_TargetFlow < 20000)
|
//{
|
// //至少5米的扬程
|
// if (outlet_wl2 < 5 + (inlet_wl3 + inlet_wl4) / 2)
|
// {
|
// outlet_wl2 = 5 + (inlet_wl3 + inlet_wl4) / 2;
|
// }
|
//}
|
//else
|
{
|
if (outlet_wl2 < 2.5 + (inlet_wl3 + inlet_wl4) / 2)
|
{
|
outlet_wl_calc = 2.5 + (inlet_wl3 + inlet_wl4) / 2;
|
}
|
}
|
|
|
Common.DispatchAnaGeneralHelper压力 calc_pipe2_helper = new Common.DispatchAnaGeneralHelper压力();
|
|
int i = 0;
|
for (i = 0; i <= 10; i++)
|
{//扬程过低,算不出来就增加出口压力
|
calc_pipe2_helper.InitialParas(
|
pipe2_TargetFlow,//假设一边输出一半
|
(inlet_wl3 + inlet_wl4) / 2, true,
|
outlet_wl_calc, true,
|
null, null,
|
(from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter, out error_info);
|
|
calc_pipe2_helper.IsAllowOverTargetPress = true;//是否允许超过目标压力, 但最小变频频率都比要求压力高时, 按最小频率开泵
|
pipe2_results = calc_pipe2_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
if (pipe2_results != null && pipe2_results.Count > 0)
|
{
|
break;
|
}
|
ResultStatus = 2;
|
outlet_wl_calc = outlet_wl_calc * 1.03;
|
ResultStatusInfo = "提高了二号出口管液位参数";
|
}
|
if (pipe2_results == null || pipe2_results.Count() == 0)
|
{
|
error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,进口液位:{0}m {1}m,出口液位:{2}m,流量要求:{3}",
|
inlet_wl3, inlet_wl4, outlet_wl2, pipe2_TargetFlow);
|
return null;
|
}
|
|
pipe2_result = pipe2_results.First();
|
|
totalQ += pipe2_result.TotalWrkQ;
|
totalP += pipe2_result.TotalWrkP;
|
totalH += pipe2_result.TotalWrkH;
|
pipe_count++;
|
}
|
|
|
|
|
var plan = new Model.AnaScheme();
|
plan.ID = 1;
|
plan.TotalWrkQ = Math.Round(totalQ, 1);
|
plan.TotalWrkH = Math.Round(totalH / pipe_count, 2);
|
plan.TotalWrkP = Math.Round(totalP, 1);
|
plan.TotalWrkE = CalcConnectPipeEta(new List<AnaScheme>() { pipe1_result, pipe2_result });
|
plan.UWP = CalculateUWP(plan.TotalWrkP, plan.TotalWrkQ, plan.TotalWrkH);
|
plan.WP = CalculateWP(plan.TotalWrkP, plan.TotalWrkQ);
|
|
plan.Items = new List<Model.AnaSchemeItem>();
|
if (pipe1_result.Items != null && pipe1_result.Items.Count > 0)
|
plan.Items.AddRange(pipe1_result.Items);
|
if (pipe2_result.Items != null && pipe2_result.Items.Count > 0)
|
plan.Items.AddRange(pipe2_result.Items);
|
|
|
plan.ResultStatus = ResultStatus;
|
plan.ResultStatusInfo = ResultStatusInfo;
|
return new List<Model.AnaScheme>() { plan };
|
#endregion
|
}
|
|
|
private List<IStation.Calculation.DispatchAna.Model.AnaScheme> CalcSchemes扬程(
|
IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras,
|
IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status,
|
out string error_info)
|
{
|
error_info = "";
|
if (complex_request_paras == null)
|
{
|
error_info = "ERROR 30";
|
return null;
|
}
|
if (complex_request_paras.OutletPipePara == null ||
|
complex_request_paras.OutletPipePara.Count < 2)
|
{
|
error_info = "ERROR 35,松浦大桥需要两个管路的流量";
|
return null;
|
}
|
|
if (complex_request_paras == null)
|
{
|
error_info = "ERROR 30";
|
return null;
|
}
|
if (complex_request_paras.OutletPipePara == null ||
|
complex_request_paras.OutletPipePara.Count < 2)
|
{
|
error_info = "ERROR 35,松浦大桥需要两个出口管路的流量";
|
return null;
|
}
|
if (complex_request_paras.InletPipePara == null ||
|
complex_request_paras.InletPipePara.Count < 4)
|
{
|
error_info = "ERROR 35,松浦大桥需要4个进水液位参数";
|
return null;
|
}
|
double inlet_wl1 = complex_request_paras.InletPipePara[0].Value;
|
double inlet_wl2 = complex_request_paras.InletPipePara[1].Value;
|
double inlet_wl3 = complex_request_paras.InletPipePara[2].Value;
|
double inlet_wl4 = complex_request_paras.InletPipePara[3].Value;
|
|
|
double pipe1_TargetFlow = complex_request_paras.OutletPipePara[0].TargetFlow;
|
double pipe2_TargetFlow = complex_request_paras.OutletPipePara[1].TargetFlow;
|
if (pipe1_TargetFlow < 50 && pipe2_TargetFlow < 50)
|
{//都关机
|
error_info = "ERROR 35,松浦大桥需要两个管路的流量都为0";
|
return null;
|
}
|
|
double pipe1_TargetHead = complex_request_paras.OutletPipePara[0].TargetPress;
|
double pipe2_TargetHead = complex_request_paras.OutletPipePara[1].TargetPress;
|
|
if (pipe1_TargetHead < 0)
|
{
|
error_info = "ERROR 35,松浦大桥需要东调压池液位1未赋值";
|
return default;
|
}
|
|
if (pipe2_TargetHead < 0)
|
{
|
error_info = "ERROR 35,松浦大桥需要西调压池液位未赋值";
|
return default;
|
}
|
|
|
|
|
//机泵信息
|
if (_allMachineList == null)
|
{
|
if (!BuildMachineList(
|
out _allMachineList,
|
out error_info))
|
{
|
error_info = "机泵组无法构建,ERROR 70,错误信息:" + error_info;
|
return null;
|
}
|
}
|
|
|
|
|
#region 中间阀门关的状态下
|
|
|
|
Common.DispatchAnaGeneralHelper扬程 calc_pipe1_helper =
|
new Common.DispatchAnaGeneralHelper扬程();
|
|
Common.DispatchAnaGeneralHelper扬程 calc_pipe2_helper =
|
new Common.DispatchAnaGeneralHelper扬程();
|
|
if (pipe2_TargetFlow < 50)
|
{//只开一号泵二号泵
|
calc_pipe1_helper.InitialParas(
|
pipe1_TargetFlow,
|
pipe1_TargetHead,
|
null, null,
|
(from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter);
|
|
return calc_pipe1_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
}
|
else if (pipe1_TargetFlow < 50)
|
{
|
calc_pipe2_helper.InitialParas(
|
pipe2_TargetFlow,
|
pipe2_TargetHead,
|
null, null,
|
(from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter);
|
|
return calc_pipe2_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
}
|
calc_pipe1_helper.InitialParas(
|
pipe1_TargetFlow,
|
pipe1_TargetHead,
|
null, null,
|
(from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter);
|
var pipe1_results = calc_pipe1_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
|
|
calc_pipe2_helper.InitialParas(
|
pipe2_TargetFlow,
|
pipe2_TargetHead,
|
null, null,
|
(from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(),
|
machine_run_status == null ? null : machine_run_status.MachineRunFilter);
|
|
var pipe2_results = calc_pipe2_helper.CalcOptList(complex_request_paras.SchemeSortType, 3);
|
|
if (pipe1_results == null || pipe2_results == null)
|
return default;
|
|
var result_pipe1 = pipe1_results.First();
|
var result_pipe2 = pipe2_results.First();
|
|
var plan = new Model.AnaScheme();
|
plan.ID = 1;
|
|
plan.TotalWrkQ = result_pipe1.TotalWrkQ + result_pipe2.TotalWrkQ;
|
plan.TotalWrkH = (result_pipe1.TotalWrkH + result_pipe2.TotalWrkH) / 2;
|
plan.TotalWrkP = result_pipe1.TotalWrkP + result_pipe2.TotalWrkP;
|
plan.TotalWrkE = CalcConnectPipeEta(new List<AnaScheme>() { result_pipe1, result_pipe2 });
|
plan.UWP = CalculateUWP(plan.TotalWrkP, plan.TotalWrkQ, plan.TotalWrkH);
|
plan.WP = CalculateWP(plan.TotalWrkP, plan.TotalWrkQ);
|
|
plan.Items = new List<Model.AnaSchemeItem>();
|
if (result_pipe1.Items != null && result_pipe1.Items.Count > 0)
|
plan.Items.AddRange(result_pipe1.Items);
|
if (result_pipe2.Items != null && result_pipe2.Items.Count > 0)
|
plan.Items.AddRange(result_pipe2.Items);
|
|
|
return new List<Model.AnaScheme>() { plan };
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
|
}
|
}
|