use of com.tinkerforge.BrickletMultiTouch in project openhab1-addons by openhab.
the class MBrickletMultiTouchImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sensitivity"))) {
setSensitivity(tfConfig.getSensitivity());
logger.debug("{} MultiTouchDevice uid {} setSensitivity {}", LoggerConstants.TFINIT, getUid(), getSensitivity());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("recalibrate"))) {
setRecalibrate(tfConfig.getRecalibrate());
logger.debug("{} MultiTouchDevice uid {} setRecalibrate {}", LoggerConstants.TFINIT, getUid(), getRecalibrate());
}
}
tinkerforgeDevice = new BrickletMultiTouch(getUid(), getIpConnection());
try {
if (getSensitivity() != null) {
tinkerforgeDevice.setElectrodeSensitivity(getSensitivity());
}
if (getRecalibrate() != null && getRecalibrate()) {
tinkerforgeDevice.recalibrate();
}
// enable all electrodes by default
tinkerforgeDevice.setElectrodeConfig(8191);
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
use of com.tinkerforge.BrickletMultiTouch in project openhab1-addons by openhab.
the class MBrickletMultiTouchImpl method setTinkerforgeDevice.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setTinkerforgeDevice(BrickletMultiTouch newTinkerforgeDevice) {
BrickletMultiTouch oldTinkerforgeDevice = tinkerforgeDevice;
tinkerforgeDevice = newTinkerforgeDevice;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_MULTI_TOUCH__TINKERFORGE_DEVICE, oldTinkerforgeDevice, tinkerforgeDevice));
}
use of com.tinkerforge.BrickletMultiTouch in project openhab1-addons by openhab.
the class MultiTouchDeviceImpl method enable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("disableElectrode"))) {
if (tfConfig.getDisableElectrode()) {
logger.debug("{} MultiTouchDevice uid {} subid {} disable electrode {}", LoggerConstants.TFINIT, getUid(), getSubId(), getPin());
setDisableElectrode(true);
}
}
}
MBrickletMultiTouch bricklet = getMbrick();
if (bricklet == null) {
logger.error("{} No bricklet found for MultiTouchDevice: {}:{} ", LoggerConstants.TFINIT, getUid(), subId);
} else {
try {
BrickletMultiTouch brickletMultiTouch = bricklet.getTinkerforgeDevice();
if (getDisableElectrode() != null && getDisableElectrode()) {
logger.debug("{} MultiTouchDevice uid {} subid {} disabling electrode {}", LoggerConstants.TFINIT, getUid(), getSubId(), getPin());
getEnabledA().set(false);
int electrodeConfig = brickletMultiTouch.getElectrodeConfig();
electrodeConfig &= ~mask;
brickletMultiTouch.setElectrodeConfig(electrodeConfig);
return;
}
setSensorValue(HighLowValue.UNDEF);
touchListener = new TouchListener();
brickletMultiTouch.addTouchStateListener(touchListener);
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