This project offers an API and a reader abstraction for the HWg-STE device. It uses the XML available over the built-in web server to gather the requested data.
The artifacts are published on GitHub Packages. Therefore, the following repository needs to be added to Maven:
<repository>
<id>github</id>
<name>GitHub fhnw-hwgste-reader Apache Maven Packages</name>
<url>https://maven.pkg.github.com/fhnw-imvs/fhnw-hwgste-reader</url>
</repository>
More information can be found in the documentation for Maven and GitHub Packages.
<dependency>
<groupId>ch.fhnw.imvs</groupId>
<artifactId>hwgste-api</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>ch.fhnw.imvs</groupId>
<artifactId>hwgste-reader</artifactId>
<version>1.1.0</version>
</dependency>
// create node list
List<HwgSteNode> nodes = new ArrayList<>();
HwgSteNode node1 = new HwgSteNode("node-1", "127.0.0.1");
nodes.add(node1);
HwgSteNode node2 = new HwgSteNode("node-2", "127.0.0.2");
nodes.add(node2);
// create a fetcher
HwgSteFetcher fetcher = new HwgSteFetcher();
// get the data from the nodes
List<HwgSteReading> readings = fetcher.fetch(nodes);
HwgSteReader reader = new HwgSteReader();
reader.attachNode(new HwgSteNode("node-1", "127.0.0.1"));
reader.attachNode(new HwgSteNode("node-2", "127.0.0.2"));
List<HwgSteReading> readings = reader.read();
Use the functional interface or a method reference:
HwgSteMeasurementCallback callback = readings -> doSomething(readings);
HwgStePeriodicReader reader = new HwgStePeriodicReader(callback, 2);
reader.attachNode(new HwgSteNode("node-1", "127.0.0.1"));
reader.attachNode(new HwgSteNode("node-2", "127.0.0.2"));
reader.start();
Implement the interface and pass an instance of the implementation:
HwgStePeriodicReader reader = new HwgStePeriodicReader(new Callback(), 2);
reader.attachNode(new HwgSteNode("node-1", "127.0.0.1"));
reader.attachNode(new HwgSteNode("node-2", "127.0.0.2"));
reader.start();
// ...
class Callback implements HwgSteMeasurementCallback {
@Override
public void handle(final List<HwgSteReading> readingList) {
// do something
}
}
The project has been tested with the following sensors:
This project is licensed under the Apache 2.0 license, see LICENSE.