use of tuwien.auto.calimero.process.ProcessCommunicator in project openhab1-addons by openhab.
the class KNXBinding method writeToKNX.
private void writeToKNX(String itemName, Type value) {
Iterable<Datapoint> datapoints = getDatapoints(itemName, value.getClass());
if (datapoints != null) {
ProcessCommunicator pc = KNXConnection.getCommunicator();
if (pc != null) {
for (Datapoint datapoint : datapoints) {
try {
pc.write(datapoint, toDPTValue(value, datapoint.getDPT()));
logger.debug("Wrote value '{}' to datapoint '{}'", value, datapoint);
} catch (KNXException e) {
logger.warn("Value '{}' could not be sent to the KNX bus using datapoint '{}' - retrying one time: {}", new Object[] { value, datapoint, e.getMessage() });
try {
// do a second try, maybe the reconnection was successful
pc = KNXConnection.getCommunicator();
pc.write(datapoint, toDPTValue(value, datapoint.getDPT()));
logger.debug("Wrote value '{}' to datapoint '{}' on second try", value, datapoint);
} catch (KNXException e1) {
logger.error("Value '{}' could not be sent to the KNX bus using datapoint '{}' - giving up after second try: {}", new Object[] { value, datapoint, e1.getMessage() });
}
}
}
}
}
}
use of tuwien.auto.calimero.process.ProcessCommunicator in project openhab1-addons by openhab.
the class KNXBindingDatapointReaderTask method readFromKNXBus.
private void readFromKNXBus(Datapoint datapoint) throws InterruptedException {
try {
ProcessCommunicator pc = KNXConnection.getCommunicator();
if (pc != null) {
sLogger.debug("Autorefresh: Sending read request to KNX for item '{}' DPT '{}'", datapoint.getName(), datapoint.getDPT());
pc.read(datapoint);
} else {
sLogger.debug("Autorefresh: Couldn't sent read request to KNX for item '{}'. Connection to KNX bus not (yet) established.", datapoint.getName());
}
} catch (KNXFormatException e) {
sLogger.warn("Autorefresh: Cannot read value for item '{}' from KNX bus: {}: invalid format", datapoint.getName(), e.getMessage());
} catch (KNXInvalidResponseException e) {
sLogger.warn("Autorefresh: Cannot read value for item '{}' from KNX bus: {}: invalid response", datapoint.getName(), e.getMessage());
} catch (KNXTimeoutException e) {
sLogger.warn("Autorefresh: Cannot read value for item '{}' from KNX bus: {}: timeout", datapoint.getName(), e.getMessage());
addToReadQueue(datapoint);
} catch (KNXLinkClosedException e) {
sLogger.warn("Autorefresh: Cannot read value for item '{}' from KNX bus: {}: link closed", datapoint.getName(), e.getMessage());
} catch (KNXException e) {
sLogger.warn("Autorefresh: Cannot read value for item '{}' from KNX bus: {}", datapoint.getName(), e.getMessage());
} catch (KNXIllegalArgumentException e) {
sLogger.warn("Autorefresh: Error sending KNX read request for '{}': {}", datapoint.getName(), e.getMessage());
}
}
Aggregations