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 2019/12/10 14:34:22 UTC
[plc4x] branch feature/knxnet-ip updated: - Added new Integer and
Float type references - Added a new float/ufloat type with a
exponent.mantissa notation for size - Implemented parsing and serializing
of floating point values in mspec - Renamed the "value" variable in the
generated code to "_value" to make it possible to name fields "value"
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/knxnet-ip
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/knxnet-ip by this push:
new ec42435 - Added new Integer and Float type references - Added a new float/ufloat type with a exponent.mantissa notation for size - Implemented parsing and serializing of floating point values in mspec - Renamed the "value" variable in the generated code to "_value" to make it possible to name fields "value"
ec42435 is described below
commit ec42435feba86abf1f434ff66c140de65ad811c7
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Dec 10 15:34:10 2019 +0100
- Added new Integer and Float type references
- Added a new float/ufloat type with a exponent.mantissa notation for size
- Implemented parsing and serializing of floating point values in mspec
- Renamed the "value" variable in the generated code to "_value" to make it possible to name fields "value"
---
.../language/java/JavaLanguageTemplateHelper.java | 185 ++++++++++++---------
.../main/resources/templates/java/io-template.ftlh | 71 ++++----
.../resources/templates/java/pojo-template.ftlh | 20 +--
.../plugins/codegenerator/language/mspec/MSpec.g4 | 3 +-
...ference.java => DefaultFloatTypeReference.java} | 23 +--
...rence.java => DefaultIntegerTypeReference.java} | 8 +-
.../references/DefaultSimpleTypeReference.java | 12 +-
.../DefaultSimpleVarLengthTypeReference.java | 2 +-
.../mspec/parser/MessageFormatListener.java | 27 +--
pom.xml | 2 +-
.../resources/protocols/bacnetip/bacnetip.mspec | 162 +++++++++---------
.../main/resources/protocols/knxnetip/ets5.mspec | 53 +++---
.../adapters/source/bacnetip/BacNetIpAdapter.java | 30 ++--
13 files changed, 316 insertions(+), 282 deletions(-)
diff --git a/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java b/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
index 23101f6..d61a28a 100644
--- a/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
+++ b/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
@@ -24,9 +24,7 @@ import org.apache.commons.text.WordUtils;
import org.apache.plc4x.plugins.codegenerator.protocol.freemarker.FreemarkerLanguageTemplateHelper;
import org.apache.plc4x.plugins.codegenerator.types.definitions.*;
import org.apache.plc4x.plugins.codegenerator.types.fields.*;
-import org.apache.plc4x.plugins.codegenerator.types.references.ComplexTypeReference;
-import org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
-import org.apache.plc4x.plugins.codegenerator.types.references.TypeReference;
+import org.apache.plc4x.plugins.codegenerator.types.references.*;
import org.apache.plc4x.plugins.codegenerator.types.terms.*;
import java.util.Collection;
@@ -77,40 +75,46 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
return allowPrimitive ? "boolean" : "Boolean";
}
case UINT: {
- if (simpleTypeReference.getSize() <= 4) {
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 4) {
return allowPrimitive ? "byte" : "Byte";
}
- if (simpleTypeReference.getSize() <= 8) {
+ if (integerTypeReference.getSizeInBits() <= 8) {
return allowPrimitive ? "short" : "Short";
}
- if (simpleTypeReference.getSize() <= 16) {
+ if (integerTypeReference.getSizeInBits() <= 16) {
return allowPrimitive ? "int" : "Integer";
}
- if (simpleTypeReference.getSize() <= 32) {
+ if (integerTypeReference.getSizeInBits() <= 32) {
return allowPrimitive ? "long" : "Long";
}
return "BigInteger";
}
case INT: {
- if (simpleTypeReference.getSize() <= 8) {
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 8) {
return allowPrimitive ? "byte" : "Byte";
}
- if (simpleTypeReference.getSize() <= 16) {
+ if (integerTypeReference.getSizeInBits() <= 16) {
return allowPrimitive ? "short" : "Short";
}
- if (simpleTypeReference.getSize() <= 32) {
+ if (integerTypeReference.getSizeInBits() <= 32) {
return allowPrimitive ? "int" : "Integer";
}
- if (simpleTypeReference.getSize() <= 64) {
+ if (integerTypeReference.getSizeInBits() <= 64) {
return allowPrimitive ? "long" : "Long";
}
return "BigInteger";
}
- case FLOAT: {
- if (simpleTypeReference.getSize() <= 32) {
+ case FLOAT:
+ case UFLOAT: {
+ FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
+ int sizeInBits = ((floatTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.FLOAT) ? 1 : 0) +
+ floatTypeReference.getExponent() + floatTypeReference.getMantissa();
+ if (sizeInBits <= 32) {
return allowPrimitive ? "float" : "Float";
}
- if (simpleTypeReference.getSize() <= 64) {
+ if (sizeInBits <= 64) {
return allowPrimitive ? "double" : "Double";
}
return "BigDecimal";
@@ -133,28 +137,33 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
return "false";
}
case UINT: {
- if (simpleTypeReference.getSize() <= 16) {
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 16) {
return "0";
}
- if (simpleTypeReference.getSize() <= 32) {
+ if (integerTypeReference.getSizeInBits() <= 32) {
return "0l";
}
return "null";
}
case INT: {
- if (simpleTypeReference.getSize() <= 32) {
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 32) {
return "0";
}
- if (simpleTypeReference.getSize() <= 64) {
+ if (integerTypeReference.getSizeInBits() <= 64) {
return "0l";
}
return "null";
}
case FLOAT: {
- if (simpleTypeReference.getSize() <= 32) {
+ FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
+ int sizeInBits = ((floatTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.FLOAT) ? 1 : 0) +
+ floatTypeReference.getExponent() + floatTypeReference.getMantissa();
+ if (sizeInBits <= 32) {
return "0.0f";
}
- if (simpleTypeReference.getSize() <= 64) {
+ if (sizeInBits <= 64) {
return "0.0";
}
return "null";
@@ -187,49 +196,61 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
public String getReadBufferReadMethodCall(SimpleTypeReference simpleTypeReference) {
switch (simpleTypeReference.getBaseType()) {
case BIT: {
- return "readBit()";
+ return "io.readBit()";
}
case UINT: {
- if (simpleTypeReference.getSize() <= 4) {
- return "readUnsignedByte(" + simpleTypeReference.getSize() + ")";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 4) {
+ return "io.readUnsignedByte(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 8) {
- return "readUnsignedShort(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 8) {
+ return "io.readUnsignedShort(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 16) {
- return "readUnsignedInt(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 16) {
+ return "io.readUnsignedInt(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 32) {
- return "readUnsignedLong(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 32) {
+ return "io.readUnsignedLong(" + integerTypeReference.getSizeInBits() + ")";
}
- return "readUnsignedBigInteger" + simpleTypeReference.getSize() + ")";
+ return "io.readUnsignedBigInteger" + integerTypeReference.getSizeInBits() + ")";
}
case INT: {
- if (simpleTypeReference.getSize() <= 8) {
- return "readByte(" + simpleTypeReference.getSize() + ")";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 8) {
+ return "io.readByte(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 16) {
- return "readShort(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 16) {
+ return "io.readShort(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 32) {
- return "readInt(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 32) {
+ return "io.readInt(" + integerTypeReference.getSizeInBits() + ")";
}
- if (simpleTypeReference.getSize() <= 64) {
- return "readLong(" + simpleTypeReference.getSize() + ")";
+ if (integerTypeReference.getSizeInBits() <= 64) {
+ return "io.readLong(" + integerTypeReference.getSizeInBits() + ")";
}
- return "readBigInteger(" + simpleTypeReference.getSize() + ")";
+ return "io.readBigInteger(" + integerTypeReference.getSizeInBits() + ")";
}
case FLOAT: {
- if (simpleTypeReference.getSize() <= 32) {
- return "readFloat(" + simpleTypeReference.getSize() + ")";
- }
- if (simpleTypeReference.getSize() <= 64) {
- return "readDouble(" + simpleTypeReference.getSize() + ")";
- }
- return "readBigDecimal(" + simpleTypeReference.getSize() + ")";
+ FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
+ StringBuilder sb = new StringBuilder("((Supplier<Float>) (() -> {");
+ sb.append("\n try {");
+ if (floatTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.FLOAT) {
+ sb.append("\n boolean negative = io.readBit();");
+ } else {
+ sb.append("\n boolean negative = false;");
+ }
+ sb.append("\n long exponent = io.readUnsignedLong(").append(floatTypeReference.getExponent()).append(");");
+ sb.append("\n long mantissa = io.readUnsignedLong(").append(floatTypeReference.getMantissa()).append(");");
+ sb.append("\n return (float) ((negative ? -1 : 1) * (0.01 * mantissa) * (2 ^ exponent));");
+ sb.append("\n } catch(ParseException e) {");
+ sb.append("\n return 0.0f;");
+ sb.append("\n }");
+ sb.append("\n })).get()");
+ return sb.toString();
}
case STRING: {
- return "readString(" + simpleTypeReference.getSize() + ")";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ return "io.readString(" + integerTypeReference.getSizeInBits() + ")";
}
}
return "Hurz";
@@ -238,49 +259,57 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
public String getWriteBufferReadMethodCall(SimpleTypeReference simpleTypeReference, String fieldName) {
switch (simpleTypeReference.getBaseType()) {
case BIT: {
- return "writeBit((boolean) " + fieldName + ")";
+ return "io.writeBit((boolean) " + fieldName + ")";
}
case UINT: {
- if (simpleTypeReference.getSize() <= 4) {
- return "writeUnsignedByte(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").byteValue())";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 4) {
+ return "io.writeUnsignedByte(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").byteValue())";
}
- if (simpleTypeReference.getSize() <= 8) {
- return "writeUnsignedShort(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").shortValue())";
+ if (integerTypeReference.getSizeInBits() <= 8) {
+ return "io.writeUnsignedShort(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").shortValue())";
}
- if (simpleTypeReference.getSize() <= 16) {
- return "writeUnsignedInt(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").intValue())";
+ if (integerTypeReference.getSizeInBits() <= 16) {
+ return "io.writeUnsignedInt(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").intValue())";
}
- if (simpleTypeReference.getSize() <= 32) {
- return "writeUnsignedLong(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").longValue())";
+ if (integerTypeReference.getSizeInBits() <= 32) {
+ return "io.writeUnsignedLong(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").longValue())";
}
- return "writeUnsignedBigInteger" + simpleTypeReference.getSize() + ", (BigInteger) " + fieldName + ")";
+ return "io.writeUnsignedBigInteger" + integerTypeReference.getSizeInBits() + ", (BigInteger) " + fieldName + ")";
}
case INT: {
- if (simpleTypeReference.getSize() <= 8) {
- return "writeByte(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").byteValue())";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ if (integerTypeReference.getSizeInBits() <= 8) {
+ return "io.writeByte(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").byteValue())";
}
- if (simpleTypeReference.getSize() <= 16) {
- return "writeShort(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").shortValue())";
+ if (integerTypeReference.getSizeInBits() <= 16) {
+ return "io.writeShort(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").shortValue())";
}
- if (simpleTypeReference.getSize() <= 32) {
- return "writeInt(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").intValue())";
+ if (integerTypeReference.getSizeInBits() <= 32) {
+ return "io.writeInt(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").intValue())";
}
- if (simpleTypeReference.getSize() <= 64) {
- return "writeLong(" + simpleTypeReference.getSize() + ", ((Number) " + fieldName + ").longValue())";
+ if (integerTypeReference.getSizeInBits() <= 64) {
+ return "io.writeLong(" + integerTypeReference.getSizeInBits() + ", ((Number) " + fieldName + ").longValue())";
}
- return "writeBigInteger(" + simpleTypeReference.getSize() + ", (BigInteger) " + fieldName + ")";
+ return "io.writeBigInteger(" + integerTypeReference.getSizeInBits() + ", (BigInteger) " + fieldName + ")";
}
- case FLOAT: {
- if (simpleTypeReference.getSize() <= 32) {
- return "writeFloat(" + simpleTypeReference.getSize() + ", (float) " + fieldName + ")";
- }
- if (simpleTypeReference.getSize() <= 64) {
- return "writeDouble(" + simpleTypeReference.getSize() + ", (double) " + fieldName + ")";
- }
- return "writeBigDecimal(" + simpleTypeReference.getSize() + ", (BigDecimal) " + fieldName + ")";
+ case FLOAT:
+ case UFLOAT: {
+ FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
+ StringBuilder sb = new StringBuilder();
+ if(simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.FLOAT) {
+ sb.append("\n boolean negative = value < 0;");
+ sb.append("\n io.writeBit(negative);");
+ }
+ sb.append("\n final int exponent = Math.getExponent(value);");
+ sb.append("\n final double mantissa = value / Math.pow(2, exponent);");
+ sb.append("\n io.writeInt(").append(floatTypeReference.getExponent()).append(", exponent);");
+ sb.append("\n io.writeDouble(").append(floatTypeReference.getMantissa()).append(", mantissa)");
+ return sb.toString().substring(9);
}
case STRING: {
- return "writeString(" + simpleTypeReference.getSize() + ", (String) " + fieldName + ")";
+ IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
+ return "io.writeString(" + integerTypeReference.getSizeInBits() + ", (String) " + fieldName + ")";
}
}
return "Hurz";
@@ -539,8 +568,8 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
}
if(arg instanceof VariableLiteral) {
VariableLiteral va = (VariableLiteral) arg;
- // "io" and "value" are always available in every parser.
- boolean isSerializerArg = "io".equals(va.getName()) || "value".equals(va.getName()) || "element".equals(va.getName());
+ // "io" and "_value" are always available in every parser.
+ boolean isSerializerArg = "io".equals(va.getName()) || "_value".equals(va.getName()) || "element".equals(va.getName());
if(parserArguments != null) {
for (Argument parserArgument : parserArguments) {
if (parserArgument.getName().equals(va.getName())) {
@@ -609,7 +638,7 @@ public class JavaLanguageTemplateHelper implements FreemarkerLanguageTemplateHel
if(isSerializerArg) {
return vl.getName() + ((vl.getChild() != null) ? "." + toVariableExpressionRest(vl.getChild()) : "");
} else {
- return "value." + toVariableExpressionRest(vl);
+ return "_value." + toVariableExpressionRest(vl);
}
}
diff --git a/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
index bd05d15..e6e891a 100644
--- a/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
@@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
+import java.util.function.Supplier;
public class ${typeName}IO {
@@ -71,7 +72,7 @@ public class ${typeName}IO {
int _${field.name}Count = ${helper.toDeserializationExpression(field.loopExpression, type.parserArguments)?no_esc};
${helper.getLanguageTypeNameForField(field)}[] ${field.name} = new ${helper.getLanguageTypeNameForField(field)}[_${field.name}Count];
for(int i = 0; i < _${field.name}Count; i++) {
- ${field.name}[i] = <#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>;
+ ${field.name}[i] = <#if helper.isSimpleType(field.type)>${helper.getReadBufferReadMethodCall(field.type)?no_esc}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>;
}
<#-- In all other cases do we have to work with a list, that is later converted to an array -->
<#else>
@@ -82,7 +83,7 @@ public class ${typeName}IO {
List<${helper.getNonPrimitiveLanguageTypeNameForField(field)}> _${field.name}List = new LinkedList<>();
int ${field.name}EndPos = io.getPos() + _${field.name}Length;
while(io.getPos() < ${field.name}EndPos) {
- _${field.name}List.add(<#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>);
+ _${field.name}List.add(<#if helper.isSimpleType(field.type)>${helper.getReadBufferReadMethodCall(field.type)?no_esc}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>);
<#-- After parsing, update the current position, but only if it's needed -->
<#if field.loopExpression.contains("curPos")>
curPos = io.getPos() - startPos;
@@ -93,7 +94,7 @@ public class ${typeName}IO {
// Terminated array
List<${helper.getNonPrimitiveLanguageTypeNameForField(field)}> _${field.name}List = new LinkedList<>();
while(!((boolean) (${helper.toDeserializationExpression(field.loopExpression, type.parserArguments)?no_esc}))) {
- _${field.name}List.add(<#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>);
+ _${field.name}List.add(<#if helper.isSimpleType(field.type)>${helper.getReadBufferReadMethodCall(field.type)?no_esc}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)?no_esc})<#sep>, </#sep></#list></#if>)</#if>);
<#-- After parsing, update the current position, but only if it's needed -->
<#if field.loopExpression.contains("curPos")>
@@ -119,7 +120,7 @@ public class ${typeName}IO {
<#case "checksum">
// Checksum Field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
${helper.getLanguageTypeNameForField(field)} _${field.name}Ref = (${helper.getLanguageTypeNameForField(field)}) (${helper.toDeserializationExpression(field.checksumExpression, type.parserArguments)});
if(${field.name} != _${field.name}Ref) {
throw new ParseException(String.format("Checksum verification failed. Expected %04X but got %04X",_${field.name}Ref & 0xFFFF, ${field.name} & 0xFFFF));
@@ -128,7 +129,7 @@ public class ${typeName}IO {
<#case "const">
// Const Field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
if(${field.name} != ${typeName}.${field.name?upper_case}) {
throw new ParseException("Expected constant value " + ${typeName}.${field.name?upper_case} + " but got " + ${field.name});
}
@@ -136,17 +137,17 @@ public class ${typeName}IO {
<#case "enum">
// Enum field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getLanguageTypeNameForField(field)}.valueOf(io.${helper.getReadBufferReadMethodCall(helper.getEnumBaseType(field.type))});
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getLanguageTypeNameForField(field)}.valueOf(${helper.getReadBufferReadMethodCall(helper.getEnumBaseType(field.type))?no_esc});
<#break>
<#case "discriminator">
// Discriminator Field (${field.name}) (Used as input to a switch field)
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
<#break>
<#case "implicit">
// Implicit Field (${field.name}) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
<#break>
<#case "manualArray">
@@ -219,7 +220,7 @@ public class ${typeName}IO {
</#if>
${helper.getLanguageTypeNameForField(field)} ${field.name} = null;
if(${helper.toDeserializationExpression(field.conditionExpression, type.parserArguments)?no_esc}) {
- ${field.name} = <#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
+ ${field.name} = <#if helper.isSimpleType(field.type)>${helper.getReadBufferReadMethodCall(field.type)?no_esc}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
}
<#break>
<#case "padding">
@@ -228,14 +229,14 @@ public class ${typeName}IO {
boolean _${field.name}NeedsPadding = (boolean) (${helper.toDeserializationExpression(field.paddingCondition, type.parserArguments)});
if(_${field.name}NeedsPadding) {
// Just read the padding data and ignore it
- io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
}
<#break>
<#case "reserved">
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
- ${helper.getLanguageTypeNameForField(field)} reserved = io.${helper.getReadBufferReadMethodCall(field.type)};
+ ${helper.getLanguageTypeNameForField(field)} reserved = ${helper.getReadBufferReadMethodCall(field.type)?no_esc};
if(reserved != ${field.referenceValue}) {
LOGGER.info("Expected constant value " + ${field.referenceValue} + " but got " + reserved + " for reserved field.");
}
@@ -244,7 +245,7 @@ public class ${typeName}IO {
<#case "simple">
// Simple Field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = <#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = <#if helper.isSimpleType(field.type)>${helper.getReadBufferReadMethodCall(field.type)?no_esc}<#else>${field.type.name}IO.parse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getArgumentType(field.type, parserArgument?index)}) (${helper.toDeserializationExpression(parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>;
<#break>
<#case "switch">
@@ -273,16 +274,16 @@ public class ${typeName}IO {
}
<#if outputFlavor != "passive">
- public static void serialize(WriteBuffer io, ${typeName} value) throws ParseException {
+ public static void serialize(WriteBuffer io, ${typeName} _value) throws ParseException {
<#list type.fields as field>
<#switch field.typeName>
<#case "array">
// Array Field (${field.name})
- if(value.get${field.name?cap_first}() != null) {
- for(${helper.getLanguageTypeNameForField(field)} element : value.get${field.name?cap_first}()) {
+ if(_value.get${field.name?cap_first}() != null) {
+ for(${helper.getLanguageTypeNameForField(field)} element : _value.get${field.name?cap_first}()) {
<#if helper.isSimpleType(field.type)>
- io.${helper.getWriteBufferReadMethodCall(field.type, "element")};
+ ${helper.getWriteBufferReadMethodCall(field.type, "element")?no_esc};
<#else>
${field.type.name}IO.serialize(io, element);
</#if>
@@ -293,36 +294,36 @@ public class ${typeName}IO {
// Checksum Field (${field.name}) (Calculated)
${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(field.checksumExpression, type.parserArguments)});
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#break>
<#case "const">
// Const Field (${field.name})
- io.${helper.getWriteBufferReadMethodCall(field.type, field.referenceValue)};
+ ${helper.getWriteBufferReadMethodCall(field.type, field.referenceValue)?no_esc};
<#break>
<#case "discriminator">
// Discriminator Field (${field.name}) (Used as input to a switch field)
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) value.getDiscriminatorValues()[0];
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) _value.getDiscriminatorValues()[0];
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#break>
<#case "enum">
// Enum field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) value.get${field.name?cap_first}();
- io.${helper.getWriteBufferReadMethodCall(helper.getEnumBaseType(field.type), "(" + field.name + ".getValue())")};
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) _value.get${field.name?cap_first}();
+ ${helper.getWriteBufferReadMethodCall(helper.getEnumBaseType(field.type), "(" + field.name + ".getValue())")?no_esc};
<#break>
<#case "implicit">
// Implicit Field (${field.name}) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(field.serializationExpression, type.parserArguments)});
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#break>
<#case "manualArray">
// Manual Array Field (${field.name})
- if(value.get${field.name?cap_first}() != null) {
- for(${helper.getLanguageTypeNameForField(field)} element : value.get${field.name?cap_first}()) {
+ if(_value.get${field.name?cap_first}() != null) {
+ for(${helper.getLanguageTypeNameForField(field)} element : _value.get${field.name?cap_first}()) {
${helper.toSerializationExpression(field.serializationExpression, type.parserArguments)};
}
}
@@ -331,16 +332,16 @@ public class ${typeName}IO {
// Manual Field (${field.name})
${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(field.serializationExpression, type.parserArguments)});
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#break>
<#case "optional">
// Optional Field (${field.name}) (Can be skipped, if the value is null)
${helper.getLanguageTypeNameForField(field)} ${field.name} = null;
- if(value.get${field.name?cap_first}() != null) {
- ${field.name} = (${helper.getLanguageTypeNameForField(field)}) value.get${field.name?cap_first}();
+ if(_value.get${field.name?cap_first}() != null) {
+ ${field.name} = (${helper.getLanguageTypeNameForField(field)}) _value.get${field.name?cap_first}();
<#if helper.isSimpleType(field.type)>
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#else>
${field.type.name}IO.serialize(io, ${field.name});
</#if>
@@ -352,20 +353,20 @@ public class ${typeName}IO {
boolean _${field.name}NeedsPadding = (boolean) (${helper.toSerializationExpression(field.paddingCondition, type.parserArguments)});
if(_${field.name}NeedsPadding) {
${helper.getLanguageTypeNameForField(field)} _${field.name}PaddingValue = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(field.paddingValue, type.parserArguments)});
- io.${helper.getWriteBufferReadMethodCall(field.type, "(_" + field.name + "PaddingValue)")?no_esc};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(_" + field.name + "PaddingValue)")?no_esc};
}
<#break>
<#case "reserved">
// Reserved Field
- io.${helper.getWriteBufferReadMethodCall(field.type, field.referenceValue)};
+ ${helper.getWriteBufferReadMethodCall(field.type, field.referenceValue)?no_esc};
<#break>
<#case "simple">
// Simple Field (${field.name})
- ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) value.get${field.name?cap_first}();
+ ${helper.getLanguageTypeNameForField(field)} ${field.name} = (${helper.getLanguageTypeNameForField(field)}) _value.get${field.name?cap_first}();
<#if helper.isSimpleType(field.type)>
- io.${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")};
+ ${helper.getWriteBufferReadMethodCall(field.type, "(" + field.name + ")")?no_esc};
<#else>
${field.type.name}IO.serialize(io, ${field.name});
</#if>
@@ -374,8 +375,8 @@ public class ${typeName}IO {
// Switch field (Depending on the discriminator values, passes the instantiation to a sub-type)
<#list field.cases as case>
- if(value instanceof ${case.name}) {
- ${case.name}IO.serialize(io, (${case.name}) value);
+ if(_value instanceof ${case.name}) {
+ ${case.name}IO.serialize(io, (${case.name}) _value);
}<#sep> else </#sep>
</#list>
<#break>
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 3582e8e..9e746be 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
@@ -120,7 +120,7 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
// Array field
<#if helper.isSimpleType(field.type)>
- lengthInBits += ${field.type.size} * ${field.name}.length;
+ lengthInBits += ${field.type.sizeInBits} * ${field.name}.length;
<#else>
if(${field.name} != null) {
for(Message element : ${field.name}) {
@@ -132,27 +132,27 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
<#case "checksum">
// Checksum Field (${field.name})
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#break>
<#case "const">
// Const Field (${field.name})
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#break>
<#case "discriminator">
// Discriminator Field (${field.name})
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#break>
<#case "enum">
// Enum Field (${field.name})
- lengthInBits += ${helper.getEnumBaseType(field.type).size};
+ lengthInBits += ${helper.getEnumBaseType(field.type).sizeInBits};
<#break>
<#case "implicit">
// Implicit Field (${field.name})
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#break>
<#case "manualArray">
@@ -169,7 +169,7 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
// Optional Field (${field.name})
if(${field.name} != null) {
<#if helper.isSimpleType(field.type)>
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#else>
lengthInBits += ${field.name}.getLengthInBytes() * 8;
</#if>
@@ -179,19 +179,19 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
// Padding Field (${field.name})
if((boolean) (${helper.toDeserializationExpression(field.paddingCondition, type.parserArguments)})) {
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
}
<#break>
<#case "reserved">
// Reserved Field
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#break>
<#case "simple">
// Simple field (${field.name})
<#if helper.isSimpleType(field.type)>
- lengthInBits += ${field.type.size};
+ lengthInBits += ${field.type.sizeInBits};
<#else>
lengthInBits += ${field.name}.getLengthInBytes() * 8;
</#if>
diff --git a/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
index 0ec45e9..1603242 100644
--- a/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
+++ b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
@@ -129,7 +129,8 @@ dataType
: base='bit'
| base='int' size=INTEGER_LITERAL
| base='uint' size=INTEGER_LITERAL
- | base='float' size=INTEGER_LITERAL
+ | base='float' exponent=INTEGER_LITERAL '.' mantissa=INTEGER_LITERAL
+ | base='ufloat' exponent=INTEGER_LITERAL '.' mantissa=INTEGER_LITERAL
| base='string'
;
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultFloatTypeReference.java
similarity index 59%
copy from build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
copy to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultFloatTypeReference.java
index a1f3aea..07d2db4 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultFloatTypeReference.java
@@ -19,26 +19,27 @@
package org.apache.plc4x.plugins.codegenerator.language.mspec.model.references;
-import org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
+import org.apache.plc4x.plugins.codegenerator.types.references.FloatTypeReference;
-public class DefaultSimpleTypeReference implements SimpleTypeReference {
+public class DefaultFloatTypeReference extends DefaultSimpleTypeReference implements FloatTypeReference {
- private final SimpleBaseType baseType;
- private final int size;
+ private final int exponent;
+ private final int mantissa;
- public DefaultSimpleTypeReference(SimpleBaseType baseType, int size) {
- this.baseType = baseType;
- this.size = size;
+ public DefaultFloatTypeReference(SimpleBaseType baseType, int exponent, int mantissa) {
+ super(baseType, (baseType == SimpleBaseType.FLOAT ? 1 : 0) + exponent + mantissa);
+ this.exponent = exponent;
+ this.mantissa = mantissa;
}
@Override
- public SimpleBaseType getBaseType() {
- return baseType;
+ public int getExponent() {
+ return exponent;
}
@Override
- public int getSize() {
- return size;
+ public int getMantissa() {
+ return mantissa;
}
}
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultIntegerTypeReference.java
similarity index 73%
copy from build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
copy to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultIntegerTypeReference.java
index dd3f8e4..793cc0e 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultIntegerTypeReference.java
@@ -19,12 +19,12 @@
package org.apache.plc4x.plugins.codegenerator.language.mspec.model.references;
-import org.apache.plc4x.plugins.codegenerator.types.references.SimpleVarLengthTypeReference;
+import org.apache.plc4x.plugins.codegenerator.types.references.IntegerTypeReference;
-public class DefaultSimpleVarLengthTypeReference extends DefaultSimpleTypeReference implements SimpleVarLengthTypeReference {
+public class DefaultIntegerTypeReference extends DefaultSimpleTypeReference implements IntegerTypeReference {
- public DefaultSimpleVarLengthTypeReference(SimpleBaseType baseType) {
- super(baseType, -1);
+ public DefaultIntegerTypeReference(SimpleBaseType baseType, int sizeInBits) {
+ super(baseType, sizeInBits);
}
}
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
index a1f3aea..87e5290 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
@@ -21,14 +21,14 @@ package org.apache.plc4x.plugins.codegenerator.language.mspec.model.references;
import org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
-public class DefaultSimpleTypeReference implements SimpleTypeReference {
+public abstract class DefaultSimpleTypeReference implements SimpleTypeReference {
private final SimpleBaseType baseType;
- private final int size;
+ private final int sizeInBits;
- public DefaultSimpleTypeReference(SimpleBaseType baseType, int size) {
+ public DefaultSimpleTypeReference(SimpleBaseType baseType, int sizeInBits) {
this.baseType = baseType;
- this.size = size;
+ this.sizeInBits = sizeInBits;
}
@Override
@@ -37,8 +37,8 @@ public class DefaultSimpleTypeReference implements SimpleTypeReference {
}
@Override
- public int getSize() {
- return size;
+ public int getSizeInBits() {
+ return sizeInBits;
}
}
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
index dd3f8e4..f4febf5 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
@@ -21,7 +21,7 @@ package org.apache.plc4x.plugins.codegenerator.language.mspec.model.references;
import org.apache.plc4x.plugins.codegenerator.types.references.SimpleVarLengthTypeReference;
-public class DefaultSimpleVarLengthTypeReference extends DefaultSimpleTypeReference implements SimpleVarLengthTypeReference {
+public class DefaultSimpleVarLengthTypeReference extends DefaultIntegerTypeReference implements SimpleVarLengthTypeReference {
public DefaultSimpleVarLengthTypeReference(SimpleBaseType baseType) {
super(baseType, -1);
diff --git a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
index 74ff1cf..03270ea 100644
--- a/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
+++ b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
@@ -29,6 +29,8 @@ import org.apache.plc4x.plugins.codegenerator.language.mspec.model.definitions.D
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.definitions.DefaultEnumValue;
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.fields.*;
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.DefaultComplexTypeReference;
+import org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.DefaultFloatTypeReference;
+import org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.DefaultIntegerTypeReference;
import org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.DefaultSimpleTypeReference;
import org.apache.plc4x.plugins.codegenerator.types.definitions.Argument;
import org.apache.plc4x.plugins.codegenerator.types.definitions.DiscriminatedComplexTypeDefinition;
@@ -39,6 +41,7 @@ import org.apache.plc4x.plugins.codegenerator.types.fields.Field;
import org.apache.plc4x.plugins.codegenerator.types.fields.ManualArrayField;
import org.apache.plc4x.plugins.codegenerator.types.fields.SwitchField;
import org.apache.plc4x.plugins.codegenerator.types.references.ComplexTypeReference;
+import org.apache.plc4x.plugins.codegenerator.types.references.FloatTypeReference;
import org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
import org.apache.plc4x.plugins.codegenerator.types.references.TypeReference;
import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
@@ -383,14 +386,7 @@ public class MessageFormatListener extends MSpecBaseListener {
private TypeReference getTypeReference(MSpecParser.TypeReferenceContext ctx) {
if(ctx.simpleTypeReference != null) {
- SimpleTypeReference.SimpleBaseType simpleBaseType = SimpleTypeReference.SimpleBaseType.valueOf(
- ctx.simpleTypeReference.base.getText().toUpperCase());
- if(ctx.simpleTypeReference.size != null) {
- int size = Integer.parseInt(ctx.simpleTypeReference.size.getText());
- return new DefaultSimpleTypeReference(simpleBaseType, size);
- } else {
- return new DefaultSimpleTypeReference(simpleBaseType, 1);
- }
+ return getSimpleTypeReference(ctx.simpleTypeReference);
} else {
return new DefaultComplexTypeReference(ctx.complexTypeReference.getText());
}
@@ -399,11 +395,20 @@ public class MessageFormatListener extends MSpecBaseListener {
private SimpleTypeReference getSimpleTypeReference(MSpecParser.DataTypeContext ctx) {
SimpleTypeReference.SimpleBaseType simpleBaseType =
SimpleTypeReference.SimpleBaseType.valueOf(ctx.base.getText().toUpperCase());
+ // If a size it specified its a simple integer length based type.
if(ctx.size != null) {
int size = Integer.parseInt(ctx.size.getText());
- return new DefaultSimpleTypeReference(simpleBaseType, size);
- } else {
- return new DefaultSimpleTypeReference(simpleBaseType, 1);
+ return new DefaultIntegerTypeReference(simpleBaseType, size);
+ }
+ // If exponent and mantissa are present, it's a floating point representation.
+ else if((ctx.exponent != null) && (ctx.mantissa != null)) {
+ int exponent = Integer.parseInt(ctx.exponent.getText());
+ int mantissa = Integer.parseInt(ctx.mantissa.getText());
+ return new DefaultFloatTypeReference(simpleBaseType, exponent, mantissa);
+ }
+ // In all other cases (bit) it's just assume it's length it 1.
+ else {
+ return new DefaultIntegerTypeReference(simpleBaseType, 1);
}
}
diff --git a/pom.xml b/pom.xml
index a3e4e5e..57c35ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,7 +103,7 @@
<!-- Exclude all generated code -->
<sonar.exclusions>**/generated-sources</sonar.exclusions>
- <plc4x-code-generation.version>1.0.0</plc4x-code-generation.version>
+ <plc4x-code-generation.version>1.1.0-SNAPSHOT</plc4x-code-generation.version>
<antlr.version>4.7.2</antlr.version>
<asm.version>5.0.4</asm.version>
diff --git a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
index f94e776..cc45a2c 100644
--- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
+++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
@@ -18,8 +18,8 @@
//
[discriminatedType 'BVLC'
- [const uint 8 'bacnetType' '0x81']
- [discriminator uint 8 'bvlcFunction']
+ [const uint 8 'bacnetType' '0x81' ]
+ [discriminator uint 8 'bvlcFunction' ]
[implicit uint 16 'bvlcLength' 'lengthInBytes']
[typeSwitch 'bvlcFunction'
['0x00' BVLCResult
@@ -31,8 +31,8 @@
['0x03' BVLCReadBroadcastDistributionTableAck
]
['0x04' BVLCForwardedNPDU [uint 16 'bvlcLength']
- [array uint 8 'ip' count '4']
- [simple uint 16 'port']
+ [array uint 8 'ip' count '4' ]
+ [simple uint 16 'port' ]
[simple NPDU 'npdu' ['bvlcLength - 10']]
]
['0x05' BVLCRegisterForeignDevice
@@ -72,7 +72,7 @@
[optional uint 8 'sourceLength' 'sourceSpecified']
[array uint 8 'sourceAddress' count 'sourceSpecified ? sourceLength : 0']
[optional uint 8 'hopCount' 'destinationSpecified']
- [optional NLM 'nlm' 'messageTypeFieldPresent' ['npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))']]
+ [optional NLM 'nlm' 'messageTypeFieldPresent' ['npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))']]
[optional APDU 'apdu' '!messageTypeFieldPresent' ['npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))']]
]
@@ -93,58 +93,58 @@
[discriminator uint 4 'apduType']
[typeSwitch 'apduType'
['0x0' APDUConfirmedRequest
- [simple bit 'segmentedMessage']
- [simple bit 'moreFollows']
- [simple bit 'segmentedResponseAccepted']
- [reserved uint 2 '0']
- [simple uint 3 'maxSegmentsAccepted']
- [simple uint 4 'maxApduLengthAccepted']
- [simple uint 8 'invokeId']
- [optional uint 8 'sequenceNumber' 'segmentedMessage']
- [optional uint 8 'proposedWindowSize' 'segmentedMessage']
- [simple BACnetConfirmedServiceRequest 'serviceRequest' ['apduLength - (3 + (segmentedMessage ? 2 : 0))']]
+ [simple bit 'segmentedMessage' ]
+ [simple bit 'moreFollows' ]
+ [simple bit 'segmentedResponseAccepted' ]
+ [reserved uint 2 '0' ]
+ [simple uint 3 'maxSegmentsAccepted' ]
+ [simple uint 4 'maxApduLengthAccepted' ]
+ [simple uint 8 'invokeId' ]
+ [optional uint 8 'sequenceNumber' 'segmentedMessage']
+ [optional uint 8 'proposedWindowSize' 'segmentedMessage']
+ [simple BACnetConfirmedServiceRequest 'serviceRequest' ['apduLength - (3 + (segmentedMessage ? 2 : 0))']]
]
['0x1' APDUUnconfirmedRequest
- [reserved uint 4 '0']
+ [reserved uint 4 '0' ]
[simple BACnetUnconfirmedServiceRequest 'serviceRequest' ['apduLength - 1']]
]
['0x2' APDUSimpleAck
- [reserved uint 4 '0']
+ [reserved uint 4 '0' ]
[simple uint 8 'originalInvokeId']
- [simple uint 8 'serviceChoice']
+ [simple uint 8 'serviceChoice' ]
]
['0x3' APDUComplexAck
- [simple bit 'segmentedMessage']
- [simple bit 'moreFollows']
- [reserved uint 2 '0']
- [simple uint 8 'originalInvokeId']
- [optional uint 8 'sequenceNumber' 'segmentedMessage']
- [optional uint 8 'proposedWindowSize' 'segmentedMessage']
- [simple BACnetServiceAck 'serviceAck']
+ [simple bit 'segmentedMessage' ]
+ [simple bit 'moreFollows' ]
+ [reserved uint 2 '0' ]
+ [simple uint 8 'originalInvokeId' ]
+ [optional uint 8 'sequenceNumber' 'segmentedMessage']
+ [optional uint 8 'proposedWindowSize' 'segmentedMessage']
+ [simple BACnetServiceAck 'serviceAck' ]
]
['0x4' APDUSegmentAck
- [reserved uint 2 '0x00']
- [simple bit 'negativeAck']
- [simple bit 'server']
- [simple uint 8 'originalInvokeId']
- [simple uint 8 'sequenceNumber']
+ [reserved uint 2 '0x00' ]
+ [simple bit 'negativeAck' ]
+ [simple bit 'server' ]
+ [simple uint 8 'originalInvokeId' ]
+ [simple uint 8 'sequenceNumber' ]
[simple uint 8 'proposedWindowSize']
]
['0x5' APDUError
- [reserved uint 4 '0x00']
- [simple uint 8 'originalInvokeId']
- [simple BACnetError 'error']
+ [reserved uint 4 '0x00' ]
+ [simple uint 8 'originalInvokeId']
+ [simple BACnetError 'error' ]
]
['0x6' APDUReject
- [reserved uint 4 '0x00']
+ [reserved uint 4 '0x00' ]
[simple uint 8 'originalInvokeId']
- [simple uint 8 'rejectReason']
+ [simple uint 8 'rejectReason' ]
]
['0x7' APDUAbort
- [reserved uint 3 '0x00']
- [simple bit 'server']
+ [reserved uint 3 '0x00' ]
+ [simple bit 'server' ]
[simple uint 8 'originalInvokeId']
- [simple uint 8 'abortReason']
+ [simple uint 8 'abortReason' ]
]
]
]
@@ -155,20 +155,20 @@
['0x00' BACnetConfirmedServiceRequestAcknowledgeAlarm
]
['0x01' BACnetConfirmedServiceRequestConfirmedCOVNotification
- [const uint 8 'subscriberProcessIdentifierHeader' '0x09']
- [simple uint 8 'subscriberProcessIdentifier']
- [const uint 8 'monitoredObjectIdentifierHeader' '0x1C']
- [simple uint 10 'monitoredObjectType']
- [simple uint 22 'monitoredObjectInstanceNumber']
- [const uint 8 'issueConfirmedNotificationsHeader' '0x2C']
- [simple uint 10 'issueConfirmedNotificationsType']
- [simple uint 22 'issueConfirmedNotificationsInstanceNumber']
- [const uint 5 'lifetimeHeader' '0x07']
- [simple uint 3 'lifetimeLength']
- [array int 8 'lifetimeSeconds' count 'lifetimeLength']
- [const uint 8 'listOfValuesOpeningTag' '0x4E']
- [array BACnetTagWithContent 'notifications' length 'len - 18']
- [const uint 8 'listOfValuesClosingTag' '0x4F']
+ [const uint 8 'subscriberProcessIdentifierHeader' '0x09' ]
+ [simple uint 8 'subscriberProcessIdentifier' ]
+ [const uint 8 'monitoredObjectIdentifierHeader' '0x1C' ]
+ [simple uint 10 'monitoredObjectType' ]
+ [simple uint 22 'monitoredObjectInstanceNumber' ]
+ [const uint 8 'issueConfirmedNotificationsHeader' '0x2C' ]
+ [simple uint 10 'issueConfirmedNotificationsType' ]
+ [simple uint 22 'issueConfirmedNotificationsInstanceNumber' ]
+ [const uint 5 'lifetimeHeader' '0x07' ]
+ [simple uint 3 'lifetimeLength' ]
+ [array int 8 'lifetimeSeconds' count 'lifetimeLength']
+ [const uint 8 'listOfValuesOpeningTag' '0x4E' ]
+ [array BACnetTagWithContent 'notifications' length 'len - 18' ]
+ [const uint 8 'listOfValuesClosingTag' '0x4F' ]
]
['0x1F' BACnetConfirmedServiceRequestConfirmedCOVNotificationMultiple
]
@@ -182,17 +182,17 @@
['0x1B' BACnetConfirmedServiceRequestLifeSafetyOperation
]
['0x05' BACnetConfirmedServiceRequestSubscribeCOV
- [const uint 8 'subscriberProcessIdentifierHeader' '0x09']
- [simple uint 8 'subscriberProcessIdentifier']
- [const uint 8 'monitoredObjectIdentifierHeader' '0x1C']
- [simple uint 10 'monitoredObjectType']
- [simple uint 22 'monitoredObjectInstanceNumber']
- [const uint 8 'issueConfirmedNotificationsHeader' '0x29']
- [const uint 7 'issueConfirmedNotificationsSkipBits' '0x00']
- [simple bit 'issueConfirmedNotifications']
- [const uint 5 'lifetimeHeader' '0x07']
- [simple uint 3 'lifetimeLength']
- [array int 8 'lifetimeSeconds' count 'lifetimeLength']
+ [const uint 8 'subscriberProcessIdentifierHeader' '0x09' ]
+ [simple uint 8 'subscriberProcessIdentifier' ]
+ [const uint 8 'monitoredObjectIdentifierHeader' '0x1C' ]
+ [simple uint 10 'monitoredObjectType' ]
+ [simple uint 22 'monitoredObjectInstanceNumber' ]
+ [const uint 8 'issueConfirmedNotificationsHeader' '0x29' ]
+ [const uint 7 'issueConfirmedNotificationsSkipBits' '0x00' ]
+ [simple bit 'issueConfirmedNotifications' ]
+ [const uint 5 'lifetimeHeader' '0x07' ]
+ [simple uint 3 'lifetimeLength' ]
+ [array int 8 'lifetimeSeconds' count 'lifetimeLength']
]
['0x1C' BACnetConfirmedServiceRequestSubscribeCOVProperty
]
@@ -213,28 +213,28 @@
['0x0B' BACnetConfirmedServiceRequestDeleteObject
]
['0x0C' BACnetConfirmedServiceRequestReadProperty
- [const uint 8 'objectIdentifierHeader' '0x0C']
- [simple uint 10 'objectType']
- [simple uint 22 'objectInstanceNumber']
- [const uint 5 'propertyIdentifierHeader' '0x03']
- [simple uint 3 'propertyIdentifierLength']
- [array int 8 'propertyIdentifier' count 'propertyIdentifierLength']
+ [const uint 8 'objectIdentifierHeader' '0x0C' ]
+ [simple uint 10 'objectType' ]
+ [simple uint 22 'objectInstanceNumber' ]
+ [const uint 5 'propertyIdentifierHeader' '0x03' ]
+ [simple uint 3 'propertyIdentifierLength' ]
+ [array int 8 'propertyIdentifier' count 'propertyIdentifierLength']
]
['0x0E' BACnetConfirmedServiceRequestReadPropertyMultiple
]
['0x1A' BACnetConfirmedServiceRequestReadRange
]
['0x0F' BACnetConfirmedServiceRequestWriteProperty
- [const uint 8 'objectIdentifierHeader' '0x0C']
- [simple uint 10 'objectType']
- [simple uint 22 'objectInstanceNumber']
- [const uint 5 'propertyIdentifierHeader' '0x03']
- [simple uint 3 'propertyIdentifierLength']
- [array int 8 'propertyIdentifier' count 'propertyIdentifierLength']
- [const uint 8 'openingTag' '0x3E']
- [simple BACnetTag 'val']
- [const uint 8 'closingTag' '0x3F']
- [optional BACnetTag 'priority' 'curPos < (len - 1)']
+ [const uint 8 'objectIdentifierHeader' '0x0C' ]
+ [simple uint 10 'objectType' ]
+ [simple uint 22 'objectInstanceNumber' ]
+ [const uint 5 'propertyIdentifierHeader' '0x03' ]
+ [simple uint 3 'propertyIdentifierLength' ]
+ [array int 8 'propertyIdentifier' count 'propertyIdentifierLength']
+ [const uint 8 'openingTag' '0x3E' ]
+ [simple BACnetTag 'value' ]
+ [const uint 8 'closingTag' '0x3F' ]
+ [optional BACnetTag 'priority' 'curPos < (len - 1)' ]
]
['0x10' BACnetConfirmedServiceRequestWritePropertyMultiple
]
@@ -371,7 +371,7 @@
[simple uint 3 'propertyIdentifierLength']
[array int 8 'propertyIdentifier' count 'propertyIdentifierLength']
[const uint 8 'openingTag' '0x3E']
- [simple BACnetTag 'val']
+ [simple BACnetTag 'value']
[const uint 8 'closingTag' '0x3F']
]
['0x0E' BACnetServiceAckReadPropertyMultiple
@@ -498,7 +498,7 @@
[optional uint 8 'extLength' 'lengthValueType == 5']
[array uint 8 'propertyIdentifier' length '(lengthValueType == 5) ? extLength : lengthValueType']
[const uint 8 'openTag' '0x2e']
- [simple BACnetTag 'val']
+ [simple BACnetTag 'value']
[const uint 8 'closingTag' '0x2f']
]
diff --git a/protocols/knxnetip/src/main/resources/protocols/knxnetip/ets5.mspec b/protocols/knxnetip/src/main/resources/protocols/knxnetip/ets5.mspec
index 6df2b19..edb5992 100644
--- a/protocols/knxnetip/src/main/resources/protocols/knxnetip/ets5.mspec
+++ b/protocols/knxnetip/src/main/resources/protocols/knxnetip/ets5.mspec
@@ -38,12 +38,12 @@
[typeSwitch 'mainNumber','subNumber'
['1' KnxDatapointB1
[reserved uint 7 '0x0']
- [simple bit 'val']
+ [simple bit 'value']
]
['2' KnxDatapointB2
[reserved uint 6 '0x0']
[simple bit 'control']
- [simple bit 'val']
+ [simple bit 'value']
]
['21' KnxDatapointB8
[simple bit 'b7']
@@ -58,67 +58,64 @@
['3' KnxDatapointB1U3
[reserved uint 4 '0x0']
[simple bit 'control']
- [simple uint 3 'val']
+ [simple uint 3 'value']
]
['18' KnxDatapointB1U6
[simple bit 'control']
[reserved uint 1 '0x0']
- [simple uint 6 'val']
+ [simple uint 6 'value']
]
['17' KnxDatapointU6
[reserved uint 2 '0x0']
- [simple uint 6 'val']
+ [simple uint 6 'value']
]
['5' KnxDatapointU8
[reserved uint 8 '0x0']
- [simple uint 8 'val']
+ [simple uint 8 'value']
]
['7' KnxDatapointU16
[reserved uint 8 '0x0']
- [simple uint 16 'val']
+ [simple uint 16 'value']
]
['12' KnxDatapointU32
[reserved uint 8 '0x0']
- [simple uint 32 'val']
+ [simple uint 32 'value']
]
['6','20' KnxDatapointB5I3
- [simple bit 'a']
- [simple bit 'b']
- [simple bit 'c']
- [simple bit 'd']
- [simple bit 'e']
- [simple int 8 'val']
+ [simple bit 'a']
+ [simple bit 'b']
+ [simple bit 'c']
+ [simple bit 'd']
+ [simple bit 'e']
+ [simple int 8 'value']
]
['6' KnxDatapointI8
[reserved uint 8 '0x0']
- [simple int 8 'val']
+ [simple int 8 'value']
]
['8' KnxDatapointI16
- [reserved uint 8 '0x0']
- [simple int 16 'val']
+ [reserved uint 8 '0x0']
+ [simple int 16 'value']
]
['13' KnxDatapointI32
- [reserved uint 8 '0x0']
- [simple int 32 'val']
+ [reserved uint 8 '0x0']
+ [simple int 32 'value']
]
['9' KnxDatapointF16
- [reserved uint 8 '0x0']
- [simple bit 'sign']
- [simple int 4 'exponent']
- [simple uint 11 'mantissa']
- [virtual float 16 'val' '(sign ? -1 : 1) * (0.01 * mantissa) * (2 ^ exponent)']
+ [reserved uint 8 '0x0']
+ [simple float 4.11 'value']
]
['14' KnxDatapointF32
- [reserved uint 8 '0x0']
- [simple float 32 'val']
+ [reserved uint 8 '0x0']
+ [simple float 8.23 'value']
]
['4' KnxDatapointA8
[reserved uint 8 '0x0']
- [simple int 8 'val']
+ [simple int 8 'value']
]
['16' KnxDatapointA112
[reserved uint 8 '0x0']
- [array int 8 'val' count '14']
+ [array int 8 'value' count '14']
]
['10' KnxDatapointTime24
[simple uint 3 'day']
diff --git a/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/bacnetip/BacNetIpAdapter.java b/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/bacnetip/BacNetIpAdapter.java
index cb30ed7..6d8e39f 100644
--- a/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/bacnetip/BacNetIpAdapter.java
+++ b/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/bacnetip/BacNetIpAdapter.java
@@ -251,13 +251,13 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
// (This is the actual value to which a given property has changed)
if (propertyId == 85) {
// Depending on the type of object, parse the data accordingly.
- if (notification.getVal() instanceof BACnetTagApplicationBoolean) {
+ if (notification.getValue() instanceof BACnetTagApplicationBoolean) {
type = "boolean";
- final BACnetTagApplicationBoolean val = (BACnetTagApplicationBoolean) notification.getVal();
+ final BACnetTagApplicationBoolean val = (BACnetTagApplicationBoolean) notification.getValue();
- } else if (notification.getVal() instanceof BACnetTagApplicationUnsignedInteger) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationUnsignedInteger) {
type = "uint";
- final BACnetTagApplicationUnsignedInteger val = (BACnetTagApplicationUnsignedInteger) notification.getVal();
+ final BACnetTagApplicationUnsignedInteger val = (BACnetTagApplicationUnsignedInteger) notification.getValue();
// Convert any number of bytes into an unsigned integer.
switch (val.getData().length) {
case 1:
@@ -278,21 +278,21 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
value = "Hurz";
break;
}
- } else if (notification.getVal() instanceof BACnetTagApplicationSignedInteger) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationSignedInteger) {
type = "int";
- final BACnetTagApplicationSignedInteger val = (BACnetTagApplicationSignedInteger) notification.getVal();
+ final BACnetTagApplicationSignedInteger val = (BACnetTagApplicationSignedInteger) notification.getValue();
- } else if (notification.getVal() instanceof BACnetTagApplicationReal) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationReal) {
type = "real";
- final BACnetTagApplicationReal val = (BACnetTagApplicationReal) notification.getVal();
+ final BACnetTagApplicationReal val = (BACnetTagApplicationReal) notification.getValue();
value = Float.intBitsToFloat(ByteBuffer.wrap(val.getData()).getInt());
- } else if (notification.getVal() instanceof BACnetTagApplicationDouble) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationDouble) {
type = "double";
- final BACnetTagApplicationDouble val = (BACnetTagApplicationDouble) notification.getVal();
+ final BACnetTagApplicationDouble val = (BACnetTagApplicationDouble) notification.getValue();
- } else if (notification.getVal() instanceof BACnetTagApplicationBitString) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationBitString) {
type = "bit-string";
- final BACnetTagApplicationBitString val = (BACnetTagApplicationBitString) notification.getVal();
+ final BACnetTagApplicationBitString val = (BACnetTagApplicationBitString) notification.getValue();
int numBits = (val.getData().length * 8) - val.getUnusedBits();
BitSet bitSet = BitSet.valueOf(val.getData());
boolean[] bits = new boolean[numBits];
@@ -300,16 +300,16 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
bits[i] = bitSet.get(i);
}
value = bits;
- } else if (notification.getVal() instanceof BACnetTagApplicationEnumerated) {
+ } else if (notification.getValue() instanceof BACnetTagApplicationEnumerated) {
type = "enumeration";
- final BACnetTagApplicationEnumerated val = (BACnetTagApplicationEnumerated) notification.getVal();
+ final BACnetTagApplicationEnumerated val = (BACnetTagApplicationEnumerated) notification.getValue();
}
}
// Status-Flags have the property id 111
// (This is some additional information passed along)
else if (propertyId == 111) {
- final BACnetTagApplicationBitString val = (BACnetTagApplicationBitString) notification.getVal();
+ final BACnetTagApplicationBitString val = (BACnetTagApplicationBitString) notification.getValue();
int numBits = (val.getData().length * 8) - val.getUnusedBits();
BitSet bitSet = BitSet.valueOf(val.getData());
boolean[] bits = new boolean[numBits];