private void CreateSys() { sys = new ESystem(CreateF1.sys1.current_state); if (sys != null) { //грузим полученный sys в формочку if (SI == null && sys != null)//проверка на открытие файла снова { SI = new SysInfo(sys); } else { SI.UpdateInfo(sys); } //разблокировка элементов this.showStateInfoToolStripMenuItem.Enabled = true; this.startEmulationToolStripMenuItem.Enabled = true; tabControl1.SelectTab(0); if (!debug) { step = 0; } else { step = 4; } tabPage2.Controls.Clear(); tabPage2.Controls.Add(button2); tabPage1.Controls.Clear(); tabPage1.Controls.Add(button1); tabPage1.Controls.Add(label1); tabPage1.Controls.Add(lAnalogEquation); lAnalogEquation.Text = "x'(t) = "; for (int i = 0; i < sys.current_state.analog_A()[0].Count; i++) { if (i != 0) { this.lAnalogEquation.Text += " + "; } this.lAnalogEquation.Text += "Ан" + i.ToString() + "x(t"; if (i == 0) { this.lAnalogEquation.Text += ")"; } else { this.lAnalogEquation.Text += " - " + sys.current_state.tau[i] + ")"; } } for (int i = 0; i < sys.current_state.analog_B()[0].Count; i++) { this.lAnalogEquation.Text += " + Bн" + i.ToString() + "u(t"; if (i == 0) { this.lAnalogEquation.Text += ")"; } else { this.lAnalogEquation.Text += " - " + sys.current_state.teta[i] + ")"; } } UniversalMatrixBox = new List <MatrixDrawer>(); LabelList = new List <System.Windows.Forms.Label>(); int loctemp = 20; int j = 0; for (int i = 0; i < sys.current_state.analog_B()[0].Count + sys.current_state.analog_A()[0].Count; i++) { MatrixDrawer tmp = new MatrixDrawer(new MatrixLibrary.Matrix(10, 10)); this.UniversalMatrixBox.Add(new MatrixDrawer(new MatrixLibrary.Matrix(10, 10))); this.LabelList.Add(new System.Windows.Forms.Label()); UniversalMatrixBox[i].Visible = false; UniversalMatrixBox[i].Location = new Point(loctemp, 130); this.LabelList[i].Location = new Point(loctemp, 115); this.LabelList[i].Font = new Font(this.Font, FontStyle.Bold); this.tabPage1.Controls.Add(UniversalMatrixBox[i]); this.tabPage1.Controls.Add(LabelList[i]); if (i < sys.current_state.analog_A()[0].Count) { this.UniversalMatrixBox[i].ReloadMatrix(sys.current_state.analog_A()[0][i]); this.LabelList[i].Text = "Ан" + i.ToString() + ": "; } else { this.UniversalMatrixBox[i].ReloadMatrix(sys.current_state.analog_B()[0][j]); this.LabelList[i].Text = "Bн" + j.ToString() + ": "; j++; } UniversalMatrixBox[i].Visible = true; loctemp += UniversalMatrixBox[i].Size.Width + 20; } button1.Location = new Point(20, UniversalMatrixBox[0].Location.Y + 20 + UniversalMatrixBox[0].Size.Height); button1.Visible = true; } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { //отлавливаем исключения инициализации try { //загрузка sys из файла sys = GUI.OpenJsonFile(isSpline, isNoiseEnabled); } catch (Exception excption) //если при определении следующего шага чтото пошло нетак { MessageBox.Show(excption.Message + "\n" + excption.StackTrace.ToString(), "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //вываливаем сообщение } //если файл был успешно загружен if (sys != null) { //грузим полученный sys в формочку if (SI == null && sys != null)//проверка на открытие файла снова { SI = new SysInfo(sys); } else { SI.UpdateInfo(sys); } //разблокировка элементов this.showStateInfoToolStripMenuItem.Enabled = true; this.startEmulationToolStripMenuItem.Enabled = true; tabControl1.SelectTab(0); if (!debug) { step = 0; } else { step = 4; } tabPage2.Controls.Clear(); tabPage2.Controls.Add(button2); tabPage1.Controls.Clear(); tabPage1.Controls.Add(button1); tabPage1.Controls.Add(label1); tabPage1.Controls.Add(lAnalogEquation); lAnalogEquation.Text = "x'(t) = "; for (int i = 0; i < sys.current_state.analog_A()[0].Count; i++) { if (i != 0) { this.lAnalogEquation.Text += " + "; } this.lAnalogEquation.Text += "Ан" + i.ToString() + "x(t"; if (i == 0) { this.lAnalogEquation.Text += ")"; } else { this.lAnalogEquation.Text += " - " + sys.current_state.tau[i] + ")"; } } for (int i = 0; i < sys.current_state.analog_B()[0].Count; i++) { this.lAnalogEquation.Text += " + Bн" + i.ToString() + "u(t"; if (i == 0) { this.lAnalogEquation.Text += ")"; } else { this.lAnalogEquation.Text += " - " + sys.current_state.teta[i] + ")"; } } UniversalMatrixBox = new List <MatrixDrawer>(); LabelList = new List <System.Windows.Forms.Label>(); int loctemp = 20; int j = 0; for (int i = 0; i < sys.current_state.analog_B()[0].Count + sys.current_state.analog_A()[0].Count; i++) { MatrixDrawer tmp = new MatrixDrawer(new MatrixLibrary.Matrix(10, 10)); this.UniversalMatrixBox.Add(new MatrixDrawer(new MatrixLibrary.Matrix(10, 10))); this.LabelList.Add(new System.Windows.Forms.Label()); UniversalMatrixBox[i].Visible = false; UniversalMatrixBox[i].Location = new Point(loctemp, 130); this.LabelList[i].Location = new Point(loctemp, 115); this.LabelList[i].Font = new Font(this.Font, FontStyle.Bold); this.tabPage1.Controls.Add(UniversalMatrixBox[i]); this.tabPage1.Controls.Add(LabelList[i]); if (i < sys.current_state.analog_A()[0].Count) { this.UniversalMatrixBox[i].ReloadMatrix(sys.current_state.analog_A()[0][i]); this.LabelList[i].Text = "Ан" + i.ToString() + ": "; } else { this.UniversalMatrixBox[i].ReloadMatrix(sys.current_state.analog_B()[0][j]); this.LabelList[i].Text = "Bн" + j.ToString() + ": "; j++; } UniversalMatrixBox[i].Visible = true; loctemp += UniversalMatrixBox[i].Size.Width + 20; } button1.Location = new Point(20, UniversalMatrixBox[0].Location.Y + 20 + UniversalMatrixBox[0].Size.Height); button1.Visible = true; } }
/// <summary> /// Дискретизация /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { tabPage1.Controls.Add(label2); tabPage1.Controls.Add(lDEquation); int loctemp = UniversalMatrixBox[0].Location.Y + 60 + UniversalMatrixBox[0].Size.Height; label2.Location = new Point(20, loctemp); label2.Visible = true; this.lDEquation.Text = "x(k+1)= "; this.lDEquation.Location = new Point(10, loctemp + 45); for (int i = 0; i < sys.current_state.get_A()[0].Count; i++) { if (i != 0) { this.lDEquation.Text += " + "; } this.lDEquation.Text += "А" + i.ToString() + "x(k"; if (i == 0) { this.lDEquation.Text += ")"; } else { this.lDEquation.Text += " - " + sys.current_state.L[i] + ")"; } } for (int i = 0; i < sys.current_state.B()[0].Count; i++) { this.lDEquation.Text += " + B" + i.ToString() + "u(k"; if (i == 0) { this.lDEquation.Text += ")"; } else { this.lDEquation.Text += " - " + sys.current_state.M[i] + ")"; } } loctemp += 70; int loctemp2 = 20; UniversalMatrixBox2 = new List <MatrixDrawer>(); LabelList2 = new List <System.Windows.Forms.Label>(); int j = 0; for (int i = 0; i < sys.current_state.B()[0].Count + sys.current_state.get_A()[0].Count; i++) { MatrixDrawer tmp = new MatrixDrawer(new MatrixLibrary.Matrix(10, 10)); this.UniversalMatrixBox2.Add(new MatrixDrawer(new MatrixLibrary.Matrix(10, 10))); this.LabelList2.Add(new System.Windows.Forms.Label()); UniversalMatrixBox2[i].Visible = false; UniversalMatrixBox2[i].Location = new Point(loctemp2, loctemp + 15); this.LabelList2[i].Location = new Point(loctemp2, loctemp); this.LabelList2[i].Font = new Font(this.Font, FontStyle.Bold); this.tabPage1.Controls.Add(UniversalMatrixBox2[i]); this.tabPage1.Controls.Add(LabelList2[i]); if (i < sys.current_state.get_A()[0].Count) { this.UniversalMatrixBox2[i].ReloadMatrix(sys.current_state.get_A()[0][i]); this.LabelList2[i].Text = "А" + i.ToString() + ": "; } else { this.UniversalMatrixBox2[i].ReloadMatrix(sys.current_state.B()[0][j]); this.LabelList2[i].Text = "B" + j.ToString() + ": "; j++; } UniversalMatrixBox2[i].Visible = true; loctemp2 += UniversalMatrixBox2[i].Size.Width + 20; if (!debug) { step = 1; // дискретизция закончилась } } }
private void DrawMatrix() { String MatrixGxName = "Gx"; String MatrixGuName = "Gu"; int locationY_gx = 10; int locationX_gx = 10; int locationY_gu = 10; int locationX_gu = 0; //UniversalMatrixBox_new2 = new List<TBMatrixDrawer>(); UniversalMatrixBox_gx = new List <MatrixDrawer>(); LabelList_gx = new List <System.Windows.Forms.Label>(); UniversalMatrixBox_gu = new List <MatrixDrawer>(); LabelList_gu = new List <System.Windows.Forms.Label>(); int j = 0; for (int i = 0; i < sys.current_state.get_Gx().Count + sys.current_state.get_Gu().Count; i++) { MatrixDrawer tmp = new MatrixDrawer(new MatrixLibrary.Matrix(10, 10)); if (i < sys.current_state.get_Gx().Count) { this.UniversalMatrixBox_gx.Add(new MatrixDrawer(new MatrixLibrary.Matrix(10, 10))); this.LabelList_gx.Add(new System.Windows.Forms.Label()); UniversalMatrixBox_gx[i].Visible = false; UniversalMatrixBox_gx[i].Location = new Point(locationX_gx, locationY_gx + 15); this.LabelList_gx[i].Location = new Point(locationX_gx, locationY_gx); this.LabelList_gx[i].Font = new Font(this.Font, FontStyle.Bold); this.Controls.Add(UniversalMatrixBox_gx[i]); this.Controls.Add(LabelList_gx[i]); this.UniversalMatrixBox_gx[i].ReloadMatrix(sys.current_state.get_Gx()[i]); //this.UniversalMatrixBox_new2[i].ReloadMatrix(sys.current_state.get_Gx()[i]); this.LabelList_gx[i].Text = MatrixGxName + i.ToString() + ": "; UniversalMatrixBox_gx[i].Visible = true; locationX_gx += UniversalMatrixBox_gx[i].Size.Width + 20; } else if (sys.current_state.get_Gu().Any()) { this.UniversalMatrixBox_gu.Add(new MatrixDrawer(new MatrixLibrary.Matrix(10, 10))); this.LabelList_gu.Add(new System.Windows.Forms.Label()); if (locationY_gu == 0 && UniversalMatrixBox_gx.Any()) { locationY_gu = UniversalMatrixBox_gx[0].Height + 15; } UniversalMatrixBox_gu[j].Visible = false; UniversalMatrixBox_gu[j].Location = new Point(locationX_gu, locationY_gu + 15); this.LabelList_gu[j].Location = new Point(locationX_gu, locationY_gu); this.LabelList_gu[j].Font = new Font(this.Font, FontStyle.Bold); this.Controls.Add(UniversalMatrixBox_gu[j]); this.Controls.Add(LabelList_gu[j]); this.UniversalMatrixBox_gu[j].ReloadMatrix(sys.current_state.get_Gu()[j]); this.LabelList_gu[j].Text = MatrixGuName + j.ToString() + ": "; UniversalMatrixBox_gu[j].Visible = true; locationX_gu += UniversalMatrixBox_gu[j].Size.Width + 20; j++; } } //пустышка аднака - пустой блок для отображения матриц //this.UniversalMatrixBox = new TBMatrixDrawer(new MatrixLibrary.Matrix(10, 10)); //UniversalMatrixBox.Visible = false; //UniversalMatrixBox.Location = new Point(209, 56); //this.Controls.Add(UniversalMatrixBox); }