// Called when the acceleration unit selection is changed
 private void OnAccelerationUnitSelectionChanged(object sender, EventArgs e)
 {
     foreach (ControlEnums.BASEUNITS unit in Enum.GetValues(typeof(ControlEnums.BASEUNITS)))
     {
         if (CurrentAccelerationUnitSelectionBox.Text == ControlEnums.GetAttribute(unit).disp)
         {
             currentAccelerationUnit = unit;
             break;
         }
     }
     WriteMessage("Selected Acceleration Unit updated to " + ControlEnums.GetAttribute(currentAccelerationUnit).disp);
 }
 // Calculates the unit conversion factors for position, velocity and acceleration, in deg, rad and revs
 public double GetBaseUnitConversionFactor(ControlEnums.AXISOPTIONS axis, ControlEnums.BASEUNITS unit)
 {
     if (unit == ControlEnums.BASEUNITS.DEG)
     {
         return(360.0 / 2000.0);
     }
     if (unit == ControlEnums.BASEUNITS.RAD)
     {
         return(2.0 * Math.PI / 2000.0);
     }
     if (unit == ControlEnums.BASEUNITS.REVS)
     {
         if (axis == ControlEnums.AXISOPTIONS.POSITION)
         {
             return(1.0 / 2000.0);
         }
         else
         {
             return(60.0 / 2000.0);
         }
     }
     return(1.0);
 }
 // Sets the unit conversion factors for position, velocity and acceleration, for either axis mapper
 public void CalculateBaseUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.AXISOPTIONS axis, ControlEnums.BASEUNITS unit, bool xAxis)
 {
     if (axis == ControlEnums.AXISOPTIONS.POSITION)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.position * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.position * GetBaseUnitConversionFactor(axis, unit));
         }
     }
     if (axis == ControlEnums.AXISOPTIONS.VELOCITY)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.velocity * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.velocity * GetBaseUnitConversionFactor(axis, unit));
         }
     }
     if (axis == ControlEnums.AXISOPTIONS.ACCELERATION)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.acceleration * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.acceleration * GetBaseUnitConversionFactor(axis, unit));
         }
     }
 }