You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/10/06 11:58:22 UTC
[plc4x] branch develop updated: - removed the toPlcValue method
from the Message interface (It was actually only used in one place of the
experimental BACnetIp driver)
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 dc60b42 - removed the toPlcValue method from the Message interface (It was actually only used in one place of the experimental BACnetIp driver)
dc60b42 is described below
commit dc60b42e1ca28e2dd27786d885caf452e88002dc
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Oct 6 13:58:15 2020 +0200
- removed the toPlcValue method from the Message interface (It was actually only used in one place of the experimental BACnetIp driver)
---
.../resources/templates/java/pojo-template.ftlh | 93 ----------------------
.../apache/plc4x/java/spi/generation/Message.java | 4 -
.../configuration/BacNetIpConfiguration.java | 5 +-
.../bacnetip/protocol/BacNetIpProtocolLogic.java | 17 +++-
4 files changed, 18 insertions(+), 101 deletions(-)
diff --git a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
index bf09737..e6d546d 100644
--- a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
@@ -290,99 +290,6 @@ public<#if helper.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${
return lengthInBits;
}
- public PlcValue toPlcValue() {
-<#if type.propertyFields?has_content>
- Map<String, PlcValue> fieldValues = new TreeMap<>();
-<#list type.propertyFields as field>
-<#switch field.typeName>
-<#case "array">
- <#assign arrayField = field>
-
- {
- List<PlcValue> plcValues = new ArrayList<>(${arrayField.name}.length);
- for(${helper.getLanguageTypeNameForField(field)} item : ${arrayField.name}) {
- <#if helper.isSimpleTypeReference(arrayField.type)>
- plcValues.add(PlcValues.of(item));
- <#else>
- plcValues.add(item.toPlcValue());
- </#if>
- }
- fieldValues.put("${arrayField.name}", new PlcList(plcValues));
- }
- <#break>
-<#case "manualArray">
- <#assign manualArrayField = field>
-
- {
- List<PlcValue> plcValues = new ArrayList<>(${manualArrayField.name}.length);
- for(${helper.getLanguageTypeNameForField(field)} item : ${manualArrayField.name}) {
- <#if helper.isSimpleTypeReference(manualArrayField.type)>
- plcValues.add(PlcValues.of(item));
- <#else>
- plcValues.add(item.toPlcValue());
- </#if>
- }
- fieldValues.put("${manualArrayField.name}", new PlcList(plcValues));
- }
-<#break>
-<#case "enum">
- <#assign enumField = field>
-
- fieldValues.put("${enumField.name}", new PlcString(${enumField.name}.name()));
-<#break>
-<#case "manual">
- <#assign manualField = field>
-
- <#if helper.isSimpleTypeReference(manualField.type)>
- fieldValues.put("${manualField.name}", PlcValues.of(${manualField.name}));
- <#else>
- fieldValues.put("${manualField.name}", ${manualField.name}.toPlcValue());
- </#if>
-<#break>
-<#case "simple">
- <#assign simpleField = field>
-
- <#if helper.isSimpleTypeReference(simpleField.type)>
- fieldValues.put("${simpleField.name}", PlcValues.of(${simpleField.name}));
- <#else>
- fieldValues.put("${simpleField.name}", ${simpleField.name}.toPlcValue());
- </#if>
-<#break>
-<#case "optional">
- <#assign optionalField = field>
-
- if(${optionalField.name} != null) {
- <#if helper.isSimpleTypeReference(optionalField.type)>
- fieldValues.put("${optionalField.name}", PlcValues.of(${optionalField.name}));
- <#else>
- fieldValues.put("${optionalField.name}", ${optionalField.name}.toPlcValue());
- </#if>
- } else {
- fieldValues.put("${optionalField.name}", null);
- }
-<#break>
-<#case "switch">
- <#assign switchField = field>
-
- PlcStruct superStruct = (PlcStruct) super.toPlcValue();
- fieldValues.putAll(superStruct.getStruct());
-<#break>
-<#case "virtual">
- <#assign virtualField = field>
- <#if helper.isSimpleTypeReference(virtualField.type)>
-
- fieldValues.put("${virtualField.name}", PlcValues.of(${virtualField.name}));
- </#if>
-<#break>
-</#switch>
-</#list>
-
- return new PlcStruct(fieldValues);
-<#else>
- return null;
-</#if>
- }
-
@Override
@JsonIgnore
public MessageIO<<#if type.parentType??>${type.parentType.name}<#else>${type.name}</#if>, <#if type.parentType??>${type.parentType.name}<#else>${type.name}</#if>> getMessageIO() {
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/Message.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/Message.java
index 7d9afef..5b394d3 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/Message.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/Message.java
@@ -19,16 +19,12 @@
package org.apache.plc4x.java.spi.generation;
-import org.apache.plc4x.java.api.value.PlcValue;
-
public interface Message {
int getLengthInBytes();
int getLengthInBits();
- PlcValue toPlcValue();
-
MessageIO<? extends Message, ? extends Message> getMessageIO();
}
diff --git a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java
index 0056bda..b277519 100644
--- a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java
+++ b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/configuration/BacNetIpConfiguration.java
@@ -103,8 +103,11 @@ public class BacNetIpConfiguration implements Configuration, UdpTransportConfigu
}
// This is a normal udp packet.
else {
- return packet.getPayload().getPayload().getPayload().getRawData();
+ if((packet.getPayload() != null) && (packet.getPayload().getPayload() != null) && (packet.getPayload().getPayload().getPayload() != null)) {
+ return packet.getPayload().getPayload().getPayload().getRawData();
+ }
}
+ return null;
};
}
diff --git a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
index 4e3992e..4041d1a 100644
--- a/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
+++ b/sandbox/test-java-bacnetip-driver/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
@@ -136,7 +136,6 @@ public class BacNetIpProtocolLogic extends Plc4xProtocolBase<BVLC> implements Ha
// These are value change notifications. Ignore the rest.
if(notification.getPropertyIdentifier()[0] == (short) 0x55) {
final BACnetTag baCnetTag = notification.getValue();
- final PlcValue plcValue = baCnetTag.toPlcValue();
// Initialize an enriched version of the PlcStruct.
final Map<String, PlcValue> enrichedPlcValue = new HashMap<>();
@@ -144,8 +143,20 @@ public class BacNetIpProtocolLogic extends Plc4xProtocolBase<BVLC> implements Ha
enrichedPlcValue.put("objectType", new PlcDINT(objectType));
enrichedPlcValue.put("objectInstance", new PlcUDINT(objectInstance));
enrichedPlcValue.put("address", new PlcString(toString(curField)));
- // Add all of the existing attributes.
- enrichedPlcValue.putAll(plcValue.getStruct());
+
+ // From the original BACNet tag
+ enrichedPlcValue.put("typeOrTagNumber", PlcValues.of(baCnetTag.getTypeOrTagNumber()));
+ enrichedPlcValue.put("lengthValueType", PlcValues.of(baCnetTag.getLengthValueType()));
+ if(baCnetTag.getExtTagNumber() != null) {
+ enrichedPlcValue.put("extTagNumber", PlcValues.of(baCnetTag.getExtTagNumber()));
+ } else {
+ enrichedPlcValue.put("extTagNumber", new PlcNull());
+ }
+ if(baCnetTag.getExtLength() != null) {
+ enrichedPlcValue.put("extLength", PlcValues.of(baCnetTag.getExtLength()));
+ } else {
+ enrichedPlcValue.put("extLength", new PlcNull());
+ }
// Use the information in the edeModel to enrich the information.
if(edeModel != null) {