use of com.robo4j.hw.lego.provider.SensorProvider in project robo4j by Robo4J.
the class TouchPlatformSpeedUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
lcdTarget = configuration.getString(PROPERTY_TARGET, null);
if (lcdTarget == null) {
throw ConfigurationException.createMissingConfigNameException(PROPERTY_TARGET);
}
platformTarget = configuration.getString(PROPERTY_PLATFORM_TARGET, null);
if (platformTarget == null) {
throw ConfigurationException.createMissingConfigNameException(PROPERTY_PLATFORM_TARGET);
}
String sensorPort = configuration.getString(PROPERTY_SENSOR_PORT, null);
if (sensorPort == null) {
throw ConfigurationException.createMissingConfigNameException(PROPERTY_SENSOR_PORT);
}
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorPort), SensorTypeEnum.TOUCH);
sensorActive.set(true);
speedMin = configuration.getInteger(PROPERTY_SPEED_MIN, 150);
speedMax = configuration.getInteger(PROPERTY_SPEED_MAX, 300);
speedIncrement = configuration.getInteger(PROPERTY_SPEED_INCREMENT, 50);
if ((speedMin % speedIncrement != 0) || (speedMax % speedIncrement != 0)) {
throw new ConfigurationException(String.format("min: %d and max: %d speed needs to be divisible by increment: %d", speedMin, speedMax, speedIncrement));
}
currentSpeed = speedMin;
}
Aggregations