diff --git a/.gitattributes b/.gitattributes old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/Jenkinsfile b/Jenkinsfile old mode 100755 new mode 100644 diff --git a/LICENSE.txt b/LICENSE.txt old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalConfiguration.h b/arduino/HalMultiSensor/HalConfiguration.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalInclude.h b/arduino/HalMultiSensor/HalInclude.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalInterfaces.h b/arduino/HalMultiSensor/HalInterfaces.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalMultiSensor.ino b/arduino/HalMultiSensor/HalMultiSensor.ino old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalMultiSensorEnclosure.FCStd b/arduino/HalMultiSensor/HalMultiSensorEnclosure.FCStd old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalMultiSensorEnclosure_bottom.stl b/arduino/HalMultiSensor/HalMultiSensorEnclosure_bottom.stl old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/HalMultiSensorEnclosure_top.stl b/arduino/HalMultiSensor/HalMultiSensorEnclosure_top.stl old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/Interrupt.cpp b/arduino/HalMultiSensor/Interrupt.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/Interrupt.h b/arduino/HalMultiSensor/Interrupt.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/ProtocolNexa.cpp b/arduino/HalMultiSensor/ProtocolNexa.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/ProtocolNexa.h b/arduino/HalMultiSensor/ProtocolNexa.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/ProtocolOregon.cpp b/arduino/HalMultiSensor/ProtocolOregon.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/ProtocolOregon.h b/arduino/HalMultiSensor/ProtocolOregon.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorBH1750.cpp b/arduino/HalMultiSensor/SensorBH1750.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorBH1750.h b/arduino/HalMultiSensor/SensorBH1750.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorDHT.cpp b/arduino/HalMultiSensor/SensorDHT.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorDHT.h b/arduino/HalMultiSensor/SensorDHT.h old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorPhotocell.cpp b/arduino/HalMultiSensor/SensorPhotocell.cpp old mode 100755 new mode 100644 diff --git a/arduino/HalMultiSensor/SensorPhotocell.h b/arduino/HalMultiSensor/SensorPhotocell.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/AUTHORS.txt b/external/tellstick-core/AUTHORS.txt old mode 100755 new mode 100644 diff --git a/external/tellstick-core/LICENSE.txt b/external/tellstick-core/LICENSE.txt old mode 100755 new mode 100644 diff --git a/external/tellstick-core/Protocol.cpp b/external/tellstick-core/Protocol.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/Protocol.h b/external/tellstick-core/Protocol.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolBrateck.cpp b/external/tellstick-core/ProtocolBrateck.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolBrateck.h b/external/tellstick-core/ProtocolBrateck.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolComen.cpp b/external/tellstick-core/ProtocolComen.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolComen.h b/external/tellstick-core/ProtocolComen.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolEverflourish.cpp b/external/tellstick-core/ProtocolEverflourish.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolEverflourish.h b/external/tellstick-core/ProtocolEverflourish.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolFineoffset.cpp b/external/tellstick-core/ProtocolFineoffset.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolFineoffset.h b/external/tellstick-core/ProtocolFineoffset.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolFuhaote.cpp b/external/tellstick-core/ProtocolFuhaote.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolFuhaote.h b/external/tellstick-core/ProtocolFuhaote.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolGroup.cpp b/external/tellstick-core/ProtocolGroup.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolGroup.h b/external/tellstick-core/ProtocolGroup.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolHasta.cpp b/external/tellstick-core/ProtocolHasta.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolHasta.h b/external/tellstick-core/ProtocolHasta.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolIkea.cpp b/external/tellstick-core/ProtocolIkea.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolIkea.h b/external/tellstick-core/ProtocolIkea.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolMandolyn.cpp b/external/tellstick-core/ProtocolMandolyn.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolMandolyn.h b/external/tellstick-core/ProtocolMandolyn.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolNexa.cpp b/external/tellstick-core/ProtocolNexa.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolNexa.h b/external/tellstick-core/ProtocolNexa.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolOregon.cpp b/external/tellstick-core/ProtocolOregon.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolOregon.h b/external/tellstick-core/ProtocolOregon.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolRisingSun.cpp b/external/tellstick-core/ProtocolRisingSun.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolRisingSun.h b/external/tellstick-core/ProtocolRisingSun.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolSartano.cpp b/external/tellstick-core/ProtocolSartano.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolSartano.h b/external/tellstick-core/ProtocolSartano.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolScene.cpp b/external/tellstick-core/ProtocolScene.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolScene.h b/external/tellstick-core/ProtocolScene.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolSilvanChip.cpp b/external/tellstick-core/ProtocolSilvanChip.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolSilvanChip.h b/external/tellstick-core/ProtocolSilvanChip.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolUpm.cpp b/external/tellstick-core/ProtocolUpm.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolUpm.h b/external/tellstick-core/ProtocolUpm.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolWaveman.cpp b/external/tellstick-core/ProtocolWaveman.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolWaveman.h b/external/tellstick-core/ProtocolWaveman.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolX10.cpp b/external/tellstick-core/ProtocolX10.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolX10.h b/external/tellstick-core/ProtocolX10.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolYidong.cpp b/external/tellstick-core/ProtocolYidong.cpp old mode 100755 new mode 100644 diff --git a/external/tellstick-core/ProtocolYidong.h b/external/tellstick-core/ProtocolYidong.h old mode 100755 new mode 100644 diff --git a/external/tellstick-core/README.txt b/external/tellstick-core/README.txt old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/Static/amd64/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows/Static/amd64/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/Static/i386/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows/Static/i386/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftbusui.dll b/external/tellstick-driver/SerialDriver_Windows/amd64/ftbusui.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftcserco.dll b/external/tellstick-driver/SerialDriver_Windows/amd64/ftcserco.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows/amd64/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftd2xx64.dll b/external/tellstick-driver/SerialDriver_Windows/amd64/ftd2xx64.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftdibus.sys b/external/tellstick-driver/SerialDriver_Windows/amd64/ftdibus.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftlang.dll b/external/tellstick-driver/SerialDriver_Windows/amd64/ftlang.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftser2k.sys b/external/tellstick-driver/SerialDriver_Windows/amd64/ftser2k.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/amd64/ftserui2.dll b/external/tellstick-driver/SerialDriver_Windows/amd64/ftserui2.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/dpinst-amd64.exe b/external/tellstick-driver/SerialDriver_Windows/dpinst-amd64.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/dpinst-x86.exe b/external/tellstick-driver/SerialDriver_Windows/dpinst-x86.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/ftd2xx.h b/external/tellstick-driver/SerialDriver_Windows/ftd2xx.h old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/ftdibus.cat b/external/tellstick-driver/SerialDriver_Windows/ftdibus.cat old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/ftdibus.inf b/external/tellstick-driver/SerialDriver_Windows/ftdibus.inf old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/ftdiport.cat b/external/tellstick-driver/SerialDriver_Windows/ftdiport.cat old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/ftdiport.inf b/external/tellstick-driver/SerialDriver_Windows/ftdiport.inf old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftbusui.dll b/external/tellstick-driver/SerialDriver_Windows/i386/ftbusui.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftcserco.dll b/external/tellstick-driver/SerialDriver_Windows/i386/ftcserco.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftd2xx.dll b/external/tellstick-driver/SerialDriver_Windows/i386/ftd2xx.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows/i386/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftdibus.sys b/external/tellstick-driver/SerialDriver_Windows/i386/ftdibus.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftlang.dll b/external/tellstick-driver/SerialDriver_Windows/i386/ftlang.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftser2k.sys b/external/tellstick-driver/SerialDriver_Windows/i386/ftser2k.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/i386/ftserui2.dll b/external/tellstick-driver/SerialDriver_Windows/i386/ftserui2.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/readme.txt b/external/tellstick-driver/SerialDriver_Windows/readme.txt old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows/setup.exe b/external/tellstick-driver/SerialDriver_Windows/setup.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/Static/amd64/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows8_1/Static/amd64/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/Static/i386/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows8_1/Static/i386/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftbusui.dll b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftbusui.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftcserco.dll b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftcserco.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftd2xx64.dll b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftd2xx64.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftdibus.sys b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftdibus.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftlang.dll b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftlang.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftser2k.sys b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftser2k.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftserui2.dll b/external/tellstick-driver/SerialDriver_Windows8_1/amd64/ftserui2.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/dpinst-amd64.exe b/external/tellstick-driver/SerialDriver_Windows8_1/dpinst-amd64.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/dpinst-x86.exe b/external/tellstick-driver/SerialDriver_Windows8_1/dpinst-x86.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/ftd2xx.h b/external/tellstick-driver/SerialDriver_Windows8_1/ftd2xx.h old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/ftdibus.cat b/external/tellstick-driver/SerialDriver_Windows8_1/ftdibus.cat old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/ftdibus.inf b/external/tellstick-driver/SerialDriver_Windows8_1/ftdibus.inf old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/ftdiport.cat b/external/tellstick-driver/SerialDriver_Windows8_1/ftdiport.cat old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/ftdiport.inf b/external/tellstick-driver/SerialDriver_Windows8_1/ftdiport.inf old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftbusui.dll b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftbusui.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftcserco.dll b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftcserco.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftd2xx.dll b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftd2xx.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftd2xx.lib b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftd2xx.lib old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftdibus.sys b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftdibus.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftlang.dll b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftlang.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftser2k.sys b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftser2k.sys old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftserui2.dll b/external/tellstick-driver/SerialDriver_Windows8_1/i386/ftserui2.dll old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/SerialDriver_Windows8_1/setup.exe b/external/tellstick-driver/SerialDriver_Windows8_1/setup.exe old mode 100755 new mode 100644 diff --git a/external/tellstick-driver/ftdi_linux.zip b/external/tellstick-driver/ftdi_linux.zip old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/CMakeLists.txt b/external/tellstick-rfcmd/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/COPYING b/external/tellstick-rfcmd/COPYING old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/Makefile b/external/tellstick-rfcmd/Makefile old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/build.sh b/external/tellstick-rfcmd/build.sh old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/find_telldus.c b/external/tellstick-rfcmd/find_telldus.c old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/ftdi.c b/external/tellstick-rfcmd/ftdi.c old mode 100755 new mode 100644 diff --git a/external/tellstick-rfcmd/rfcmd.c b/external/tellstick-rfcmd/rfcmd.c old mode 100755 new mode 100644 diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/hal-core/src/se/hal/EventControllerManager.java b/hal-core/src/se/hal/EventControllerManager.java index 81164110..667493e1 100644 --- a/hal-core/src/se/hal/EventControllerManager.java +++ b/hal-core/src/se/hal/EventControllerManager.java @@ -2,6 +2,7 @@ package se.hal; import se.hal.intf.*; import se.hal.struct.Event; +import se.hal.util.HalDeviceUtil; import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.plugin.PluginManager; @@ -35,6 +36,25 @@ public class EventControllerManager extends HalAbstractControllerManager limboEvents = Collections.synchronizedList(new LinkedList<>()); + public void initialize(PluginManager pluginManager) { + super.initialize(pluginManager); + instance = this; + + // Read in existing devices + + try { + DBConnection db = HalContext.getDB(); + + logger.info("Reading in existing events."); + + for (Event event : Event.getLocalEvents(db)) { + EventControllerManager.getInstance().register(event); + } + } catch (SQLException e) { + logger.log(Level.SEVERE, "Unable to read in existing events.", e); + } + } + // ---------------------------------------------------- // EVENTS // ---------------------------------------------------- @@ -61,7 +81,7 @@ public class EventControllerManager extends HalAbstractControllerManager list){ - for (int i=0; i controllerManagers = new ArrayList<>(); + private static ScheduledExecutorService daemonExecutor; private static List daemons = new ArrayList<>(); @@ -91,23 +93,7 @@ public class HalServer { for (Iterator it = pluginManager.getSingletonIterator(HalAbstractControllerManager.class); it.hasNext(); ) { HalAbstractControllerManager manager = it.next(); manager.initialize(pluginManager); - } - - // ------------------------------------ - // Import sensors,events and triggers - // ------------------------------------ - - logger.info("Initializing Sensors and Events."); - - for (Sensor sensor : Sensor.getLocalSensors(db)) { - SensorControllerManager.getInstance().register(sensor); - } - for (Event event : Event.getLocalEvents(db)) { - EventControllerManager.getInstance().register(event); - } - // Import triggers - for (TriggerFlow flow : TriggerFlow.getTriggerFlows(db)) { - TriggerManager.getInstance().register(flow); + controllerManagers.add(manager); } // ------------------------------------ @@ -183,4 +169,9 @@ public class HalServer { pages.add(page); http.setPage(page.getId(), page); } + + + public static List getControllerManagers() { + return controllerManagers; + } } diff --git a/hal-core/src/se/hal/SensorControllerManager.java b/hal-core/src/se/hal/SensorControllerManager.java index c8fe5303..b6527327 100644 --- a/hal-core/src/se/hal/SensorControllerManager.java +++ b/hal-core/src/se/hal/SensorControllerManager.java @@ -2,6 +2,7 @@ package se.hal; import se.hal.intf.*; import se.hal.struct.Sensor; +import se.hal.util.HalDeviceUtil; import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.plugin.PluginManager; @@ -35,6 +36,27 @@ public class SensorControllerManager extends HalAbstractControllerManager limboSensors = Collections.synchronizedList(new LinkedList<>()); + + @Override + public void initialize(PluginManager pluginManager){ + super.initialize(pluginManager); + instance = this; + + // Read in existing devices + + try { + DBConnection db = HalContext.getDB(); + + logger.info("Reading in existing sensors."); + + for (Sensor sensor : Sensor.getLocalSensors(db)) { + SensorControllerManager.getInstance().register(sensor); + } + } catch (SQLException e) { + logger.log(Level.SEVERE, "Unable to read in existing sensors.", e); + } + } + // ---------------------------------------------------- // SENSORS // ---------------------------------------------------- @@ -61,7 +83,8 @@ public class SensorControllerManager extends HalAbstractControllerManager list){ - for (int i=0; i> it = pluginManager.getClassIterator(HalTrigger.class); + it.hasNext(); ) { + manager.addAvailableTrigger(it.next()); + } + + for (Iterator> it = pluginManager.getClassIterator(HalAction.class); + it.hasNext(); ) { + manager.addAvailableAction(it.next()); + } + + manager.setEvaluationInterval(EVALUATION_INTERVAL); + instance = manager; + + try { + // Import triggers + + DBConnection db = HalContext.getDB(); + + logger.info("Reading in existing sensors."); + + for (TriggerFlow flow : TriggerFlow.getTriggerFlows(db)) { + TriggerManager.getInstance().register(flow); + } + } catch (SQLException e) { + logger.log(Level.SEVERE, "Unable to read in existing triggers.", e); + } + } + public void setEvaluationInterval(long interval) { if (executor != null) @@ -86,23 +119,6 @@ public class TriggerManager { } - public static void initialize(PluginManager pluginManager) { - TriggerManager manager = new TriggerManager(); - - for (Iterator> it = pluginManager.getClassIterator(HalTrigger.class); - it.hasNext(); ) { - manager.addAvailableTrigger(it.next()); - } - - for (Iterator> it = pluginManager.getClassIterator(HalAction.class); - it.hasNext(); ) { - manager.addAvailableAction(it.next()); - } - - manager.setEvaluationInterval(EVALUATION_INTERVAL); - instance = manager; - } - public static TriggerManager getInstance(){ return instance; } diff --git a/hal-core/src/se/hal/intf/HalAbstractControllerManager.java b/hal-core/src/se/hal/intf/HalAbstractControllerManager.java index fdef6ac6..d6cd2f5f 100644 --- a/hal-core/src/se/hal/intf/HalAbstractControllerManager.java +++ b/hal-core/src/se/hal/intf/HalAbstractControllerManager.java @@ -20,6 +20,28 @@ public abstract class HalAbstractControllerManager controllerMap = new HashMap<>(); + /** + * Will instantiate a generic ControllerManager. + * + * @param pluginManager a PluginManager instance that will be used to find Controller plugins. + */ + public void initialize(PluginManager pluginManager) { + Class[] genericClasses = ClassUtil.getGenericClasses(HalAbstractControllerManager.class); + + if (genericClasses.length >= 1 && genericClasses[0] != null) { + for (Iterator> it = pluginManager.getClassIterator(genericClasses[0]); it.hasNext(); ) { + addAvailableDevice(it.next()); + } + } else { + logger.severe("Unable to retrieve Controller class from generics."); + } + + for (Iterator> it = pluginManager.getClassIterator(HalAutoScannableController.class); it.hasNext(); ){ + Class controller = it.next(); + getControllerInstance(controller); // Instantiate controller + } + } + // ---------------------------------------------------- // Abstract methods // ---------------------------------------------------- @@ -131,26 +153,4 @@ public abstract class HalAbstractControllerManager= 1 && genericClasses[0] != null) { - for (Iterator> it = pluginManager.getClassIterator(genericClasses[0]); it.hasNext(); ) { - addAvailableDevice(it.next()); - } - } else { - logger.severe("Unable to retrieve Controller class from generics."); - } - - for (Iterator> it = pluginManager.getClassIterator(HalAutoScannableController.class); it.hasNext(); ){ - Class controller = it.next(); - getControllerInstance(controller); // Instantiate controller - } - } } diff --git a/hal-core/src/se/hal/intf/HalDeviceConfig.java b/hal-core/src/se/hal/intf/HalDeviceConfig.java index 920c3ac1..0c22057b 100644 --- a/hal-core/src/se/hal/intf/HalDeviceConfig.java +++ b/hal-core/src/se/hal/intf/HalDeviceConfig.java @@ -5,6 +5,9 @@ package se.hal.intf; */ public interface HalDeviceConfig { + /** + * @return the controller class that is responsible to track this configuration + */ Class getDeviceControllerClass(); /** @@ -13,9 +16,11 @@ public interface HalDeviceConfig { Class getDeviceDataClass(); /** - * This method needs to be implemented. - * NOTE: it should not compare data and timestamp, only static or unique data for the event type. + * This method is required to be implemented. + * This method compares two configuration objects static or unique configuration. it should not compare data and timestamp type dynamic values. + * + * @param obj is the target object to compare to. + * @return true if the configuration of the two objects are same, false if the objects are not of same type or configuration does not match. */ boolean equals(Object obj); - } diff --git a/hal-core/src/se/hal/util/HalDeviceUtil.java b/hal-core/src/se/hal/util/HalDeviceUtil.java new file mode 100644 index 00000000..a56991d1 --- /dev/null +++ b/hal-core/src/se/hal/util/HalDeviceUtil.java @@ -0,0 +1,29 @@ +package se.hal.util; + +import se.hal.intf.HalAbstractDevice; +import se.hal.intf.HalDeviceConfig; + +import java.util.List; + +/** + * A class containing utility methods for HalDevice objects. + */ +public class HalDeviceUtil { + + /** + * Method will search a list for a device matching the given configuration object. + * + * @param deviceConfig the configuration object to identify the device by. + * @param list the list to search through. + * @return a HalAbstractDevice object matching the configuration object, null if no device was found. + */ + public static D findDevice(HalDeviceConfig deviceConfig, List list){ + for (int i=0; i getDeviceDataClass() { return OnOffEventData.class; } + + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } public static class TestEvent2 implements HalEventConfig { @@ -105,6 +110,11 @@ public class EventControllerManagerTest { public Class getDeviceDataClass() { return OnOffEventData.class; } + + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } public static class TestController implements HalEventController { diff --git a/hal-core/test/se/hal/SensorControllerManagerTest.java b/hal-core/test/se/hal/SensorControllerManagerTest.java index 8539f085..5a4c2298 100644 --- a/hal-core/test/se/hal/SensorControllerManagerTest.java +++ b/hal-core/test/se/hal/SensorControllerManagerTest.java @@ -104,6 +104,11 @@ public class SensorControllerManagerTest { public Class getDeviceDataClass() { return TemperatureSensorData.class; } + + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } public static class TestSensor2 implements HalSensorConfig { @@ -127,6 +132,11 @@ public class SensorControllerManagerTest { public Class getDeviceDataClass() { return HumiditySensorData.class; } + + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } public static class TestController implements HalSensorController { diff --git a/hal-core/test/se/hal/test/TestDeviceConfig.java b/hal-core/test/se/hal/test/TestDeviceConfig.java new file mode 100644 index 00000000..879931ca --- /dev/null +++ b/hal-core/test/se/hal/test/TestDeviceConfig.java @@ -0,0 +1,45 @@ +package se.hal.test; + +import se.hal.intf.*; +import se.hal.struct.devicedata.TemperatureSensorData; + +/** + * A dymmy device config class + */ +public class TestDeviceConfig implements HalSensorConfig, HalEventConfig { + + private String id; + + + public TestDeviceConfig(String id) { + this.id = id; + } + + + @Override + public long getDataInterval() { + return 60 * 1000; // 1 min + } + + @Override + public AggregationMethod getAggregationMethod() { + return AggregationMethod.AVERAGE; + } + + @Override + public Class getDeviceControllerClass() { + return null; + } + + @Override + public Class getDeviceDataClass() { + return TemperatureSensorData.class; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof TestDeviceConfig) + return id.equals(((TestDeviceConfig) obj).id); + return false; + } +} diff --git a/hal-core/test/se/hal/util/HalDeviceUtilTest.java b/hal-core/test/se/hal/util/HalDeviceUtilTest.java new file mode 100644 index 00000000..9f40b97f --- /dev/null +++ b/hal-core/test/se/hal/util/HalDeviceUtilTest.java @@ -0,0 +1,31 @@ +package se.hal.util; + +import junit.framework.TestCase; +import org.junit.Test; +import se.hal.struct.Event; +import se.hal.test.TestDeviceConfig; + +import java.util.ArrayList; +import java.util.List; + +public class HalDeviceUtilTest extends TestCase { + + @Test + public void testFindDevice() { + List eventList = new ArrayList<>(); + + Event device = new Event(); + device.setDeviceConfig(new TestDeviceConfig("not test")); + eventList.add(device); + + Event device2 = new Event(); + device2.setDeviceConfig(new TestDeviceConfig("not test")); + eventList.add(device2); + + Event expectedDevice = new Event(); + expectedDevice.setDeviceConfig(new TestDeviceConfig("test")); + eventList.add(expectedDevice); + + assertEquals(expectedDevice, HalDeviceUtil.findDevice(new TestDeviceConfig("test"), eventList)); + } +} \ No newline at end of file diff --git a/hal.conf.example b/hal.conf.example old mode 100755 new mode 100644 diff --git a/logging.properties b/logging.properties old mode 100755 new mode 100644 diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java index 5b8b32ba..9b358fe3 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java @@ -1,11 +1,7 @@ package se.hal.plugin.dummy; -import se.hal.intf.HalDeviceData; -import se.hal.intf.HalSensorConfig; -import se.hal.intf.HalSensorController; -import se.hal.intf.HalSensorData; +import se.hal.intf.*; import se.hal.struct.devicedata.HumiditySensorData; -import se.hal.struct.devicedata.TemperatureSensorData; public class DummyHumiditySensor implements DummyDevice, HalSensorConfig { @@ -40,4 +36,8 @@ public class DummyHumiditySensor implements DummyDevice, HalSensorConfig { return HumiditySensorData.class; } + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java index 7f63775c..ec0f6a51 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java @@ -24,4 +24,9 @@ public class DummySwitchEvent implements DummyDevice, HalEventConfig { public Class getDeviceDataClass() { return OnOffEventData.class; } + + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java index e013e680..c92ea41d 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java @@ -1,9 +1,6 @@ package se.hal.plugin.dummy; -import se.hal.intf.HalDeviceData; -import se.hal.intf.HalSensorConfig; -import se.hal.intf.HalSensorController; -import se.hal.intf.HalSensorData; +import se.hal.intf.*; import se.hal.struct.devicedata.TemperatureSensorData; @@ -39,4 +36,8 @@ public class DummyTemperatureSensor implements DummyDevice, HalSensorConfig { return TemperatureSensorData.class; } + @Override + public boolean equals(Object obj) { + return this.equals(obj); + } } diff --git a/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java b/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java index f9112f50..3e15f591 100644 --- a/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java +++ b/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java @@ -48,6 +48,7 @@ package se.hal.plugin.mqtt.device; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -79,4 +80,11 @@ public class HalMqttDeviceConfig implements HalEventConfig { public Class getDeviceDataClass() { return HalMqttDeviceData.class; } + + @Override + public boolean equals(Object obj) { + if (obj instanceof HalMqttDeviceConfig) + return topic.equals(((HalMqttDeviceConfig) obj).topic); + return false; + } } diff --git a/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java b/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java index e4501d99..ae58092d 100644 --- a/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java +++ b/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java @@ -1,5 +1,6 @@ package se.hal.plugin.netscan; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -23,16 +24,6 @@ public class NetworkDevice implements HalEventConfig { return host; } - @Override - public String toString(){ - return "Host: "+ host; - } - @Override - public boolean equals(Object obj){ - if (obj instanceof NetworkDevice) - return host != null && host.equals(((NetworkDevice) obj).host); - return false; - } @Override public Class getDeviceControllerClass() { @@ -42,4 +33,16 @@ public class NetworkDevice implements HalEventConfig { public Class getDeviceDataClass() { return OnOffEventData.class; } + + + @Override + public boolean equals(Object obj){ + if (obj instanceof NetworkDevice) + return host != null && host.equals(((NetworkDevice) obj).host); + return false; + } + @Override + public String toString(){ + return "Host: "+ host; + } } diff --git a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java index fc4b044f..53be6f63 100644 --- a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java +++ b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java @@ -48,6 +48,7 @@ package se.hal.plugin.nutups; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; @@ -86,17 +87,6 @@ public class NutUpsDevice implements HalSensorConfig{ return 60*1000; // 1 min } - @Override - public boolean equals(Object obj){ - if (obj instanceof NutUpsDevice) - return upsId != null && upsId.equals(((NutUpsDevice)obj).upsId); - return false; - } - - public String toString(){ - return "upsId: "+ upsId; - } - @Override public AggregationMethod getAggregationMethod() { return AggregationMethod.SUM; @@ -109,4 +99,16 @@ public class NutUpsDevice implements HalSensorConfig{ public Class getDeviceDataClass() { return PowerConsumptionSensorData.class; } + + @Override + public boolean equals(Object obj){ + if (obj instanceof NutUpsDevice) + return upsId != null && upsId.equals(((NutUpsDevice)obj).upsId); + return false; + } + @Override + public String toString(){ + return "upsId: "+ upsId; + } + } diff --git a/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java b/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java index 8e755162..7dd6a8db 100644 --- a/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java +++ b/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java @@ -24,6 +24,7 @@ package se.hal.plugin.nvr.rtsp; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalDeviceData; import se.hal.plugin.nvr.intf.HalCameraController; import se.hal.plugin.nvr.intf.HalCameraConfig; @@ -53,4 +54,11 @@ public class RTSPCameraConfig implements HalCameraConfig { public Class getDeviceDataClass() { return null; // TODO: } + + @Override + public boolean equals(Object obj) { + if (obj instanceof RTSPCameraConfig) + return rtspUrl.equals(((RTSPCameraConfig) obj).rtspUrl); + return false; + } } diff --git a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java index 170908ce..91220e2e 100644 --- a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java +++ b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java @@ -1,5 +1,6 @@ package se.hal.plugin.raspberry; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; diff --git a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java index 65322e1d..5378b5e4 100644 --- a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java +++ b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java @@ -1,5 +1,6 @@ package se.hal.plugin.raspberry; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; @@ -12,13 +13,17 @@ public class RPiTemperatureSensor implements HalSensorConfig { private String w1Address; - public RPiTemperatureSensor() { } public RPiTemperatureSensor(String w1Address) { this.w1Address = w1Address; } + public String get1WAddress() { + return w1Address; + } + + @Override public long getDataInterval() { return 10*60*1000; // 10 min @@ -45,9 +50,4 @@ public class RPiTemperatureSensor implements HalSensorConfig { return this.get1WAddress().equals(((RPiTemperatureSensor) obj).w1Address); return false; } - - public String get1WAddress() { - return w1Address; - } - } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickDevice.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickDevice.java index 72a92f6d..c987f96c 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickDevice.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickDevice.java @@ -1,12 +1,13 @@ package se.hal.plugin.tellstick; +import se.hal.intf.HalDeviceConfig; + /** * This interface represents a device configuration and links it to a protocol. * * Created by Ziver on 2016-08-18. */ -public interface TellstickDevice { - +public interface TellstickDevice extends HalDeviceConfig { String getProtocolName(); // TODO: could be implemented in a better way String getModelName(); // TODO: could be implemented in a better way diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickProtocol.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickProtocol.java index fe7a2884..0b0c2e91 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickProtocol.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickProtocol.java @@ -37,21 +37,25 @@ public abstract class TellstickProtocol { private final String model; - public TellstickProtocol(String protocol, String model){ + public TellstickProtocol(String protocol, String model) { this.protocol = protocol; this.model = model; } - public String getProtocolName(){ + public String getProtocolName() { return protocol; } - public String getModelName(){ + + public String getModelName() { return model; } - public TellstickCmd encode(HalEventConfig deviceConfig, HalEventData deviceData){ return null; } + public TellstickCmd encode(HalEventConfig deviceConfig, HalEventData deviceData) { + return null; + } + public abstract List decode(byte[] data); @@ -59,15 +63,16 @@ public abstract class TellstickProtocol { private TellstickDevice device; private HalDeviceData data; - public TellstickDecodedEntry(TellstickDevice device, HalDeviceData data){ + public TellstickDecodedEntry(TellstickDevice device, HalDeviceData data) { this.device = device; this.data = data; } - public TellstickDevice getDevice(){ + public TellstickDevice getDevice() { return device; } - public HalDeviceData getData(){ + + public HalDeviceData getData() { return data; } } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickSerialComm.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickSerialComm.java index 59ce7947..d595dda9 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickSerialComm.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/TellstickSerialComm.java @@ -57,19 +57,15 @@ public class TellstickSerialComm implements Runnable, private SerialPort serial; private InputStream in; private OutputStream out; - private TimedHashSet set; // To check for duplicate transmissions + private TimedHashSet receivedTransmissionSet = new TimedHashSet<>(TRANSMISSION_UNIQUENESS_TTL); // To check for duplicate transmissions - protected TellstickParser parser; + protected TellstickParser parser = new TellstickParser(); private HalDeviceReportListener deviceListener; - private List registeredDevices; + private List registeredDevices = Collections.synchronizedList(new ArrayList()); - public TellstickSerialComm() { - set = new TimedHashSet<>(TRANSMISSION_UNIQUENESS_TTL); - parser = new TellstickParser(); - registeredDevices = Collections.synchronizedList(new ArrayList()); - } + public TellstickSerialComm() {} // -------------------------- // Lifecycle methods @@ -79,6 +75,7 @@ public class TellstickSerialComm implements Runnable, public boolean isAvailable() { return HalContext.containsProperty(CONFIG_TELLSTICK_COM_PORT); } + @Override public void initialize() throws Exception { initialize(HalContext.getStringProperty(CONFIG_TELLSTICK_COM_PORT)); @@ -163,14 +160,16 @@ public class TellstickSerialComm implements Runnable, entry.getData().setTimestamp(System.currentTimeMillis()); boolean registered = registeredDevices.contains(entry.getDevice()); - if (registered && !set.contains(data) || // check for duplicates transmissions of registered devices - !registered && set.contains(data)) { // required duplicate transmissions before reporting unregistered devices + if (registered && !receivedTransmissionSet.contains(data) || // check for duplicates transmissions of registered devices + !registered && receivedTransmissionSet.contains(data)) { // required duplicate transmissions before reporting unregistered devices - //Check for registered device that are in the same group + // Check for registered device that are in the same group if (entry.getDevice() instanceof TellstickDeviceGroup) { TellstickDeviceGroup groupProtocol = (TellstickDeviceGroup) entry.getDevice(); + for (int i = 0; i < registeredDevices.size(); ++i) { // Don't use foreach for concurrency reasons - TellstickDevice childDevice = registeredDevices.get(i); + HalDeviceConfig childDevice = registeredDevices.get(i); + if (childDevice instanceof TellstickDeviceGroup && groupProtocol.equalsGroup((TellstickDeviceGroup)childDevice) && !entry.getDevice().equals(childDevice)) { @@ -182,11 +181,12 @@ public class TellstickSerialComm implements Runnable, reportEvent(entry.getDevice(), entry.getData()); } } - set.add(data); + + receivedTransmissionSet.add(data); } - private void reportEvent(TellstickDevice tellstickDevice, HalDeviceData deviceData){ + private void reportEvent(HalDeviceConfig tellstickDevice, HalDeviceData deviceData) { if (deviceListener != null) - deviceListener.reportReceived((HalDeviceConfig) tellstickDevice, deviceData); + deviceListener.reportReceived(tellstickDevice, deviceData); } @Override @@ -224,14 +224,14 @@ public class TellstickSerialComm implements Runnable, @Override public void register(HalDeviceConfig deviceConfig) { if(deviceConfig instanceof TellstickDevice) - registeredDevices.add((TellstickDevice) deviceConfig); + registeredDevices.add(deviceConfig); else throw new IllegalArgumentException( "Device config is not an instance of " + TellstickDevice.class + ": " + deviceConfig.getClass()); } public List getRegisteredDevices(Class clazz){ ArrayList list = new ArrayList<>(); - for (TellstickDevice device : registeredDevices){ + for (HalDeviceConfig device : registeredDevices){ if (clazz.isAssignableFrom(device.getClass())) list.add((T) device); } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java index d4523c1f..e2f0ccd8 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java @@ -22,6 +22,7 @@ package se.hal.plugin.tellstick.device; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -35,7 +36,7 @@ import zutil.ui.Configurator; /** * Created by Ziver on 2015-02-18. */ -public class NexaSelfLearning implements HalEventConfig,TellstickDevice,TellstickDeviceGroup { +public class NexaSelfLearning implements TellstickDevice, HalEventConfig, TellstickDeviceGroup { @Configurator.Configurable("House code") private int house = 0; @@ -55,7 +56,6 @@ public class NexaSelfLearning implements HalEventConfig,TellstickDevice,Tellstic } - public int getHouse() { return house; } @@ -76,11 +76,18 @@ public class NexaSelfLearning implements HalEventConfig,TellstickDevice,Tellstic } + @Override + public String getProtocolName() { return NexaSelfLearningProtocol.PROTOCOL; } + @Override + public String getModelName() { return NexaSelfLearningProtocol.MODEL; } - public String toString(){ - return "house:"+house+ - ", group:"+group+ - ", unit:"+unit; + @Override + public Class getDeviceControllerClass() { + return TellstickSerialComm.class; + } + @Override + public Class getDeviceDataClass() { + return OnOffEventData.class; } @Override @@ -98,19 +105,10 @@ public class NexaSelfLearning implements HalEventConfig,TellstickDevice,Tellstic (((NexaSelfLearning) obj).group || group ); return false; } - - @Override - public Class getDeviceControllerClass() { - return TellstickSerialComm.class; + public String toString(){ + return "house:" + house + + ", group:" + group + + ", unit:" + unit; } - @Override - public Class getDeviceDataClass() { - return OnOffEventData.class; - } - - @Override - public String getProtocolName() { return NexaSelfLearningProtocol.PROTOCOL; } - @Override - public String getModelName() { return NexaSelfLearningProtocol.MODEL; } } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java index 1b4c84f8..4dd41d2d 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java @@ -22,6 +22,7 @@ package se.hal.plugin.tellstick.device; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -34,7 +35,7 @@ import zutil.ui.Configurator; /** * Created by Ziver on 2015-02-18. */ -public class NexaSelfLearningDimmer implements HalEventConfig,TellstickDevice { +public class NexaSelfLearningDimmer implements TellstickDevice, HalEventConfig { @Configurator.Configurable("House code") private int house = 0; @@ -50,7 +51,6 @@ public class NexaSelfLearningDimmer implements HalEventConfig,TellstickDevice { } - public int getHouse() { return house; } @@ -65,19 +65,10 @@ public class NexaSelfLearningDimmer implements HalEventConfig,TellstickDevice { } - - public String toString(){ - return "house:"+house+ - ", unit:"+unit; - } - @Override - public boolean equals(Object obj){ - if(obj instanceof NexaSelfLearningDimmer) - return ((NexaSelfLearningDimmer) obj).house == house && - ((NexaSelfLearningDimmer)obj).unit == unit; - return false; - } + public String getProtocolName() { return NexaSelfLearningProtocol.PROTOCOL; } + @Override + public String getModelName() { return NexaSelfLearningProtocol.MODEL; } @Override @@ -90,7 +81,15 @@ public class NexaSelfLearningDimmer implements HalEventConfig,TellstickDevice { } @Override - public String getProtocolName() { return NexaSelfLearningProtocol.PROTOCOL; } + public boolean equals(Object obj){ + if(obj instanceof NexaSelfLearningDimmer) + return ((NexaSelfLearningDimmer) obj).house == house && + ((NexaSelfLearningDimmer)obj).unit == unit; + return false; + } @Override - public String getModelName() { return NexaSelfLearningProtocol.MODEL; } + public String toString(){ + return "house:" + house + + ", unit:" + unit; + } } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java index 6c93e481..90a3645b 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java @@ -1,5 +1,6 @@ package se.hal.plugin.tellstick.device; +import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; @@ -18,7 +19,7 @@ import java.util.logging.Logger; /** * Created by Ziver on 2015-11-19. */ -public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice { +public class Oregon0x1A2D implements TellstickDevice, HalSensorConfig { private static final Logger logger = LogUtil.getLogger(); public enum OregonSensorType{ @@ -52,17 +53,11 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice { return sensorType; } - @Override - public boolean equals(Object obj){ - if(! (obj instanceof Oregon0x1A2D)) - return false; - return ((Oregon0x1A2D)obj).address == this.address && - ((Oregon0x1A2D)obj).sensorType == this.sensorType; - } - public String toString(){ - return "address:"+address+",sensorType:"+ sensorType; - } + @Override + public String getProtocolName() { return Oregon0x1A2DProtocol.PROTOCOL; } + @Override + public String getModelName() { return Oregon0x1A2DProtocol.MODEL; } @Override @@ -95,7 +90,15 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice { } @Override - public String getProtocolName() { return Oregon0x1A2DProtocol.PROTOCOL; } + public boolean equals(Object obj){ + if(obj instanceof Oregon0x1A2D) + return ((Oregon0x1A2D)obj).address == this.address && + ((Oregon0x1A2D)obj).sensorType == this.sensorType; + return false; + } @Override - public String getModelName() { return Oregon0x1A2DProtocol.MODEL; } + public String toString(){ + return "address:" + address + ",sensorType:" + sensorType; + } + } diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommEventTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java similarity index 54% rename from plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommEventTest.java rename to plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java index cc464755..11c151bd 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommEventTest.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java @@ -3,44 +3,45 @@ package se.hal.plugin.tellstick; import org.junit.Before; import org.junit.Test; import se.hal.intf.*; -import se.hal.struct.devicedata.DimmerEventData; -import zutil.converter.Converter; +import se.hal.plugin.tellstick.test.TestEventDevice; +import se.hal.plugin.tellstick.test.TestProtocol; import java.util.ArrayList; -import java.util.List; import static org.junit.Assert.assertEquals; /** * Created by Ziver on 2015-11-19. */ -public class TelstickSerialCommEventTest { +public class TellstickSerialCommEventTest { @Before - public void init(){ - TellstickParser.registerProtocol(TestEvent.class); + public void init() { + TellstickParser.registerProtocol(TestProtocol.class); } - - //############# Non crashing TC + // ---------------------------------------------------- + // Non crashing TC + // ---------------------------------------------------- @Test - public void startup(){ + public void startup() { TellstickSerialComm tellstick = new TellstickSerialComm(); tellstick.handleLine("+V2"); } @Test - public void unregisteredListener(){ + public void unregisteredListener() { TellstickSerialComm tellstick = new TellstickSerialComm(); tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:1234;"); } - - //############ Normal TCs + // ---------------------------------------------------- + // Normal TCs + // ---------------------------------------------------- @Test - public void receiveUnregisteredEvent(){ + public void receiveUnregisteredEvent() { // Setup TellstickSerialComm tellstick = new TellstickSerialComm(); final ArrayList list = new ArrayList<>(); @@ -51,14 +52,14 @@ public class TelstickSerialCommEventTest { } }); // Execution - tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:2345;"); + tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:6345;"); assertEquals("Events first transmission", 0, list.size()); - tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:2345;"); + tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:6345;"); assertEquals("Events Second transmission", 1, list.size()); } @Test - public void receiveEvent(){ + public void receiveEvent() { // Setup TellstickSerialComm tellstick = new TellstickSerialComm(); final ArrayList list = new ArrayList<>(); @@ -69,45 +70,13 @@ public class TelstickSerialCommEventTest { } }); // Execution - TestEvent event = new TestEvent(); + TestEventDevice event = new TestEventDevice(); event.testData = 0xAAAA; tellstick.register(event); tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:AAAA;"); // Verification assertEquals("Nr of received events", 1, list.size()); - assertEquals("Data", event.testData, ((TestEvent)list.get(0)).testData); + assertEquals("Data", event.testData, ((TestEventDevice)list.get(0)).testData); } - - - - private static class TestEvent extends TellstickProtocol implements HalEventConfig,TellstickDevice { - public int testData; - - public TestEvent(){ - super("test-prot", "test-model"); - } - - @Override - public List decode(byte[] data) { - testData = Converter.toInt(data); - - ArrayList list = new ArrayList<>(); - list.add(new TellstickDecodedEntry( - this, new DimmerEventData(testData, System.currentTimeMillis()) - )); - return list; - } - - - @Override - public Class getDeviceControllerClass() { return null; } - @Override - public Class getDeviceDataClass() { - return null; - } - - @Override - public boolean equals(Object obj) {return testData == ((TestEvent)obj).testData;} - } } diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java new file mode 100644 index 00000000..05bc8d1d --- /dev/null +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java @@ -0,0 +1,67 @@ +package se.hal.plugin.tellstick; + +import org.junit.Before; +import org.junit.Test; +import se.hal.intf.*; +import se.hal.plugin.tellstick.test.TestProtocol; +import se.hal.plugin.tellstick.test.TestSensorDevice; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; + +/** + * Created by Ziver on 2015-11-19. + */ +public class TellstickSerialCommSensorTest { + + @Before + public void init(){ + TellstickParser.registerProtocol(TestProtocol.class); + } + + + // ---------------------------------------------------- + // Normal TCs + // ---------------------------------------------------- + + @Test + public void receiveUnregisteredSensor() { + // Setup + TellstickSerialComm tellstick = new TellstickSerialComm(); + final ArrayList list = new ArrayList<>(); + tellstick.setListener(new HalDeviceReportListener() { + @Override + public void reportReceived(HalSensorConfig e, HalSensorData d) { + list.add(e); + } + }); + // Execution + tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:15;"); + assertEquals("Sensors first transmission", 0, list.size()); + tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:15;"); + assertEquals("Sensors Second transmission", 1, list.size()); + } + + @Test + public void receiveSensor() { + // Setup + TellstickSerialComm tellstick = new TellstickSerialComm(); + final ArrayList list = new ArrayList<>(); + tellstick.setListener(new HalDeviceReportListener() { + @Override + public void reportReceived(HalSensorConfig e, HalSensorData d) { + list.add(e); + } + }); + // Execution + TestSensorDevice sensor = new TestSensorDevice(); + sensor.testData = 0xAA; + tellstick.register(sensor); + tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:AA;"); + // Verification + assertEquals("Nr of received sensors", 1, list.size()); + assertEquals("Data", sensor.testData, ((TestSensorDevice)list.get(0)).testData); + } + +} diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommSensorTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommSensorTest.java deleted file mode 100644 index b3dc2d29..00000000 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommSensorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.hal.plugin.tellstick; - -import org.junit.Before; -import org.junit.Test; -import se.hal.intf.*; -import se.hal.struct.devicedata.TemperatureSensorData; -import zutil.converter.Converter; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -/** - * Created by Ziver on 2015-11-19. - */ -public class TelstickSerialCommSensorTest { - - @Before - public void init(){ - TellstickParser.registerProtocol(TestSensor.class); - } - - - //############ Normal TCs - - @Test - public void receiveUnregisteredSensor(){ - // Setup - TellstickSerialComm tellstick = new TellstickSerialComm(); - final ArrayList list = new ArrayList<>(); - tellstick.setListener(new HalDeviceReportListener() { - @Override - public void reportReceived(HalSensorConfig e, HalSensorData d) { - list.add(e); - } - }); - // Execution - tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:2345;"); - assertEquals("Sensors first transmission", 0, list.size()); - tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:2345;"); - assertEquals("Sensors Second transmission", 1, list.size()); - } - - @Test - public void receiveSensor(){ - // Setup - TellstickSerialComm tellstick = new TellstickSerialComm(); - final ArrayList list = new ArrayList<>(); - tellstick.setListener(new HalDeviceReportListener() { - @Override - public void reportReceived(HalSensorConfig e, HalSensorData d) { - list.add(e); - } - }); - // Execution - TestSensor sensor = new TestSensor(); - sensor.testData = 0xAAAA; - tellstick.register(sensor); - tellstick.handleLine("+Wclass:sensor;protocol:test-prot;model:test-model;data:AAAA;"); - // Verification - assertEquals("Nr of received sensors", 1, list.size()); - assertEquals("Data", sensor.testData, ((TestSensor)list.get(0)).testData); - } - - - - - private static class TestSensor extends TellstickProtocol implements HalSensorConfig,TellstickDevice { - public int testData; - - public TestSensor(){ - super("test-prot", "test-model"); - } - - @Override - public List decode(byte[] data) { - testData = Converter.toInt(data); - - ArrayList list = new ArrayList<>(); - list.add(new TellstickDecodedEntry( - this, new TemperatureSensorData(testData, 0) - )); - return list; - } - - - @Override - public boolean equals(Object obj) {return testData == ((TestSensor)obj).testData;} - - - @Override - public long getDataInterval() { return 0; } - @Override - public AggregationMethod getAggregationMethod() { return null; } - @Override - public Class getDeviceControllerClass() { return null; } - @Override - public Class getDeviceDataClass() { - return null; - } - } -} diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java new file mode 100644 index 00000000..1efad020 --- /dev/null +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java @@ -0,0 +1,39 @@ +package se.hal.plugin.tellstick.test; + +import se.hal.intf.HalDeviceConfig; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventController; +import se.hal.intf.HalEventData; +import se.hal.plugin.tellstick.TellstickDevice; +import se.hal.plugin.tellstick.TellstickSerialCommEventTest; + +public class TestEventDevice implements TellstickDevice, HalEventConfig { + public int testData; + + + @Override + public String getProtocolName() { + return "test-prot"; + } + + @Override + public String getModelName() { + return "test-model"; + } + + + @Override + public Class getDeviceControllerClass() { + return null; + } + + @Override + public Class getDeviceDataClass() { + return null; + } + + @Override + public boolean equals(Object obj) { + return testData == ((TestEventDevice) obj).testData; + } +} diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestProtocol.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestProtocol.java new file mode 100644 index 00000000..bbf6c5a2 --- /dev/null +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestProtocol.java @@ -0,0 +1,39 @@ +package se.hal.plugin.tellstick.test; + +import se.hal.plugin.tellstick.TellstickProtocol; +import se.hal.struct.devicedata.DimmerEventData; +import se.hal.struct.devicedata.TemperatureSensorData; +import zutil.converter.Converter; + +import java.util.ArrayList; +import java.util.List; + +public class TestProtocol extends TellstickProtocol { + + public TestProtocol() { + super("test-prot", "test-model"); + } + + @Override + public List decode(byte[] data) { + ArrayList list = new ArrayList<>(); + int parsedData = Converter.toInt(data); + + if (parsedData > 5000) { + TestEventDevice device = new TestEventDevice(); + device.testData = Converter.toInt(data); + + list.add(new TellstickDecodedEntry( + device, new DimmerEventData(device.testData, System.currentTimeMillis()) + )); + } else { + TestSensorDevice device = new TestSensorDevice(); + device.testData = Converter.toInt(data); + + list.add(new TellstickDecodedEntry( + device, new TemperatureSensorData(device.testData, System.currentTimeMillis()) + )); + } + return list; + } +} diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java new file mode 100644 index 00000000..1ed11fc2 --- /dev/null +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java @@ -0,0 +1,48 @@ +package se.hal.plugin.tellstick.test; + +import se.hal.intf.HalDeviceConfig; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorController; +import se.hal.intf.HalSensorData; +import se.hal.plugin.tellstick.TellstickDevice; +import se.hal.plugin.tellstick.TellstickSerialCommSensorTest; + +public class TestSensorDevice implements HalSensorConfig, TellstickDevice { + public int testData; + + @Override + public String getProtocolName() { + return "test-prot"; + } + + @Override + public String getModelName() { + return "test-model"; + } + + @Override + public long getDataInterval() { + return 0; + } + + @Override + public AggregationMethod getAggregationMethod() { + return null; + } + + @Override + public Class getDeviceControllerClass() { + return null; + } + + @Override + public Class getDeviceDataClass() { + return null; + } + + @Override + public boolean equals(Object obj) { + return testData == ((TestSensorDevice) obj).testData; + } + +} diff --git a/plugins/hal-zigbee/build.gradle b/plugins/hal-zigbee/build.gradle index 34410b83..d7e83b41 100644 --- a/plugins/hal-zigbee/build.gradle +++ b/plugins/hal-zigbee/build.gradle @@ -1,5 +1,6 @@ dependencies { def ZIGBEE_LIB_VERSION = "1.3.10" + //def ZIGBEE_LIB_VERSION = "1.3.11-SNAPSHOT" implementation project(':hal-core') diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java index 7693722b..5c91c598 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java @@ -58,8 +58,8 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { private final FlowControl flowControl; private SerialPort serialPort; - private InputStream serialInputstream; - private OutputStream serialOutputstream; + private InputStream serialInputStream; + private OutputStream serialOutputStream; /** @@ -140,8 +140,8 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { throw new RuntimeException("Error opening serial port: " + portName); } - serialInputstream = serialPort.getInputStream(); - serialOutputstream = serialPort.getOutputStream(); + serialInputStream = serialPort.getInputStream(); + serialOutputStream = serialPort.getOutputStream(); switch (flowControl) { case FLOWCONTROL_OUT_NONE: @@ -170,8 +170,8 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { purgeRxBuffer(); serialPort.closePort(); - serialInputstream = null; - serialOutputstream = null; + serialInputStream = null; + serialOutputStream = null; serialPort = null; } catch (Exception e) { logger.warn("Error closing portName portName: '" + portName + "'", e); @@ -180,11 +180,11 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { @Override public void write(int value) { - if (serialOutputstream == null) + if (serialOutputStream == null) throw new RuntimeException("Unable to write, Serial port is not open."); try { - serialOutputstream.write(value); + serialOutputStream.write(value); } catch (IOException e) { logger.error("Was unable to write to serial port.", e); } @@ -197,14 +197,14 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { @Override public int read(int timeout) { - if (serialInputstream == null) + if (serialInputStream == null) throw new RuntimeException("Unable to read, Serial port is not open."); try { if (serialPort.getReadTimeout() != timeout) serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING, timeout, 0); - return serialInputstream.read(); + return serialInputStream.read(); } catch (IOException e) { logger.error("Was unable to read from serial port.", e); } @@ -213,11 +213,11 @@ public class ZigBeeJSerialCommPort implements ZigBeePort { @Override public void purgeRxBuffer() { - if (serialOutputstream == null) + if (serialOutputStream == null) return; try { - serialOutputstream.flush(); + serialOutputStream.flush(); } catch (IOException e) { logger.error("Was unable to flush serial data.", e); } diff --git a/run.sh b/run.sh old mode 100755 new mode 100644