using IStation.CalcModel;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
|
|
namespace IStation.Calc
|
{
|
internal partial class ErQuCalcBaseHelper
|
{
|
protected int _timeDataListCount = 0;
|
protected List<TimePoint> _timeList;
|
protected double GetReservoirDropFlowTotalByTimeIndex(int time_index)
|
{
|
if (time_index >= _timeDataListCount)
|
return _timeList.Last().ReservoirDropFlowTotal;
|
return _timeList[time_index].ReservoirDropFlowTotal;
|
}
|
internal IStation.CalcModel.TimeDataBundle _timeDataListOpen1;
|
internal IStation.CalcModel.TimeDataBundle _timeDataListOpen2;
|
internal IStation.CalcModel.TimeDataBundle _timeDataListOpen3;
|
internal IStation.CalcModel.TimeDataBundle _timeDataListOpen4;
|
internal IStation.CalcModel.TimeDataBundle GetTimeDataBundle(int PumpCount)
|
{
|
if (PumpCount == 0)
|
{
|
return null;
|
}
|
if (PumpCount == 1)
|
{
|
return _timeDataListOpen1;
|
}
|
if (PumpCount == 2)
|
{
|
return _timeDataListOpen2;
|
}
|
if (PumpCount == 3)
|
{
|
return _timeDataListOpen3;
|
}
|
if (PumpCount == 4)
|
{
|
return _timeDataListOpen4;
|
}
|
return null;
|
}
|
|
|
/// <summary>
|
/// 导出实时数据
|
/// </summary>
|
/// <param name="error_info"></param>
|
/// <returns></returns>
|
public bool ExportTimeData(string file_path, out string error_info)
|
{
|
error_info = null;
|
|
#region 检查数据
|
if (this._calStartTime >= this._calEndTime)
|
{
|
error_info = "时间范围不对";
|
return false;
|
}
|
if (this._allPumpInfo == null || this._allPumpInfo.Count() != 5)
|
{
|
error_info = "泵台数不正确";
|
return false;
|
}
|
if (this._riverWaterLevels == null || this._riverWaterLevels.Count() < 1)
|
{
|
error_info = "长江水位未赋值";
|
return false;
|
}
|
|
if (_listRiverWaterLevelDrop == null)
|
{
|
_listRiverWaterLevelDrop = IStation.AnaGlobalParas.RiverWaterLevelDropList;
|
if (_listRiverWaterLevelDrop == null || _listRiverWaterLevelDrop.Count() == 0)
|
{
|
error_info = "无法读取长江水位与水池落差的关系数据";
|
return false;
|
}
|
}
|
|
#endregion
|
|
|
|
|
//
|
int dd_minute = 0;
|
CalcTimeData(dd_minute);
|
|
|
|
|
StreamWriter streamWriter = new StreamWriter(file_path, false, System.Text.Encoding.GetEncoding("gb2312"));
|
|
StringBuilder StringBuilder = new StringBuilder();
|
// 写出表头
|
StringBuilder.AppendFormat("{0},{1},{2},{3},{4} ",
|
"时间",
|
"1台时前池水位",
|
"1台时水量",
|
"1台时电量",
|
"1台时电费");
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
"2台时前池水位",
|
"2台时水量",
|
"2台时电量",
|
"2台时电费");
|
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
"3台时前池水位",
|
"3台时水量",
|
"3台时电量",
|
"3台时电费");
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
"4台时前池水位",
|
"4台时水量",
|
"4台时电量",
|
"4台时电费");
|
|
// 写出数据
|
for (int i = 0; i < _timeDataListOpen1.TimeDatas.Count; i++)
|
{
|
StringBuilder.AppendLine();
|
StringBuilder.AppendFormat("{0},{1},{2},{3},{4} ",
|
_timeList[i],
|
_timeDataListOpen1.TimeDatas[i].WaterLevelQ,
|
_timeDataListOpen1.TimeDatas[i].SumFlow,
|
_timeDataListOpen1.TimeDatas[i].SumPower,
|
_timeDataListOpen1.TimeDatas[i].SumMoney);
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
_timeDataListOpen2.TimeDatas[i].WaterLevelQ,
|
_timeDataListOpen2.TimeDatas[i].SumFlow,
|
_timeDataListOpen2.TimeDatas[i].SumPower,
|
_timeDataListOpen2.TimeDatas[i].SumMoney);
|
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
_timeDataListOpen3.TimeDatas[i].WaterLevelQ,
|
_timeDataListOpen3.TimeDatas[i].SumFlow,
|
_timeDataListOpen3.TimeDatas[i].SumPower,
|
_timeDataListOpen3.TimeDatas[i].SumMoney);
|
|
StringBuilder.AppendFormat(",{0},{1},{2},{3}",
|
_timeDataListOpen4.TimeDatas[i].WaterLevelQ,
|
_timeDataListOpen4.TimeDatas[i].SumFlow,
|
_timeDataListOpen4.TimeDatas[i].SumPower,
|
_timeDataListOpen4.TimeDatas[i].SumMoney);
|
|
}
|
streamWriter.Write(StringBuilder.ToString());
|
|
streamWriter.Flush();
|
streamWriter.Close();
|
return true;
|
}
|
|
//protected List<int> _defaultOpenPumpIndex1, _defaultOpenPumpIndex2, _defaultOpenPumpIndex3, _defaultOpenPumpIndex4;
|
/// <summary>
|
/// 计算时序数据
|
/// </summary>
|
/// <param name="dd_minute"></param>
|
protected void CalcTimeData(int dd_minute)
|
{
|
//时间段
|
_timeList = new List<TimePoint>();
|
for (var time = _calStartTime; time <= this._calEndTime; time = time.AddMinutes(this._calcSpaceMinute))
|
{
|
var t = new TimePoint(time);
|
t.WaterLevelC = IStation.Calc.ErQuCalcBaseHelper.GetRiverWaterLevelByTime(
|
this._riverWaterLevels, time);
|
|
_timeList.Add(t);
|
}
|
_timeDataListCount = _timeList.Count();
|
|
|
//是否受限
|
if (_limitSwitchPumpTimes != null)
|
{
|
for (int i = 0; i < _timeDataListCount; i++)
|
{
|
var time = _timeList[i].Time;
|
bool isSwitchPump = true;
|
foreach (var s in _limitSwitchPumpTimes)
|
{
|
if (time >= s.Start && time <= s.End)
|
{
|
isSwitchPump = false;
|
break;
|
}
|
}
|
_timeList[i].IsSwitchPumpAble = isSwitchPump;
|
}
|
}
|
|
|
|
|
//
|
CalcReservoirTimeData();
|
|
|
|
|
|
|
|
|
|
//根据同扬程下 流量从大到小的泵 2->5->3->1->4
|
|
_timeDataListOpen4 = new IStation.CalcModel.TimeDataBundle();
|
_timeDataListOpen4.TimeDatas = new List<StationTimeData>(_timeDataListCount);
|
//if(_defaultOpenPumpIndex4 != null && _defaultOpenPumpIndex4.Count() == 4)
|
//{
|
// _timeDataListOpen4.OpenPumpInfos = new List<PumpCurveInfo> {
|
// this._allPumpInfo[_defaultOpenPumpIndex4[0]],
|
// this._allPumpInfo[_defaultOpenPumpIndex4[1]],
|
// this._allPumpInfo[_defaultOpenPumpIndex4[2]],
|
// this._allPumpInfo[_defaultOpenPumpIndex4[3]] };
|
//}
|
//else
|
{
|
_timeDataListOpen4.OpenPumpInfos = new List<IStation.CalcModel.PumpCurveInfo> { this._allPumpInfo[1], this._allPumpInfo[4], this._allPumpInfo[2], this._allPumpInfo[0] };
|
}
|
CalcTimeDataList(dd_minute, ref _timeDataListOpen4);
|
|
|
|
|
_timeDataListOpen3 = new IStation.CalcModel.TimeDataBundle();
|
_timeDataListOpen3.TimeDatas = new List<StationTimeData>(_timeDataListCount);
|
//if (_defaultOpenPumpIndex3 != null && _defaultOpenPumpIndex3.Count() == 3)
|
//{
|
// _timeDataListOpen3.OpenPumpInfos = new List<PumpCurveInfo> {
|
// this._allPumpInfo[_defaultOpenPumpIndex3[0]],
|
// this._allPumpInfo[_defaultOpenPumpIndex3[1]],
|
// this._allPumpInfo[_defaultOpenPumpIndex3[2]] };
|
//}
|
//else
|
{
|
_timeDataListOpen3.OpenPumpInfos = new List<IStation.CalcModel.PumpCurveInfo> { this._allPumpInfo[1], this._allPumpInfo[4], this._allPumpInfo[2] };
|
}
|
CalcTimeDataList(dd_minute, ref _timeDataListOpen3);
|
|
|
|
|
_timeDataListOpen2 = new IStation.CalcModel.TimeDataBundle();
|
_timeDataListOpen2.TimeDatas = new List<StationTimeData>(_timeDataListCount);
|
//if (_defaultOpenPumpIndex2 != null && _defaultOpenPumpIndex2.Count() == 2)
|
//{
|
// _timeDataListOpen2.OpenPumpInfos = new List<PumpCurveInfo> {
|
// this._allPumpInfo[_defaultOpenPumpIndex2[0]],
|
// this._allPumpInfo[_defaultOpenPumpIndex2[1]] };
|
//}
|
//else
|
{
|
_timeDataListOpen2.OpenPumpInfos = new List<IStation.CalcModel.PumpCurveInfo> { this._allPumpInfo[1], this._allPumpInfo[4] };
|
}
|
CalcTimeDataList(dd_minute, ref _timeDataListOpen2);
|
|
|
|
|
_timeDataListOpen1 = new IStation.CalcModel.TimeDataBundle();
|
_timeDataListOpen1.TimeDatas = new List<StationTimeData>(_timeDataListCount);
|
//if (_defaultOpenPumpIndex1 != null && _defaultOpenPumpIndex1.Count() == 1)
|
//{
|
// _timeDataListOpen1.OpenPumpInfos = new List<PumpCurveInfo> {
|
// this._allPumpInfo[_defaultOpenPumpIndex1[0]] };
|
//}
|
//else
|
{
|
_timeDataListOpen1.OpenPumpInfos = new List<IStation.CalcModel.PumpCurveInfo> { this._allPumpInfo[1] };
|
}
|
|
CalcTimeDataList(dd_minute, ref _timeDataListOpen1);
|
}
|
|
internal void CalcTimeDataList(int dd_minute, ref IStation.CalcModel.TimeDataBundle timeDataList)
|
{
|
if (timeDataList.TimeDatas == null)
|
timeDataList.TimeDatas = new List<StationTimeData>(_timeDataListCount);
|
|
int openPumpCount = timeDataList.OpenPumpInfos.Count;
|
double dropHeight1 = GetDropHeightByPumpCount(openPumpCount);
|
|
//timeData.PumpDatas = new List<TimeData.PumpData>(timeDataList.OpenPumpInfos.Count());
|
bool isLimitOpenPumpTime = false;
|
if (_limitOpenPumpTimes != null && _limitOpenPumpTimes.Count > 0)
|
{
|
isLimitOpenPumpTime = true;
|
}
|
|
for (int t = 0; t < _timeDataListCount; t++)
|
{
|
StationTimeData timeData = new StationTimeData();
|
timeData.PumpDatas = new List<PumpTimeData>(5);
|
for (int pu = 0; pu < 5; pu++)
|
{
|
timeData.PumpDatas.Add(new PumpTimeData());
|
}
|
|
|
var time = this._timeList[t].Time;
|
var m2 = CalcPumpOutletPressM(time);
|
var riverWaterLevel = GetRiverWaterLevelByTime(time);//长江水位
|
double dropHeight前池 = dropHeight1;
|
double head4Drop = 0;//扬程
|
for (int i = 0; i < 3; i++)
|
{
|
head4Drop = m2 - (riverWaterLevel - dropHeight前池);
|
//不断迭代 计算扬程, 因为流量变量会造成吸水高度差变化, 从而造成扬程有变化
|
double totalFlow4drop = 0;
|
foreach (var pump_curve in timeDataList.OpenPumpInfos)
|
{
|
var grpPt = pump_curve.GetPointByH(head4Drop);
|
if (grpPt == null)
|
{
|
throw new Exception("出现特殊情况,未考虑!");
|
}
|
totalFlow4drop += grpPt.Q;
|
}
|
|
dropHeight前池 = GetDropHeightByFlow(totalFlow4drop);
|
}
|
|
|
|
|
|
|
|
double realHead = head4Drop;
|
double totalFlow = 0;
|
double totalPower = 0;
|
foreach (var pump_curve in timeDataList.OpenPumpInfos)
|
{
|
var indx = pump_curve.PumpIndex;
|
|
var pumpData = timeData.PumpDatas[indx];
|
|
pumpData.Head = realHead;
|
var grpPt2 = pump_curve.GetPointByH(realHead);
|
if (grpPt2 == null)
|
{
|
throw new Exception("出现特殊情况,未考虑!");
|
}
|
pumpData.Flow = grpPt2.Q;
|
pumpData.Power = grpPt2.P;
|
pumpData.SumFlow = Math.Round(pumpData.Flow * this._calcSpaceMinute / 60, 1);
|
pumpData.SumPower = Math.Round(pumpData.Power * this._calcSpaceMinute / 60, 1);
|
pumpData.SumMoney = Math.Round(CalcMoney(time, pumpData.Power) * this._calcSpaceMinute / 60, 1);
|
|
|
totalFlow += grpPt2.Q;
|
totalPower += grpPt2.P;
|
}
|
|
timeData.WaterLevelQ = riverWaterLevel - dropHeight前池;
|
|
|
timeData.Head = realHead;
|
timeData.Flow = Math.Round(totalFlow, 1);
|
timeData.Power = Math.Round(totalPower, 1);
|
|
timeData.SumFlow = Math.Round(totalFlow * this._calcSpaceMinute / 60, 1);
|
timeData.SumPower = Math.Round(totalPower * this._calcSpaceMinute / 60, 1);
|
timeData.SumMoney = Math.Round(CalcMoney(time, totalPower) * this._calcSpaceMinute / 60, 1);
|
|
if (isLimitOpenPumpTime)
|
{
|
foreach (var lt in _limitOpenPumpTimes)
|
{
|
if (time >= lt.Start && time < lt.End)
|
{
|
timeData.Power = double.MaxValue;
|
timeData.SumFlow = 0;
|
timeData.SumPower = double.MaxValue;
|
timeData.SumMoney = double.MaxValue;
|
}
|
}
|
}
|
|
timeDataList.TimeDatas.Add(timeData);
|
}
|
|
//缓存用
|
// timeDataList.InitialSpanCache( );
|
timeDataList.CalcSpanCache(this._clacOptType);
|
}
|
}
|
}
|