use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class AccelerometerDirectionImpl method fetchSensorValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
Short currAcceleration;
Acceleration acceleration;
try {
acceleration = tinkerforgeDevice.getAcceleration();
if (getDirection() == AccelerometerCoordinate.X) {
currAcceleration = acceleration.x;
} else if (getDirection() == AccelerometerCoordinate.Y) {
currAcceleration = acceleration.y;
} else {
currAcceleration = acceleration.z;
}
DecimalValue value = Tools.calculate1000(currAcceleration);
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 AccelerometerLedImpl method fetchDigitalValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchDigitalValue() {
try {
HighLowValue value = tinkerforgeDevice.isLEDOn() ? HighLowValue.HIGH : HighLowValue.LOW;
setDigitalState(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 MBrickDCImpl method enable.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void enable() {
tinkerforgeDevice = new BrickDC(uid, ipConnection);
if (tfConfig != null) {
logger.debug("found tfConfig");
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("acceleration"))) {
setAcceleration(tfConfig.getAcceleration());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("pwmFrequency"))) {
setPwmFrequency(tfConfig.getPwmFrequency());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("driveMode"))) {
setDriveMode(DCDriveMode.get(tfConfig.getDriveMode()));
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
setThreshold(tfConfig.getThreshold());
}
if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
setCallbackPeriod(tfConfig.getCallbackPeriod());
}
}
try {
tinkerforgeDevice.setPWMFrequency(pwmFrequency);
if (driveMode == DCDriveMode.BRAKE) {
tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_BRAKE);
} else if (driveMode == DCDriveMode.COAST) {
tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_COAST);
}
tinkerforgeDevice.setCurrentVelocityPeriod((int) callbackPeriod);
listener = new VelocityListener();
tinkerforgeDevice.addCurrentVelocityListener(listener);
tinkerforgeDevice.enable();
handleVelocity(tinkerforgeDevice.getVelocity(), false);
} 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 MBrickletBarometerImpl 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());
}
}
tinkerforgeDevice = new BrickletBarometer(uid, ipConnection);
try {
tinkerforgeDevice.setResponseExpected(BrickletBarometer.FUNCTION_SET_AIR_PRESSURE_CALLBACK_PERIOD, false);
tinkerforgeDevice.setAirPressureCallbackPeriod(callbackPeriod);
listener = new AirPressureListener();
tinkerforgeDevice.addAirPressureListener(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 MBrickletCO2Impl method fetchSensorValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
int co2Concentration = tinkerforgeDevice.getCO2Concentration();
DecimalValue value = Tools.calculate(co2Concentration);
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);
}
}
Aggregations