Skip to content

Commit 6d071c3

Browse files
committed
updated to JPM, JDK ver 11
got this to work with OpenHAB
1 parent b797840 commit 6d071c3

File tree

90 files changed

+1043
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1043
-581
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ nb-configuration.xml
1515
nbactions.xml
1616
.idea
1717

18+
/de.ibapl.fhz4j.parser.cul/nbproject/

de.ibapl.fhz4j.console/src/main/java/de/ibapl/fhz4j/console/Main.java

+83-75
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@
4848
import org.apache.commons.cli.DefaultParser;
4949

5050
import de.ibapl.fhz4j.api.Adapter;
51-
import de.ibapl.fhz4j.api.FhzAdapter;
52-
import de.ibapl.fhz4j.api.FhzDataListener;
5351
import de.ibapl.fhz4j.api.Protocol;
5452
import de.ibapl.fhz4j.cul.CulAdapter;
55-
import de.ibapl.fhz4j.parser.cul.CulMessage;
53+
import de.ibapl.fhz4j.cul.CulMessage;
5654
import de.ibapl.fhz4j.protocol.em.EmMessage;
5755
import de.ibapl.fhz4j.protocol.evohome.EvoHomeMessage;
5856
import de.ibapl.fhz4j.protocol.fht.FhtMessage;
@@ -64,35 +62,38 @@
6462
import de.ibapl.spsw.logging.LoggingSerialPortSocket;
6563
import de.ibapl.spsw.logging.TimeStampLogging;
6664
import de.ibapl.spsw.ser2net.Ser2NetProvider;
65+
import de.ibapl.fhz4j.api.FhzHandler;
66+
import de.ibapl.fhz4j.cul.CulMessageListener;
6767

