@Test public void testCar() throws Exception { Car car = getCar(); car.setPowerOn(); int tvalues[]= {-1,120,1000}; for (int tvalue:tvalues) { car.turn(new ServoPosition(tvalue,tvalue*10)); } int dvalues[]= {-1,150,1000}; for (int dvalue:dvalues) { car.drive(new ServoPosition(dvalue,dvalue*10)); } if (debug) servoCommand.showLog(); }
private Car() { if (servoCommand == null) { Environment env = Config.getEnvironment(); String servo_CommandConfig="servoblaster"; try { servo_CommandConfig = env.getString(Config.SERVO_COMMAND); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } switch (servo_CommandConfig) { case "adafruit": try { servoCommand=new AdaFruit(); LOG.info("using AdaFruit ServoCommand handling"); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } break; default: servoCommand = new ServoBlaster(); } } engine = new Engine(this, new EngineMap(servoCommand)); steering = new Steering(this, new SteeringMap(servoCommand)); led = new Led(new LedMap(servoCommand)); }
Car { private Car() { if (servoCommand == null) { Environment env = Config.getEnvironment(); String servo_CommandConfig="servoblaster"; try { servo_CommandConfig = env.getString(Config.SERVO_COMMAND); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } switch (servo_CommandConfig) { case "adafruit": try { servoCommand=new AdaFruit(); LOG.info("using AdaFruit ServoCommand handling"); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } break; default: servoCommand = new ServoBlaster(); } } engine = new Engine(this, new EngineMap(servoCommand)); steering = new Steering(this, new SteeringMap(servoCommand)); led = new Led(new LedMap(servoCommand)); } }
Car { private Car() { if (servoCommand == null) { Environment env = Config.getEnvironment(); String servo_CommandConfig="servoblaster"; try { servo_CommandConfig = env.getString(Config.SERVO_COMMAND); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } switch (servo_CommandConfig) { case "adafruit": try { servoCommand=new AdaFruit(); LOG.info("using AdaFruit ServoCommand handling"); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } break; default: servoCommand = new ServoBlaster(); } } engine = new Engine(this, new EngineMap(servoCommand)); steering = new Steering(this, new SteeringMap(servoCommand)); led = new Led(new LedMap(servoCommand)); } private  Car(); }
Car { private Car() { if (servoCommand == null) { Environment env = Config.getEnvironment(); String servo_CommandConfig="servoblaster"; try { servo_CommandConfig = env.getString(Config.SERVO_COMMAND); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } switch (servo_CommandConfig) { case "adafruit": try { servoCommand=new AdaFruit(); LOG.info("using AdaFruit ServoCommand handling"); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } break; default: servoCommand = new ServoBlaster(); } } engine = new Engine(this, new EngineMap(servoCommand)); steering = new Steering(this, new SteeringMap(servoCommand)); led = new Led(new LedMap(servoCommand)); } private  Car(); void configure(Engine engine, Steering steering, Led led); void setPowerOn(); void setPowerOff(); boolean powerIsOn(); void stop(); void turn(ServoPosition position); void drive(ServoPosition speed); Engine getEngine(); Steering getSteering(); Led getLed(); static Car getInstance(); static void resetInstance(); }
Car { private Car() { if (servoCommand == null) { Environment env = Config.getEnvironment(); String servo_CommandConfig="servoblaster"; try { servo_CommandConfig = env.getString(Config.SERVO_COMMAND); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } switch (servo_CommandConfig) { case "adafruit": try { servoCommand=new AdaFruit(); LOG.info("using AdaFruit ServoCommand handling"); } catch (Exception e) { ErrorHandler.getInstance().handle(e); } break; default: servoCommand = new ServoBlaster(); } } engine = new Engine(this, new EngineMap(servoCommand)); steering = new Steering(this, new SteeringMap(servoCommand)); led = new Led(new LedMap(servoCommand)); } private  Car(); void configure(Engine engine, Steering steering, Led led); void setPowerOn(); void setPowerOff(); boolean powerIsOn(); void stop(); void turn(ServoPosition position); void drive(ServoPosition speed); Engine getEngine(); Steering getSteering(); Led getLed(); static Car getInstance(); static void resetInstance(); static ServoCommand servoCommand; }