use of com.robo4j.hw.lego.enums.DigitalPortEnum in project robo4j by Robo4J.
the class InfraSensorUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
setState(LifecycleState.UNINITIALIZED);
scanInitialDelay = configuration.getInteger(PROPERTY_SCAN_INIT_DELAY, VALUE_SCAN_INIT_DELAY);
scanPeriod = configuration.getInteger(PROPERTY_SCAN_PERIOD, VALUE_SCAN_PERIOD);
String port = configuration.getString(PROPERTY_SENSOR_PORT, null);
DigitalPortEnum sensorPort = DigitalPortEnum.getByType(port);
target = configuration.getString(PROPERTY_TARGET, null);
if (sensorPort == null) {
throw new ConfigurationException("infraRed sensor port required: {S1,S2,S3,S4}");
}
if (target == null) {
throw new ConfigurationException("infraRed sensor target required");
}
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, sensorPort, SensorTypeEnum.INFRA);
setState(LifecycleState.INITIALIZED);
}
use of com.robo4j.hw.lego.enums.DigitalPortEnum in project robo4j by Robo4J.
the class SonicSensorUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
setState(LifecycleState.UNINITIALIZED);
scanInitialDelay = configuration.getInteger(PROPERTY_SCAN_INIT_DELAY, VALUE_SCAN_INIT_DELAY);
scanPeriod = configuration.getInteger(PROPERTY_SCAN_PERIOD, VALUE_SCAN_PERIOD);
String port = configuration.getString(PROPERTY_SENSOR_PORT, null);
DigitalPortEnum sensorPort = DigitalPortEnum.getByType(port);
target = configuration.getString(PROPERTY_TARGET, null);
if (sensorPort == null) {
throw new ConfigurationException("sonic sensor port required: {S1,S2,S3,S4}");
}
if (target == null) {
throw new ConfigurationException("sonic sensor target required");
}
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, sensorPort, SensorTypeEnum.SONIC);
setState(LifecycleState.INITIALIZED);
}
Aggregations