2 * Copyright (c) 2010-2021 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.knx.internal.handler;
15 import java.util.concurrent.ConcurrentHashMap;
16 import java.util.concurrent.Executors;
17 import java.util.concurrent.ScheduledExecutorService;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.knx.internal.client.KNXClient;
22 import org.openhab.binding.knx.internal.client.StatusUpdateCallback;
23 import org.openhab.core.common.ThreadPoolManager;
24 import org.openhab.core.thing.Bridge;
25 import org.openhab.core.thing.ChannelUID;
26 import org.openhab.core.thing.ThingStatus;
27 import org.openhab.core.thing.ThingStatusDetail;
28 import org.openhab.core.thing.binding.BaseBridgeHandler;
29 import org.openhab.core.types.Command;
31 import tuwien.auto.calimero.IndividualAddress;
32 import tuwien.auto.calimero.mgmt.Destination;
35 * The {@link KNXBridgeBaseThingHandler} is responsible for handling commands, which are
36 * sent to one of the channels.
38 * @author Simon Kaufmann - Initial contribution and API
41 public abstract class KNXBridgeBaseThingHandler extends BaseBridgeHandler implements StatusUpdateCallback {
43 protected ConcurrentHashMap<IndividualAddress, Destination> destinations = new ConcurrentHashMap<>();
44 private final ScheduledExecutorService knxScheduler = ThreadPoolManager.getScheduledPool("knx");
45 private final ScheduledExecutorService backgroundScheduler = Executors.newSingleThreadScheduledExecutor();
47 public KNXBridgeBaseThingHandler(Bridge bridge) {
51 protected abstract KNXClient getClient();
54 public void handleCommand(ChannelUID channelUID, Command command) {
58 public ScheduledExecutorService getScheduler() {
62 public ScheduledExecutorService getBackgroundScheduler() {
63 return backgroundScheduler;
67 public void updateStatus(ThingStatus status) {
68 super.updateStatus(status);
72 public void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description) {
73 super.updateStatus(status, statusDetail, description);