using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace IStation.Calc { internal partial class ErQuCalcBaseHelper { protected double _start_level水库水位; protected bool _isHaveLevelLimit = false; protected double _min_level水库水位 = 0, _max_level水库水位 = 10000; protected List _reservoirDropFlowList = null;//排水流量时间分配(万方) protected List _reservoirMinLimitHours = null; protected List _reservoirMaxLimitHours = null; protected bool Initial水库参数(IStation.CalcModel.AnaRequest anaRequest) { //var list水库面积 = IStation.BLL.ReservoirHelper.GetList(); //if (list水库面积 != null) //{ // _area水库面积 = list水库面积.First().Area; //} this._reservoirDropFlowList = anaRequest.ReservoirDropFlow; this._reservoirMinLimitHours = anaRequest.ReservoirMinLimitHours; this._reservoirMaxLimitHours = anaRequest.ReservoirMaxLimitHours; return true; } /// /// 计算因用水,造成的水位下降 /// private void CalcReservoirTimeData() { if (this._reservoirDropFlowList == null || this._reservoirDropFlowList.Count() == 0) return; var time_count = 60.0 / this._calcSpaceMinute; int last_hour = _calStartTime.Hour; int inx_hour = 0; double flowTotal = 0; int i = 0; double flow_space = _reservoirDropFlowList[0] / time_count; for (var time = _calStartTime; time < this._calEndTime; time = time.AddMinutes(this._calcSpaceMinute)) { if (time.Hour != last_hour) { last_hour = time.Hour; inx_hour++; if (inx_hour > _reservoirDropFlowList.Count) { flow_space = 0; } else { flow_space = _reservoirDropFlowList[inx_hour] / time_count; } } if (time.Minute == 0) { if (_reservoirMinLimitHours != null && _reservoirMinLimitHours[inx_hour] != null) { _timeList[i].ReservoirMinLevel = _reservoirMinLimitHours[inx_hour].Value; } if (_reservoirMaxLimitHours != null && _reservoirMaxLimitHours[inx_hour] != null) { _timeList[i].ReservoirMaxLevel = _reservoirMaxLimitHours[inx_hour].Value; } } flowTotal = flowTotal + flow_space; _timeList[i+1].ReservoirDropFlowTotal = flowTotal * 10000; i++; } if (_reservoirMinLimitHours != null && _reservoirMinLimitHours.Last() != null) { _timeList.Last().ReservoirMinLevel = _reservoirMinLimitHours.Last().Value; } if (_reservoirMaxLimitHours != null && _reservoirMaxLimitHours.Last() != null) { _timeList.Last().ReservoirMaxLevel = _reservoirMaxLimitHours.Last().Value; } } /// /// /// /// /// /// protected double CalcReservoirHeight( int start_time_index, int end_time_index, double in_total_flow, double start_level) { if (start_time_index >= end_time_index) { return start_level; } double out_total_flow = GetReservoirDropFlowTotalByTimeIndex(end_time_index) - GetReservoirDropFlowTotalByTimeIndex(start_time_index); return IStation.AnaGlobalParas.CalcReservoirLevel(start_level, in_total_flow - out_total_flow); } /// /// /// /// /// /// /// protected double CalcReservoirHeight( double out_total_flow, double in_total_flow, double start_level) { return IStation.AnaGlobalParas.CalcReservoirLevel(start_level, in_total_flow - out_total_flow); } /// /// /// /// /// /// protected bool CheckReservoirHeight(double level) { if (level < this._min_level水库水位) return false; if (level > this._max_level水库水位) return false; //if (_reservoirLimitTimeIndexDict == null) // return true; return true; } /// /// /// /// /// protected bool CheckReservoirHeightOnlyOne(RunBlock first_block) { double min_height = _start_level水库水位; min_height = Math.Min(min_height, first_block.ReservoirStartHeight); min_height = Math.Min(min_height, first_block.ReservoirEndHeight); double max_height = _start_level水库水位; max_height = Math.Max(max_height, first_block.ReservoirEndHeight); max_height = Math.Max(max_height, first_block.ReservoirEndHeight); var total_drop_flow = this._timeList.Last().ReservoirDropFlowTotal - this._timeList[first_block.EndIndx].ReservoirDropFlowTotal; var last_heigt = CalcReservoirHeight(total_drop_flow, 0, first_block.ReservoirEndHeight); min_height = Math.Min(min_height, last_heigt); bool isOk_min = false; if (min_height <= this._min_level水库水位) isOk_min = true; bool isOk_max = false; if (max_height >= this._max_level水库水位) isOk_max = true; if (isOk_max && isOk_min) return true; else return false; } /// /// /// /// /// protected bool CheckReservoirHeight (double height1,double height2) { if (Math.Min(height1, height2) > this._min_level水库水位) return false; if (Math.Max(height1, height2) < this._max_level水库水位) return false; return true; } /// /// /// /// /// protected bool CheckReservoirHeight(double height1, double height2, double height3) { if (Min(height1, height2,height3) > this._min_level水库水位) return false; if (Max(height1, height2, height3) < this._max_level水库水位) return false; return true; } /// /// /// /// /// /// /// protected double Min(double v1,double v2,double v3) { double min = Math.Min(v1, v2); min = Math.Min(min,v3); return min; } protected double Max(double v1, double v2, double v3) { double max = Math.Max(v1, v2); max = Math.Max(max, v3); return max; } } }