]> git.basschouten.com Git - openhab-addons.git/blob
9e4ca0b5b68fdf7143a1c15e38d74c21f44a0e84
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.knx.internal.handler;
14
15 import java.util.concurrent.ConcurrentHashMap;
16 import java.util.concurrent.Executors;
17 import java.util.concurrent.ScheduledExecutorService;
18
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;
30
31 import tuwien.auto.calimero.IndividualAddress;
32 import tuwien.auto.calimero.mgmt.Destination;
33
34 /**
35  * The {@link KNXBridgeBaseThingHandler} is responsible for handling commands, which are
36  * sent to one of the channels.
37  *
38  * @author Simon Kaufmann - Initial contribution and API
39  */
40 @NonNullByDefault
41 public abstract class KNXBridgeBaseThingHandler extends BaseBridgeHandler implements StatusUpdateCallback {
42
43     protected ConcurrentHashMap<IndividualAddress, Destination> destinations = new ConcurrentHashMap<>();
44     private final ScheduledExecutorService knxScheduler = ThreadPoolManager.getScheduledPool("knx");
45     private final ScheduledExecutorService backgroundScheduler = Executors.newSingleThreadScheduledExecutor();
46
47     public KNXBridgeBaseThingHandler(Bridge bridge) {
48         super(bridge);
49     }
50
51     protected abstract KNXClient getClient();
52
53     @Override
54     public void handleCommand(ChannelUID channelUID, Command command) {
55         // Nothing to do here
56     }
57
58     public ScheduledExecutorService getScheduler() {
59         return knxScheduler;
60     }
61
62     public ScheduledExecutorService getBackgroundScheduler() {
63         return backgroundScheduler;
64     }
65
66     @Override
67     public void updateStatus(ThingStatus status) {
68         super.updateStatus(status);
69     }
70
71     @Override
72     public void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description) {
73         super.updateStatus(status, statusDetail, description);
74     }
75 }