some refactoring in TellStickController
This commit is contained in:
parent
2f3dbf462e
commit
12673437da
1 changed files with 9 additions and 12 deletions
|
|
@ -47,8 +47,11 @@ import java.util.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public class TellstickSerialComm implements Runnable,
|
public class TellstickSerialComm implements Runnable,
|
||||||
HalSensorController, HalEventController, HalAutoScannableController {
|
HalSensorController, HalEventController, HalAutoScannableController {
|
||||||
private static final long TRANSMISSION_UNIQUENESS_TTL = 1000; // milliseconds
|
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
|
private static String CONFIG_TELLSTICK_COM_PORT = "tellstick.com_port";
|
||||||
|
private static final long TRANSMISSION_UNIQUENESS_TTL = 1000; // milliseconds
|
||||||
|
|
||||||
private static TellstickSerialComm instance; // Todo: Don't like this but it is the best I could come up with
|
private static TellstickSerialComm instance; // Todo: Don't like this but it is the best I could come up with
|
||||||
|
|
||||||
private SerialPort serial;
|
private SerialPort serial;
|
||||||
|
|
@ -57,13 +60,12 @@ public class TellstickSerialComm implements Runnable,
|
||||||
private TimedHashSet<String> set; // To check for duplicate transmissions
|
private TimedHashSet<String> set; // To check for duplicate transmissions
|
||||||
|
|
||||||
protected TellstickParser parser;
|
protected TellstickParser parser;
|
||||||
|
|
||||||
private HalSensorReportListener sensorListener;
|
private HalSensorReportListener sensorListener;
|
||||||
private HalEventReportListener eventListener;
|
private HalEventReportListener eventListener;
|
||||||
|
|
||||||
private List<TellstickDevice> registeredDevices;
|
private List<TellstickDevice> registeredDevices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TellstickSerialComm() {
|
public TellstickSerialComm() {
|
||||||
set = new TimedHashSet<>(TRANSMISSION_UNIQUENESS_TTL);
|
set = new TimedHashSet<>(TRANSMISSION_UNIQUENESS_TTL);
|
||||||
parser = new TellstickParser();
|
parser = new TellstickParser();
|
||||||
|
|
@ -72,16 +74,11 @@ public class TellstickSerialComm implements Runnable,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return HalContext.getStringProperty("tellstick.com_port") != null;
|
return HalContext.getStringProperty(CONFIG_TELLSTICK_COM_PORT) != null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
// Read properties
|
initialize(HalContext.getStringProperty(CONFIG_TELLSTICK_COM_PORT));
|
||||||
String port = HalContext.getStringProperty("tellstick.com_port");
|
|
||||||
if (port == null)
|
|
||||||
port = "COM1"; // defaults
|
|
||||||
|
|
||||||
initialize(port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(String portName) throws Exception {
|
public void initialize(String portName) throws Exception {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue