Search in sources :

Example 1 with SimpleTankTestUnit

use of com.robo4j.units.lego.SimpleTankTestUnit in project robo4j by Robo4J.

the class TankExampleTests method legoTankExampleTest.

@Test
public void legoTankExampleTest() throws Exception {
    RoboSystem system = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    HttpServerUnit http = new HttpServerUnit(system, "http");
    config.setString("target", UNIT_CONTROLLER_NAME);
    config.setInteger("port", PORT);
    config.setString("packages", "com.robo4j.units.lego.example.codec");
    /* specific configuration */
    Configuration targetUnits = config.createChildConfiguration(RoboHttpUtils.HTTP_TARGET_UNITS);
    targetUnits.setString(UNIT_CONTROLLER_NAME, "GET");
    http.initialize(config);
    TankExampleController ctrl = new TankExampleController(system, UNIT_CONTROLLER_NAME);
    config = ConfigurationFactory.createEmptyConfiguration();
    config.setString("target", "platform");
    ctrl.initialize(config);
    /* platform is listening to the bus */
    SimpleTankTestUnit platform = new SimpleTankTestUnit(system, "platform");
    config = ConfigurationFactory.createEmptyConfiguration();
    config.setString("leftMotorPort", "B");
    config.setCharacter("leftMotorType", 'N');
    config.setString("rightMotorPort", "C");
    config.setCharacter("rightMotorType", 'N');
    platform.initialize(config);
    /* lcd is listening to the bus */
    LcdTestUnit lcd = new LcdTestUnit(system, "lcd");
    config = ConfigurationFactory.createEmptyConfiguration();
    lcd.initialize(config);
    // BasicSonicUnit sonic = new BasicSonicUnit(system, "sonic");
    // config = ConfigurationFactory.createEmptyConfiguration();
    // config.setString("target", "controller");
    // sonic.initialize(config);
    // system.addUnits(http, ctrl, platform, lcd, sonic);
    system.addUnits(http, ctrl, platform, lcd);
    system.start();
    lcd.onMessage("Press Key to end...");
    //		System.in.read();
    system.stop();
    system.shutdown();
}
Also used : SimpleTankTestUnit(com.robo4j.units.lego.SimpleTankTestUnit) RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) LcdTestUnit(com.robo4j.units.lego.LcdTestUnit) HttpServerUnit(com.robo4j.core.httpunit.HttpServerUnit) Test(org.junit.Test)

Aggregations

RoboSystem (com.robo4j.core.RoboSystem)1 Configuration (com.robo4j.core.configuration.Configuration)1 HttpServerUnit (com.robo4j.core.httpunit.HttpServerUnit)1 LcdTestUnit (com.robo4j.units.lego.LcdTestUnit)1 SimpleTankTestUnit (com.robo4j.units.lego.SimpleTankTestUnit)1 Test (org.junit.Test)1