Skip to content

Commit a60b246

Browse files
committed
feat: Introduces a new type of configuration parameter "FILE".
1 parent 5c6b690 commit a60b246

12 files changed

Lines changed: 50 additions & 34 deletions

File tree

RELEASE_NOTES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
New Features
66
------------
77

8+
- Java Configurations of drivers now support a "FILE" type
9+
of configuration parameter.
10+
811
Incompatible changes
912
--------------------
1013

14+
- Dropped support for Java 11, new baseline Java version is
15+
Java 21.
16+
1117
Bug Fixes
1218
---------
1319

plc4j/api/src/main/java/org/apache/plc4x/java/api/types/OptionType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ public enum OptionType {
2626
FLOAT,
2727
DOUBLE,
2828
STRING,
29+
FILE,
2930
STRUCT
3031
}

plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,34 @@
2222
import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter;
2323
import org.apache.plc4x.java.spi.configuration.annotations.Description;
2424

25+
import java.io.File;
26+
2527
public class BacNetIpConfiguration implements PlcConnectionConfiguration {
2628

2729
// Path to a single EDE file.
2830
@ConfigurationParameter("ede-file-path")
2931
@Description("Path to the location of a single EDE file, that contains the descriptor for the target device.")
30-
private String edeFilePath;
32+
private File edeFile;
3133

3234
// Path to a directory containing many EDE files.
3335
@ConfigurationParameter("ede-directory-path")
3436
@Description("Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices.")
35-
private String edeDirectoryPath;
37+
private File edeDirectory;
3638

37-
public String getEdeFilePath() {
38-
return edeFilePath;
39+
public File getEdeFile() {
40+
return edeFile;
3941
}
4042

41-
public void setEdeFilePath(String edeFilePath) {
42-
this.edeFilePath = edeFilePath;
43+
public void setEdeFile(File edeFile) {
44+
this.edeFile = edeFile;
4345
}
4446

45-
public String getEdeDirectoryPath() {
46-
return edeDirectoryPath;
47+
public File getEdeDirectory() {
48+
return edeDirectory;
4749
}
4850

49-
public void setEdeDirectoryPath(String edeDirectoryPath) {
50-
this.edeDirectoryPath = edeDirectoryPath;
51+
public void setEdeDirectory(File edeDirectory) {
52+
this.edeDirectory = edeDirectory;
5153
}
5254

5355
}

plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ public class BacNetIpProtocolLogic extends Plc4xProtocolBase<BVLC> implements Ha
6868

6969
@Override
7070
public void setConfiguration(BacNetIpConfiguration configuration) {
71-
if (configuration.getEdeFilePath() != null) {
72-
File edeFile = new File(configuration.getEdeFilePath());
71+
if (configuration.getEdeFile() != null) {
72+
File edeFile = configuration.getEdeFile();
7373
if (!edeFile.exists() || !edeFile.isFile()) {
7474
throw new PlcRuntimeException(String.format(
7575
"File specified with 'ede-file-path' does not exist or is not a file: '%s'",
76-
configuration.getEdeFilePath()));
76+
configuration.getEdeFile()));
7777
}
7878
edeModel = new EdeParser().parseFile(edeFile);
79-
} else if (configuration.getEdeDirectoryPath() != null) {
80-
File edeDirectory = new File(configuration.getEdeDirectoryPath());
79+
} else if (configuration.getEdeDirectory() != null) {
80+
File edeDirectory = configuration.getEdeDirectory();
8181
if (!edeDirectory.exists() || !edeDirectory.isDirectory()) {
8282
throw new PlcRuntimeException(String.format(
8383
"File specified with 'ede-directory-path' does not exist or is not a directory: '%s'",
84-
configuration.getEdeDirectoryPath()));
84+
configuration.getEdeDirectory()));
8585
}
8686
edeModel = new EdeParser().parseDirectory(edeDirectory);
8787
}

plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/configuration/KnxNetIpConfiguration.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue;
2727
import org.apache.plc4x.java.spi.configuration.exceptions.ConfigurationException;
2828

29+
import java.io.File;
30+
2931
public class KnxNetIpConfiguration implements PlcConnectionConfiguration {
3032

3133
@ConfigurationParameter("knxproj-file-path")
3234
@Description("Path to the `knxproj` file. The default KNXnet/IP protocol doesn't provide all the information needed to be able to fully decode the messages.")
33-
public String knxprojFilePath;
35+
public File knxprojFile;
3436

3537
@ConfigurationParameter("knxproj-password")
3638
@Description("Optional password needed to read the knxproj file.")
@@ -56,12 +58,12 @@ public class KnxNetIpConfiguration implements PlcConnectionConfiguration {
5658
"- 'BUSMONITOR': The client operates as a busmonitor where he can't actively participate on the bus. Only one 'BUSMONITOR' connection is allowed at the same time on a KNXnet/IP gateway.")
5759
public String connectionType = "LINK_LAYER";
5860

59-
public String getKnxprojFilePath() {
60-
return knxprojFilePath;
61+
public File getKnxprojFile() {
62+
return knxprojFile;
6163
}
6264

63-
public void setKnxprojFilePath(String knxprojFilePath) {
64-
this.knxprojFilePath = knxprojFilePath;
65+
public void setKnxprojFile(File knxprojFile) {
66+
this.knxprojFile = knxprojFile;
6567
}
6668

6769
public String getKnxprojPassword() {
@@ -98,7 +100,7 @@ public void setConnectionType(String connectionType) {
98100
@Override
99101
public String toString() {
100102
return "Configuration{" +
101-
"knxprojFilePath=" + knxprojFilePath + ", " +
103+
"knxprojFile=" + knxprojFile + ", " +
102104
"groupAddressNumLevels=" + groupAddressNumLevels +
103105
'}';
104106
}

plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/context/KnxNetIpDriverContext.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
2929
import org.apache.plc4x.java.spi.context.DriverContext;
3030

31-
import java.io.File;
32-
3331
public class KnxNetIpDriverContext implements DriverContext, HasConfiguration<KnxNetIpConfiguration> {
3432

3533
private boolean passiveMode = false;
@@ -45,16 +43,15 @@ public class KnxNetIpDriverContext implements DriverContext, HasConfiguration<Kn
4543

4644
@Override
4745
public void setConfiguration(KnxNetIpConfiguration configuration) {
48-
if (configuration.knxprojFilePath != null) {
49-
File knxprojFile = new File(configuration.knxprojFilePath);
50-
if (knxprojFile.exists() && knxprojFile.isFile()) {
46+
if (configuration.knxprojFile != null) {
47+
if (configuration.knxprojFile.exists() && configuration.knxprojFile.isFile()) {
5148
final EtsParser parser = new EtsParser();
52-
etsModel = parser.parse(knxprojFile, configuration.knxprojPassword);
49+
etsModel = parser.parse(configuration.knxprojFile, configuration.knxprojPassword);
5350
groupAddressType = etsModel.getGroupAddressType();
5451
} else {
5552
throw new PlcRuntimeException(String.format(
5653
"File specified with 'knxproj-file-path' does not exist or is not a file: '%s'",
57-
configuration.knxprojFilePath));
54+
configuration.knxprojFile));
5855
}
5956
} else {
6057
groupAddressType = (byte) configuration.groupAddressNumLevels;

plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/configuration/S7Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class S7Configuration implements PlcConnectionConfiguration {
103103
public int maxAmqCallee = 8;
104104

105105
@ConfigurationParameter("controller-type")
106-
@Description("As part of the connection process, usually the PLC4X S7 driver would try to identify the remote device. However some devices seem to have problems with this and hang up or cause other problems. In such a case, providing the controller-type will skip the identification process and hereby avoid this type of problem. Possible values are:/n- S7_300\n- S7_400\n- S7_1200\n- S7-1500\n- LOGO")
106+
@Description("As part of the connection process, usually the PLC4X S7 driver would try to identify the remote device. However some devices seem to have problems with this and hang up or cause other problems. In such a case, providing the controller-type will skip the identification process and hereby avoid this type of problem. Possible values are:/n- S7_200\n- S7_300\n- S7_400\n- S7_1200\n- S7-1500\n- LOGO")
107107
public String controllerType;
108108

109109
@ConfigurationParameter("read-timeout")

plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
3232

33+
import java.io.File;
3334
import java.lang.reflect.Field;
3435
import java.lang.reflect.InvocationTargetException;
3536
import java.lang.reflect.ParameterizedType;
@@ -270,6 +271,9 @@ private static Object toFieldValue(Field field, String valueString) {
270271
if ((field.getType() == double.class) || (field.getType() == Double.class)) {
271272
return Double.parseDouble(valueString);
272273
}
274+
if (field.getType() == File.class) {
275+
return new File(valueString);
276+
}
273277
if (field.getType().isEnum()) {
274278
return parseEnumValue(field, valueString);
275279
}

plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ private List<DefaultOption> optionsForField(Field field) {
189189
case "String":
190190
type = OptionType.STRING;
191191
break;
192+
case "File":
193+
type = OptionType.FILE;
194+
break;
192195
default:
193196
// If there's a property-converter, use "STRING" as type.
194197
var parameterConverterAnnotation = field.getAnnotation(ParameterConverter.class);

website/asciidoc/modules/users/partials/bacnet-ip.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
- `tcp`
3939
- `pcap`
4040
5+|Config options:
41-
|`ede-file-path` |STRING | | |Path to the location of a single EDE file, that contains the descriptor for the target device.
42-
|`ede-directory-path` |STRING | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices.
41+
|`ede-file-path` |FILE | | |Path to the location of a single EDE file, that contains the descriptor for the target device.
42+
|`ede-directory-path` |FILE | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices.
4343
5+|Transport config options:
4444
5+|
4545
+++

0 commit comments

Comments
 (0)