예제 #1
0
 public void SetArg(string value, ServoMotor_Args x)
 {
     if (TestArg(value, x))
     {
         WriteVar(ServoMotor_Args_To_String(x), value);
     }
 }
예제 #2
0
 public void SetArg(int value, ServoMotor_Args x)
 {
     if (TestArg(value, x))
     {
         WriteVar(ServoMotor_Args_To_String(x), value.ToString());
     }
 }
예제 #3
0
        public string ServoMotor_Args_To_String(ServoMotor_Args x)
        {
            switch (x)
            {
            case (ServoMotor_Args.max_pulse_sp):
                return("max_pulse_sp");

            case (ServoMotor_Args.mid_pulse_sp):
                return("mid_pulse_sp");

            case (ServoMotor_Args.min_pulse_sp):
                return("min_pulse_sp");

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

            case (ServoMotor_Args.rate_sp):
                return("rate_sp");

            default:
                return("INVALID");
            }
        }
예제 #4
0
        private bool TestArg(int value, ServoMotor_Args forArg)
        {
            switch (forArg)
            {
            case (ServoMotor_Args.max_pulse_sp):
                if (value > 2700)
                {
                    return(false);
                }
                if (value < 2300)
                {
                    return(false);
                }
                return(true);

            case (ServoMotor_Args.mid_pulse_sp):
                if (value > 1700)
                {
                    return(false);
                }
                if (value < 1300)
                {
                    return(false);
                }
                return(true);

            case (ServoMotor_Args.min_pulse_sp):
                if (value > 700)
                {
                    return(false);
                }
                if (value < 300)
                {
                    return(false);
                }
                return(true);

            case (ServoMotor_Args.position_sp):
                if (value > 100)
                {
                    return(false);
                }
                if (value < -100)
                {
                    return(false);
                }
                return(true);

            case (ServoMotor_Args.rate_sp):
                if (value < 0)
                {
                    return(false);
                }
                if (value > 1000)
                {
                    return(false);
                }
                return(true);
            }
            return(false);//should never happen
        }
예제 #5
0
 //safty functions
 private bool TestArg(string value, ServoMotor_Args forArg)
 {
     return(TestArg(int.Parse(value), forArg));
 }