This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push: new a60b246bd4 feat: Introduces a new type of configuration parameter "FILE". a60b246bd4 is described below commit a60b246bd43ed8b93ee942b68e718c40955397a6 Author: Christofer Dutz <christofer.d...@c-ware.de> AuthorDate: Sat Sep 13 11:09:55 2025 -0500 feat: Introduces a new type of configuration parameter "FILE". --- RELEASE_NOTES | 6 ++++++ .../apache/plc4x/java/api/types/OptionType.java | 1 + .../configuration/BacNetIpConfiguration.java | 22 ++++++++++++---------- .../bacnetip/protocol/BacNetIpProtocolLogic.java | 12 ++++++------ .../configuration/KnxNetIpConfiguration.java | 14 ++++++++------ .../knxnetip/context/KnxNetIpDriverContext.java | 11 ++++------- .../readwrite/configuration/S7Configuration.java | 2 +- .../spi/configuration/ConfigurationFactory.java | 4 ++++ .../java/spi/connection/GeneratedDriverBase.java | 3 +++ .../asciidoc/modules/users/partials/bacnet-ip.adoc | 4 ++-- .../asciidoc/modules/users/partials/knxnet-ip.adoc | 2 +- website/asciidoc/modules/users/partials/s7.adoc | 3 ++- 12 files changed, 50 insertions(+), 34 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index f5bbfd9a64..0bc18f4996 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -5,9 +5,15 @@ New Features ------------ +- Java Configurations of drivers now support a "FILE" type + of configuration parameter. + Incompatible changes -------------------- +- Dropped support for Java 11, new baseline Java version is + Java 21. + Bug Fixes --------- diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/OptionType.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/OptionType.java index 1adddafb8c..72fb613e16 100644 --- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/OptionType.java +++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/types/OptionType.java @@ -26,5 +26,6 @@ public enum OptionType { FLOAT, DOUBLE, STRING, + FILE, STRUCT } diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java index 57649458fa..71b79ec07e 100644 --- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java +++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java @@ -22,32 +22,34 @@ import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; import org.apache.plc4x.java.spi.configuration.annotations.Description; +import java.io.File; + public class BacNetIpConfiguration implements PlcConnectionConfiguration { // Path to a single EDE file. @ConfigurationParameter("ede-file-path") @Description("Path to the location of a single EDE file, that contains the descriptor for the target device.") - private String edeFilePath; + private File edeFile; // Path to a directory containing many EDE files. @ConfigurationParameter("ede-directory-path") @Description("Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices.") - private String edeDirectoryPath; + private File edeDirectory; - public String getEdeFilePath() { - return edeFilePath; + public File getEdeFile() { + return edeFile; } - public void setEdeFilePath(String edeFilePath) { - this.edeFilePath = edeFilePath; + public void setEdeFile(File edeFile) { + this.edeFile = edeFile; } - public String getEdeDirectoryPath() { - return edeDirectoryPath; + public File getEdeDirectory() { + return edeDirectory; } - public void setEdeDirectoryPath(String edeDirectoryPath) { - this.edeDirectoryPath = edeDirectoryPath; + public void setEdeDirectory(File edeDirectory) { + this.edeDirectory = edeDirectory; } } diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java index ecf8b79d40..8c58934b92 100644 --- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java +++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java @@ -68,20 +68,20 @@ public class BacNetIpProtocolLogic extends Plc4xProtocolBase<BVLC> implements Ha @Override public void setConfiguration(BacNetIpConfiguration configuration) { - if (configuration.getEdeFilePath() != null) { - File edeFile = new File(configuration.getEdeFilePath()); + if (configuration.getEdeFile() != null) { + File edeFile = configuration.getEdeFile(); if (!edeFile.exists() || !edeFile.isFile()) { throw new PlcRuntimeException(String.format( "File specified with 'ede-file-path' does not exist or is not a file: '%s'", - configuration.getEdeFilePath())); + configuration.getEdeFile())); } edeModel = new EdeParser().parseFile(edeFile); - } else if (configuration.getEdeDirectoryPath() != null) { - File edeDirectory = new File(configuration.getEdeDirectoryPath()); + } else if (configuration.getEdeDirectory() != null) { + File edeDirectory = configuration.getEdeDirectory(); if (!edeDirectory.exists() || !edeDirectory.isDirectory()) { throw new PlcRuntimeException(String.format( "File specified with 'ede-directory-path' does not exist or is not a directory: '%s'", - configuration.getEdeDirectoryPath())); + configuration.getEdeDirectory())); } edeModel = new EdeParser().parseDirectory(edeDirectory); } diff --git a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/configuration/KnxNetIpConfiguration.java b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/configuration/KnxNetIpConfiguration.java index 493f4b795e..f0fdf631fe 100644 --- a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/configuration/KnxNetIpConfiguration.java +++ b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/configuration/KnxNetIpConfiguration.java @@ -26,11 +26,13 @@ import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultVa import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; import org.apache.plc4x.java.spi.configuration.exceptions.ConfigurationException; +import java.io.File; + public class KnxNetIpConfiguration implements PlcConnectionConfiguration { @ConfigurationParameter("knxproj-file-path") @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.") - public String knxprojFilePath; + public File knxprojFile; @ConfigurationParameter("knxproj-password") @Description("Optional password needed to read the knxproj file.") @@ -56,12 +58,12 @@ public class KnxNetIpConfiguration implements PlcConnectionConfiguration { "- '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.") public String connectionType = "LINK_LAYER"; - public String getKnxprojFilePath() { - return knxprojFilePath; + public File getKnxprojFile() { + return knxprojFile; } - public void setKnxprojFilePath(String knxprojFilePath) { - this.knxprojFilePath = knxprojFilePath; + public void setKnxprojFile(File knxprojFile) { + this.knxprojFile = knxprojFile; } public String getKnxprojPassword() { @@ -98,7 +100,7 @@ public class KnxNetIpConfiguration implements PlcConnectionConfiguration { @Override public String toString() { return "Configuration{" + - "knxprojFilePath=" + knxprojFilePath + ", " + + "knxprojFile=" + knxprojFile + ", " + "groupAddressNumLevels=" + groupAddressNumLevels + '}'; } diff --git a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/context/KnxNetIpDriverContext.java b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/context/KnxNetIpDriverContext.java index 2e702b6647..66fc9ad18c 100644 --- a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/context/KnxNetIpDriverContext.java +++ b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/context/KnxNetIpDriverContext.java @@ -28,8 +28,6 @@ import org.apache.plc4x.java.knxnetip.readwrite.KnxLayer; import org.apache.plc4x.java.spi.configuration.HasConfiguration; import org.apache.plc4x.java.spi.context.DriverContext; -import java.io.File; - public class KnxNetIpDriverContext implements DriverContext, HasConfiguration<KnxNetIpConfiguration> { private boolean passiveMode = false; @@ -45,16 +43,15 @@ public class KnxNetIpDriverContext implements DriverContext, HasConfiguration<Kn @Override public void setConfiguration(KnxNetIpConfiguration configuration) { - if (configuration.knxprojFilePath != null) { - File knxprojFile = new File(configuration.knxprojFilePath); - if (knxprojFile.exists() && knxprojFile.isFile()) { + if (configuration.knxprojFile != null) { + if (configuration.knxprojFile.exists() && configuration.knxprojFile.isFile()) { final EtsParser parser = new EtsParser(); - etsModel = parser.parse(knxprojFile, configuration.knxprojPassword); + etsModel = parser.parse(configuration.knxprojFile, configuration.knxprojPassword); groupAddressType = etsModel.getGroupAddressType(); } else { throw new PlcRuntimeException(String.format( "File specified with 'knxproj-file-path' does not exist or is not a file: '%s'", - configuration.knxprojFilePath)); + configuration.knxprojFile)); } } else { groupAddressType = (byte) configuration.groupAddressNumLevels; diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/configuration/S7Configuration.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/configuration/S7Configuration.java index d9d120340a..0702723b12 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/configuration/S7Configuration.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/configuration/S7Configuration.java @@ -103,7 +103,7 @@ public class S7Configuration implements PlcConnectionConfiguration { public int maxAmqCallee = 8; @ConfigurationParameter("controller-type") - @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") + @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") public String controllerType; @ConfigurationParameter("read-timeout") diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java index 8b7ecd373e..cb9f6fd493 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java @@ -30,6 +30,7 @@ import org.apache.plc4x.java.spi.configuration.annotations.defaults.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; @@ -270,6 +271,9 @@ public class ConfigurationFactory { if ((field.getType() == double.class) || (field.getType() == Double.class)) { return Double.parseDouble(valueString); } + if (field.getType() == File.class) { + return new File(valueString); + } if (field.getType().isEnum()) { return parseEnumValue(field, valueString); } diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java index c8a85f2c22..959b73de16 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java @@ -189,6 +189,9 @@ public abstract class GeneratedDriverBase<BASE_PACKET extends Message> implement case "String": type = OptionType.STRING; break; + case "File": + type = OptionType.FILE; + break; default: // If there's a property-converter, use "STRING" as type. var parameterConverterAnnotation = field.getAnnotation(ParameterConverter.class); diff --git a/website/asciidoc/modules/users/partials/bacnet-ip.adoc b/website/asciidoc/modules/users/partials/bacnet-ip.adoc index f6f6c6bcb6..f495d950d7 100644 --- a/website/asciidoc/modules/users/partials/bacnet-ip.adoc +++ b/website/asciidoc/modules/users/partials/bacnet-ip.adoc @@ -38,8 +38,8 @@ - `tcp` - `pcap` 5+|Config options: -|`ede-file-path` |STRING | | |Path to the location of a single EDE file, that contains the descriptor for the target device. -|`ede-directory-path` |STRING | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices. +|`ede-file-path` |FILE | | |Path to the location of a single EDE file, that contains the descriptor for the target device. +|`ede-directory-path` |FILE | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices. 5+|Transport config options: 5+| +++ diff --git a/website/asciidoc/modules/users/partials/knxnet-ip.adoc b/website/asciidoc/modules/users/partials/knxnet-ip.adoc index 2e5c1435d2..f60e173e57 100644 --- a/website/asciidoc/modules/users/partials/knxnet-ip.adoc +++ b/website/asciidoc/modules/users/partials/knxnet-ip.adoc @@ -38,7 +38,7 @@ - `pcap` - `raw` 5+|Config options: -|`knxproj-file-path` |STRING | | |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. +|`knxproj-file-path` |FILE | | |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. |`knxproj-password` |STRING | | |Optional password needed to read the knxproj file. |`group-address-num-levels` |INT |3| |KNX Addresses can be encoded in multiple ways. Which encoding is used, is too not provided by the protocol itself so it has to be provided externally: + + diff --git a/website/asciidoc/modules/users/partials/s7.adoc b/website/asciidoc/modules/users/partials/s7.adoc index 2e730915b4..8dedd30eda 100644 --- a/website/asciidoc/modules/users/partials/s7.adoc +++ b/website/asciidoc/modules/users/partials/s7.adoc @@ -65,7 +65,8 @@ Allowed values: + |`pdu-size` |INT |1024| |Maximum size of a data-packet sent to and received from the remote PLC. During the connection process both parties will negotiate a maximum size both parties can work with and is equal or smaller than the given value is used. The driver will automatically split up large requests to not exceed this value in a request or expected response. |`max-amq-caller` |INT |8| |Maximum number of unconfirmed requests the PLC will accept in parallel before discarding with errors. This parameter also will be negotiated during the connection process and the maximum both parties can work with and is equal or smaller than the given value is used. The driver will automatically take care not exceeding this value while processing requests. Too many requests can cause a growing queue. |`max-amq-callee` |INT |8| |Maximum number of unconfirmed responses or requests PLC4X will accept in parallel before discarding with errors. This option is available for completeness and is correctly handled out during the connection process, however it is currently not enforced on PLC4X’s side. So if a PLC would send more messages than agreed upon, these would still be processed. -|`controller-type` |STRING | | |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 + +|`controller-type` |STRING | | |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 + +- S7_300 + - S7_400 + - S7_1200 + - S7-1500 +