use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class MBrickletSoundIntensityImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
setThreshold(tfConfig.getThreshold());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
setCallbackPeriod(tfConfig.getCallbackPeriod());
}
}
try {
tinkerforgeDevice = new BrickletSoundIntensity(getUid(), getIpConnection());
tinkerforgeDevice.setIntensityCallbackPeriod(getCallbackPeriod());
listener = new SoundIntensityListener();
tinkerforgeDevice.addIntensityListener(listener);
fetchSensorValue();
} 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.NotConnectedException in project openhab1-addons by openhab.
the class MBrickletSolidStateRelayImpl method fetchSwitchState.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSwitchState() {
try {
OnOffValue switchValue = OnOffValue.UNDEF;
boolean state = tinkerforgeDevice.getState();
switchValue = state ? OnOffValue.ON : OnOffValue.OFF;
setSwitchState(switchValue);
} 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.NotConnectedException in project openhab1-addons by openhab.
the class MBrickletPTCImpl method enable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
tinkerforgeDevice = new BrickletPTC(getUid(), getIpConnection());
// default BrickletPTC.WIRE_MODE_2;
Short wireMode = null;
Short noiseRejectionFilter = null;
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("wireMode"))) {
Short wireModeFromConfig = tfConfig.getWireMode();
if (wireModeFromConfig != 2 || wireModeFromConfig != 3 || wireModeFromConfig != 4) {
logger.error("wireMode must be 2, 3 or 4. \"{}\" is configured. Falling back to default", wireModeFromConfig);
} else {
wireMode = wireModeFromConfig;
}
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("noiseRejectionFilter"))) {
Short noiseRejectionFilterFromConfig = tfConfig.getNoiseRejectionFilter();
if (noiseRejectionFilterFromConfig != 0 || noiseRejectionFilterFromConfig != 1) {
logger.error("noiseRejectionFilter must be 0 or 1. \"{}\" is configured. Fallback is using no reduction filter.");
} else {
noiseRejectionFilter = noiseRejectionFilterFromConfig;
}
}
}
try {
if (wireMode != null) {
tinkerforgeDevice.setWireMode(wireMode);
}
if (noiseRejectionFilter != null) {
tinkerforgeDevice.setNoiseRejectionFilter(noiseRejectionFilter);
}
} 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.NotConnectedException 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.NotConnectedException in project openhab1-addons by openhab.
the class MBrickletOLE64x48Impl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("contrast"))) {
Short contrast = tfConfig.getContrast();
logger.debug("contrast {}", contrast);
setContrast(contrast);
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("invert"))) {
boolean invert = tfConfig.isInvert();
logger.debug("invert {}", invert);
setInvert(invert);
}
}
try {
tinkerforgeDevice = new BrickletOLED64x48(getUid(), getIpConnection());
tinkerforgeDevice.setDisplayConfiguration(getContrast(), isInvert());
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
Aggregations