public TeamControlModel(Int16 plat1, Int16 plat2, Int16 obs1, Int16 obs2, Int16 hover, Int16 start, Int16 motor1, Int16 motor2, Int16 frontLim, Int16 backLim) { Platform1Led = new LedModel(plat1); Platform2Led = new LedModel(plat2); Obstacle1Led = new LedModel(obs1); Obstacle2Led = new LedModel(obs2); HoverLed = new LedModel(hover); StartLed = new LedModel(start); BackLimSwitch = new SensorModel(backLim); FrontLimSwitch = new SensorModel(frontLim); Motor = new MotorModel(motor1, motor2, FrontLimSwitch, BackLimSwitch); Motor.LimitMode = true; EnableLimitSwitches = true; }
//Commands Arduino to change physical motor state to match current motor state values. //Returns false if communication or motor pins are bad. public bool SetMotor(MotorModel motor) { bool success = false; if (_comOK && motor.PinNumber1 >= 0 && motor.PinNumber2 >= 0) { try { success = true; _session.SetDigitalPin(motor.PinNumber1, motor.In1); _session.SetDigitalPin(motor.PinNumber2, motor.In2); } catch { success = false; _comOK = false; motor.In1 = false; motor.In2 = false; } } return(success); }
private void OnMotorChanged(object sender, PropertyChangedEventArgs e) { MotorModel motor = (MotorModel)sender; SetMotor(motor); }