using IStation.CalcModel;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
|
namespace IStation.Calc
|
{
|
internal partial class ErQuCalcHelper_2_递归 : ErQuCalcBaseHelper
|
{
|
class BlockItemList
|
{
|
public List<RunBlock> Items { get; set; }
|
public double TotalCompare;//功率或者电费(合计)
|
public double TotalFlow;
|
}
|
|
|
|
|
protected override List<AnaPrj> CalcOptPrjsCore()
|
{
|
_minTimeCountOpenPump = this.MinOpenPumpMinute / this.CalcSpaceMinute;
|
_minTimeCountSwitch = this.MinSwitchPumpMinute / this.CalcSpaceMinute;
|
//this._maxPumpSwitchCount = 5;
|
|
if (_isHaveLevelLimit)
|
{
|
var result = CalcOptPrjsCore控制水位();
|
if (result == null)
|
return null;
|
return ToAnaPrj(result);
|
}
|
else
|
{
|
var result = CalcOptPrjsCore只考虑总流量();
|
if (result == null)
|
return null;
|
return ToAnaPrj(result);
|
}
|
|
|
|
|
|
|
//AnaPrj opt_prj = new AnaPrj();
|
//opt_prj.BlockTimes = new List<AnaPrjBlockTime>();
|
//opt_prj.PointTimes = new List<AnaPrjPointTime>();
|
//opt_prj.ID = Guid.NewGuid().ToString("N");
|
//opt_prj.StartTime = this._calStartTime;
|
//opt_prj.EndTime = this._calEndTime;
|
|
//double sumPower = 0, sumFlow = 0, sumMoney = 0;
|
//foreach (var s in from x in result.Items orderby x.StartIndx select x)
|
//{
|
// if (s.PumpCount == 0)
|
// {
|
// var itemSumDatas = new List<AnaPrjPointTime>();
|
// for (int i = s.StartIndx; i < s.EndIndx; i++)
|
// {
|
// itemSumDatas.Add(new AnaPrjPointTime(_timeList[i]));
|
// }
|
|
// opt_prj.BlockTimes.Add(new AnaPrjBlockTime()
|
// {
|
// StartTime = _timeList[s.StartIndx].Time,
|
// EndTime = _timeList[s.EndIndx].Time,
|
// OpenPumpCount = 0,
|
// //SumData = itemSumDatas
|
// });
|
// }
|
// else
|
// {
|
// var itemSumDatas = new List<AnaPrjPointTime>();
|
// var td = GetTimeDataBundle(s.PumpCount);
|
|
// for (int i = s.StartIndx; i < s.EndIndx; i++)
|
// {
|
// itemSumDatas.Add(new AnaPrjPointTime(_timeList[i],
|
// td.TimeDatas[i], s.PumpCount));
|
// sumPower += td.TimeDatas[i].SumPower;
|
// sumFlow += td.TimeDatas[i].SumFlow;
|
// sumMoney += td.TimeDatas[i].SumMoney;
|
// }
|
|
// opt_prj.BlockTimes.Add(new AnaPrjBlockTime()
|
// {
|
// StartTime = _timeList[s.StartIndx].Time,
|
// EndTime = _timeList[s.EndIndx].Time,
|
// OpenPumpCount = td.OpenPumpInfos.Count,
|
// //SumData = itemSumDatas
|
// });
|
// }
|
//}
|
//if (double.IsNaN(sumMoney) || double.IsInfinity(sumMoney) || sumMoney == double.MaxValue)
|
// return null;
|
//if (double.IsNaN(sumPower) || double.IsInfinity(sumPower) || sumPower == double.MaxValue)
|
// return null;
|
//opt_prj.SumMoney = sumMoney;
|
//opt_prj.SumFlow = sumFlow;
|
//opt_prj.SumPower = sumPower;
|
|
|
//OnShowDebugInfo.Invoke(string.Format("计算次数:{0:N0}, 缓存使用次数:{1:N0}", this._totalCalcCount, this._totalCacheCount));
|
|
|
//var opt_prjs = new List<AnaPrj>();
|
//opt_prjs.Add(opt_prj);
|
//return opt_prjs;
|
}
|
private List<AnaPrj> ToAnaPrj(BlockItemList opt_bundle)
|
{
|
AnaPrj opt_prj = new AnaPrj();
|
opt_prj.ID = Guid.NewGuid().ToString("N");
|
opt_prj.StartTime = this._calStartTime;
|
opt_prj.EndTime = this._calEndTime;
|
opt_prj.BlockTimes = new List<AnaPrjBlockTime>();
|
opt_prj.PointTimes = new List<AnaPrjPointTime>();
|
opt_prj.CalcSpaceMinute = this.CalcSpaceMinute;
|
|
var items = (from x in opt_bundle.Items orderby x.StartIndx select x).ToArray();
|
int item_count = items.Count();
|
for (int k = 0; k < item_count; k++)
|
{
|
var item = items[k];
|
|
double sumPower_item = 0, sumFlow_item = 0, sumMoney_item = 0;
|
var block_time = new AnaPrjBlockTime();
|
block_time.StartTime = _timeList[item.StartIndx].Time;
|
block_time.EndTime = _timeList[item.EndIndx].Time;
|
block_time.OpenPumpCount = item.PumpCount;
|
|
int last_index = item.EndIndx;
|
//if (k == item_count - 1)
|
// last_index = item.EndIndx + 1;
|
int start_indx = item.StartIndx ;
|
|
|
if (item.PumpCount == 0)
|
{
|
for (int i = start_indx; i < last_index; i++)
|
{
|
var si = new AnaPrjPointTime(_timeList[i]);
|
//si.WaterLevelH = CalcReservoirHeight(_timeList[i].ReservoirDropFlowTotal, 0,
|
// item.ReservoirStartHeight);
|
si.WaterLevelH = Math.Round(
|
item.ReservoirStartHeight +
|
(item.StartIndx - i) * (-item.ReservoirStartHeight + item.ReservoirEndHeight) / (item.StartIndx - item.EndIndx), 4);
|
|
opt_prj.PointTimes.Add(si);
|
}
|
}
|
else
|
{
|
var td = GetTimeDataBundle(item.PumpCount);
|
|
for (int i = start_indx; i < last_index; i++)
|
{
|
var si = new AnaPrjPointTime(_timeList[i], td.TimeDatas[i], item.PumpCount);
|
si.WaterLevelH = Math.Round(
|
item.ReservoirStartHeight +
|
(item.StartIndx - i) * (-item.ReservoirStartHeight + item.ReservoirEndHeight) / (item.StartIndx - item.EndIndx), 4);
|
|
sumPower_item += td.TimeDatas[i].SumPower;
|
sumFlow_item += td.TimeDatas[i].SumFlow;
|
sumMoney_item += td.TimeDatas[i].SumMoney;
|
|
opt_prj.PointTimes.Add(si);
|
}
|
}
|
|
block_time.SumPower = sumPower_item;
|
block_time.SumFlow = sumFlow_item;
|
block_time.SumMoney = sumMoney_item;
|
|
opt_prj.BlockTimes.Add(block_time);
|
}
|
|
double sumPower = 0, sumFlow = 0, sumMoney = 0;
|
foreach (var item in opt_prj.BlockTimes)
|
{
|
sumPower += item.SumPower;
|
sumFlow += item.SumFlow;
|
sumMoney += item.SumMoney;
|
}
|
if (double.IsNaN(sumMoney) || double.IsInfinity(sumMoney) || sumMoney == double.MaxValue)
|
return null;
|
if (double.IsNaN(sumPower) || double.IsInfinity(sumPower) || sumPower == double.MaxValue)
|
return null;
|
opt_prj.SumMoney = sumMoney;
|
opt_prj.SumFlow = sumFlow;
|
opt_prj.SumPower = sumPower;
|
|
|
OnShowDebugInfo.Invoke(string.Format("计算次数:{0:N0}, 缓存使用次数:{1:N0}", this._totalCalcCount, this._totalCacheCount));
|
|
|
var opt_prjs = new List<AnaPrj>();
|
opt_prjs.Add(opt_prj);
|
return opt_prjs;
|
}
|
|
}
|
}
|