/// <summary> /// Default constructor /// </summary> public BrushedDCMotor(string serialNo) { serialNumber = serialNo; TryToReconnect(); // Try to connect to the device to check if it exists motor.resume(); // motor.setSpeed((short)CONSTANTS.MAX_SPEED); // Set the speed and direction using the constants }
/// <summary> /// This function runs when the user clicks the Reverse button. /// </summary> void reverseButton_Click(object sender, EventArgs e) { try { using (Smc device = connectToDevice()) // Find a device and temporarily connect. { device.resume(); // Clear as many errors as possible. device.setSpeed(-3200); // Set the speed to full reverse (-100%). } } catch (Exception exception) // Handle exceptions by displaying them to the user. { displayException(exception); } }
public void setSpeedRight(Smc device, short speed) { try { // Find a device and temporarily connect. { device.resume(); // Clear as many errors as possible. device.setSpeed(speed); // Set the speed to full forward (+100%). } } catch (Exception exception) // Handle exceptions by displaying them to the user. { Console.WriteLine(exception.Message); device.stop(); } }
public void resume(List <DeviceListItem> deviceList) { try { // Find a device and temporarily connect. foreach (var dev in deviceList) { Smc device = new Smc(dev); device.setSpeed(50); device.resume(); } } catch (Exception error) // Handle exceptions by displaying them to the user. { Console.WriteLine(error.Message); } }