]> git.basschouten.com Git - openhab-addons.git/blob
590d4f0825ffd1e45dc01c0517719717f7a8b220
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.knx.internal.client.AbstractKNXClient;
17 import org.openhab.binding.knx.internal.client.SerialClient;
18 import org.openhab.binding.knx.internal.config.SerialBridgeConfiguration;
19 import org.openhab.core.thing.Bridge;
20 import org.openhab.core.thing.ThingStatus;
21
22 /**
23  * The {@link IPBridgeThingHandler} is responsible for handling commands, which are
24  * sent to one of the channels. It implements a KNX Serial/USB Gateway, that either acts a a
25  * conduit for other {@link DeviceThingHandler}s, or for Channels that are
26  * directly defined on the bridge
27  *
28  * @author Karel Goderis - Initial contribution
29  * @author Simon Kaufmann - Refactoring & cleanup
30  */
31 @NonNullByDefault
32 public class SerialBridgeThingHandler extends KNXBridgeBaseThingHandler {
33
34     private final SerialClient client;
35
36     public SerialBridgeThingHandler(Bridge bridge) {
37         super(bridge);
38         SerialBridgeConfiguration config = getConfigAs(SerialBridgeConfiguration.class);
39         client = new SerialClient(config.getAutoReconnectPeriod(), thing.getUID(),
40                 config.getResponseTimeout().intValue(), config.getReadingPause().intValue(),
41                 config.getReadRetriesLimit().intValue(), getScheduler(), config.getSerialPort(), this);
42     }
43
44     @Override
45     public void initialize() {
46         updateStatus(ThingStatus.UNKNOWN);
47         client.initialize();
48     }
49
50     @Override
51     public void dispose() {
52         super.dispose();
53         client.dispose();
54     }
55
56     @Override
57     protected AbstractKNXClient getClient() {
58         return client;
59     }
60 }