use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.
the class MBrickletIndustrialDual020mAImpl method enable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
tinkerforgeDevice = new BrickletIndustrialDual020mA(getUid(), getIpConnection());
Short sampleRate = null;
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sampleRate"))) {
Short sampleRateFromConfig = tfConfig.getSampleRate();
if (sampleRateFromConfig != 0 || sampleRateFromConfig != 1 || sampleRateFromConfig != 2 || sampleRateFromConfig != 3) {
logger.error("sampleRate must be 0, 1, 2, or 3. \"{}\" is configured. Falling back to default", sampleRateFromConfig);
} else {
sampleRate = sampleRateFromConfig;
}
}
}
if (sampleRate != null) {
try {
tinkerforgeDevice.setSampleRate(sampleRate);
} 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.TimeoutException in project openhab1-addons by openhab.
the class MLCD20x4BacklightImpl method fetchSwitchState.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSwitchState() {
OnOffValue switchValue = OnOffValue.UNDEF;
try {
switchValue = brickletLCD20x4.isBacklightOn() ? 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);
}
setSwitchState(switchValue);
}
use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.
the class MDualRelayImpl method fetchSwitchState.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSwitchState() {
OnOffValue switchValue = OnOffValue.UNDEF;
try {
State state = getMbrick().getTinkerforgeDevice().getState();
if (relayNum == 1) {
switchValue = (state.relay1) ? OnOffValue.ON : OnOffValue.OFF;
} else {
switchValue = (state.relay2) ? 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);
}
setSwitchState(switchValue);
}
use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.
the class MBrickletVoltageCurrentImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
if (tfConfig != null) {
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("averaging"))) {
setAveraging(tfConfig.getAveraging());
logger.debug("{} VoltageCurrent uid {} averaging {}", LoggerConstants.TFINIT, getUid(), getAveraging());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("voltageConversionTime"))) {
setVoltageConversionTime(tfConfig.getVoltageConversionTime());
logger.debug("{} VoltageCurrent uid {} voltageConversionTime {}", LoggerConstants.TFINIT, getUid(), getVoltageConversionTime());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("currentConversionTime"))) {
setVoltageConversionTime(tfConfig.getCurrentConversionTime());
logger.debug("{} VoltageCurrent uid {} currentConversionTime {}", LoggerConstants.TFINIT, getUid(), getCurrentConversionTime());
}
}
tinkerforgeDevice = new BrickletVoltageCurrent(getUid(), getIpConnection());
try {
tinkerforgeDevice.setConfiguration(getAveraging(), getVoltageConversionTime(), getCurrentConversionTime());
} 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.TimeoutException in project openhab1-addons by openhab.
the class MServoImpl method enable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
MBrickServo brick = getMbrick();
if (brick == null) {
logger.error("No servo brick configured for servo: " + uid);
} else {
if (tfConfig != null) {
logger.debug("found tfConfig");
if (tfConfig.getVelocity() != 0) {
// TODO check for
setVelocity(tfConfig.getVelocity());
}
// state
if (tfConfig.getAcceleration() != 0) {
setAcceleration(tfConfig.getAcceleration());
}
if (tfConfig.getPeriod() != 0) {
setPeriod(tfConfig.getPeriod());
}
if (tfConfig.getPulseWidthMax() != 0 && tfConfig.getPulseWidthMin() != 0) {
setPulseWidthMax(tfConfig.getPulseWidthMax());
setPulseWidthMin(tfConfig.getPulseWidthMin());
}
if (tfConfig.getOutputVoltage() != 0) {
setOutputVoltage(tfConfig.getOutputVoltage());
}
}
BrickServo tinkerBrickServo = brick.getTinkerforgeDevice();
try {
servoNum = Short.parseShort(String.valueOf(subId.charAt(subId.length() - 1)));
// tinkerBrickServo.setVelocity(servoNum, velocity);
// tinkerBrickServo.setAcceleration(servoNum, acceleration);
tinkerBrickServo.setPulseWidth(servoNum, pulseWidthMin, pulseWidthMax);
tinkerBrickServo.setPeriod(servoNum, period);
tinkerBrickServo.setOutputVoltage(outputVoltage);
// initialize target postion with
setTargetPosition(tinkerBrickServo.getPosition(servoNum));
// current position value
listener = new PositionReachedListener();
tinkerBrickServo.addPositionReachedListener(listener);
tinkerBrickServo.enablePositionReachedCallback();
tinkerBrickServo.enable(servoNum);
fetchSwitchState();
} catch (NumberFormatException e) {
TinkerforgeErrorHandler.handleError(this, "can not determine servoNum", e);
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
}
Aggregations