6868
/**
6969
* DOCUMENT ME!
7070
*
7171
* @author Arne Plöse
7272
*/
7373
public class Main {
74-
public final static String FHZ_CONSOLE = "fhz-console";
74+
75+
public final static String FHZ_CONSOLE = "fhz-console";
7576

7677
private static final Logger LOG = Logger.getLogger(FHZ_CONSOLE);
7778

78-
private class FhzListener implements FhzDataListener {
79-
80-
FhzAdapter fhzAdapter;
79+
private class FhzListener implements CulMessageListener {
80+
81+
FhzHandler fhzAdapter;
8182

8283
@Override
8384
public void fhtDataParsed(FhtMessage fhtMessage) {
8485
printTimeStamp();
8586
System.out.println(fhtMessage.toString());
8687
//Just testing
8788
if (true) {
88-
return;
89+
return;
8990
}
90-
91+
9192
if (DEVICES_HOME_CODE.add(fhtMessage.housecode)) {
9293
try {
9394
if (fhzAdapter != null) {
94-
fhzAdapter.writeFhtTimeAndDate(fhtMessage.housecode, LocalDateTime.now());
95-
fhzAdapter.initFhtReporting(fhtMessage.housecode);
95+
fhzAdapter.writeFhtTimeAndDate(fhtMessage.housecode, LocalDateTime.now());
96+
fhzAdapter.initFhtReporting(fhtMessage.housecode);
9697
}
9798
} catch (Throwable t) {
9899
//no-op
@@ -148,17 +149,23 @@ public void failed(Throwable t) {
148149
}
149150
}
150151

151-
@Override
152-
public void culMessageParsed(CulMessage culMessage) {
152+
@Override
153+
public void culMessageParsed(CulMessage culMessage) {
153154
printTimeStamp();
154155
System.err.println(": CUL " + culMessage);
155-
}
156+
}
156157

157-
@Override
158-
public void evoHomeParsed(EvoHomeMessage evoHomeMsg) {
158+
@Override
159+
public void evoHomeParsed(EvoHomeMessage evoHomeMsg) {
159160
printTimeStamp();
160161
System.out.println(evoHomeMsg.toString());
161-
}
162+
}
163+
164+
@Override
165+
public void signalStrength(float signalStrength) {
166+
printTimeStamp();
167+
System.out.append("Signal strength: ").println(signalStrength);
168+
}
162169

163170
}
164171

@@ -192,17 +199,17 @@ public static void main(String[] args) throws FileNotFoundException, IOException
192199
optg.addOption(opt);
193200

194201
options.addOptionGroup(optg);
195-
196-
opt = new Option(null, "enable-fhz", false, "enable receive of fhz messages");
202+
203+
opt = new Option(null, "enable-fht", false, "enable receive of fht messages");
197204
options.addOption(opt);
198205

199206
opt = new Option(null, "enable-evo-home", false, "enable receive of evo home messages");
200207
options.addOption(opt);
201208

202-
opt = new Option("s", "scan", false, "scan for serial ports");
203-
209+
opt = new Option("s", "scan", false, "scan for serial ports");
210+
204211
options.addOption(opt);
205-
212+
206213
opt = null;
207214
optg = null;
208215

@@ -217,25 +224,24 @@ public static void main(String[] args) throws FileNotFoundException, IOException
217224
return;
218225
}
219226

220-
if (cmd.hasOption("help") || args.length == 0) {
227+
if (cmd.hasOption("help") || args.length == 0) {
221228
printHelp(options);
222229

223230
return;
224231
}
225232
ServiceLoader<SerialPortSocketFactory> sl = ServiceLoader.load(SerialPortSocketFactory.class);
226233
Iterator<SerialPortSocketFactory> i = sl.iterator();
227234
if (!i.hasNext()) {
228-
throw new RuntimeException("No provider for SerialPortSocketFactory found, pleas add one to you class path ");
235+
throw new RuntimeException("No provider for SerialPortSocketFactory found, pleas add one to you class path ");
229236
}
230237
final SerialPortSocketFactory serialPortSocketFactory = i.next();
231238

232-
233239
if (cmd.hasOption("scan")) {
234240
System.out.println("Java Properties:");
235241
System.getProperties().forEach((Object key, Object value) -> {
236242
System.out.printf("\t\"%s\" = \"%s\"\n", key, value);
237243
});
238-
244+
239245
final List<String> ports = serialPortSocketFactory.getPortNames(false);
240246
System.out.println("Serial ports available");
241247
for (String port : ports) {
@@ -246,15 +252,15 @@ public static void main(String[] args) throws FileNotFoundException, IOException
246252
}
247253

248254
Set<Protocol> protocols = EnumSet.noneOf(Protocol.class);
249-
if (cmd.hasOption("enable-fhz")) {
250-
protocols.add(Protocol.FHZ);
255+
if (cmd.hasOption("enable-fht")) {
256+
protocols.add(Protocol.FHT);
251257
}
252-
258+
253259
if (cmd.hasOption("enable-evo-home")) {
254-
protocols.add(Protocol.EVO_HOME);
260+
protocols.add(Protocol.EVO_HOME);
255261
}
256-
257-
final File logFile= File.createTempFile("cul_", ".txt", Paths.get(".").toFile());
262+
263+
final File logFile = File.createTempFile("cul_", ".txt", Paths.get(".").toFile());
258264

259265
if (cmd.hasOption("ser2net")) {
260266
new Main().runSer2Net(cmd.getOptionValue("ser2net"), protocols, logFile);
@@ -263,19 +269,19 @@ public static void main(String[] args) throws FileNotFoundException, IOException
263269
if (cmd.hasOption("port")) {
264270
new Main().runLocalPort(cmd.getOptionValue("port"), protocols, logFile);
265271
}
266-
272+
267273
}
268274

269275
private final Set<Short> DEVICES_HOME_CODE = new HashSet<>();
270276

271277
public void runSer2Net(String ser2net, Set<Protocol> protocols, File logFile) {
272278
try {
273279
LOG.info("LOG File: " + logFile.getAbsolutePath());
274-
String[] split = ser2net.split(":");
280+
String[] split = ser2net.split(":");
275281
SerialPortSocket serialPort = LoggingSerialPortSocket.wrapWithAsciiOutputStream(new Ser2NetProvider(split[0], Integer.valueOf(split[1])), new FileOutputStream(logFile), false, TimeStampLogging.NONE);
276282
run(serialPort, protocols);
277283
} catch (Exception ex) {
278-
throw new RuntimeException(ex);
284+
throw new RuntimeException(ex);
279285
}
280286
}
281287

@@ -284,71 +290,73 @@ public void runLocalPort(String port, Set<Protocol> protocols, File logFile) {
284290
ServiceLoader<SerialPortSocketFactory> sl = ServiceLoader.load(SerialPortSocketFactory.class);
285291
Iterator<SerialPortSocketFactory> i = sl.iterator();
286292
if (!i.hasNext()) {
287-
throw new RuntimeException("No provider for SerialPortSocketFactory found, pleas add one to you class path ");
293+
throw new RuntimeException("No provider for SerialPortSocketFactory found, pleas add one to you class path ");
288294
}
289295
final SerialPortSocketFactory serialPortSocketFactory = i.next();
290296

291297
LOG.info("LOG File: " + logFile.getAbsolutePath());
292298
SerialPortSocket serialPort = LoggingSerialPortSocket.wrapWithAsciiOutputStream(serialPortSocketFactory.createSerialPortSocket(port), new FileOutputStream(logFile), false, TimeStampLogging.UTC);
293299
run(serialPort, protocols);
294300
} catch (Exception ex) {
295-
throw new RuntimeException(ex);
301+
throw new RuntimeException(ex);
296302
}
297303
}
298-
304+
299305
public void run(SerialPortSocket serialPortSocket, Set<Protocol> protocols) throws Exception {
300306
final FhzListener listener = new FhzListener();
301-
try (CulAdapter culAddapter = (CulAdapter)FhzAdapter.open(serialPortSocket, listener)) {
307+
try ( CulAdapter culAddapter = new CulAdapter(serialPortSocket, listener)) {
308+
culAddapter.open();
302309
listener.fhzAdapter = culAddapter;
303-
try {
304310
try {
305-
Thread.sleep(100);
306-
} catch (InterruptedException ex) {
307-
LOG.log(Level.SEVERE, null, ex);
308-
}
309-
if (protocols.contains(Protocol.FHZ)) {
310-
culAddapter.initFhz((short) 0001);
311-
culAddapter.initFhtReporting((short)302);
311+
try {
312+
Thread.sleep(100);
313+
} catch (InterruptedException ex) {
314+
LOG.log(Level.SEVERE, null, ex);
315+
}
316+
if (protocols.contains(Protocol.FHT)) {
317+
culAddapter.initFhz((short) 0001);
318+
culAddapter.initFhtReporting((short) 302);
312319
// fhzAddapter.writeFhtTimeAndDate((short) 302, LocalDateTime.now());
313320
// fhzAddapter.writeFhtCycle((short) 302, DayOfWeek.MONDAY, LocalTime.of(5, 0), LocalTime.of(8, 30), null, null);
314321
// fhzAddapter.writeFht((short)302, FhtProperty.DESIRED_TEMP, 24.0f);
315322
// fhzAddapter.writeFhtModeManu((short)302);
316323
// fhzAddapter.writeFhtModeHoliday((short) 302, 16.0f, LocalDate.now().plusMonths(2).plusDays(4));
324+
}
325+
if (protocols.contains(Protocol.EVO_HOME)) {
326+
culAddapter.initEvoHome();
327+
}
328+
329+
} catch (IOException ex) {
330+
LOG.log(Level.SEVERE, ex.getMessage(), ex);
331+
throw new RuntimeException("Can't init fhzAdapter" + ex);
317332
}
318-
if (protocols.contains(Protocol.EVO_HOME)) {
319-
culAddapter.initEvoHome();
320-
}
333+
try {
334+
char c;
335+
do {
336+
c = (char) System.in.read();
337+
338+
switch (c) {
339+
case 'q':
340+
System.out.print("Bye will close down!");
341+
break;
342+
case 'r':
343+
culAddapter.initFhtReporting(DEVICES_HOME_CODE);
344+
break;
345+
default:
346+
}
347+
} while (c != 'q');
321348

322-
} catch (IOException ex) {
323-
LOG.log(Level.SEVERE, ex.getMessage(), ex);
324-
throw new RuntimeException("Can't init fhzAdapter" + ex);
325-
}
326-
try {
327-
char c;
328-
do {
329-
c = (char) System.in.read();
330-
331-
switch (c) {
332-
case 'q':
333-
System.out.print("Bye will close down!");
334-
break;
335-
case 'r':
336-
culAddapter.initFhtReporting(DEVICES_HOME_CODE);
337-
break;
338-
default:
339-
}
340-
} while (c != 'q');
349+
} catch (IOException ex) {
350+
LOG.log(Level.SEVERE, null, ex);
351+
}
352+
System.out.println("CLOSE");
341353

342-
} catch (IOException ex) {
343-
LOG.log(Level.SEVERE, null, ex);
344354
}
345-
System.out.println("CLOSE");
346-
347-
}
348355
}
356+
349357
private static void printHelp(Options opts) {
350358
HelpFormatter formatter = new HelpFormatter();
351359
formatter.setWidth(300);
352-
formatter.printHelp("openv4j-memory-image", opts);
360+
formatter.printHelp("java -jar fhz4j-console-{VERSION}-jar-with-dependencies.jar ", opts);
353361
}
354362
}

de.ibapl.fhz4j.parser.cul/bnd.bnd

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Export-Package: \
22
de.ibapl.fhz4j.api,\
3+
de.ibapl.fhz4j.cul,\
34
de.ibapl.fhz4j.parser.api,\
4-
de.ibapl.fhz4j.parser.cul,\
5-
de.ibapl.fhz4j.writer.cul,\
65
de.ibapl.fhz4j.protocol.em,\
6+
de.ibapl.fhz4j.protocol.evohome,\
77
de.ibapl.fhz4j.protocol.fht,\
88
de.ibapl.fhz4j.protocol.fs20,\
99
de.ibapl.fhz4j.protocol.hms,\

de.ibapl.fhz4j.parser.cul/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
<groupId>de.ibapl.spsw</groupId>
2222
<artifactId>de.ibapl.spsw.api</artifactId>
2323
</dependency>
24-
<dependency>
25-
<groupId>org.osgi</groupId>
26-
<artifactId>org.osgi.dto</artifactId>
27-
</dependency>
2824
<dependency>
2925
<groupId>org.junit.jupiter</groupId>
3026
<artifactId>junit-jupiter-api</artifactId>

de.ibapl.fhz4j.parser.cul/src/main/java/de/ibapl/fhz4j/api/EvoHomeAdapter.java de.ibapl.fhz4j.parser.cul/src/main/java/de/ibapl/fhz4j/api/EvoHomeHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import java.io.IOException;
2525

26-
public interface EvoHomeAdapter extends Adapter {
26+
public interface EvoHomeHandler extends Adapter {
2727

2828
void initEvoHome() throws IOException;
2929

0 commit comments

Comments
 (0)