use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class MBrickletIndustrialDualAnalogInImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sampleRate"))) {
Short sampleRate = tfConfig.getSampleRate();
logger.debug("sampleRate {}", sampleRate);
setSampleRate(sampleRate);
}
}
try {
tinkerforgeDevice = new BrickletIndustrialDualAnalogIn(getUid(), getIpConnection());
tinkerforgeDevice.setSampleRate(getSampleRate());
} 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 MBrickletTiltImpl method fetchSensorValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
DecimalValue value = convert(tinkerforgeDevice.getTiltState());
setSensorValue(value);
} 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 MBrickletTemperatureImpl 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());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("slowI2C"))) {
setSlowI2C(true);
}
}
try {
tinkerforgeDevice = new BrickletTemperature(uid, getIpConnection());
if (isSlowI2C()) {
logger.debug("setting I2C slow mode");
tinkerforgeDevice.setI2CMode(BrickletTemperature.I2C_MODE_SLOW);
} else {
logger.debug("working with I2C fast mode");
}
tinkerforgeDevice.setResponseExpected(BrickletTemperature.FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD, false);
tinkerforgeDevice.setTemperatureCallbackPeriod(callbackPeriod);
listener = new TemperatureListener();
tinkerforgeDevice.addTemperatureListener(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 MServoImpl method setPoint.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public boolean setPoint(Short newPosition, int newVelocity, int newAccelleration) {
Short max = getMaxPosition();
Short min = getMinPosition();
if (newPosition > max) {
if (this.targetPosition < newPosition) {
logger.debug("setting value to max speed {}, which is lower than target speed {}", max, newPosition);
newPosition = max;
} else {
logger.debug("max value already reached {}", max);
return true;
}
} else if (newPosition < min) {
if (this.targetPosition > newPosition) {
logger.debug("setting velocity to min speed {}, which is higher than target speed {}", min, newPosition);
newPosition = min;
} else {
logger.debug("min value already reached {}", min);
return true;
}
}
try {
BrickServo tinkerBrickServo = getMbrick().getTinkerforgeDevice();
tinkerBrickServo.setVelocity(servoNum, newVelocity);
tinkerBrickServo.setAcceleration(servoNum, newAccelleration);
tinkerBrickServo.setPosition(servoNum, newPosition);
setTargetPosition(newPosition);
return true;
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
return false;
}
use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class MServoImpl method fetchSensorValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
short position = getMbrick().getTinkerforgeDevice().getPosition(servoNum);
DecimalValue newValue = Tools.calculate(position);
setSensorValue(newValue);
OnOffValue newSwitchState = newValue.onOffValue(0);
logger.trace("new switchstate {} new value {}", newSwitchState, newValue);
setSwitchState(newSwitchState);
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
Aggregations