Moved main class into a test class
This commit is contained in:
parent
04864434a1
commit
b7c7913c92
3 changed files with 45 additions and 13 deletions
1
Hal.iml
1
Hal.iml
|
|
@ -11,6 +11,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/test" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/test" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zigbee/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zigbee/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zwave/test" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/build" />
|
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/build" />
|
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/build" />
|
||||||
|
|
|
||||||
|
|
@ -32,20 +32,11 @@ public class HalZWaveController implements HalSensorController, HalEventControll
|
||||||
private List<AbstractDevice> registeredDevices;
|
private List<AbstractDevice> registeredDevices;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
LogUtil.setGlobalFormatter(new CompactLogFormatter());
|
|
||||||
HalZWaveController controller = new HalZWaveController();
|
|
||||||
controller.initialize(
|
|
||||||
"/dev/serial/by-id/usb-0658_0200-if00",
|
|
||||||
"./");
|
|
||||||
|
|
||||||
System.in.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HalZWaveController() {
|
public HalZWaveController() {
|
||||||
NativeLibraryLoader.loadLibrary(ZWave4j.LIBRARY_NAME, ZWave4j.class);
|
NativeLibraryLoader.loadLibrary(ZWave4j.LIBRARY_NAME, ZWave4j.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return HalContext.getStringProperty(CONFIG_ZWAVE_PORT) != null &&
|
return HalContext.getStringProperty(CONFIG_ZWAVE_PORT) != null &&
|
||||||
|
|
@ -72,13 +63,18 @@ public class HalZWaveController implements HalSensorController, HalEventControll
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
logger.info("Shutting down OpenZWave Manager...");
|
||||||
manager.removeWatcher(this, null);
|
manager.removeWatcher(this, null);
|
||||||
manager.removeDriver(serialPort);
|
manager.removeDriver(serialPort);
|
||||||
manager.destroy();
|
Manager.destroy();
|
||||||
Options.destroy();
|
Options.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------------
|
||||||
|
// OpenZWave Overrides
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotification(Notification notification, Object context) {
|
public void onNotification(Notification notification, Object context) {
|
||||||
switch (notification.getType()) {
|
switch (notification.getType()) {
|
||||||
|
|
@ -100,8 +96,9 @@ public class HalZWaveController implements HalSensorController, HalEventControll
|
||||||
case ALL_NODES_QUERIED:
|
case ALL_NODES_QUERIED:
|
||||||
logger.info("All nodes queried");
|
logger.info("All nodes queried");
|
||||||
manager.writeConfig(homeId);
|
manager.writeConfig(homeId);
|
||||||
// Controller is done initializing
|
logger.info(" Controller is done initializing");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POLLING_ENABLED:
|
case POLLING_ENABLED:
|
||||||
System.out.println("Polling enabled");
|
System.out.println("Polling enabled");
|
||||||
break;
|
break;
|
||||||
|
|
@ -309,7 +306,9 @@ public class HalZWaveController implements HalSensorController, HalEventControll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------
|
||||||
|
// Hal Overrides
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(HalEventConfig event) {
|
public void register(HalEventConfig event) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package se.hal.plugin.zwave;
|
||||||
|
|
||||||
|
import org.zwave4j.*;
|
||||||
|
import se.hal.HalContext;
|
||||||
|
import se.hal.intf.*;
|
||||||
|
import se.hal.struct.AbstractDevice;
|
||||||
|
import zutil.log.CompactLogFormatter;
|
||||||
|
import zutil.log.LogUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zagumennikov
|
||||||
|
*/
|
||||||
|
public class HalZWaveControllerTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
LogUtil.setGlobalFormatter(new CompactLogFormatter());
|
||||||
|
HalZWaveController controller = new HalZWaveController();
|
||||||
|
controller.initialize(
|
||||||
|
"/dev/serial/by-id/usb-0658_0200-if00",
|
||||||
|
"./");
|
||||||
|
|
||||||
|
System.out.println("Press ENTER to exit application.");
|
||||||
|
System.in.read();
|
||||||
|
|
||||||
|
controller.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue