duheng
2024-03-26 bb006801e4d7fc281e8c1b43ab4b7b83da044ab6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using IStation.Untity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.CalcModel
{
    /// <summary>
    /// 
    /// </summary>
    internal class TimeDataBundle
    {
        protected IStation.CalcModel.eCalcOptType _clacOptType = CalcModel.eCalcOptType.功率;
        public List<IStation.CalcModel.StationTimeData> TimeDatas;
        public List<IStation.CalcModel.PumpCurveInfo> OpenPumpInfos { get; set; }//开泵角标
        public double[,] SpanSumCacheFlow { get; set; }//缓存用:第一个元素是开始,第二元素是结束
        public double[,] SpanSumCachePower { get; set; }//缓存用
        public double[,] SpanSumCacheMoney { get; set; }//缓存用 
        public double[,] SpanSumCacheCompare { get; set; }//缓存用
 
 
        public void CalcSpanCache(IStation.CalcModel.eCalcOptType clacOptType)
        {
            this._clacOptType = clacOptType;
 
            int time_count = this.TimeDatas.Count;
            SpanSumCacheFlow = new double[time_count, time_count];
            SpanSumCachePower = new double[time_count, time_count];
            SpanSumCacheMoney = new double[time_count, time_count];
 
            for (int j = 0; j < time_count; j++)
            {
                for (int k = 0; k < time_count; k++)
                {
                    SpanSumCacheFlow[j, k] = SpanSumCachePower[j, k] = SpanSumCacheMoney[j, k] = 0;//负数表示
                }
            }
            for (int startIndx = 0; startIndx < time_count; startIndx++)
            {
                double flow = TimeDatas[startIndx].SumFlow;
                double power = TimeDatas[startIndx].SumPower;
                double money = TimeDatas[startIndx].SumMoney;
 
                bool isLimitRange = false;
                for (int endIndx = startIndx+1; endIndx < time_count; endIndx++)
                {
                    if(isLimitRange == false)
                    {//只要中间出现,整个区域都不许
                        isLimitRange = TimeDatas[endIndx].SumPower == double.MaxValue ? true : false;
                    }
                    if(isLimitRange)
                    { 
                        SpanSumCacheFlow[startIndx, endIndx] = flow; 
                        SpanSumCachePower[startIndx, endIndx] = double.MaxValue;
                        SpanSumCacheMoney[startIndx, endIndx] = double.MaxValue;
                    }
                    else
                    { 
                        flow += TimeDatas[endIndx].SumFlow;
                        SpanSumCacheFlow[startIndx, endIndx] = flow;
 
         
                        power += TimeDatas[endIndx].SumPower;
                        money += TimeDatas[endIndx].SumMoney;
                        SpanSumCachePower[startIndx, endIndx] = power;
                        SpanSumCacheMoney[startIndx, endIndx] = money;
                    }
                }
 
            }
 
            if (clacOptType == CalcModel.eCalcOptType.功率)
            {
                SpanSumCacheCompare = SpanSumCachePower;
            }
            else
            {
                SpanSumCacheCompare = SpanSumCacheMoney;
            }
        }
 
        public bool GetRangeData1(int startIndx, int endIndx, out double flow, out double compare)
        {
            flow = 0;
            compare = 0;
 
            if (endIndx == 0)
                return false;
            if (endIndx <= startIndx)
                return false;
            flow = SpanSumCacheFlow[startIndx, endIndx - 1];
            compare = SpanSumCacheCompare[startIndx, endIndx - 1];
 
            //if (flow > -0.1) return true;
            //for (int i = startIndx; i < endIndx; i++)
            //{
            //    flow += TimeDatas[i].SumFlow;
            //    compare += TimeDatas[i].SumCompare; 
            //}
            //SpanSumCacheFlow[startIndx, endIndx - 1] = flow;
            //SpanSumCacheCompare[startIndx, endIndx - 1] = compare;
 
            return true;
        }
 
        public bool GetRangeDataStart1(int startIndx,  out double flow, out double compare)
        {
            flow = 0;
            compare = 0;
            int time_count = this.TimeDatas.Count;
 
 
            flow = SpanSumCacheFlow[startIndx, time_count - 1];
            compare = SpanSumCacheCompare[startIndx, time_count - 1];
 
            //if (flow > -0.1) return true;
            //for (int i = startIndx; i < endIndx; i++)
            //{
            //    flow += TimeDatas[i].SumFlow;
            //    compare += TimeDatas[i].SumCompare; 
            //}
            //SpanSumCacheFlow[startIndx, endIndx - 1] = flow;
            //SpanSumCacheCompare[startIndx, endIndx - 1] = compare;
 
            return true;
        }
 
        public bool GetRangeData2(int startIndx, int endIndx, out double flow, out double power, out double money)
        {
            flow = 0;
            power = 0;
            money = 0;
 
            if (endIndx == 0)
                return false;
            if (endIndx <= startIndx)
                return false;
            flow = SpanSumCacheFlow[startIndx, endIndx - 1];
            power = SpanSumCachePower[startIndx, endIndx - 1];
            money = SpanSumCacheMoney[startIndx, endIndx - 1];
            //if (flow > -0.1) return true;
 
 
            //for (int i = startIndx; i < endIndx; i++)
            //{
            //    flow += TimeDatas[i].SumFlow;
            //    power += TimeDatas[i].SumPower;
            //    money += TimeDatas[i].SumMoney;
            //}
            //SpanSumCacheFlow[startIndx, endIndx - 1] = flow;
            //SpanSumCachePower[startIndx, endIndx - 1] = power;
            //SpanSumCacheMoney[startIndx, endIndx - 1] = money;
 
            return true;
        }
    }
}