public SAGEScan(ref double[] scan_massSA, ref double[] scan_mass, ref string versionPribor, ref SerialPort newPort, ref int countscan) { int countSA; Regex regex1; bool message1 = true; if (versionPribor.Contains("2")) { countSA = 8; } else { countSA = 4; } LogoForm logoform = new LogoForm(); string GE5_1 = ""; string indata = newPort.ReadExisting(); int indata_zero = 0; string indata_0 = ""; bool indata_bool = true; int GEbyteRecieved4_1 = newPort.ReadBufferSize; byte[] GEbuffer4_1 = new byte[GEbyteRecieved4_1]; Regex regex = new Regex(@"\W"); newPort.Write("SA " + countSA + "\r"); indata = newPort.ReadExisting(); indata_zero = 0; indata_0 = ""; indata_bool = true; while (indata_bool == true) { if (indata.Contains(">")) { indata_bool = false; } else { indata = newPort.ReadExisting(); } } newPort.Write("GE 1\r"); indata_0 = ""; for (int i = 0; i <= 5000000; i++) { indata = newPort.ReadExisting(); if (indata_0.Contains("\r>")) { break; } indata_0 += indata; } indata_zero = 0; indata_bool = true; regex = new Regex(@"\W"); regex1 = new Regex(@"\D"); GE5_1 = regex.Replace(indata_0, ""); GE5_1 = regex1.Replace(GE5_1, ""); string GE5_1_0 = regex.Replace(indata_0, ""); GE5_1_0 = regex1.Replace(GE5_1, ""); double GAText1 = (Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1_0)) * 100; double OptPlot = Math.Log10(Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1)); double OptPlot1 = OptPlot - Math.Truncate(OptPlot); while (Convert.ToInt32(GE5_1) > 10000 && countSA > 1) { countSA--; newPort.Write("SA " + countSA + "\r"); int SAAnalisByteRecieved1_1_1 = newPort.ReadBufferSize; // Thread.Sleep(100); indata = newPort.ReadExisting(); indata_zero = 0; indata_0 = ""; indata_bool = true; while (indata_bool == true) { if (indata.Contains(">")) { indata_bool = false; } else { indata = newPort.ReadExisting(); } } newPort.Write("GE 1\r"); indata_0 = ""; for (int i = 0; i <= 5000000; i++) { indata = newPort.ReadExisting(); if (indata_0.Contains("\r>")) { break; } indata_0 += indata; } indata_zero = 0; indata_bool = true; regex = new Regex(@"\W"); regex1 = new Regex(@"\D"); GE5_1 = regex.Replace(indata_0, ""); GE5_1 = regex1.Replace(GE5_1, ""); GE5_1_0 = regex.Replace(indata_0, ""); GE5_1_0 = regex1.Replace(GE5_1, ""); GAText1 = (Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1_0)) * 100; OptPlot = Math.Log10(Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1)); OptPlot1 = OptPlot - Math.Truncate(OptPlot); } Application.OpenForms["LogoForm"].Close(); // listBox1.Items.Add(GE5_1_0); scan_mass[countscan] = Convert.ToDouble(GE5_1_0); scan_massSA[countscan] = Convert.ToDouble(countSA); }
public Calibrovka(Ecoview parent) { this._Analis = parent; _Analis.button1.Enabled = false; try { _Analis.label59.Visible = false; switch (_Analis.selet_rezim) { case 5: /* _Analis.StopSpectr = false; * _Analis.countscan = 0; * _Analis.scan_massSA = new double[ScanTable.Rows.Count - 1]; * _Analis.scan_mass = new double[ScanTable.Rows.Count - 1]; * Application.DoEvents(); * LogoForm(); * while ((_Analis.countscan != _Analis.ScanTable.Rows.Count - 1) && (_Analis.StopSpectr != true)) * { * * Application.DoEvents(); * _Analis.label33.Visible = true; * _Analis.Podskazka.Text = "Можно остановить"; * Application.DoEvents(); * _Analis.GWNew.Text = string.Format("{0:0.0}", _Analis.ScanTable.Rows[_Analis.countscan].Cells[0].Value.ToString()); * SW_Scan(); * Thread.Sleep(50); * SAGEScan(ref countSA, ref GE5_1_0); * Application.DoEvents(); * * * _Analis.countscan++; * } * Application.OpenForms["LogoFrm"].Close(); * MessageBox.Show("Калибровка закончена!"); * _Analis.Podskazka.Text = "Можно сканировать"; * _Analis.label59.Visible = false; * _Analis.label28.Visible = true; * _Analis.label25.Visible = false; * _Analis.label26.Visible = false; * _Analis.label33.Visible = false;*/ break; case 3: _Analis.StopSpectr = false; _Analis.countscan = 0; _Analis.scan_massSA = new double[_Analis.dataGridView5.Columns.Count - 2]; _Analis.scan_mass = new double[_Analis.dataGridView5.Columns.Count - 2]; Application.DoEvents(); LogoForm logoform = new LogoForm(); while ((_Analis.countscan != _Analis.dataGridView5.Columns.Count - 2) && (_Analis.StopSpectr != true)) { _Analis.label33.Visible = true; _Analis.Podskazka.Text = "Можно остановить"; Application.DoEvents(); _Analis.SW_MultiScan(); Application.DoEvents(); _Analis.GWNew.Text = string.Format("{0:0.0}", _Analis.textBoxCO[_Analis.countscan].Text); _Analis.button12.Enabled = false; _Analis.button14.Enabled = false; _Analis.button11.Enabled = true; SAGEScan sageScan = new SAGEScan(ref _Analis.scan_massSA, ref _Analis.scan_mass, ref _Analis.versionPribor, ref _Analis.newPort, ref _Analis.countscan); Application.DoEvents(); _Analis.countscan++; } Application.OpenForms["LogoForm"].Close(); _Analis.button12.Enabled = true; _Analis.button14.Enabled = true; _Analis.button11.Enabled = false; MessageBox.Show("Калибровка закончена!"); _Analis.label59.Visible = false; _Analis.label28.Visible = true; _Analis.label25.Visible = false; _Analis.label26.Visible = false; _Analis.Podskazka.Text = "Можно сканировать"; _Analis.label33.Visible = false; break; default: SAGE sage = new SAGE(ref _Analis.countSA, ref _Analis.GE5_1_0, ref _Analis.versionPribor, ref _Analis.newPort); MessageBox.Show("Калибровка закончена!"); _Analis.label59.Visible = false; _Analis.label28.Visible = true; _Analis.label25.Visible = false; _Analis.label26.Visible = false; _Analis.label27.Visible = false; _Analis.label33.Visible = false; _Analis.Podskazka.Text = "Можно сканировать"; break; } _Analis.button3.Enabled = true; _Analis.Podskazka.Text = "Можно сканировать"; _Analis.button1.Enabled = true; } catch { } }
public SAGE(ref int countSA, ref string GE5_1_0, ref string versionPribor, ref SerialPort newPort) { if (versionPribor.Contains("2")) { countSA = 8; } else { countSA = 4; } LogoForm logoform = new LogoForm(); newPort.Write("SA " + countSA + "\r"); string indata = newPort.ReadExisting(); string indata_0; bool indata_bool = true; while (indata_bool == true) { if (indata.Contains(">")) { indata_bool = false; } else { indata = newPort.ReadExisting(); } } newPort.Write("GE 1\r"); indata_0 = ""; for (int i = 0; i <= 5000000; i++) { indata = newPort.ReadExisting(); if (indata_0.Contains("\r>")) { break; } indata_0 += indata; } int indata_zero = 0; indata_bool = true; string GE5_1 = ""; Regex regex = new Regex(@"\W"); Regex regex1 = new Regex(@"\D"); GE5_1 = regex.Replace(indata_0, ""); GE5_1 = regex1.Replace(GE5_1, ""); GE5_1_0 = regex.Replace(indata_0, ""); GE5_1_0 = regex1.Replace(GE5_1, ""); //GEText.Text = GE5_1_0; //if(GE5_1 == "") { double GAText1 = (Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1_0)) * 100; // GAText.Text = string.Format("{0:0.00}", GAText1); double OptPlot = Math.Log10(Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1)); double OptPlot1 = OptPlot - Math.Truncate(OptPlot); // OptichPlot.Text = string.Format("{0:0.0000}", OptPlot1); while (Convert.ToInt32(GE5_1) > 10000 && countSA > 1) { countSA--; newPort.Write("SA " + countSA + "\r"); int SAAnalisByteRecieved1_1_1 = newPort.ReadBufferSize; // Thread.Sleep(100); indata = newPort.ReadExisting(); indata_zero = 0; indata_0 = ""; indata_bool = true; while (indata_bool == true) { if (indata.Contains(">")) { indata_bool = false; } else { indata = newPort.ReadExisting(); } } newPort.Write("GE 1\r"); indata_0 = ""; for (int i = 0; i <= 5000000; i++) { indata = newPort.ReadExisting(); if (indata_0.Contains("\r>")) { break; } indata_0 += indata; } indata_zero = 0; indata_bool = true; regex = new Regex(@"\W"); regex1 = new Regex(@"\D"); GE5_1 = regex.Replace(indata_0, ""); GE5_1 = regex1.Replace(GE5_1, ""); GE5_1_0 = regex.Replace(indata_0, ""); GE5_1_0 = regex1.Replace(GE5_1, ""); //GEText.Text = GE5_1_0; // if (GE5_1 == "") { GAText1 = (Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1_0)) * 100; // GAText.Text = string.Format("{0:0.00}", GAText1); OptPlot = Math.Log10(Convert.ToDouble(GE5_1_0) / Convert.ToDouble(GE5_1)); OptPlot1 = OptPlot - Math.Truncate(OptPlot); // OptichPlot.Text = string.Format("{0:0.0000}", OptPlot1); } } } SWF.Application.OpenForms["LogoForm"].Close(); }