ningshuxia
2024-05-06 8f6d2b48f22b695574bd4a6c4ac91b1ac9f780b1
Schedule/IStation.Client/Form1.cs
@@ -10,13 +10,33 @@
            {
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            };
            this.cmbStation.SelectedIndex = 0;
        }
        int _stationIndex = 0;
        string _floder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");
        private void cmbStation_SelectedIndexChanged(object sender, EventArgs e)
        {
            _stationIndex = cmbStation.SelectedIndex;
            if (_stationIndex == 0)
            {
                this.txtFlow.Text = "16406";
                this.txtHead.Text = "15.92";
                this.txtCurrentOpen.Text = "11,12,13,17";
            }
            else
            {
                this.txtFlow.Text = "39,460";
                this.txtHead.Text = "19.65";
                this.txtCurrentOpen.Text = "22,23,25,26";
            }
        }
        private void btnAnaCombine_Click(object sender, EventArgs e)
        {
            this.richTextBox1.Text += "\r\n正在分析泵组合";
            this.txtInfo.Text += "\r\n正在分析泵组合";
            var ch1 = _floder + "\\" + "陈行一输.json";
            var ch1_json = File.ReadAllText(ch1);
            var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
@@ -31,31 +51,27 @@
                helper.AnaCombine(ch1Pumps);
                this.Invoke(() =>
                {
                    this.richTextBox1.Text += "\r\n分析泵组合完毕";
                    this.txtInfo.Text += "\r\n分析泵组合完毕";
                });
            });
        }
        private void btnAnaCh1Combine_Click(object sender, EventArgs e)
        {
            var ch1 = _floder + "\\" + "陈行一输.json";
            var ch1_json = File.ReadAllText(ch1);
            var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
            this.richTextBox1.Text += "\r\n正在分析1输水泵组合";
            this.txtInfo.Text += "\r\n正在分析1输水泵组合";
            Task.Run(() =>
            {
                var helper = new Algorithm.SchedulingAnaHelper();
                helper.AnaCombine(ch1Pumps);
                this.Invoke(() =>
                {
                    this.richTextBox1.Text += "\r\n分析1输水泵组合完毕";
                    this.txtInfo.Text += "\r\n分析1输水泵组合完毕";
                });
            });
        }
        private void btnAnaCh2Combine_Click(object sender, EventArgs e)
        {
@@ -63,35 +79,35 @@
            var ch2_json = File.ReadAllText(ch2);
            var ch2Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch2_json);
            this.richTextBox1.Text += "\r\n正在分析2输水泵组合";
            this.txtInfo.Text += "\r\n正在分析2输水泵组合";
            Task.Run(() =>
            {
                var helper = new Algorithm.SchedulingAnaHelper();
                helper.AnaCombine(ch2Pumps);
                this.Invoke(() =>
                {
                    this.richTextBox1.Text += "\r\n分析2输水泵组合完毕";
                    this.txtInfo.Text += "\r\n分析2输水泵组合完毕";
                });
            });
        }
        private void btnAnaChConclusion_Click(object sender, EventArgs e)
        {
            this.richTextBox1.Text += "\r\n正在分析全部泵组合结论";
            this.txtInfo.Text += "\r\n正在分析全部泵组合结论";
            Task.Run(() =>
            {
                var helper = new Algorithm.SchedulingAnaHelper();
                helper.AnaConclusion();
                this.Invoke(() =>
                {
                    this.richTextBox1.Text += "\r\n全部泵组合分析完毕";
                    this.txtInfo.Text += "\r\n全部泵组合分析完毕";
                });
            });
        }
        private void btnAna_Click(object sender, EventArgs e)
        {
            this.txtInfo.Text = string.Empty;
            if (!double.TryParse(this.txtFlow.Text, out double targetFlow))
            {
                MessageBox.Show("请输入流量!");
@@ -102,24 +118,69 @@
                MessageBox.Show("请输入压力!");
                return;
            }
            var combine = this.txtOpenCombineList.Text.Trim();
            if (string.IsNullOrEmpty(combine))
            List<int> current_open_pump_list = new List<int>();
            List<int> must_open_pump_list = new List<int>();
            List<int> must_not_open_pump_list = new List<int>();
            var current_open_pump_list_txt = this.txtCurrentOpen.Text.Trim();
            if (!string.IsNullOrEmpty(current_open_pump_list_txt))
            {
                MessageBox.Show("请输入泵组合!");
                return;
                current_open_pump_list = IntListHelper.ToList(current_open_pump_list_txt);
                if (current_open_pump_list == null || current_open_pump_list.Count < 1)
                {
                    MessageBox.Show("请输入有效泵组合!\r\n','号间隔!");
                    return;
                }
            }
            var combineList = IntListHelper.ToList(combine);
            if (combineList == null || combineList.Count < 1)
            var must_open_pump_list_txt = this.txtMustOpen.Text.Trim();
            if (!string.IsNullOrEmpty(must_open_pump_list_txt))
            {
                MessageBox.Show("请输入有效泵组合!\r\n','号间隔!");
                return;
                must_open_pump_list = IntListHelper.ToList(must_open_pump_list_txt);
                if (must_open_pump_list == null || must_open_pump_list.Count < 1)
                {
                    MessageBox.Show("请输入有效泵组合!\r\n','号间隔!");
                    return;
                }
            }
            var ch1 = _floder + "\\" + "陈行一输.json";
            var ch1_json = File.ReadAllText(ch1);
            var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
            var must_not_open_pump_list_txt = this.txtMustNotOpen.Text.Trim();
            if (!string.IsNullOrEmpty(must_not_open_pump_list_txt))
            {
                must_not_open_pump_list = IntListHelper.ToList(must_not_open_pump_list_txt);
                if (must_not_open_pump_list == null || must_not_open_pump_list.Count < 1)
                {
                    MessageBox.Show("请输入有效泵组合!\r\n','号间隔!");
                    return;
                }
            }
            List<Model.Pump> pumps;
            List<int> flags_part1, flags_part2;
            if (_stationIndex == 0)
            {
                var filePath = _floder + "\\" + "陈行一输.json";
                var jsonInfo = File.ReadAllText(filePath);
                pumps = JsonHelper.Json2Object<List<Model.Pump>>(jsonInfo);
                flags_part1 = new List<int>() { 11, 12, 13, 14, 16, 17, 18 };
                flags_part2 = new List<int>() { 15 };
            }
            else
            {
                var filePath = _floder + "\\" + "陈行二输.json";
                var jsonInfo = File.ReadAllText(filePath);
                pumps = JsonHelper.Json2Object<List<Model.Pump>>(jsonInfo);
                flags_part1 = new List<int>() { 22, 23, 24, 25, 26 };
                flags_part2 = new List<int>() { 21, 27 };
            }
            var helper = new Algorithm.SchedulingHelper();
            helper.Ana(ch1Pumps, targetFlow, targetHead);
            var info = helper.Ana(pumps, flags_part1, flags_part2, targetFlow, targetHead, current_open_pump_list, must_open_pump_list, must_not_open_pump_list);
            this.txtInfo.Text = info;
        }
    }
}