/// <summary> /// execute a command on the motor controller /// </summary> /// <param name="motorcode">the motor on which perform</param> public void executeCommandMotorController(string motorcode, int duration, int speed, bool clockwise) { if (executecommand == null) { executecommand = new SmartToyExecuteStatus(); } if (executecommand.motorControlCommands != null) { List <MotorControllerSetter> temp = executecommand.motorControlCommands.ToList(); MotorControllerSetter t = new MotorControllerSetter(); t.code = motorcode; t.duration = duration; t.speed = speed; t.direction = clockwise ? "cw" : "ccw"; temp.Add(t); executecommand.motorControlCommands = temp.ToArray(); } else { MotorControllerSetter t = new MotorControllerSetter(); t.code = motorcode; t.duration = duration; t.speed = speed; t.direction = clockwise ? "cw" : "ccw"; executecommand.motorControlCommands = new MotorControllerSetter[1]; executecommand.motorControlCommands[0] = t; } }
/// <summary> /// execute a command on the motor controller /// </summary> /// <param name="motorcode">the motor on which perform</param> /// <param name="value">the value of the motor: for vibrational and contunous motor represent the duration of the motion, for step motor the number of steps for servo the angle to reach</param> public void executeCommandMotorController(string motorcode, float value) { if (executecommand == null) { executecommand = new SmartToyExecuteStatus(); } if (executecommand.motorControlCommands != null) { List <MotorControllerSetter> temp = executecommand.motorControlCommands.ToList(); MotorControllerSetter t = new MotorControllerSetter(); t.code = motorcode; t.destination = value; temp.Add(t); executecommand.motorControlCommands = temp.ToArray(); } else { MotorControllerSetter t = new MotorControllerSetter(); t.code = motorcode; t.destination = value; executecommand.motorControlCommands = new MotorControllerSetter[1]; executecommand.motorControlCommands[0] = t; } }