use of org.openhab.binding.tinkerforge.internal.model.MBrickletIO16 in project openhab1-addons by openhab.
the class DigitalSensorImpl method enable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
setSensorValue(HighLowValue.UNDEF);
if (tfConfig != null) {
logger.debug("{} found config for DigitalSensor", LoggerConstants.TFINIT);
setPullUpResistorEnabled(tfConfig.isPullUpResistorEnabled());
logger.debug("{} pull-up resistor state is {}", LoggerConstants.TFINIT, isPullUpResistorEnabled());
}
MBrickletIO16 bricklet = getMbrick();
if (bricklet == null) {
logger.error("{} No bricklet found for DigitalSensor: {} ", LoggerConstants.TFINIT, subId);
} else {
BrickletIO16 brickletIO16 = bricklet.getTinkerforgeDevice();
try {
logger.debug("{} setting InterruptListener for DigitalSensor: {} ", LoggerConstants.TFINIT, subId);
interruptListener = new InterruptListener();
brickletIO16.addInterruptListener(interruptListener);
brickletIO16.setPortConfiguration(getPort(), (short) mask, BrickletIO16.DIRECTION_IN, isPullUpResistorEnabled());
fetchSensorValue();
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
}
Aggregations