Cleanedup property names
This commit is contained in:
parent
c3731ca4b4
commit
12a6c1d31b
5 changed files with 14 additions and 9 deletions
|
|
@ -65,7 +65,10 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
public class NutUpsController implements HalSensorController, HalAutoScannableController, Runnable{
|
public class NutUpsController implements HalSensorController, HalAutoScannableController, Runnable{
|
||||||
public static Logger logger = LogUtil.getLogger();
|
public static Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
private static final int SYNC_INTERVAL = 60 * 1000;
|
private static final int SYNC_INTERVAL = 60 * 1000;
|
||||||
|
public static final String PROPERTY_HOST = "nutups.host";
|
||||||
|
public static final String PROPERTY_PORT = "nutups.port";
|
||||||
|
|
||||||
private HashMap<String, NutUpsDevice> registeredDevices = new HashMap<>();
|
private HashMap<String, NutUpsDevice> registeredDevices = new HashMap<>();
|
||||||
private NutUPSClient client;
|
private NutUPSClient client;
|
||||||
|
|
@ -76,15 +79,16 @@ public class NutUpsController implements HalSensorController, HalAutoScannableCo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return HalContext.getStringProperty("nutups.host") != null;
|
return HalContext.containsProperty(PROPERTY_HOST);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
int port = NutUPSClient.DEFAULT_PORT;
|
int port = NutUPSClient.DEFAULT_PORT;
|
||||||
if (HalContext.getStringProperty("nutups.port") != null)
|
if (HalContext.containsProperty(PROPERTY_PORT))
|
||||||
port = Integer.parseInt(HalContext.getStringProperty("nutups.port"));
|
port = HalContext.getIntegerProperty(PROPERTY_PORT);
|
||||||
client = new NutUPSClient(HalContext.getStringProperty("nutups.host"), port);
|
|
||||||
|
client = new NutUPSClient(HalContext.getStringProperty(PROPERTY_HOST), port);
|
||||||
|
|
||||||
executor = Executors.newScheduledThreadPool(1);
|
executor = Executors.newScheduledThreadPool(1);
|
||||||
executor.scheduleAtFixedRate(this, 5000, SYNC_INTERVAL, TimeUnit.MILLISECONDS);
|
executor.scheduleAtFixedRate(this, 5000, SYNC_INTERVAL, TimeUnit.MILLISECONDS);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class TellstickSerialComm implements Runnable,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return HalContext.getStringProperty(CONFIG_TELLSTICK_COM_PORT) != null;
|
return HalContext.containsProperty(CONFIG_TELLSTICK_COM_PORT);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ public class HalZWaveController implements HalSensorController, HalEventControll
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return HalContext.getStringProperty(CONFIG_ZWAVE_PORT) != null &&
|
return HalContext.containsProperty(CONFIG_ZWAVE_PORT) &&
|
||||||
HalContext.getStringProperty(CONFIG_ZWAVE_CFG_PATH) != null;
|
HalContext.containsProperty(CONFIG_ZWAVE_CFG_PATH);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public class HalContext {
|
||||||
// Constants
|
// Constants
|
||||||
public static final String PROPERTY_DB_VERSION = "hal.db_version";
|
public static final String PROPERTY_DB_VERSION = "hal.db_version";
|
||||||
public static final String PROPERTY_HTTP_PORT = "hal.http_port";
|
public static final String PROPERTY_HTTP_PORT = "hal.http_port";
|
||||||
|
public static final String PROPERTY_MAP_BACKGROUND_IMAGE = "hal.map_bgimage";
|
||||||
|
|
||||||
private static final String CONF_FILE = "hal.conf";
|
private static final String CONF_FILE = "hal.conf";
|
||||||
private static final String DB_FILE = "hal.db";
|
private static final String DB_FILE = "hal.db";
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class MapWebPage extends HalWebPage {
|
||||||
|
|
||||||
|
|
||||||
private void loadBgImage() {
|
private void loadBgImage() {
|
||||||
String property = HalContext.getStringProperty("map_bgimage");
|
String property = HalContext.getStringProperty(HalContext.PROPERTY_MAP_BACKGROUND_IMAGE);
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
String[] split = property.split(",", 2);
|
String[] split = property.split(",", 2);
|
||||||
bgType = split[0];
|
bgType = split[0];
|
||||||
|
|
@ -86,6 +86,6 @@ public class MapWebPage extends HalWebPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveBgImage(String type, byte[] data) throws SQLException {
|
private void saveBgImage(String type, byte[] data) throws SQLException {
|
||||||
HalContext.setProperty("map_bgimage", type + "," + Base64Encoder.encode(data));
|
HalContext.setProperty(HalContext.PROPERTY_MAP_BACKGROUND_IMAGE, type + "," + Base64Encoder.encode(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue