use of com.robo4j.hw.lego.provider.SensorProvider in project robo4j by Robo4J.
the class BasicSonicUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
setState(LifecycleState.UNINITIALIZED);
target = configuration.getString("target", null);
if (target == null) {
throw ConfigurationException.createMissingConfigNameException("target");
}
String sensorType = configuration.getString("sonicSensorPort", DigitalPortEnum.S3.getType());
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorType), SensorTypeEnum.SONIC);
String servoPort = configuration.getString("sonicServoPort", AnalogPortEnum.A.getType());
Character servoType = configuration.getCharacter("sonicServoType", MotorTypeEnum.MEDIUM.getType());
MotorProvider motorProvider = new MotorProvider();
servo = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(servoPort), MotorTypeEnum.getByType(servoType));
unitActive.set(true);
servoRight.set(true);
setState(LifecycleState.INITIALIZED);
}
use of com.robo4j.hw.lego.provider.SensorProvider in project robo4j by Robo4J.
the class BasicSonicServoUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
setState(LifecycleState.UNINITIALIZED);
target = configuration.getString("target", null);
if (target == null) {
throw ConfigurationException.createMissingConfigNameException("target");
}
String sensorType = configuration.getString("sonicSensorPort", DigitalPortEnum.S3.getType());
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorType), SensorTypeEnum.SONIC);
String servoPort = configuration.getString("sonicServoPort", AnalogPortEnum.A.getType());
Character servoType = configuration.getCharacter("sonicServoType", MotorTypeEnum.MEDIUM.getType());
MotorProvider motorProvider = new MotorProvider();
servo = new MotorWrapper<>(motorProvider, AnalogPortEnum.getByType(servoPort), MotorTypeEnum.getByType(servoType));
unitActive.set(true);
servoRight.set(true);
setState(LifecycleState.INITIALIZED);
}
use of com.robo4j.hw.lego.provider.SensorProvider 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.provider.SensorProvider in project robo4j by Robo4J.
the class TouchMotorUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
setState(LifecycleState.UNINITIALIZED);
target = configuration.getString("target", null);
if (target == null) {
throw ConfigurationException.createMissingConfigNameException("target");
}
String sensorPort = configuration.getString("touchSensorPort", DigitalPortEnum.S1.getType());
SensorProvider provider = new SensorProvider();
sensor = new SensorWrapper<>(provider, DigitalPortEnum.getByType(sensorPort), SensorTypeEnum.TOUCH);
sensorActive.set(true);
currentState = MotorRotationEnum.STOP;
runTouchSensor();
setState(LifecycleState.INITIALIZED);
}
use of com.robo4j.hw.lego.provider.SensorProvider 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