public void setPlotVar(ref workhorse current) { int i = 0; for (i = 0; i < current.ncol; i++) { if (current.colnames[i].Contains("TPS")) { current.tpsIndex = i; filldata(ref current.TPS, ref current, current.tpsIndex); } else if (current.colnames[i].Contains("STR")) { current.strIndex = i; filldata(ref current.STR, ref current, current.strIndex); } else if (current.colnames[i].Contains("FBPS")) { current.fbpsIndex = i; filldata(ref current.BPS, ref current, current.fbpsIndex); } } //label1.Text = Convert.ToString(current.rbpsIndex); //label1.Text = current.colnames[13]; //label1.Text = Convert.ToString(current.colnames[24].StartsWith("\" RBPS")); }
public void fillaccelydata(ref double[] x, ref workhorse current) // Fills data int the channels (one at a time) for further processing { x = new double[current.nrow - 1]; // Because header row has been removed int j; String str = "Accelz"; for (j = 1; j < current.ncol - 1; j++) { if (String.Compare(current.colnames[j], 1, str, 0, 6, true) == 0)// make sure that the col name is like "accely" { for (int i = 1; i < current.nrow - 1; i++) { x[i] = current.elements[i, j]; // Dropdown items are indexed from 0 } } } for (int k = 1; k < current.nrow - 1; k++) { if (k > 10) { double summ = 0; for (int l = k; l > k - 10; l--) { summ = summ + x[l]; } summ = summ / 10; x[k] = summ; } } }
public void filldata(ref double[] x, ref workhorse current) { x = new double[current.nrow - 1]; for (int i = 1; i < current.nrow - 1; i++) { x[i] = current.elements[i, comboBox1.SelectedIndex]; } }
public void populate(ComboBox dropdown, ref workhorse current) { dropdown.Items.Clear(); for (int i = 0; i < current.ncol; i++) { dropdown.Items.Add(current.colnames[i]); } }
public void readit(Label file, ref workhorse current) { OpenFileDialog open = new OpenFileDialog(); open.Title = "Open"; open.Filter = "Text Files (*.csv)|*.csv| All Files (*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) { StreamReader read = new StreamReader(File.OpenRead(open.FileName)); String fileName = open.FileName; file.Text = Path.GetFileName(fileName); String text = read.ReadToEnd(); String[] lines = text.Split('\n'); current.nrow = lines.Length - 1; current.ncol = lines[1].Split(',').Length; current.elements = new Double[current.nrow - 1, current.ncol]; String[] row; row = new String[current.ncol]; current.colnames = new string[current.ncol]; for (int i = 0; i < current.nrow; i++) { row = lines[i].Split(','); for (int j = 0; j < current.ncol; j++) { if (i == 0) { current.colnames[j] = row[j]; listBox1.Items.Add(current.colnames[j]); } else { current.elements[i - 1, j] = Convert.ToDouble(row[j]); } } read.Dispose(); } } }
public void populate(ComboBox dropdown, ref workhorse current) // Populates the dropdown menu with column headers { dropdown.Items.Clear(); // Clears the list. Necessary if files are changed. for (int i = 0; i < current.ncol; i++) { dropdown.Items.Add(current.colnames[i]); // This is what populates the list } dropdown.SelectedIndex = 0; }
public void filldata(ref double[] x, ref workhorse current, int index) // Fills data int the channels (one at a time) for further processing { try { x = new double[current.nrow - 1]; // Because header row has been removed for (int i = 0; i < current.nrow - 1; i++) { x[i] = current.elements[i, index]; // Dropdown items are indexed from 0 //listBox1.Items.Add(x[i]); } } catch { for (int i = 0; i < current.nrow - 1; i++) { x[i] = 0; // Set default value to zero } } }
/// <summary> /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// </summary> // The next few are functions I have defined to read and load the data... public void readit(Label file, ref workhorse current) // Reads the data and extracts it's contents as a matrix { OpenFileDialog open = new OpenFileDialog(); // Opens dialogue box to ask for file to read. open.Title = "Open"; open.Filter = "Text Files (*.log)|*.log| All Files (*.*)|*.*"; // What type to read. if (open.ShowDialog() == DialogResult.OK) // Executes iff "OK" is pressed on the dialogue box. { StreamReader read = new StreamReader(File.OpenRead(open.FileName)); // good luck with PTSD. String FN = open.FileName; current.filename = Path.GetFileName(FN); file.Text = current.filename; // Displays filename in a label. String text = read.ReadToEnd(); // Reads the entire file but as a string. String[] lines = text.Split('\n'); // Use blank space as delimiter to distingish rows. current.nrow = lines.Length - 1; // Last line is empty... current.ncol = lines[1].Split(',').Length + 1; // Use commas to distinguish elemints current.elements = new Double[current.nrow - 1, current.ncol]; // Dimensioning the matrix String[] row; // Temporary storage for the row-data row = new String[current.ncol]; current.colnames = new string[current.ncol]; // For headers current.colnames[0] = "None"; for (int i = 0; i < current.nrow; i++) { row = lines[i].Split(','); // Stores lines in row as a string. for (int j = 0; j < current.ncol; j++) { if (i == 0) { if (j < current.ncol - 1) { current.colnames[j + 1] = row[j]; // Stores column names. } } else { if (j == 0) { current.elements[i - 1, j] = -9999.9999; continue; } String temp = row[j - 1]; // technical reasons if (temp.Length == 0) { current.elements[i - 1, j] = -9999.9999; // If a field iss empty, enter a preassigned value } else { current.elements[i - 1, j] = Convert.ToDouble(row[j - 1]); // Stores corresponding numerical data. } } } read.Dispose(); // Destroy !! current.status = 1; } } else { current.status = 0; } }