use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class RotaryEncoderImpl method fetchSensorValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
int count = tinkerforgeDevice.getCount(false);
DecimalValue value = Tools.calculate(count);
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 Dual020mADeviceImpl method fetchSensorValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
int current = tinkerforgeDevice.getCurrent(getSensorNum());
DecimalValue value = Tools.calculate1000000(current);
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 DualButtonButtonImpl method fetchSensorValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
if (tactile || this.sensorValue == null || this.sensorValue == OnOffValue.UNDEF) {
try {
ButtonState buttonState = tinkerforgeDevice.getButtonState();
OnOffValue newValue;
if (position == DualButtonDevicePosition.LEFT) {
newValue = getValue4State(buttonState.buttonL);
} else {
newValue = getValue4State(buttonState.buttonR);
}
setSensorValue(newValue);
logger.trace("{} fetch value: {}", position, newValue);
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
} else {
// send current state to update the eventbus
setSensorValue(getSensorValue());
}
}
use of com.tinkerforge.NotConnectedException in project openhab1-addons by openhab.
the class JoystickYPositionImpl method fetchSensorValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void fetchSensorValue() {
try {
Position position = tinkerforgeDevice.getPosition();
DecimalValue value = Tools.calculate(position.y);
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 LEDGroupImpl method setSelectedColor.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void setSelectedColor(HSBType color) {
// get the rgb values from HSBType
Color rgbColor = color.toColor();
short red = (short) rgbColor.getRed();
short green = (short) rgbColor.getGreen();
short blue = (short) rgbColor.getBlue();
logger.debug("rgb is: {}:{}:{}", red, green, blue);
// construct the values for the setRGBValues call
HashMap<Character, short[]> colorMap = new HashMap<Character, short[]>(3);
short[] reds = { red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red };
short[] greens = { green, green, green, green, green, green, green, green, green, green, green, green, green, green, green, green };
short[] blues = { blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue };
colorMap.put('r', reds);
colorMap.put('g', greens);
colorMap.put('b', blues);
try {
if (ledList.hasLedRanges()) {
Map<Integer, Short> ledRanges = ledList.getLedRanges();
for (Integer led : ledRanges.keySet()) {
logger.debug("setting color for range from led {} to range {}", led, ledRanges.get(led));
logger.debug("color from mapping{},{},{}", colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
tinkerforgeDevice.setRGBValues(led, ledRanges.get(led), colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
}
}
if (ledList.hasLeds()) {
for (Integer led : ledList.getLedNumbers()) {
logger.debug("setting color for led {}", led);
logger.debug("color from mapping{},{},{}", colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
tinkerforgeDevice.setRGBValues(led, (short) 1, colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
}
}
setColor(new HSBValue(color));
} catch (TimeoutException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
} catch (NotConnectedException e) {
TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
}
}
Aggregations