using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Calculation.DispatchAna.@base
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class CalculatorBase : IDispatchAnalyCalculator
|
{
|
/// <summary>
|
/// 公司ID
|
/// </summary>
|
protected long _corpID = 0;
|
|
/// <summary>
|
/// 泵站ID
|
/// </summary>
|
protected long _stationID = 0;
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="CorpID"></param>
|
/// <param name="StationID"></param>
|
public virtual void SetBaseInfo(long CorpID, long StationID)
|
{
|
_corpID = CorpID;
|
_stationID = StationID;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public virtual Model.CurrentRecordBundle GetCurrentRecord(
|
out string error_info)
|
{
|
error_info = "未实例化GetCurrentRecord";
|
return null;
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="machine_run_status"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public virtual List<Model.AnaScheme> CalcOptListByRealTime(
|
Model.RequestParasComplex complex_request_paras,
|
Model.MachineRunPara machine_run_status,
|
out string error_info)
|
{
|
error_info = "未实例化CalcOptListByRealTime";
|
return null;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="machine_run_status"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public virtual List<Model.AnaScheme> CalcOptListByWhole(
|
Model.RequestParasComplex complex_request_paras,
|
Model.MachineRunPara machine_run_status,
|
out string error_info)
|
{
|
return CalcOptListCore(complex_request_paras, machine_run_status, out error_info);
|
}
|
/// <summary>
|
/// 计算(最优)
|
/// </summary>
|
public virtual List<Model.AnaScheme> CalcOptListCore(
|
Model.RequestParasComplex complex_request_paras,
|
Model.MachineRunPara runParas,
|
out string error_info)
|
{
|
error_info = "未实现CalcOptListCore!Error:21";
|
return null;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="open_machine_ids"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public virtual Model.AnaScheme CalcKeepStatusByWhole(
|
Model.RequestParasComplex complex_request_paras,
|
List<long> open_machine_ids,
|
out string error_info)
|
{
|
return CalcKeepStatusCore(complex_request_paras, open_machine_ids, out error_info);
|
}
|
|
/// <summary>
|
/// 计算保持当前开机状态
|
/// </summary>
|
/// <param name="complex_request_paras"></param>
|
/// <param name="open_machine_ids"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
protected virtual Model.AnaScheme CalcKeepStatusCore(
|
Model.RequestParasComplex complex_request_paras,
|
List<long> open_machine_ids,
|
out string error_info)
|
{
|
error_info = "未实现!Error:34";
|
return null;
|
}
|
|
/// <summary>
|
/// 初始化机泵列表
|
/// </summary>
|
/// <param name="allMachineList"></param>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
protected bool BuildMachineList(
|
out List<Model.MachineDetail> allMachineList,
|
out string error_info)
|
{
|
if (_corpID <= 0)
|
{
|
allMachineList = null;
|
error_info = "_corpID未赋值";
|
return false;
|
}
|
if (_stationID <= 0)
|
{
|
allMachineList = null;
|
error_info = "_stationID未赋值";
|
return false;
|
}
|
allMachineList = null;
|
Service.Product service_product = new Service.Product();
|
Service.PumpCurve service_curve = new Service.PumpCurve();
|
|
var allEnginePumpList = service_product.GetEnginePumpListByBelongTypeAndBelongID(
|
_corpID,
|
ObjectType.Station,
|
_stationID); //获取机泵列表
|
if (allEnginePumpList == null || allEnginePumpList.Count() == 0)
|
{
|
error_info = "未配置机泵";
|
return false;
|
}
|
|
//var allPumpList = service_product.GetChildPumpByID(this._stationID);
|
|
allMachineList = new List<Model.MachineDetail>();
|
|
allEnginePumpList = allEnginePumpList.OrderBy(x => x.SortCode).ToList();
|
foreach (var engine in allEnginePumpList)
|
{
|
IStation.Model.Product<IStation.Model.Pump> pump = service_product.GetChildPumpByEnginePumpID(
|
_corpID, engine.ID);
|
if (pump == null)
|
{
|
error_info = string.Format("机泵ID:{0},未配备泵信息", engine.ID);
|
return false;
|
}
|
|
|
var curve_default = service_curve.GetWorkingByPumpID(_corpID, pump.ID);
|
if (curve_default == null)
|
{
|
error_info = string.Format("机泵ID:{0},泵{1},未配备泵曲线信息", engine.ID, pump.ID);
|
return false;
|
}
|
if (curve_default.CurveInfo == null)
|
{
|
error_info = string.Format("机泵ID:{0},泵{1},未配备泵曲线信息", engine.ID, pump.ID);
|
return false;
|
}
|
//var motor = service_product.GetChildMotorProductByID(machine.ID);
|
//if (motor == null)
|
// continue;
|
Model.MachineDetail machine_detail =
|
new Model.MachineDetail(engine, pump, curve_default);
|
|
allMachineList.Add(machine_detail);
|
}
|
|
error_info = null;
|
return true;
|
}
|
|
|
#region 计算能耗
|
|
/// <summary>
|
/// 计算千吨能耗
|
/// </summary>
|
/// <param name="p">功率kW</param>
|
/// <param name="q">瞬时流量m³/h</param>
|
/// <returns>kW·h/km³</returns>
|
public static double CalculateWP(double p, double q)
|
{
|
if (q < 0.1)
|
return 0;
|
return p / q * 1000;
|
}
|
|
/// <summary>
|
/// 计算单位能耗
|
/// </summary>
|
/// <param name="p">功率kW</param>
|
/// <param name="q">瞬时流量m³/h</param>
|
/// <param name="h">扬程m</param>
|
/// <returns>kW·h/km³</returns>
|
public static double CalculateUWP(double p, double q, double h)
|
{
|
if (q < 0.1)
|
return default;
|
if (h < 0.1)
|
return default;
|
return p / q / h * 1000;
|
}
|
|
#endregion
|
|
}
|
}
|