namespace IStation.Client
|
{
|
public partial class Form1 : Form
|
{
|
public Form1()
|
{
|
InitializeComponent();
|
|
this.FormClosed += (sender, e) =>
|
{
|
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.txtInfo.Text += "\r\nÕýÔÚ·ÖÎö±Ã×éºÏ";
|
var ch1 = _floder + "\\" + "³ÂÐÐÒ»Êä.json";
|
var ch1_json = File.ReadAllText(ch1);
|
var ch1Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch1_json);
|
|
var ch2 = _floder + "\\" + "³ÂÐжþÊä.json";
|
var ch2_json = File.ReadAllText(ch2);
|
var ch2Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch2_json);
|
|
Task.Run(() =>
|
{
|
var helper = new Algorithm.SchedulingAnaHelper();
|
helper.AnaCombine(ch1Pumps);
|
this.Invoke(() =>
|
{
|
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.txtInfo.Text += "\r\nÕýÔÚ·ÖÎö1ÊäË®±Ã×éºÏ";
|
Task.Run(() =>
|
{
|
var helper = new Algorithm.SchedulingAnaHelper();
|
helper.AnaCombine(ch1Pumps);
|
this.Invoke(() =>
|
{
|
this.txtInfo.Text += "\r\n·ÖÎö1ÊäË®±Ã×éºÏÍê±Ï";
|
});
|
});
|
}
|
|
private void btnAnaCh2Combine_Click(object sender, EventArgs e)
|
{
|
var ch2 = _floder + "\\" + "³ÂÐжþÊä.json";
|
var ch2_json = File.ReadAllText(ch2);
|
var ch2Pumps = JsonHelper.Json2Object<List<Model.Pump>>(ch2_json);
|
|
this.txtInfo.Text += "\r\nÕýÔÚ·ÖÎö2ÊäË®±Ã×éºÏ";
|
Task.Run(() =>
|
{
|
var helper = new Algorithm.SchedulingAnaHelper();
|
helper.AnaCombine(ch2Pumps);
|
this.Invoke(() =>
|
{
|
this.txtInfo.Text += "\r\n·ÖÎö2ÊäË®±Ã×éºÏÍê±Ï";
|
});
|
});
|
}
|
|
private void btnAnaChConclusion_Click(object sender, EventArgs e)
|
{
|
this.txtInfo.Text += "\r\nÕýÔÚ·ÖÎöÈ«²¿±Ã×éºÏ½áÂÛ";
|
Task.Run(() =>
|
{
|
var helper = new Algorithm.SchedulingAnaHelper();
|
helper.AnaConclusion();
|
this.Invoke(() =>
|
{
|
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("ÇëÊäÈëÁ÷Á¿!");
|
return;
|
}
|
if (!double.TryParse(this.txtHead.Text, out double targetHead))
|
{
|
MessageBox.Show("ÇëÊäÈëѹÁ¦!");
|
return;
|
}
|
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))
|
{
|
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 must_open_pump_list_txt = this.txtMustOpen.Text.Trim();
|
if (!string.IsNullOrEmpty(must_open_pump_list_txt))
|
{
|
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 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();
|
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;
|
}
|
|
}
|
}
|