private void SaveCalibrationData() { calData.pullEtalonP0 = Convert.ToInt32(pollEtalonP0.Text); calData.pullADCP0 = Convert.ToInt32(pollADCP0.Text); calData.pullEtalonP1 = Convert.ToInt32(pollEtalonP1.Text); calData.pullADCP1 = Convert.ToInt32(pollADCP1.Text); calData.torqueEtalonP0 = Convert.ToInt32(torqueEtalonP0.Text); calData.torqueADCP0 = Convert.ToInt32(torqueADCP0.Text); calData.torqueEtalonP1 = Convert.ToInt32(torqueEtalonP1.Text); calData.torqueADCP1 = Convert.ToInt32(torqueADCP1.Text); calData.ADCMaximum = Convert.ToInt32(ADCMaximumV.Text); calData.ADCRefVoltage = Convert.ToInt32(ADCRefVoltageV.Text); calData.ResistanceB = Convert.ToInt32(ResistanceBV.Text); calData.ResistanceR0 = Convert.ToInt32(ResistanceR0V.Text); calData.ResistanceT0 = Convert.ToInt32(ResistanceT0V.Text); calData.ADCBallResistance = Convert.ToInt32(ADCBallResistanceV.Text); CalibrationConfig.Serialize(mainWindow.fileName, calData); _isChanged = false; }
public void UpdateCaldata() { calData = CalibrationConfig.Deserialize(mainWindow.fileName); linPullSensor = new LinearEQS(calData.pullEtalonP0, calData.pullADCP0, calData.pullEtalonP1, calData.pullADCP1); linTorqueSensor = new LinearEQS(calData.torqueEtalonP0, calData.torqueADCP0, calData.torqueEtalonP1, calData.torqueADCP1); linTemperatureSensor = new LinearEQS(0, 0, calData.ADCRefVoltage, calData.ADCMaximum); }
public static void Serialize(string file, CalibrationConfig c) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(c.GetType()); StreamWriter writer = File.CreateText(file); xs.Serialize(writer, c); writer.Flush(); writer.Close(); }
public static CalibrationConfig Deserialize(string file) { CalibrationConfig c = new CalibrationConfig(); try { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer( typeof(CalibrationConfig)); StreamReader reader = File.OpenText(file); c = (CalibrationConfig)xs.Deserialize(reader); reader.Close(); } catch (Exception) { } return(c); }
private void Settings_Load(object sender, EventArgs e) { calData = CalibrationConfig.Deserialize(mainWindow.fileName); pollEtalonP0.Text = calData.pullEtalonP0.ToString(); pollEtalonP1.Text = calData.pullEtalonP1.ToString(); pollADCP0.Text = calData.pullADCP0.ToString(); pollADCP1.Text = calData.pullADCP1.ToString(); torqueEtalonP0.Text = calData.torqueEtalonP0.ToString(); torqueEtalonP1.Text = calData.torqueEtalonP1.ToString(); torqueADCP0.Text = calData.torqueADCP0.ToString(); torqueADCP1.Text = calData.torqueADCP1.ToString(); ADCMaximumV.Text = calData.ADCMaximum.ToString(); ADCRefVoltageV.Text = calData.ADCRefVoltage.ToString(); ResistanceBV.Text = calData.ResistanceB.ToString(); ResistanceR0V.Text = calData.ResistanceR0.ToString(); ResistanceT0V.Text = calData.ResistanceT0.ToString(); ADCBallResistanceV.Text = calData.ADCBallResistance.ToString(); _ignoreLoad = false; }