using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { MistINS INS; Boolean Is_F = false; Matrix OurF; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { INS = new MistINS(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text), double.Parse(textBox4.Text));//вычисляем новые значения матриц по введеным данным if (Is_F) INS.F = OurF; Measuring.R = Math.Sqrt(double.Parse(textBox6.Text)); Kalman Filtr = new Kalman(double.Parse(textBox7.Text), double.Parse(textBox8.Text), INS.F); insKalmanV.Series[0].Points.Clear(); insKalmanF.Series[0].Points.Clear(); insKalmanE.Series[0].Points.Clear(); insKalmanV.Series[2].Points.Clear(); insKalmanV.Series[3].Points.Clear(); insKalmanV.Series[4].Points.Clear(); insKalmanF.Series[2].Points.Clear(); insKalmanE.Series[2].Points.Clear(); insKalmanF.Series[3].Points.Clear(); insKalmanE.Series[3].Points.Clear(); //строим граффик за время t int time = int.Parse(textBox5.Text); double t1 = 0; for (int i = 0; i < time/INS.Period; i++) { double t = i * INS.Period; INS.Next(); insKalmanV.Series[0].Points.AddXY(t, INS.Xk1.Mbody[0, 0]); insKalmanF.Series[0].Points.AddXY(t, INS.Xk1.Mbody[1, 0]); insKalmanE.Series[0].Points.AddXY(t, INS.Xk1.Mbody[2, 0]); t1 = Measuring.z(INS.Xk1.Mbody[0, 0]); Filtr.Next(t1); if (i > 50) { insKalmanV.Series[3].Points.AddXY(t, INS.Xk1.Mbody[0, 0]);//t1); insKalmanF.Series[3].Points.AddXY(t, INS.Xk1.Mbody[1, 0]); insKalmanE.Series[3].Points.AddXY(t, INS.Xk1.Mbody[2, 0]); insKalmanV.Series[2].Points.AddXY(t, Filtr.Xk.Mbody[0, 0]); insKalmanF.Series[2].Points.AddXY(t, Filtr.Xk.Mbody[1, 0]); insKalmanE.Series[2].Points.AddXY(t, Filtr.Xk.Mbody[2, 0]); insKalmanV.Series[4].Points.AddXY(t, t1); } } } private void button2_Click(object sender, EventArgs e) { INS = new MistINS(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text), double.Parse(textBox4.Text)); saveFileDialog1.Filter = "Текстовые файлы|*.txt"; if (saveFileDialog1.ShowDialog() != DialogResult.OK) return; INS.SaveToFile(saveFileDialog1.FileName); } private void Form1_Shown(object sender, EventArgs e) { INS = new MistINS(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text), double.Parse(textBox4.Text));//вычисляем новые значения матриц по введеным данным } private void button3_Click(object sender, EventArgs e) { INS = new MistINS(double.Parse(textBox1.Text), double.Parse(textBox2.Text), double.Parse(textBox3.Text), double.Parse(textBox4.Text)); openFileDialog1.Filter = "Текстовые файлы|*.txt"; if (openFileDialog1.ShowDialog() != DialogResult.OK) return; INS.LoadFromFile(openFileDialog1.FileName); textBox1.Text = INS.Bias_x.ToString("e"); textBox2.Text = INS.Betta.ToString("e"); textBox3.Text = INS.Drift_y.ToString("e"); textBox4.Text = INS.Period.ToString("e"); } private void button4_Click_1(object sender, EventArgs e) { Is_F = true; OurF = new Matrix(3, 3); OurF.Mbody[0, 0] = Double.Parse(textBox9.Text); OurF.Mbody[0, 1] = Double.Parse(textBox10.Text); OurF.Mbody[0, 2] = Double.Parse(textBox11.Text); OurF.Mbody[1, 0] = Double.Parse(textBox14.Text); OurF.Mbody[1, 1] = Double.Parse(textBox13.Text); OurF.Mbody[1, 2] = Double.Parse(textBox12.Text); OurF.Mbody[2, 0] = Double.Parse(textBox17.Text); OurF.Mbody[2, 1] = Double.Parse(textBox16.Text); OurF.Mbody[2, 2] = Double.Parse(textBox15.Text); } private void tabPage1_Click(object sender, EventArgs e) { } private void button6_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "Текстовые файлы|*.txt"; if (saveFileDialog1.ShowDialog() != DialogResult.OK) return; string[] lines = { textBox9.Text, textBox10.Text, textBox11.Text, textBox12.Text, textBox13.Text, textBox14.Text, textBox1.Text, textBox16.Text, textBox17.Text}; File.WriteAllLines(saveFileDialog1.FileName, lines); } private void button5_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Текстовые файлы|*.txt"; if (openFileDialog1.ShowDialog() != DialogResult.OK) return; string[] lines = File.ReadAllLines(openFileDialog1.FileName); textBox9.Text = lines[0]; textBox10.Text = lines[1]; textBox11.Text = lines[2]; textBox12.Text = lines[3]; textBox13.Text = lines[4]; textBox14.Text = lines[5]; textBox15.Text = lines[6]; textBox16.Text = lines[7]; textBox17.Text = lines[8]; } private void groupBox5_Enter(object sender, EventArgs e) { } private void button12_Click(object sender, EventArgs e) { Matrix F = new Matrix(1, 1); F.Mbody[0, 0] = double.Parse(textBox20.Text); INS = new MistINS(F, 0, 1, double.Parse(textBox28.Text));//вычисляем новые значения матриц по введеным данным Measuring.R = Math.Sqrt(double.Parse(textBox34.Text)); Kalman Filtr; Matrix F1 = new Matrix(1, 1); F1.Mbody[0, 0] = double.Parse(textBox18.Text); if (!newF) Filtr = new Kalman(double.Parse(textBox33.Text), double.Parse(textBox32.Text), INS.F, 1, double.Parse(textBox19.Text)); else Filtr = new Kalman(double.Parse(textBox33.Text), double.Parse(textBox32.Text), F1, 1, double.Parse(textBox19.Text)); chart7.Series[0].Points.Clear(); chart7.Series[1].Points.Clear(); chart7.Series[2].Points.Clear(); //строим граффик за время t int time = int.Parse(textBox31.Text); double t1=0; double sum=0; double sr=0; for (int t = 0; t < time; t++) { INS.Next(); chart7.Series[0].Points.AddXY(t, INS.Xk1.Mbody[0, 0]); t1 = Measuring.z(INS.Xk1.Mbody[0, 0]); sum += t1; sr = sum / (t + 1); Filtr.Next(t1); // if (i > 50) // { chart7.Series[0].Points.AddXY(t, t1);//t1); chart7.Series[1].Points.AddXY(t, Filtr.Xk.Mbody[0, 0]); chart7.Series[2].Points.AddXY(t, sr); // chart4.Series[0].Points.AddXY(t, Filtr.Xk.Mbody[0, 0]); // chart5.Series[0].Points.AddXY(t, Filtr.Xk.Mbody[1, 0]); // chart6.Series[0].Points.AddXY(t, Filtr.Xk.Mbody[2, 0]); // chart4.Series[2].Points.AddXY(t, t1); // } } } bool newF = false; private void button8_Click(object sender, EventArgs e) { newF = true; } private void textBox33_TextChanged(object sender, EventArgs e) { } private void groupBox8_Enter(object sender, EventArgs e) { } } }