Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Mwork {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace System::Diagnostics;
- using namespace System::IO;
- using namespace System::Drawing::Drawing2D;
- using namespace System::Collections::Generic;
- using namespace System::Windows::Forms::DataVisualization::Charting;
- /// <summary>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- private:
- double delta;
- double b;
- double **a;
- double kn;
- double kd;
- double h;
- double lambda;
- double **d;
- int n; //size of a
- int cntP;
- double *X;
- private: System::Windows::Forms::DataVisualization::Charting::Chart^ chart1;
- double *Y;
- public:
- MyForm(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label4;
- protected:
- private: System::Windows::Forms::Button^ button5;
- private: System::Windows::Forms::Button^ button6;
- private: System::Windows::Forms::TextBox^ textBox13;
- private: System::Windows::Forms::TextBox^ textBox14;
- private: System::Windows::Forms::TextBox^ textBox15;
- private: System::Windows::Forms::TextBox^ textBox16;
- private: System::Windows::Forms::TextBox^ textBox17;
- private: System::Windows::Forms::TextBox^ textBox12;
- private: System::Windows::Forms::TextBox^ textBox11;
- private: System::Windows::Forms::TextBox^ textBox10;
- private: System::Windows::Forms::TextBox^ textBox9;
- private: System::Windows::Forms::TextBox^ textBox8;
- private: System::Windows::Forms::TextBox^ textBox7;
- private: System::Windows::Forms::TextBox^ textBox6;
- private: System::Windows::Forms::TextBox^ textBox5;
- private: System::Windows::Forms::TextBox^ textBox4;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Button^ button4;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::Label^ label6;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::CheckBox^ ПИ;
- private: System::Windows::Forms::CheckBox^ ПИД;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- System::Windows::Forms::DataVisualization::Charting::ChartArea^ chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
- System::Windows::Forms::DataVisualization::Charting::Legend^ legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
- System::Windows::Forms::DataVisualization::Charting::Series^ series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->button5 = (gcnew System::Windows::Forms::Button());
- this->button6 = (gcnew System::Windows::Forms::Button());
- this->textBox13 = (gcnew System::Windows::Forms::TextBox());
- this->textBox14 = (gcnew System::Windows::Forms::TextBox());
- this->textBox15 = (gcnew System::Windows::Forms::TextBox());
- this->textBox16 = (gcnew System::Windows::Forms::TextBox());
- this->textBox17 = (gcnew System::Windows::Forms::TextBox());
- this->textBox12 = (gcnew System::Windows::Forms::TextBox());
- this->textBox11 = (gcnew System::Windows::Forms::TextBox());
- this->textBox10 = (gcnew System::Windows::Forms::TextBox());
- this->textBox9 = (gcnew System::Windows::Forms::TextBox());
- this->textBox8 = (gcnew System::Windows::Forms::TextBox());
- this->textBox7 = (gcnew System::Windows::Forms::TextBox());
- this->textBox6 = (gcnew System::Windows::Forms::TextBox());
- this->textBox5 = (gcnew System::Windows::Forms::TextBox());
- this->textBox4 = (gcnew System::Windows::Forms::TextBox());
- this->textBox3 = (gcnew System::Windows::Forms::TextBox());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->button4 = (gcnew System::Windows::Forms::Button());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->label6 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->ПИ = (gcnew System::Windows::Forms::CheckBox());
- this->ПИД = (gcnew System::Windows::Forms::CheckBox());
- this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->BeginInit();
- this->SuspendLayout();
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(12, 9);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(465, 13);
- this->label4->TabIndex = 66;
- this->label4->Text = L"Cинтез интервальных систем автоматического управления на основе корневого подхода"
- L"";
- //
- // button5
- //
- this->button5->Location = System::Drawing::Point(18, 159);
- this->button5->Name = L"button5";
- this->button5->Size = System::Drawing::Size(199, 23);
- this->button5->TabIndex = 65;
- this->button5->Text = L"Задать коэфициенты полинома А";
- this->button5->UseVisualStyleBackColor = true;
- //
- // button6
- //
- this->button6->Location = System::Drawing::Point(346, 159);
- this->button6->Name = L"button6";
- this->button6->Size = System::Drawing::Size(163, 23);
- this->button6->TabIndex = 64;
- this->button6->Text = L"Создать полином";
- this->button6->UseVisualStyleBackColor = true;
- //
- // textBox13
- //
- this->textBox13->Location = System::Drawing::Point(219, 214);
- this->textBox13->Name = L"textBox13";
- this->textBox13->Size = System::Drawing::Size(54, 20);
- this->textBox13->TabIndex = 63;
- //
- // textBox14
- //
- this->textBox14->Location = System::Drawing::Point(168, 214);
- this->textBox14->Name = L"textBox14";
- this->textBox14->Size = System::Drawing::Size(54, 20);
- this->textBox14->TabIndex = 62;
- //
- // textBox15
- //
- this->textBox15->Location = System::Drawing::Point(116, 214);
- this->textBox15->Name = L"textBox15";
- this->textBox15->Size = System::Drawing::Size(54, 20);
- this->textBox15->TabIndex = 61;
- //
- // textBox16
- //
- this->textBox16->Location = System::Drawing::Point(66, 214);
- this->textBox16->Name = L"textBox16";
- this->textBox16->Size = System::Drawing::Size(54, 20);
- this->textBox16->TabIndex = 60;
- //
- // textBox17
- //
- this->textBox17->Location = System::Drawing::Point(15, 214);
- this->textBox17->Name = L"textBox17";
- this->textBox17->Size = System::Drawing::Size(54, 20);
- this->textBox17->TabIndex = 59;
- //
- // textBox12
- //
- this->textBox12->Location = System::Drawing::Point(219, 197);
- this->textBox12->Name = L"textBox12";
- this->textBox12->Size = System::Drawing::Size(54, 20);
- this->textBox12->TabIndex = 58;
- //
- // textBox11
- //
- this->textBox11->Location = System::Drawing::Point(168, 197);
- this->textBox11->Name = L"textBox11";
- this->textBox11->Size = System::Drawing::Size(54, 20);
- this->textBox11->TabIndex = 57;
- //
- // textBox10
- //
- this->textBox10->Location = System::Drawing::Point(116, 197);
- this->textBox10->Name = L"textBox10";
- this->textBox10->Size = System::Drawing::Size(54, 20);
- this->textBox10->TabIndex = 56;
- //
- // textBox9
- //
- this->textBox9->Location = System::Drawing::Point(66, 197);
- this->textBox9->Name = L"textBox9";
- this->textBox9->Size = System::Drawing::Size(54, 20);
- this->textBox9->TabIndex = 55;
- //
- // textBox8
- //
- this->textBox8->Location = System::Drawing::Point(15, 197);
- this->textBox8->Name = L"textBox8";
- this->textBox8->Size = System::Drawing::Size(54, 20);
- this->textBox8->TabIndex = 54;
- //
- // textBox7
- //
- this->textBox7->Location = System::Drawing::Point(18, 264);
- this->textBox7->Name = L"textBox7";
- this->textBox7->Size = System::Drawing::Size(102, 20);
- this->textBox7->TabIndex = 53;
- //
- // textBox6
- //
- this->textBox6->Location = System::Drawing::Point(417, 351);
- this->textBox6->Name = L"textBox6";
- this->textBox6->Size = System::Drawing::Size(102, 20);
- this->textBox6->TabIndex = 52;
- //
- // textBox5
- //
- this->textBox5->Location = System::Drawing::Point(286, 351);
- this->textBox5->Name = L"textBox5";
- this->textBox5->Size = System::Drawing::Size(102, 20);
- this->textBox5->TabIndex = 51;
- //
- // textBox4
- //
- this->textBox4->Location = System::Drawing::Point(149, 351);
- this->textBox4->Name = L"textBox4";
- this->textBox4->Size = System::Drawing::Size(102, 20);
- this->textBox4->TabIndex = 50;
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(18, 351);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(111, 20);
- this->textBox3->TabIndex = 49;
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(15, 248);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(202, 13);
- this->label3->TabIndex = 48;
- this->label3->Text = L"Задайте показатель колебательности";
- //
- // button4
- //
- this->button4->Location = System::Drawing::Point(417, 313);
- this->button4->Name = L"button4";
- this->button4->Size = System::Drawing::Size(102, 32);
- this->button4->TabIndex = 47;
- this->button4->Text = L"вычислить h";
- this->button4->UseVisualStyleBackColor = true;
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(286, 313);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(102, 32);
- this->button3->TabIndex = 46;
- this->button3->Text = L"вычислить k3";
- this->button3->UseVisualStyleBackColor = true;
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(149, 313);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(102, 32);
- this->button2->TabIndex = 45;
- this->button2->Text = L"вычислить k2";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(15, 313);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(114, 32);
- this->button1->TabIndex = 44;
- this->button1->Text = L"вычислить k1";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(338, 120);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(173, 20);
- this->textBox2->TabIndex = 43;
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(18, 120);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(173, 20);
- this->textBox1->TabIndex = 42;
- //
- // label6
- //
- this->label6->AutoSize = true;
- this->label6->Location = System::Drawing::Point(335, 104);
- this->label6->Name = L"label6";
- this->label6->Size = System::Drawing::Size(184, 13);
- this->label6->TabIndex = 41;
- this->label6->Text = L"Задайте коэфициенты полинома B";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(15, 104);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(176, 13);
- this->label2->TabIndex = 40;
- this->label2->Text = L"Задайте количество переменных";
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(12, 42);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(138, 13);
- this->label1->TabIndex = 39;
- this->label1->Text = L"Выберите вид регулятора";
- //
- // ПИ
- //
- this->ПИ->AutoSize = true;
- this->ПИ->Location = System::Drawing::Point(126, 62);
- this->ПИ->Name = L"ПИ";
- this->ПИ->Size = System::Drawing::Size(96, 17);
- this->ПИ->TabIndex = 38;
- this->ПИ->Text = L"ПИ-регулятор";
- this->ПИ->UseVisualStyleBackColor = true;
- //
- // ПИД
- //
- this->ПИД->AutoSize = true;
- this->ПИД->Location = System::Drawing::Point(15, 62);
- this->ПИД->Name = L"ПИД";
- this->ПИД->Size = System::Drawing::Size(105, 17);
- this->ПИД->TabIndex = 37;
- this->ПИД->Text = L"ПИД-регулятор";
- this->ПИД->UseVisualStyleBackColor = true;
- //
- // chart1
- //
- chartArea1->Name = L"ChartArea1";
- this->chart1->ChartAreas->Add(chartArea1);
- legend1->Name = L"Legend1";
- this->chart1->Legends->Add(legend1);
- this->chart1->Location = System::Drawing::Point(638, 42);
- this->chart1->Name = L"chart1";
- series1->ChartArea = L"ChartArea1";
- series1->Legend = L"Legend1";
- series1->Name = L"Series1";
- this->chart1->Series->Add(series1);
- this->chart1->Size = System::Drawing::Size(300, 300);
- this->chart1->TabIndex = 67;
- this->chart1->Text = L"chart1";
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(1019, 386);
- this->Controls->Add(this->chart1);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->button5);
- this->Controls->Add(this->button6);
- this->Controls->Add(this->textBox13);
- this->Controls->Add(this->textBox14);
- this->Controls->Add(this->textBox15);
- this->Controls->Add(this->textBox16);
- this->Controls->Add(this->textBox17);
- this->Controls->Add(this->textBox12);
- this->Controls->Add(this->textBox11);
- this->Controls->Add(this->textBox10);
- this->Controls->Add(this->textBox9);
- this->Controls->Add(this->textBox8);
- this->Controls->Add(this->textBox7);
- this->Controls->Add(this->textBox6);
- this->Controls->Add(this->textBox5);
- this->Controls->Add(this->textBox4);
- this->Controls->Add(this->textBox3);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->button4);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->label6);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->ПИ);
- this->Controls->Add(this->ПИД);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- delta = Double::Parse(textBox7->Text);
- b = Double::Parse(textBox2->Text);
- n = int::Parse(textBox1->Text);
- a = new double*[n + 1];
- for (int i = 0; i <= n; i++)
- a[i] = new double[2];
- d = new double*[n + 2];
- for (int i = 0; i <= n + 1; i++)
- d[i] = new double[2];
- a[0][0] = Double::Parse(textBox8->Text);
- a[1][0] = Double::Parse(textBox9->Text);
- a[2][0] = Double::Parse(textBox10->Text);
- a[3][0] = Double::Parse(textBox11->Text);
- a[0][1] = Double::Parse(textBox17->Text);
- a[1][1] = Double::Parse(textBox16->Text);
- a[2][1] = Double::Parse(textBox15->Text);
- a[3][1] = Double::Parse(textBox14->Text);
- kd = (a[1][0] * a[1][0] - delta * a[0][1] * a[2][1]) / (delta * b * a[2][1]);
- h = 0.32;
- lambda = 0.465;
- kn = lambda * (a[0][0] + b * kd - 2 * a[1][1] * h) * (a[1][1] - h * a[2][1]) / (b * a[2][1]);
- textBox3->Text = kn.ToString();
- textBox4->Text = kd.ToString();
- textBox6->Text = h.ToString();
- d[0][0] = kn, d[0][0] = kn;
- d[1][0] = a[0][0] + kn, d[1][0] = a[0][1] + kn;
- for (int i = 2; i <= n + 1; i++)
- d[i][0] = a[i - 1][0], d[i][1] = a[i - 1][1];
- StreamWriter^ sw = gcnew StreamWriter("input.txt");
- for (int i = 0; i <= n + 1; i++)
- sw->WriteLine(d[i][0].ToString() + " " + d[i][1].ToString());
- sw->Close();
- //Process::Start("python script.txt");
- //System::Threading::Thread::Sleep(5000);
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- StreamReader^ sr = gcnew StreamReader("output.txt");
- cntP = int::Parse(sr->ReadLine());
- X = new double[cntP];
- Y = new double[cntP];
- for (int i = 0; i < cntP; i++) {
- X[i] = Double::Parse(sr->ReadLine());
- Y[i] = Double::Parse(sr->ReadLine());
- }
- sr->Close();
- chart1->Series[0]->Points->Clear();
- chart1->Series[0]->ChartType = SeriesChartType::Point;
- for (int i = 0; i < cntP; i++) {
- if (X[i] > 1000 || X[i] < -1000)
- continue;
- if (Y[i] > 1000 || Y[i] < -1000)
- continue;
- chart1->Series[0]->Points->AddXY(X[i], Y[i]);
- }
- //plot (X, Y) * cntP
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement