use of com.robo4j.ConfigurationException in project robo4j by Robo4J.
the class Adafruit8x8MatrixUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
super.onInitialization(configuration);
int brightness = configuration.getInteger(ATTRIBUTE_BRIGHTNESS, AbstractBackpack.DEFAULT_BRIGHTNESS);
MatrixRotation rotation = MatrixRotation.valueOf(configuration.getString(ATTRIBUTE_ROTATION, DEFAULT_MATRIX_ROTATION).toUpperCase());
try {
device = new BiColor8x8MatrixDevice(getBus(), getAddress(), brightness);
} catch (IOException e) {
throw new ConfigurationException("Failed to instantiate device", e);
}
device.setRotation(rotation);
}
use of com.robo4j.ConfigurationException in project robo4j by Robo4J.
the class AdafruitAlphanumericUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
super.onInitialization(configuration);
int brightness = configuration.getInteger(AbstractI2CBackpackUnit.ATTRIBUTE_BRIGHTNESS, AbstractBackpack.DEFAULT_BRIGHTNESS);
try {
device = new AlphanumericDevice(getBus(), getAddress(), brightness);
} catch (IOException e) {
throw new ConfigurationException("Failed to instantiate device", e);
}
}
use of com.robo4j.ConfigurationException in project robo4j by Robo4J.
the class Bno080Unit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
final String reportType = configuration.getString(PROPERTY_REPORT_TYPE, null);
report = SensorReportId.valueOf(reportType.toUpperCase());
if (report.equals(SensorReportId.NONE)) {
throw new ConfigurationException(PROPERTY_REPORT_TYPE);
}
final Integer delay = configuration.getInteger(PROPERTY_REPORT_DELAY, null);
if (delay == null || delay <= 0) {
throw new ConfigurationException(PROPERTY_REPORT_DELAY);
}
this.reportDelay = delay;
try {
// TODO: make device configurable
device = Bno080Factory.createDefaultSPIDevice();
} catch (IOException | InterruptedException e) {
throw new ConfigurationException("Could not initiate device", e);
}
device.start(report, reportDelay);
}
use of com.robo4j.ConfigurationException in project robo4j by Robo4J.
the class GyroL3GD20Unit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
super.onInitialization(configuration);
sensitivity = Sensitivity.valueOf(configuration.getString(PROPERTY_KEY_SENSITIVITY, "DPS_245"));
period = configuration.getInteger(PROPERTY_KEY_PERIOD, 10);
highPassFilter = configuration.getBoolean(PROPERTY_KEY_HIGH_PASS_FILTER, true);
try {
gyro = new CalibratedGyro(new GyroL3GD20Device(getBus(), getAddress(), sensitivity, highPassFilter));
} catch (IOException e) {
throw new ConfigurationException(String.format("Failed to initialize lidar device. Make sure it is hooked up to bus: %d address: %xd", getBus(), getAddress()), e);
}
}
use of com.robo4j.ConfigurationException 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);
}
Aggregations