private void InitializeIgnitionMap() { IgnitionMapDataGridView.Redim(11, 11); IgnitionMapDataGridView.FixedColumns = 1; IgnitionMapDataGridView.FixedRows = 1; IgnitionMapDataGridView[0, 0] = new SourceGrid.Cells.ColumnHeader(string.Empty) { View = emptyHeaderView }; IgnitionMapDataGridView[0, 0].Column.MinimalWidth = 80; IgnitionMapDataGridView[0, 0].Column.MaximalWidth = 200; IgnitionMapDataGridView[0, 0].Column.Width = 80; for (int rowIndex = 1; rowIndex < 11; rowIndex++) { IgnitionMapDataGridView[rowIndex, 0] = new LoadCell(Font, Controller.GlobalConfiguration.LoadTypeMaximum, (binIndex, value) => Controller.IgnitionMap.UpdateLoadBin(binIndex, value)); IgnitionMapDataGridView.Rows[rowIndex].Height = 28; for (int columnIndex = 1; columnIndex < IgnitionMapDataGridView.ColumnsCount; columnIndex++) { if (rowIndex == 1) { Cell rpmHeaderCellheader = new RpmCell(Font, (binIndex, value) => Controller.IgnitionMap.UpdateRpmBin(binIndex, value)); IgnitionMapDataGridView[0, columnIndex] = rpmHeaderCellheader; rpmHeaderCellheader.Column.MinimalWidth = 60; rpmHeaderCellheader.Column.Width = 60; rpmHeaderCellheader.View = columnHeaderView; } IgnitionMapDataGridView[rowIndex, columnIndex] = new AdvanceCell(Font, true, (row, col, value) => Controller.IgnitionMap[row, col] = unchecked ((byte)value)); } } IgnitionMapDataGridView.Width = 0; //This will force a resize so the columns will stretch to fill the space. The width will not actually be set to 0 because the Dock property is set to Fill. }
void LoadCellComboBox_SelectedIndexChanged(object sender, EventArgs e) { LoadCell loadCell = (LoadCell)LoadCellComboBox.SelectedItem; ratioBox.Text = loadCell.A; ratioBox2.Text = loadCell.B; labelSign.Text = loadCell.Sign; thresholdNumericUpDown.Value = Convert.ToDecimal(loadCell.Threshold); }
/// <summary> /// 设置comboBox的默认索引 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { comboBox_boardNum.SelectedIndex = 0; SampleRateCombo.SelectedIndex = 7; stripChart_position.YAutoEnable = false; stripChart_position.AxisYMax = 10; stripChart_position.AxisYMin = 0; stripChart_weight.YAutoEnable = true; this._loadCell = new LoadCell(1.5, 1000, 5); this._displacementsensor = new DisplacementSensor(5000, 10, 0); this._thermistor = new Thermistor(100000, 3950); //stripChart_weight.AxisYMax = 1000; //stripChart_weight.AxisYMin = 0; }
private void easyButton1_Click(object sender, EventArgs e) { value = (double)numericUpDown_value.Value; for (int i = 0; i < values.Length; i++) { values[i] = value; } double[] res; switch (comboBox1.SelectedItem.ToString()) { case "位移传感器": numericUpDown_result.Value = (decimal)DisplacementSensor.Convert(value, (double)numericUpDown_maxDisp.Value, (double)numericUpDown_maxR.Value, (double)numericUpDown_minR.Value); res = DisplacementSensor.Convert(values, (double)numericUpDown_maxDisp.Value, (double)numericUpDown_maxR.Value, (double)numericUpDown_minR.Value); easyChartX1.Plot(res); break; case "荷重传感器": numericUpDown_result.Value = (decimal)LoadCell.Convert(value, (double)numericUpDown_sensitivity.Value, (double)numericUpDown_maxLoad.Value, (double)numericUpDown_excitationVolt.Value); res = LoadCell.Convert(values, (double)numericUpDown_sensitivity.Value, (double)numericUpDown_maxLoad.Value, (double)numericUpDown_excitationVolt.Value); easyChartX1.Plot(res); break; case "热电阻RTD_PT100": numericUpDown_result.Value = (decimal)RTD.Convert(value); res = RTD.Convert(values); easyChartX1.Plot(res); break; case "热敏电阻Thermistor": numericUpDown_result.Value = (decimal)Thermistor.Convert(value, (double)numericUpDown_resistorRT.Value, (double)numericUpDown_beta.Value); res = Thermistor.Convert(values, (double)numericUpDown_resistorRT.Value, (double)numericUpDown_beta.Value); easyChartX1.Plot(res); break; case "热电偶Thermocouple": numericUpDown_result.Value = (decimal)Thermocouple.Convert((ThermocoupleType)Enum.Parse(typeof(ThermocoupleType), comboBox2.Text), value, checkBox_cjcEnable.Checked, (double)numericUpDown_cjcTemperature.Value); res = Thermocouple.Convert((ThermocoupleType)Enum.Parse(typeof(ThermocoupleType), comboBox2.Text), values, checkBox_cjcEnable.Checked, (double)numericUpDown_cjcTemperature.Value); easyChartX1.Plot(res); break; default: break; } }
private void CreateCalibrationFile() { string date = ReplaceDate(); LoadCell loadCell = (LoadCell)LoadCellComboBox.SelectedItem; string fileName = "Calibration " + loadCell.Name + " load cell " + date + ".txt"; fullPath = Application.StartupPath.ToString() + "\\" + fileName; try { using (StreamWriter sw = new StreamWriter(fullPath, false, System.Text.Encoding.Default)) { string calibration = "Start calibration load cell: " + loadCell.Name; sw.WriteLine(calibration); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private void CreateLogFile() { string date = ReplaceDate(); string fileName = date + ".log"; fullPath = Application.StartupPath.ToString() + "\\logs\\" + fileName; LoadCell loadCell = (LoadCell)LoadCellComboBox.SelectedItem; try { using (StreamWriter sw = new StreamWriter(fullPath, false, System.Text.Encoding.Default)) { string log = "*Start log*" + "\n" + "Date: " + labelDateValue.Text + "\n" + "Test #" + testNumberTextBox.Text + "\n" + "Motor: " + motorTextBox.Text + "\n" + "Propellant mass, kg: " + propellantMassTextBox.Text + "\n" + "Load cell: " + loadCell.Name + "\n"; sw.WriteLine(log); } } catch (Exception e) { Console.WriteLine(e.Message); MessageBox.Show("The logs folder was not found. Create the folder and relaunch the application."); } }
public Form1() { InitializeComponent(); serialPort1.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); AxisYOperatingName = chart1.ChartAreas[0].AxisY.Title; SetAxis(); List <LoadCell> loadCells = new List <LoadCell>(); string path = Application.StartupPath.ToString() + "\\Load cells.txt"; using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default)) { string line; while ((line = sr.ReadLine()) != null) { string[] words = line.Split(new char[] { ' ' }); loadCells.Add(new LoadCell { Name = words[0], A = words[1], B = words[2], Sign = words[3], Threshold = words[4] }); } } LoadCellComboBox.DataSource = loadCells; LoadCellComboBox.DisplayMember = "Name"; LoadCell loadCell = (LoadCell)LoadCellComboBox.SelectedItem; ratioBox.Text = loadCell.A; ratioBox2.Text = loadCell.B; thresholdNumericUpDown.Value = Convert.ToDecimal(loadCell.Threshold); labelSign.Text = loadCell.Sign; LoadCellComboBox.SelectedIndexChanged += LoadCellComboBox_SelectedIndexChanged; labelDateValue.Text = DateTime.Now.ToString("dd.MM.yyy"); }
public Gripper(Servo servo, LoadCell loadCell) { this.servo = servo; this.loadCell = loadCell; }