Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.42 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace Mwork {
  4.  
  5. using namespace System;
  6. using namespace System::ComponentModel;
  7. using namespace System::Collections;
  8. using namespace System::Windows::Forms;
  9. using namespace System::Data;
  10. using namespace System::Drawing;
  11. using namespace System::Diagnostics;
  12. using namespace System::IO;
  13. using namespace System::Drawing::Drawing2D;
  14. using namespace System::Collections::Generic;
  15. using namespace System::Windows::Forms::DataVisualization::Charting;
  16.  
  17. /// <summary>
  18. /// Summary for MyForm
  19. /// </summary>
  20. public ref class MyForm : public System::Windows::Forms::Form
  21. {
  22. private:
  23. double delta;
  24. double b;
  25. double **a;
  26. double kn;
  27. double kd;
  28. double h;
  29. double lambda;
  30. double **d;
  31. int n; //size of a
  32. int cntP;
  33. double *X;
  34. private: System::Windows::Forms::DataVisualization::Charting::Chart^ chart1;
  35. double *Y;
  36.  
  37. public:
  38. MyForm(void)
  39. {
  40. InitializeComponent();
  41. //
  42. //TODO: Add the constructor code here
  43. //
  44. }
  45.  
  46. protected:
  47. /// <summary>
  48. /// Clean up any resources being used.
  49. /// </summary>
  50. ~MyForm()
  51. {
  52. if (components)
  53. {
  54. delete components;
  55. }
  56. }
  57. private: System::Windows::Forms::Label^ label4;
  58. protected:
  59. private: System::Windows::Forms::Button^ button5;
  60. private: System::Windows::Forms::Button^ button6;
  61. private: System::Windows::Forms::TextBox^ textBox13;
  62. private: System::Windows::Forms::TextBox^ textBox14;
  63. private: System::Windows::Forms::TextBox^ textBox15;
  64. private: System::Windows::Forms::TextBox^ textBox16;
  65. private: System::Windows::Forms::TextBox^ textBox17;
  66. private: System::Windows::Forms::TextBox^ textBox12;
  67. private: System::Windows::Forms::TextBox^ textBox11;
  68. private: System::Windows::Forms::TextBox^ textBox10;
  69. private: System::Windows::Forms::TextBox^ textBox9;
  70. private: System::Windows::Forms::TextBox^ textBox8;
  71. private: System::Windows::Forms::TextBox^ textBox7;
  72. private: System::Windows::Forms::TextBox^ textBox6;
  73. private: System::Windows::Forms::TextBox^ textBox5;
  74. private: System::Windows::Forms::TextBox^ textBox4;
  75. private: System::Windows::Forms::TextBox^ textBox3;
  76. private: System::Windows::Forms::Label^ label3;
  77. private: System::Windows::Forms::Button^ button4;
  78. private: System::Windows::Forms::Button^ button3;
  79. private: System::Windows::Forms::Button^ button2;
  80. private: System::Windows::Forms::Button^ button1;
  81. private: System::Windows::Forms::TextBox^ textBox2;
  82. private: System::Windows::Forms::TextBox^ textBox1;
  83. private: System::Windows::Forms::Label^ label6;
  84. private: System::Windows::Forms::Label^ label2;
  85. private: System::Windows::Forms::Label^ label1;
  86. private: System::Windows::Forms::CheckBox^ ПИ;
  87. private: System::Windows::Forms::CheckBox^ ПИД;
  88.  
  89. private:
  90. /// <summary>
  91. /// Required designer variable.
  92. /// </summary>
  93. System::ComponentModel::Container ^components;
  94.  
  95. #pragma region Windows Form Designer generated code
  96. /// <summary>
  97. /// Required method for Designer support - do not modify
  98. /// the contents of this method with the code editor.
  99. /// </summary>
  100. void InitializeComponent(void)
  101. {
  102. System::Windows::Forms::DataVisualization::Charting::ChartArea^ chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
  103. System::Windows::Forms::DataVisualization::Charting::Legend^ legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
  104. System::Windows::Forms::DataVisualization::Charting::Series^ series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
  105. this->label4 = (gcnew System::Windows::Forms::Label());
  106. this->button5 = (gcnew System::Windows::Forms::Button());
  107. this->button6 = (gcnew System::Windows::Forms::Button());
  108. this->textBox13 = (gcnew System::Windows::Forms::TextBox());
  109. this->textBox14 = (gcnew System::Windows::Forms::TextBox());
  110. this->textBox15 = (gcnew System::Windows::Forms::TextBox());
  111. this->textBox16 = (gcnew System::Windows::Forms::TextBox());
  112. this->textBox17 = (gcnew System::Windows::Forms::TextBox());
  113. this->textBox12 = (gcnew System::Windows::Forms::TextBox());
  114. this->textBox11 = (gcnew System::Windows::Forms::TextBox());
  115. this->textBox10 = (gcnew System::Windows::Forms::TextBox());
  116. this->textBox9 = (gcnew System::Windows::Forms::TextBox());
  117. this->textBox8 = (gcnew System::Windows::Forms::TextBox());
  118. this->textBox7 = (gcnew System::Windows::Forms::TextBox());
  119. this->textBox6 = (gcnew System::Windows::Forms::TextBox());
  120. this->textBox5 = (gcnew System::Windows::Forms::TextBox());
  121. this->textBox4 = (gcnew System::Windows::Forms::TextBox());
  122. this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  123. this->label3 = (gcnew System::Windows::Forms::Label());
  124. this->button4 = (gcnew System::Windows::Forms::Button());
  125. this->button3 = (gcnew System::Windows::Forms::Button());
  126. this->button2 = (gcnew System::Windows::Forms::Button());
  127. this->button1 = (gcnew System::Windows::Forms::Button());
  128. this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  129. this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  130. this->label6 = (gcnew System::Windows::Forms::Label());
  131. this->label2 = (gcnew System::Windows::Forms::Label());
  132. this->label1 = (gcnew System::Windows::Forms::Label());
  133. this->ПИ = (gcnew System::Windows::Forms::CheckBox());
  134. this->ПИД = (gcnew System::Windows::Forms::CheckBox());
  135. this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
  136. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->BeginInit();
  137. this->SuspendLayout();
  138. //
  139. // label4
  140. //
  141. this->label4->AutoSize = true;
  142. this->label4->Location = System::Drawing::Point(12, 9);
  143. this->label4->Name = L"label4";
  144. this->label4->Size = System::Drawing::Size(465, 13);
  145. this->label4->TabIndex = 66;
  146. this->label4->Text = L"Cинтез интервальных систем автоматического управления на основе корневого подхода"
  147. L"";
  148. //
  149. // button5
  150. //
  151. this->button5->Location = System::Drawing::Point(18, 159);
  152. this->button5->Name = L"button5";
  153. this->button5->Size = System::Drawing::Size(199, 23);
  154. this->button5->TabIndex = 65;
  155. this->button5->Text = L"Задать коэфициенты полинома А";
  156. this->button5->UseVisualStyleBackColor = true;
  157. //
  158. // button6
  159. //
  160. this->button6->Location = System::Drawing::Point(346, 159);
  161. this->button6->Name = L"button6";
  162. this->button6->Size = System::Drawing::Size(163, 23);
  163. this->button6->TabIndex = 64;
  164. this->button6->Text = L"Создать полином";
  165. this->button6->UseVisualStyleBackColor = true;
  166. //
  167. // textBox13
  168. //
  169. this->textBox13->Location = System::Drawing::Point(219, 214);
  170. this->textBox13->Name = L"textBox13";
  171. this->textBox13->Size = System::Drawing::Size(54, 20);
  172. this->textBox13->TabIndex = 63;
  173. //
  174. // textBox14
  175. //
  176. this->textBox14->Location = System::Drawing::Point(168, 214);
  177. this->textBox14->Name = L"textBox14";
  178. this->textBox14->Size = System::Drawing::Size(54, 20);
  179. this->textBox14->TabIndex = 62;
  180. //
  181. // textBox15
  182. //
  183. this->textBox15->Location = System::Drawing::Point(116, 214);
  184. this->textBox15->Name = L"textBox15";
  185. this->textBox15->Size = System::Drawing::Size(54, 20);
  186. this->textBox15->TabIndex = 61;
  187. //
  188. // textBox16
  189. //
  190. this->textBox16->Location = System::Drawing::Point(66, 214);
  191. this->textBox16->Name = L"textBox16";
  192. this->textBox16->Size = System::Drawing::Size(54, 20);
  193. this->textBox16->TabIndex = 60;
  194. //
  195. // textBox17
  196. //
  197. this->textBox17->Location = System::Drawing::Point(15, 214);
  198. this->textBox17->Name = L"textBox17";
  199. this->textBox17->Size = System::Drawing::Size(54, 20);
  200. this->textBox17->TabIndex = 59;
  201. //
  202. // textBox12
  203. //
  204. this->textBox12->Location = System::Drawing::Point(219, 197);
  205. this->textBox12->Name = L"textBox12";
  206. this->textBox12->Size = System::Drawing::Size(54, 20);
  207. this->textBox12->TabIndex = 58;
  208. //
  209. // textBox11
  210. //
  211. this->textBox11->Location = System::Drawing::Point(168, 197);
  212. this->textBox11->Name = L"textBox11";
  213. this->textBox11->Size = System::Drawing::Size(54, 20);
  214. this->textBox11->TabIndex = 57;
  215. //
  216. // textBox10
  217. //
  218. this->textBox10->Location = System::Drawing::Point(116, 197);
  219. this->textBox10->Name = L"textBox10";
  220. this->textBox10->Size = System::Drawing::Size(54, 20);
  221. this->textBox10->TabIndex = 56;
  222. //
  223. // textBox9
  224. //
  225. this->textBox9->Location = System::Drawing::Point(66, 197);
  226. this->textBox9->Name = L"textBox9";
  227. this->textBox9->Size = System::Drawing::Size(54, 20);
  228. this->textBox9->TabIndex = 55;
  229. //
  230. // textBox8
  231. //
  232. this->textBox8->Location = System::Drawing::Point(15, 197);
  233. this->textBox8->Name = L"textBox8";
  234. this->textBox8->Size = System::Drawing::Size(54, 20);
  235. this->textBox8->TabIndex = 54;
  236. //
  237. // textBox7
  238. //
  239. this->textBox7->Location = System::Drawing::Point(18, 264);
  240. this->textBox7->Name = L"textBox7";
  241. this->textBox7->Size = System::Drawing::Size(102, 20);
  242. this->textBox7->TabIndex = 53;
  243. //
  244. // textBox6
  245. //
  246. this->textBox6->Location = System::Drawing::Point(417, 351);
  247. this->textBox6->Name = L"textBox6";
  248. this->textBox6->Size = System::Drawing::Size(102, 20);
  249. this->textBox6->TabIndex = 52;
  250. //
  251. // textBox5
  252. //
  253. this->textBox5->Location = System::Drawing::Point(286, 351);
  254. this->textBox5->Name = L"textBox5";
  255. this->textBox5->Size = System::Drawing::Size(102, 20);
  256. this->textBox5->TabIndex = 51;
  257. //
  258. // textBox4
  259. //
  260. this->textBox4->Location = System::Drawing::Point(149, 351);
  261. this->textBox4->Name = L"textBox4";
  262. this->textBox4->Size = System::Drawing::Size(102, 20);
  263. this->textBox4->TabIndex = 50;
  264. //
  265. // textBox3
  266. //
  267. this->textBox3->Location = System::Drawing::Point(18, 351);
  268. this->textBox3->Name = L"textBox3";
  269. this->textBox3->Size = System::Drawing::Size(111, 20);
  270. this->textBox3->TabIndex = 49;
  271. //
  272. // label3
  273. //
  274. this->label3->AutoSize = true;
  275. this->label3->Location = System::Drawing::Point(15, 248);
  276. this->label3->Name = L"label3";
  277. this->label3->Size = System::Drawing::Size(202, 13);
  278. this->label3->TabIndex = 48;
  279. this->label3->Text = L"Задайте показатель колебательности";
  280. //
  281. // button4
  282. //
  283. this->button4->Location = System::Drawing::Point(417, 313);
  284. this->button4->Name = L"button4";
  285. this->button4->Size = System::Drawing::Size(102, 32);
  286. this->button4->TabIndex = 47;
  287. this->button4->Text = L"вычислить h";
  288. this->button4->UseVisualStyleBackColor = true;
  289. //
  290. // button3
  291. //
  292. this->button3->Location = System::Drawing::Point(286, 313);
  293. this->button3->Name = L"button3";
  294. this->button3->Size = System::Drawing::Size(102, 32);
  295. this->button3->TabIndex = 46;
  296. this->button3->Text = L"вычислить k3";
  297. this->button3->UseVisualStyleBackColor = true;
  298. //
  299. // button2
  300. //
  301. this->button2->Location = System::Drawing::Point(149, 313);
  302. this->button2->Name = L"button2";
  303. this->button2->Size = System::Drawing::Size(102, 32);
  304. this->button2->TabIndex = 45;
  305. this->button2->Text = L"вычислить k2";
  306. this->button2->UseVisualStyleBackColor = true;
  307. this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
  308. //
  309. // button1
  310. //
  311. this->button1->Location = System::Drawing::Point(15, 313);
  312. this->button1->Name = L"button1";
  313. this->button1->Size = System::Drawing::Size(114, 32);
  314. this->button1->TabIndex = 44;
  315. this->button1->Text = L"вычислить k1";
  316. this->button1->UseVisualStyleBackColor = true;
  317. this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
  318. //
  319. // textBox2
  320. //
  321. this->textBox2->Location = System::Drawing::Point(338, 120);
  322. this->textBox2->Name = L"textBox2";
  323. this->textBox2->Size = System::Drawing::Size(173, 20);
  324. this->textBox2->TabIndex = 43;
  325. //
  326. // textBox1
  327. //
  328. this->textBox1->Location = System::Drawing::Point(18, 120);
  329. this->textBox1->Name = L"textBox1";
  330. this->textBox1->Size = System::Drawing::Size(173, 20);
  331. this->textBox1->TabIndex = 42;
  332. //
  333. // label6
  334. //
  335. this->label6->AutoSize = true;
  336. this->label6->Location = System::Drawing::Point(335, 104);
  337. this->label6->Name = L"label6";
  338. this->label6->Size = System::Drawing::Size(184, 13);
  339. this->label6->TabIndex = 41;
  340. this->label6->Text = L"Задайте коэфициенты полинома B";
  341. //
  342. // label2
  343. //
  344. this->label2->AutoSize = true;
  345. this->label2->Location = System::Drawing::Point(15, 104);
  346. this->label2->Name = L"label2";
  347. this->label2->Size = System::Drawing::Size(176, 13);
  348. this->label2->TabIndex = 40;
  349. this->label2->Text = L"Задайте количество переменных";
  350. //
  351. // label1
  352. //
  353. this->label1->AutoSize = true;
  354. this->label1->Location = System::Drawing::Point(12, 42);
  355. this->label1->Name = L"label1";
  356. this->label1->Size = System::Drawing::Size(138, 13);
  357. this->label1->TabIndex = 39;
  358. this->label1->Text = L"Выберите вид регулятора";
  359. //
  360. // ПИ
  361. //
  362. this->ПИ->AutoSize = true;
  363. this->ПИ->Location = System::Drawing::Point(126, 62);
  364. this->ПИ->Name = L"ПИ";
  365. this->ПИ->Size = System::Drawing::Size(96, 17);
  366. this->ПИ->TabIndex = 38;
  367. this->ПИ->Text = L"ПИ-регулятор";
  368. this->ПИ->UseVisualStyleBackColor = true;
  369. //
  370. // ПИД
  371. //
  372. this->ПИД->AutoSize = true;
  373. this->ПИД->Location = System::Drawing::Point(15, 62);
  374. this->ПИД->Name = L"ПИД";
  375. this->ПИД->Size = System::Drawing::Size(105, 17);
  376. this->ПИД->TabIndex = 37;
  377. this->ПИД->Text = L"ПИД-регулятор";
  378. this->ПИД->UseVisualStyleBackColor = true;
  379. //
  380. // chart1
  381. //
  382. chartArea1->Name = L"ChartArea1";
  383. this->chart1->ChartAreas->Add(chartArea1);
  384. legend1->Name = L"Legend1";
  385. this->chart1->Legends->Add(legend1);
  386. this->chart1->Location = System::Drawing::Point(638, 42);
  387. this->chart1->Name = L"chart1";
  388. series1->ChartArea = L"ChartArea1";
  389. series1->Legend = L"Legend1";
  390. series1->Name = L"Series1";
  391. this->chart1->Series->Add(series1);
  392. this->chart1->Size = System::Drawing::Size(300, 300);
  393. this->chart1->TabIndex = 67;
  394. this->chart1->Text = L"chart1";
  395. //
  396. // MyForm
  397. //
  398. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  399. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  400. this->ClientSize = System::Drawing::Size(1019, 386);
  401. this->Controls->Add(this->chart1);
  402. this->Controls->Add(this->label4);
  403. this->Controls->Add(this->button5);
  404. this->Controls->Add(this->button6);
  405. this->Controls->Add(this->textBox13);
  406. this->Controls->Add(this->textBox14);
  407. this->Controls->Add(this->textBox15);
  408. this->Controls->Add(this->textBox16);
  409. this->Controls->Add(this->textBox17);
  410. this->Controls->Add(this->textBox12);
  411. this->Controls->Add(this->textBox11);
  412. this->Controls->Add(this->textBox10);
  413. this->Controls->Add(this->textBox9);
  414. this->Controls->Add(this->textBox8);
  415. this->Controls->Add(this->textBox7);
  416. this->Controls->Add(this->textBox6);
  417. this->Controls->Add(this->textBox5);
  418. this->Controls->Add(this->textBox4);
  419. this->Controls->Add(this->textBox3);
  420. this->Controls->Add(this->label3);
  421. this->Controls->Add(this->button4);
  422. this->Controls->Add(this->button3);
  423. this->Controls->Add(this->button2);
  424. this->Controls->Add(this->button1);
  425. this->Controls->Add(this->textBox2);
  426. this->Controls->Add(this->textBox1);
  427. this->Controls->Add(this->label6);
  428. this->Controls->Add(this->label2);
  429. this->Controls->Add(this->label1);
  430. this->Controls->Add(this->ПИ);
  431. this->Controls->Add(this->ПИД);
  432. this->Name = L"MyForm";
  433. this->Text = L"MyForm";
  434. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->EndInit();
  435. this->ResumeLayout(false);
  436. this->PerformLayout();
  437.  
  438. }
  439. #pragma endregion
  440. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  441. delta = Double::Parse(textBox7->Text);
  442. b = Double::Parse(textBox2->Text);
  443. n = int::Parse(textBox1->Text);
  444.  
  445. a = new double*[n + 1];
  446. for (int i = 0; i <= n; i++)
  447. a[i] = new double[2];
  448.  
  449. d = new double*[n + 2];
  450. for (int i = 0; i <= n + 1; i++)
  451. d[i] = new double[2];
  452.  
  453. a[0][0] = Double::Parse(textBox8->Text);
  454. a[1][0] = Double::Parse(textBox9->Text);
  455. a[2][0] = Double::Parse(textBox10->Text);
  456. a[3][0] = Double::Parse(textBox11->Text);
  457.  
  458. a[0][1] = Double::Parse(textBox17->Text);
  459. a[1][1] = Double::Parse(textBox16->Text);
  460. a[2][1] = Double::Parse(textBox15->Text);
  461. a[3][1] = Double::Parse(textBox14->Text);
  462.  
  463. kd = (a[1][0] * a[1][0] - delta * a[0][1] * a[2][1]) / (delta * b * a[2][1]);
  464. h = 0.32;
  465. lambda = 0.465;
  466. kn = lambda * (a[0][0] + b * kd - 2 * a[1][1] * h) * (a[1][1] - h * a[2][1]) / (b * a[2][1]);
  467.  
  468. textBox3->Text = kn.ToString();
  469. textBox4->Text = kd.ToString();
  470. textBox6->Text = h.ToString();
  471.  
  472. d[0][0] = kn, d[0][0] = kn;
  473. d[1][0] = a[0][0] + kn, d[1][0] = a[0][1] + kn;
  474.  
  475. for (int i = 2; i <= n + 1; i++)
  476. d[i][0] = a[i - 1][0], d[i][1] = a[i - 1][1];
  477.  
  478.  
  479. StreamWriter^ sw = gcnew StreamWriter("input.txt");
  480. for (int i = 0; i <= n + 1; i++)
  481. sw->WriteLine(d[i][0].ToString() + " " + d[i][1].ToString());
  482. sw->Close();
  483.  
  484. //Process::Start("python script.txt");
  485. //System::Threading::Thread::Sleep(5000);
  486. }
  487.  
  488. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  489. StreamReader^ sr = gcnew StreamReader("output.txt");
  490. cntP = int::Parse(sr->ReadLine());
  491. X = new double[cntP];
  492. Y = new double[cntP];
  493.  
  494. for (int i = 0; i < cntP; i++) {
  495. X[i] = Double::Parse(sr->ReadLine());
  496. Y[i] = Double::Parse(sr->ReadLine());
  497. }
  498.  
  499. sr->Close();
  500.  
  501. chart1->Series[0]->Points->Clear();
  502. chart1->Series[0]->ChartType = SeriesChartType::Point;
  503.  
  504. for (int i = 0; i < cntP; i++) {
  505. if (X[i] > 1000 || X[i] < -1000)
  506. continue;
  507. if (Y[i] > 1000 || Y[i] < -1000)
  508. continue;
  509.  
  510. chart1->Series[0]->Points->AddXY(X[i], Y[i]);
  511. }
  512.  
  513. //plot (X, Y) * cntP
  514. }
  515. };
  516. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement