Пример #1
0
        public static string TachoMotor_Args_To_String(TachoMotor_Args x)
        {
            switch (x)
            {
            case (TachoMotor_Args.duty_cycle_sp):
                return("duty_cycle_sp");

            case (TachoMotor_Args.position_sp):
                return("position_sp");

            case (TachoMotor_Args.ramp_down_sp):
                return("ramp_down_sp");

            case (TachoMotor_Args.ramp_up_sp):
                return("ramp_up_sp");

            case (TachoMotor_Args.speed_sp):
                return("speed_sp");

            case (TachoMotor_Args.time_sp):
                return("time_sp");


            default:
                return("INVALID");
            }
        }
Пример #2
0
 //hands on for more advanced users
 public void ChangeArg(TachoMotor_Args x, string value)
 {
     if (TestArg(value, x))
     {
         WriteVar(TachoMotor_Args_To_String(x), value);
     }
     else
     {
         throw new ArgumentOutOfRangeException("invalid value for this arg");
     }
 }
Пример #3
0
        private bool TestArg(int value, TachoMotor_Args forArg)
        {
            switch (forArg)
            {
            case (TachoMotor_Args.duty_cycle_sp):
                if (value < -100)
                {
                    return(false);
                }
                if (value > 100)
                {
                    return(false);
                }
                return(true);

            case (TachoMotor_Args.position_sp):    //uses full int32 range
                return(true);

            case (TachoMotor_Args.ramp_down_sp):
            case (TachoMotor_Args.ramp_up_sp):
                if (value < 0)
                {
                    return(false);
                }
                if (value > 10000)
                {
                    return(false);
                }
                return(true);

            case (TachoMotor_Args.speed_sp):
                if (value < Max_Speed * -1)
                {
                    return(false);
                }
                if (value > Max_Speed)
                {
                    return(false);
                }
                return(true);

            case (TachoMotor_Args.time_sp):
                if (value < 0)
                {
                    return(false);
                }
                return(true);
            }
            return(false);//should never happen
        }
Пример #4
0
 //safty functions
 private bool TestArg(string value, TachoMotor_Args forArg)
 {
     return(TestArg(int.Parse(value), forArg));
 }