use of com.robo4j.units.lego.LcdTestUnit 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();
}
Aggregations