public DimensionedParameter(Units.Dimension dim)
 {
     this.parameter.ManualValue = 1;
     this.parameter.variable = null;
     this.units.dimension = dim;
     this.units.multiplier = Units.Multiplier.unity;
 }
Example #2
0
        public static bool Equivalent(Units a, Units b)
        {
            if (a.dimension != b.dimension)
                return false;
            if (a.multiplier != b.multiplier)
                return false;

            return true;
        }
        protected void changeUnits(Units units)
        {
            backupDimensionedParameter.parameter = dimensionedParameter.parameter;
            backupDimensionedParameter.units = dimensionedParameter.units;
            dimensionedParameter.units = units;

                if (updateGUI != null)
                    updateGUI(this, null);
        }
Example #4
0
        /// <summary>
        /// This constructor attempts to construct a Unit object with the same long or short name as the given string.
        /// (ie it will parse strings like "mHz", "microvolts", "gigaunity", "M", "ks"). The constructor is case sensitive.
        /// If no matching unit type is found, the constructor throws an exception.
        /// </summary>
        /// <param name="unitString"></param>
        public Units(string unitString)
        {
            Units testUnit = new Units();
            foreach (Dimension dim in Dimension.allDimensions)
                foreach (Multiplier mul in Multiplier.allMultipliers)
                {
                    testUnit.myDimension = dim;
                    testUnit.myMultiplier = mul;
                    if ((unitString == testUnit.ToString()) || (unitString == testUnit.toLongString()))
                    {
                        myDimension = dim;
                        myMultiplier = mul;
                        return;
                    }
                }

            throw new Exception("Unrecognized Unit type " + unitString + " passed to Units(string unitString) constructor.");
        }
        private void HorizontalParameterEditor_ParameterChanged(object sender, EventArgs e)
        {
            unitSelector.Items.Clear();
            // Make the units list match the correct dimension type.
            for (int i = 0; i < dimensionedParameter.units.dimension.commonlyUsedMultipliers.GetLength(0); i++)
            {
                Units unit = new Units();
                unit.dimension = dimensionedParameter.units.dimension;
                unit.multiplier = dimensionedParameter.units.dimension.commonlyUsedMultipliers[i];
                unitSelector.Items.Add(unit);

            }

            // insurance policy, in case we somehow get access to really really small numbers.
            if (!unitSelector.Items.Contains(dimensionedParameter.units))
            {
                unitSelector.Items.Add(dimensionedParameter.units);
            }

            unitSelector.SelectedItem = dimensionedParameter.units;

            variableComboBox1.updateListItems();

            if (dimensionedParameter.parameter.variable != null)
            {
                variableComboBox1.Enabled = true;
                variableComboBox1.Visible = true;
                variableComboBox1.SelectedVariable = dimensionedParameter.parameter.variable;
            }
            else
            {
                variableComboBox1.Enabled = false;
                variableComboBox1.Visible = false;
                variableComboBox1.SelectedVariable = null;
            }
        }
 public DimensionedParameter(DimensionedParameter parameter)
 {
     this.parameter = parameter.parameter;
     this.units = parameter.units;
 }
 /// <summary>
 /// Forces this dimensioned parameter to take on a manual value with specified units. This will stop use of
 /// any previously used variable.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="units"></param>
 public void forceToManualValue(double value, Units units)
 {
     this.units = units;
     this.parameter.forceToManualValue(value);
 }
 public DimensionedParameter(Units units, double manualValue)
 {
     this.units = units;
     this.parameter.forceToManualValue(manualValue);
 }
			/// <summary>
			/// Dimensions of the extra parameters for this interpolation type, where yAxisDimension is the dimension
            /// of the y axis of the waveform (usually Volts, but in some cases could be Hz. Or maybe even amps?)
			/// </summary>
			public Units.Dimension [] extraParameterDimensionsForNonstandardYAxis (Units.Dimension yAxisDimension)
			{
                if (this.extraParametersCount==0)
                    return null;
                Units.Dimension[] answer = new Units.Dimension[this.extraParametersCount];
                for (int i=0; i<this.extraParametersCount; i++) {
                   if (ExtraParameterDimensionUseYAxis[(int)myID][i])
                       answer[i] = yAxisDimension;
                   else
                       answer[i] = ExtraParameterDimensions[(int)myID][i];
                }
                return answer;
			}
Example #10
0
 public Waveform(Units.Dimension nonStandardYAxisUnits)
 {
     this.YUnits = nonStandardYAxisUnits;
     this.setInterpolationType(InterpolationType.Linear);
 }
 /// <summary>
 /// Forces this dimensioned parameter to take on a manual value with specified units. This will stop use of
 /// any previously used variable.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="units"></param>
 public void forceToManualValue(double value, Units units)
 {
     this.units = units;
     this.parameter.forceToManualValue(value);
 }
 public DimensionedParameter(DimensionedParameter parameter)
 {
     this.parameter = parameter.parameter;
     this.units     = parameter.units;
 }
 public DimensionedParameter(Units units, double manualValue)
 {
     this.units = units;
     this.parameter.forceToManualValue(manualValue);
 }