Skip to content

Commit

Permalink
Merge commit '6037919a3e' into fix/modbus
Browse files Browse the repository at this point in the history
  • Loading branch information
ceos01 committed Nov 30, 2024
2 parents ed93a1c + 6037919 commit 4d90f46
Show file tree
Hide file tree
Showing 387 changed files with 4,142 additions and 2,552 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ type _${type.name} struct {
${type.parentType.orElseThrow().name}Contract
</#if>
<#if type.isDiscriminatedParentTypeDefinition()>
_SubType ${type.name}
_SubType interface {
${type.name}Contract
${type.name}Requirements
}
</#if>
<#-- Property fields are fields that require a property in the pojo -->
<#if type.propertyFields?has_content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public String getPlcValueTypeForTypeReference(TypeReference typeReference) {
case BYTE:
// Byte values are represented as signed integers in PLC4Py
emitRequiredImport("from plc4py.spi.values.PlcValues import PlcSINT");
return "PlcSINT";
return "PlcBYTE";
case UINT:
IntegerTypeReference unsignedIntegerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (unsignedIntegerTypeReference.getSizeInBits() <= 4) {
Expand Down Expand Up @@ -807,10 +807,10 @@ public String getReadBufferReadMethodCall(String logicalName, SimpleTypeReferenc
switch (simpleTypeReference.getBaseType()) {
case BIT:
String bitType = "bit";
return "read_buffer.read_" + bitType + "(\"" + logicalName + "\")";
return "read_buffer.read_" + bitType + "(\"" + logicalName + "\"";
case BYTE:
String byteType = "byte";
return "read_buffer.read_" + byteType + "(\"" + logicalName + "\")";
return "read_buffer.read_" + byteType + "(\"" + logicalName + "\"";
case UINT:
String unsignedIntegerType;
IntegerTypeReference unsignedIntegerTypeReference = (IntegerTypeReference) simpleTypeReference;
Expand All @@ -825,7 +825,7 @@ public String getReadBufferReadMethodCall(String logicalName, SimpleTypeReferenc
} else {
unsignedIntegerType = "unsigned_long";
}
return "read_buffer.read_" + unsignedIntegerType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\")";
return "read_buffer.read_" + unsignedIntegerType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\"";
case INT:
String integerType;
if (simpleTypeReference.getSizeInBits() <= 8) {
Expand All @@ -839,10 +839,10 @@ public String getReadBufferReadMethodCall(String logicalName, SimpleTypeReferenc
} else {
integerType = "long";
}
return "read_buffer.read_" + integerType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\")";
return "read_buffer.read_" + integerType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\"";
case FLOAT:
String floatType = (simpleTypeReference.getSizeInBits() <= 32) ? "float" : "double";
return "read_buffer.read_" + floatType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\")";
return "read_buffer.read_" + floatType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\"";
case STRING:
case VSTRING:
String stringType = "str";
Expand All @@ -856,7 +856,7 @@ public String getReadBufferReadMethodCall(String logicalName, SimpleTypeReferenc
VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
length = toParseExpression(field, INT_TYPE_REFERENCE, vstringTypeReference.getLengthExpression(), null);
}
return "read_buffer.read_" + stringType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\", encoding=" + "\"\")";
return "read_buffer.read_" + stringType + "(" + simpleTypeReference.getSizeInBits() + ", logical_name=\"" + logicalName + "\"";

default:
return "";
Expand Down Expand Up @@ -895,7 +895,8 @@ public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeRefere
case BIT:
return "write_buffer.write_bit(" + fieldName + ", \"" + logicalName + "\"" + writerArgsString + ")";
case BYTE:
return "write_buffer.write_byte(" + fieldName + ", \"" + logicalName + "\"" + writerArgsString + ")";
ByteTypeReference byteTypeReference = (ByteTypeReference) simpleTypeReference;
return "write_buffer.write_byte(" + fieldName + ", " + byteTypeReference.getSizeInBits() + ", \"" + logicalName + "\"" + writerArgsString + ")";
case UINT:
IntegerTypeReference unsignedIntegerTypeReference = (IntegerTypeReference) simpleTypeReference;
if (unsignedIntegerTypeReference.getSizeInBits() <= 8) {
Expand Down Expand Up @@ -945,7 +946,7 @@ public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeRefere
.orElseThrow(() -> new FreemarkerException("Encoding must be a quoted string value")).getValue();
String length = Integer.toString(simpleTypeReference.getSizeInBits());
return "write_buffer.write_str(" + fieldName + ", " + length + ", \"" +
encoding + "\", \"" + logicalName + "\"" + writerArgsString + ")";
logicalName + "\", \"" + encoding + "\"" + writerArgsString + ")";
}
case VSTRING: {
VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
Expand All @@ -957,7 +958,7 @@ public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeRefere
String lengthExpression = toExpression(field, null, vstringTypeReference.getLengthExpression(), null, Collections.singletonList(new DefaultArgument("stringLength", new DefaultIntegerTypeReference(SimpleTypeReference.SimpleBaseType.INT, 32))), true, false);
String length = Integer.toString(simpleTypeReference.getSizeInBits());
return "write_buffer.write_str(" + fieldName + ", " + lengthExpression + ", \"" +
encoding + "\", \"" + logicalName + "\"" + writerArgsString + ")";
logicalName + "\", \"" + encoding + "\"" + writerArgsString + ")";
}
case DATE:
case TIME:
Expand Down Expand Up @@ -1511,7 +1512,7 @@ else if ((variableLiteral.getChild().isPresent()) && ((ComplexTypeDefinition) th
} else if ((serializerArguments != null) && serializerArguments.stream()
.anyMatch(argument -> argument.getName().equals(variableLiteralName))) {
tracer = tracer.dive("serialization argument");
return tracer + "self." + camelCaseToSnakeCase(variableLiteralName) +
return tracer + camelCaseToSnakeCase(variableLiteralName) +
variableLiteral.getChild()
.map(child -> "." + camelCaseToSnakeCase(toVariableExpression(field, typeReference, child, parserArguments, serializerArguments, serialize, suppressPointerAccess, true)))
.orElse("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class ${type.name}<#if type.isDiscriminatedParentTypeDefinition()></#if>(<#if ty
<#if parserArgument.type.isEnumTypeReference()>
${helper.camelCaseToSnakeCase(parserArgument.name)} = ${helper.getLanguageTypeNameForTypeReference(parserArgument.type, false)}[${helper.camelCaseToSnakeCase(parserArgument.name)}]
<#elseif helper.getLanguageTypeNameForTypeReference(parserArgument.type, false) = "bool">
<@emitImport import="from distutils.util import strtobool" />
<@emitImport import="from plc4py.utils.ConnectionStringHandling import strtobool" />
${helper.camelCaseToSnakeCase(parserArgument.name)} = bool(strtobool(${helper.camelCaseToSnakeCase(parserArgument.name)}))
<#else>
${helper.camelCaseToSnakeCase(parserArgument.name)} = ${helper.getLanguageTypeNameForTypeReference(parserArgument.type, false)}(${helper.camelCaseToSnakeCase(parserArgument.name)})
Expand Down
Loading

0 comments on commit 4d90f46

Please sign in to comment.