Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/de/csdev/ebus/command/IEBusValue.java
#	src/main/java/de/csdev/ebus/command/datatypes/std/EBusTypeBit.java
  • Loading branch information
csowada committed Mar 25, 2023
2 parents 5e89f3a + d97aeb5 commit d59f7f1
Show file tree
Hide file tree
Showing 137 changed files with 684 additions and 469 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -65,4 +65,4 @@ jobs:
run: mvn -B clean package

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>eBUS core library - This library handles the communication with heating engineering via the BUS specification. This protocol is used by many heating manufacturers in Europe.</description>
<groupId>de.cs-dev.ebus</groupId>
<artifactId>ebus-core</artifactId>
<version>1.1.9</version>
<version>1.1.10</version>
<url>https://github.com/csowada/ebus</url>
<packaging>bundle</packaging>

Expand All @@ -17,7 +17,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
<license.year>2021</license.year>
<license.year>2023</license.year>
<bundle.version>${project.version}</bundle.version>
<sonar.projectKey>csowada_ebus</sonar.projectKey>
<sonar.organization>csowada</sonar.organization>
Expand Down Expand Up @@ -63,7 +63,7 @@
<plugin>
<groupId>com.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-plugin</artifactId>
<version>1.15.0</version>
<version>1.19.0</version>
<configuration>
<gitFlowConfig>
<productionBranch>master</productionBranch>
Expand Down Expand Up @@ -102,7 +102,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<version>3.5.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
Expand Down Expand Up @@ -336,7 +336,7 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.7.0</version>
<version>2.9.3</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -8,10 +8,13 @@
*/
package de.csdev.ebus.cfg;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* @author Christian Sowada - Initial contribution
*
*/
@NonNullByDefault
public class EBusConfigurationReaderException extends Exception {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/de/csdev/ebus/cfg/std/EBusConfigurationReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -358,7 +358,7 @@ protected EBusCommand parseTelegramConfiguration(@NonNull IEBusCommandCollection
* @return
*/
protected @NonNull List<@NonNull EBusValueDTO> checkedList(List<EBusValueDTO> master) {
List<EBusValueDTO> templates = new ArrayList<>();
List<@NonNull EBusValueDTO> templates = new ArrayList<>();
if (master != null) {
for (EBusValueDTO template : master) {
if (template != null) {
Expand Down Expand Up @@ -570,12 +570,16 @@ protected EBusCommand parseTelegramConfiguration(@NonNull IEBusCommandCollection
}

private void overwritePropertiesFromTemplate(@NonNull EBusCommandValue clone, @NonNull EBusValueDTO template) {

String templateLabel = template.getLabel();
String cloneLabel = clone.getLabel();

// allow placeholders in template-block mode
if (StringUtils.isNotEmpty(template.getLabel())) {
if (StringUtils.isNotEmpty(clone.getLabel()) && clone.getLabel().contains("%s")) {
clone.setLabel(String.format(clone.getLabel(), template.getLabel()));
if (StringUtils.isNotEmpty(templateLabel)) {
if (StringUtils.isNotEmpty(cloneLabel) && cloneLabel.contains("%s")) {
clone.setLabel(String.format(cloneLabel, templateLabel));
} else {
clone.setLabel(template.getLabel());
clone.setLabel(templateLabel);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/csdev/ebus/cfg/std/dto/EBusValueDTO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
50 changes: 31 additions & 19 deletions src/main/java/de/csdev/ebus/client/EBusClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -91,8 +91,10 @@ public void addEBusDeviceTableListener(final @NonNull IEBusDeviceTableListener l
*/
public void addEBusEventListener(final @NonNull IEBusConnectorEventListener listener) {
Objects.requireNonNull(listener, LABEL_LISTENER);
if (controller != null) {
controller.addEBusEventListener(listener);
IEBusController ctrl = this.controller;

if (ctrl != null) {
ctrl.addEBusEventListener(listener);
} else {
throw new IllegalStateException("Controller is not initialized!");
}
Expand Down Expand Up @@ -120,12 +122,13 @@ public void addEBusParserListener(final @NonNull IEBusParserListener listener) {
public @NonNull Integer addToSendQueue(final byte @NonNull [] buffer) throws EBusControllerException {

Objects.requireNonNull(buffer, "buffer");
IEBusController ctrl = this.controller;

if (controller == null) {
if (ctrl == null) {
throw new EBusControllerException("Controller not set!");
}

return controller.addToSendQueue(buffer);
return ctrl.addToSendQueue(buffer);
}

/**
Expand All @@ -139,11 +142,13 @@ public void addEBusParserListener(final @NonNull IEBusParserListener listener) {
*/
public @NonNull Integer addToSendQueue(final byte @NonNull [] buffer, final int maxAttemps) throws EBusControllerException {

if (this.controller == null) {
IEBusController ctrl = this.controller;

if (ctrl == null) {
throw new EBusControllerException("Controller not set!");
}

return this.controller.addToSendQueue(buffer, maxAttemps);
return ctrl.addToSendQueue(buffer, maxAttemps);
}

/**
Expand Down Expand Up @@ -179,31 +184,35 @@ public void connect(final @NonNull IEBusController controller, final byte master
controller.addEBusEventListener(resolverService);

deviceTable.setOwnAddress(masterAddress);
deviceTableService = new EBusDeviceTableService(controller, commandRegistry, deviceTable);


// add device table service
resolverService.addEBusParserListener(deviceTableService);
deviceTable.addEBusDeviceTableListener(deviceTableService);
EBusDeviceTableService lDeviceTableService = new EBusDeviceTableService(controller, commandRegistry, deviceTable);
resolverService.addEBusParserListener(lDeviceTableService);
deviceTable.addEBusDeviceTableListener(lDeviceTableService);

// add metrics service
controller.addEBusEventListener(metricsService);
resolverService.addEBusParserListener(metricsService);

this.controller = controller;
this.deviceTableService = lDeviceTableService;
}

/**
* Disposes the eBUS client with all depended services
*/
public void dispose() {
if (controller != null) {
controller.interrupt();
controller = null;

IEBusController ctrl = this.controller;
if (ctrl != null) {
ctrl.interrupt();
this.controller = null;
}

if (deviceTableService != null) {
deviceTableService.dispose();
deviceTableService = null;
EBusDeviceTableService lDeviceTableService = this.deviceTableService;
if (lDeviceTableService != null) {
lDeviceTableService.dispose();
this.deviceTableService = null;
}

if (deviceTable != null) {
Expand Down Expand Up @@ -307,9 +316,12 @@ public boolean removeEBusDeviceTableListener(final @NonNull IEBusDeviceTableList
public boolean removeEBusEventListener(final @NonNull IEBusConnectorEventListener listener) {
Objects.requireNonNull(listener);

if (controller != null) {
return controller.removeEBusEventListener(listener);
IEBusController ctrl = this.controller;

if (ctrl != null) {
return ctrl.removeEBusEventListener(listener);
}

return false;
}

Expand Down
19 changes: 10 additions & 9 deletions src/main/java/de/csdev/ebus/command/EBusCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-2021 by the respective copyright holders.
* Copyright (c) 2017-2023 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -28,7 +28,7 @@
@NonNullByDefault
public class EBusCommand implements IEBusCommand {

private Map<IEBusCommandMethod.@NonNull Method, @NonNull IEBusCommandMethod> channels = new EnumMap<>(IEBusCommandMethod.Method.class);
private Map<IEBusCommandMethod.Method, IEBusCommandMethod> channels = new EnumMap<>(IEBusCommandMethod.Method.class);

private @Nullable String configurationSource;

Expand All @@ -48,18 +48,18 @@ public void addCommandChannel(IEBusCommandMethod channel) {
}

@Override
public @NonNull Collection<IEBusCommandMethod.@NonNull Method> getCommandChannelMethods() {
public Collection<IEBusCommandMethod.Method> getCommandChannelMethods() {
return Objects.requireNonNull(Collections.unmodifiableCollection(channels.keySet()));
}

@Override
public @Nullable IEBusCommandMethod getCommandMethod(IEBusCommandMethod.@NonNull Method channel) {
public @Nullable IEBusCommandMethod getCommandMethod(IEBusCommandMethod.Method channel) {
Objects.requireNonNull(channel);
return CollectionUtils.get(channels, channel);
}

@Override
public @NonNull Collection<@NonNull IEBusCommandMethod> getCommandMethods() {
public @NonNull Collection<IEBusCommandMethod> getCommandMethods() {
return Objects.requireNonNull(Collections.unmodifiableCollection(channels.values()));
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public void addCommandChannel(IEBusCommandMethod channel) {
* @see de.csdev.ebus.command.IEBusCommand#getId()
*/
@Override
public @NonNull String getId() {
public String getId() {
return Objects.requireNonNull(id);
}

Expand All @@ -109,7 +109,7 @@ public IEBusCommandCollection getParentCollection() {
}

@Override
public Map<@NonNull String, @NonNull Object> getProperties() {
public Map<String, Object> getProperties() {
return Objects.requireNonNull(CollectionUtils.unmodifiableNotNullMap(properties));
}

Expand Down Expand Up @@ -138,8 +138,9 @@ public void setParentCollection(IEBusCommandCollection parentCollection) {

public void setProperties(Map<String, Object> properties) {
Objects.requireNonNull(properties, "properties");
this.properties = new HashMap<>();
this.properties.putAll(properties);
HashMap<String, Object> props = new HashMap<>();
props.putAll(properties);
this.properties = props;
}

public void setProperty(String key, String value) {
Expand Down
Loading

0 comments on commit d59f7f1

Please sign in to comment.