Normalized thread names (#9581)
Related to #8216 Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
committed by
GitHub
parent
79dfb43e42
commit
ac3f907b36
@@ -18,6 +18,7 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openhab.binding.keba.internal.handler.KeContactHandler;
|
||||
import org.openhab.binding.keba.internal.handler.KeContactTransceiver;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||
@@ -36,6 +37,8 @@ public class KebaHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_KECONTACTP20);
|
||||
|
||||
private final KeContactTransceiver transceiver = new KeContactTransceiver();
|
||||
|
||||
@Override
|
||||
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
|
||||
@@ -46,7 +49,7 @@ public class KebaHandlerFactory extends BaseThingHandlerFactory {
|
||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||
|
||||
if (thingTypeUID.equals(THING_TYPE_KECONTACTP20)) {
|
||||
return new KeContactHandler(thing);
|
||||
return new KeContactHandler(thing, transceiver);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -74,10 +74,10 @@ public class KeContactHandler extends BaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(KeContactHandler.class);
|
||||
|
||||
protected JsonParser parser = new JsonParser();
|
||||
protected final JsonParser parser = new JsonParser();
|
||||
private final KeContactTransceiver transceiver;
|
||||
|
||||
private ScheduledFuture<?> pollingJob;
|
||||
private static KeContactTransceiver transceiver = new KeContactTransceiver();
|
||||
private ExpiringCacheMap<String, ByteBuffer> cache;
|
||||
|
||||
private int maxPresetCurrent = 0;
|
||||
@@ -87,8 +87,9 @@ public class KeContactHandler extends BaseThingHandler {
|
||||
private int lastState = -1; // trigger a report100 at startup
|
||||
private boolean isReport100needed = true;
|
||||
|
||||
public KeContactHandler(Thing thing) {
|
||||
public KeContactHandler(Thing thing, KeContactTransceiver transceiver) {
|
||||
super(thing);
|
||||
this.transceiver = transceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +107,7 @@ public class KeContactHandler extends BaseThingHandler {
|
||||
|
||||
if (pollingJob == null || pollingJob.isCancelled()) {
|
||||
try {
|
||||
pollingJob = scheduler.scheduleWithFixedDelay(pollingRunnable, 0,
|
||||
pollingJob = scheduler.scheduleWithFixedDelay(this::pollingRunnable, 0,
|
||||
((BigDecimal) getConfig().get(POLLING_REFRESH_INTERVAL)).intValue(), TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,
|
||||
@@ -147,7 +148,7 @@ public class KeContactHandler extends BaseThingHandler {
|
||||
return super.getConfig();
|
||||
}
|
||||
|
||||
private Runnable pollingRunnable = () -> {
|
||||
private void pollingRunnable() {
|
||||
try {
|
||||
long stamp = System.currentTimeMillis();
|
||||
if (!InetAddress.getByName(((String) getConfig().get(IP_ADDRESS))).isReachable(PING_TIME_OUT)) {
|
||||
@@ -194,7 +195,7 @@ public class KeContactHandler extends BaseThingHandler {
|
||||
} catch (InterruptedException e) {
|
||||
logger.debug("Polling job has been interrupted for handler of thing '{}'.", getThing().getUID());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void onData(ByteBuffer byteBuffer) {
|
||||
String response = new String(byteBuffer.array(), 0, byteBuffer.limit());
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author Karel Goderis - Initial contribution
|
||||
*/
|
||||
|
||||
class KeContactTransceiver {
|
||||
public class KeContactTransceiver {
|
||||
|
||||
public static final int LISTENER_PORT_NUMBER = 7090;
|
||||
public static final int REMOTE_PORT_NUMBER = 7090;
|
||||
@@ -74,7 +74,7 @@ class KeContactTransceiver {
|
||||
selector = Selector.open();
|
||||
|
||||
if (transceiverThread == null) {
|
||||
transceiverThread = new Thread(transceiverRunnable, "openHAB-Keba-Transceiver");
|
||||
transceiverThread = new Thread(transceiverRunnable, "OH-binding-Keba-Transceiver");
|
||||
transceiverThread.start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user