private void btnSendParametersToRLC_Click(object sender, EventArgs e) { MeasurementType mt = MeasurementType.Unknown; if (this.rbParallelCapacitance.Checked) { mt = MeasurementType.Capacitance_Parallel; } if (this.rbSerialCapacitance.Checked) { mt = MeasurementType.Capacitance_Serial; } if (this.rbImpedance.Checked) { mt = MeasurementType.Resistance_Reactance; } int freq = (int)this.edtMeasurementFrequency.Value; double voltage = (double)this.edtVoltage.Value; double delay = (double)this.edtTriggerDelay.Value; int average = (int)this.edtAverage.Value; Debug.Assert(mt != MeasurementType.Unknown); try { Program.a.SendConfiguration(mt, freq, voltage, delay, 0, average); MessageBox.Show("Konfiguracja wysłana do mostka.\nTryb pomiarowy=" + mt.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Wyjątek podczas komunikacji z mostkiem:\n" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Program.a.SafeDisconnect(); } }
public static Attribute[] GetAttributes(this MeasurementType measType) { var fi = measType.GetType().GetField(measType.ToString()); Attribute[] attributes = (Attribute[])fi.GetCustomAttributes(typeof(Attribute), false); return(attributes); }
public static string GetDisplayName(this MeasurementType measType) { Attribute[] attributes = measType.GetAttributes(); MeasurementTypeAttribute attr = null; for (int i = 0; i < attributes.Length; i++) { if (attributes[i].GetType() == typeof(MeasurementTypeAttribute)) { attr = (MeasurementTypeAttribute)attributes[i]; break; } } if (attr == null) { return(measType.ToString()); } else { return(attr.DisplayName); } }
public override string GetMeasurementType() => MeasurementType.ToString();
public override string ToString() { return(Amount + MeasurementType.ToString()); }