tangxu
2022-10-31 8ea88fedd51e4961d0fd0aec6c2873a579fb6db8
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Calculation.DispatchAna
{
    /// <summary>
    /// 陈行二输泵站调度方案计算器
    /// </summary>
    internal class Calculator_KeepStatus_SHYS_陈行二输 : CalculatorBase_SHYS_陈行二输, IKeepStatusCalc
    {
        public Calculator_KeepStatus_SHYS_陈行二输()
        {
 
        }
        Model.RequestParasComplex _request_paras;
        List<long> _open_machine_IdList ;
 
        List<Model.MachineDetail> _allMachineList = null;
        /// <summary>
        /// 初始化参数
        /// </summary>
        /// <param name="complex_request_paras"></param>
        /// <param name="eta_ana_records"></param>
        /// <param name="open_machine_ids"></param>
        public  void IntialRequest(
            IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras,
            IStation.Calculation.DispatchAna.Model.EtaAnaRecord4Station eta_ana_records,
            List<long> open_machine_ids)
        {
            this._request_paras = complex_request_paras;
            this._open_machine_IdList = open_machine_ids;
        }
 
 
 
 
        /// <summary>
        /// 计算保持当前开机状态
        /// </summary> 
        /// <param name="error_info">错误信息</param>
        /// <returns></returns>
        public Model.AnaScheme Calc(out string error_info)
        {
            if (_open_machine_IdList == null || _open_machine_IdList.Count == 0)
            {
                error_info = "ERROR 25";
                return null;
            }
            error_info = null;
            if (_request_paras == null)
            {
                error_info = "ERROR 30";
                return null;
            }
 
            if (_request_paras.OutletPipePara == null || _request_paras.OutletPipePara.Count < 2)
            {
                error_info = "ERROR 35";
                return null;
            }
            double pipe1_TargetFlow = _request_paras.OutletPipePara[0].TargetFlow;
            double pipe2_TargetFlow = _request_paras.OutletPipePara[1].TargetFlow;
            if (pipe1_TargetFlow < 10 && pipe2_TargetFlow < 10)
            {
                return default;
            }
 
            double pipe1_TargetPess = _request_paras.OutletPipePara[0].TargetPress;
            double pipe2_TargetPess = _request_paras.OutletPipePara[1].TargetPress;
            if (pipe1_TargetFlow > 50)
            {
                if (pipe1_TargetPess < 0.01)
                {
                    error_info = "ERROR 35,陈行二输需要一号管压力未赋值";
                    return default;
                }
            }
            if (pipe2_TargetFlow > 50)
            {
                if (pipe2_TargetPess < 0.01)
                {
                    error_info = "ERROR 35,陈行二输需要二号管压力未赋值";
                    return default;
                }
            }
 
            double water_level = 0;//水位
            if (_request_paras.InletPipePara != null && _request_paras.InletPipePara.Count > 0)
            {
                    water_level = _request_paras.InletPipePara[0].Value;
            }
 
            //机泵信息
            if(_allMachineList == null)
            {
                if (!BuildMachineList(
                    out _allMachineList,
                    out error_info))
                {
                    error_info = "机泵组无法构建,ERROR 70,错误信息:" + error_info;
                    return null;
                }
            }
 
 
 
 
 
            Common.DispatchAnaGeneralHelper压力 calc_pipe1_helper
                = new Common.DispatchAnaGeneralHelper压力();
 
            Common.DispatchAnaGeneralHelper压力 calc_pipe2_helper
                = new Common.DispatchAnaGeneralHelper压力();
 
            if (pipe2_TargetFlow < 30)
            {//只开一号泵二号泵   
                calc_pipe1_helper.InitialParas(
                    pipe1_TargetFlow,
                    water_level, true,
                    pipe1_TargetPess, false,
                    null, null,
                    (from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(), null);
 
                return calc_pipe1_helper.CalcKeepStatus(_open_machine_IdList);
            }
            else if (pipe1_TargetFlow < 30)
            {
                calc_pipe2_helper.InitialParas(
                    pipe2_TargetFlow,
                    water_level,true ,
                    pipe2_TargetPess,false ,
                    null, null,
                    (from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(), null);
 
                return calc_pipe2_helper.CalcKeepStatus(_open_machine_IdList);
            }
 
 
 
 
            calc_pipe1_helper.InitialParas(
                pipe1_TargetFlow,
                water_level, true,
                pipe1_TargetPess, false,
                 null, null,
                (from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(), null);
            var pipe1_result = calc_pipe1_helper.CalcKeepStatus(_open_machine_IdList);
            if (pipe1_result == null)
            {
                error_info = "管路一调度方案无法计算请确认数据是否合理";
                return null;
            }
 
            calc_pipe2_helper.InitialParas(
                pipe2_TargetFlow,
                water_level, true,
                pipe2_TargetPess, true,
                null, null,
                (from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(), null);
 
            var pipe2_result = calc_pipe2_helper.CalcKeepStatus(_open_machine_IdList);
            if (pipe2_result == null)
            {
                error_info = "管路二调度方案无法计算请确认数据是否合理";
                return null;
            }
 
 
 
            var connect_scheme = new Model.AnaScheme();
            connect_scheme.ID = 1;
            connect_scheme.TotalWrkQ = pipe1_result.TotalWrkQ + pipe2_result.TotalWrkQ;
            connect_scheme.TotalWrkH = (pipe1_result.TotalWrkH + pipe2_result.TotalWrkH) / 2;
            connect_scheme.TotalWrkP = pipe1_result.TotalWrkP + pipe2_result.TotalWrkP;
            connect_scheme.TotalWrkE = IStation.Common.PumpParaHelper.CalculateE(connect_scheme.TotalWrkQ, connect_scheme.TotalWrkH, connect_scheme.TotalWrkP);
            connect_scheme.UWP = CalculateUWP(connect_scheme.TotalWrkP, connect_scheme.TotalWrkQ, connect_scheme.TotalWrkH);
            connect_scheme.WP = CalculateWP(connect_scheme.TotalWrkP, connect_scheme.TotalWrkQ);
 
            connect_scheme.Items = new List<Model.AnaSchemeItem>();
            if (pipe1_result.Items != null && pipe1_result.Items.Count > 0)
                connect_scheme.Items.AddRange(pipe1_result.Items);
            if (pipe2_result.Items != null && pipe2_result.Items.Count > 0)
                connect_scheme.Items.AddRange(pipe2_result.Items);
 
 
            return connect_scheme;
 
        }
    }
}