You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2023/05/21 04:34:27 UTC
[plc4x] 02/03: feat(plc4py): Fix issues with serializing data for Modbus
This is an automated email from the ASF dual-hosted git repository.
hutcheb pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 4350fb28ee3767bd8a4256ea2a0379ebf968e2dc
Author: Ben Hutcheson <be...@gmail.com>
AuthorDate: Sun May 21 06:23:48 2023 +0200
feat(plc4py): Fix issues with serializing data for Modbus
---
.../python/PythonLanguageTemplateHelper.java | 16 +-
.../python/complex-type-template.python.ftlh | 7 +-
.../plc4py/plc4py/protocols/modbus/StaticHelper.py | 106 ++++++
.../plc4py/protocols/modbus/readwrite/DataItem.py | 354 ++++++++---------
.../plc4py/protocols/modbus/readwrite/ModbusADU.py | 10 +-
.../protocols/modbus/readwrite/ModbusAsciiADU.py | 12 +-
.../readwrite/ModbusDeviceInformationObject.py | 2 +-
.../plc4py/protocols/modbus/readwrite/ModbusPDU.py | 80 ++--
.../readwrite/ModbusPDUGetComEventLogResponse.py | 2 +-
.../modbus/readwrite/ModbusPDUReadCoilsResponse.py | 2 +-
.../ModbusPDUReadDiscreteInputsResponse.py | 2 +-
.../ModbusPDUReadFileRecordResponseItem.py | 2 +-
.../ModbusPDUReadHoldingRegistersResponse.py | 2 +-
.../ModbusPDUReadInputRegistersResponse.py | 2 +-
...sPDUReadWriteMultipleHoldingRegistersRequest.py | 2 +-
...PDUReadWriteMultipleHoldingRegistersResponse.py | 2 +-
.../readwrite/ModbusPDUReportServerIdResponse.py | 2 +-
.../ModbusPDUWriteFileRecordRequestItem.py | 2 +-
.../ModbusPDUWriteFileRecordResponseItem.py | 2 +-
.../ModbusPDUWriteMultipleCoilsRequest.py | 2 +-
...odbusPDUWriteMultipleHoldingRegistersRequest.py | 2 +-
.../protocols/modbus/readwrite/ModbusRtuADU.py | 12 +-
.../protocols/modbus/readwrite/ModbusTcpADU.py | 6 +-
.../protocols/simulated/readwrite/DataItem.py | 420 ++++++++++-----------
.../plc4py/plc4py/spi/generation/WriteBuffer.py | 4 +-
25 files changed, 580 insertions(+), 475 deletions(-)
diff --git a/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java b/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
index e706ef78b7..9e946ad645 100644
--- a/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
+++ b/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
@@ -321,7 +321,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
final ArrayTypeReference arrayTypeReference = typeReference.asArrayTypeReference().orElseThrow();
return getDataWriterCall(arrayTypeReference.getElementTypeReference(), fieldName);
} else if (typeReference.isComplexTypeReference()) {
- return "DataWriterComplexDefault(write_buffer)";
+ return "write_serializable";
} else {
throw new IllegalStateException("What is this type? " + typeReference);
}
@@ -880,12 +880,12 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
} else if (term instanceof VariableLiteral) {
tracer = tracer.dive("variable literal instanceOf");
VariableLiteral variableLiteral = (VariableLiteral) term;
- if ("curPos".equals(((VariableLiteral) term).getName())) {
- return "(positionAware.GetPos() - startPos)";
+ if ("cur_pos".equals(((VariableLiteral) term).getName())) {
+ return "(position_aware.get_pos() - startPos)";
} else if ("BIG_ENDIAN".equals(((VariableLiteral) term).getName()) && (fieldType instanceof ByteOrderTypeReference)) {
- return "binary.BigEndian";
+ return "ByteOrder.BIG_ENDIAN";
} else if ("LITTLE_ENDIAN".equals(((VariableLiteral) term).getName()) && (fieldType instanceof ByteOrderTypeReference)) {
- return "binary.LittleEndian";
+ return "ByteOrder.LITTLE_ENDIAN";
}
return tracer + toVariableExpression(field, fieldType, (VariableLiteral) term, parserArguments, serializerArguments, serialize, suppressPointerAccess);
} else {
@@ -1032,7 +1032,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
final ImplicitField referencedImplicitField = getReferencedImplicitField(variableLiteral);
return tracer + toSerializationExpression(referencedImplicitField, referencedImplicitField.getType(), getReferencedImplicitField(variableLiteral).getSerializeExpression(), serializerArguments);
} else {
- return tracer + variableLiteralName;
+ return tracer + camelCaseToSnakeCase(variableLiteralName);
//return toParseExpression(getReferencedImplicitField(vl), getReferencedImplicitField(vl).getSerializeExpression(), serializerArguments);
}
}
@@ -1056,7 +1056,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
if ((parserArguments != null) && parserArguments.stream()
.anyMatch(argument -> argument.getName().equals(variableLiteralName))) {
tracer = tracer.dive("parser argument");
- return tracer + variableLiteralName +
+ return tracer + variableLiteralName + "66" +
variableLiteral.getChild()
.map(child -> "." + camelCaseToSnakeCase(toVariableExpression(field, typeReference, child, parserArguments, serializerArguments, false, suppressPointerAccess, true)))
.orElse("");
@@ -1235,7 +1235,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
break;
}
} else {
- sb.append(toVariableExpression(field, typeReference, va, parserArguments, serializerArguments, serialize, suppressPointerAccess));
+ sb.append("self." + toVariableExpression(field, typeReference, va, parserArguments, serializerArguments, serialize, suppressPointerAccess));
}
} else if (arg instanceof StringLiteral) {
tracer = tracer.dive("StringLiteral");
diff --git a/code-generation/language-python/src/main/resources/templates/python/complex-type-template.python.ftlh b/code-generation/language-python/src/main/resources/templates/python/complex-type-template.python.ftlh
index 11ce0db831..f7fabe211f 100644
--- a/code-generation/language-python/src/main/resources/templates/python/complex-type-template.python.ftlh
+++ b/code-generation/language-python/src/main/resources/templates/python/complex-type-template.python.ftlh
@@ -109,7 +109,7 @@ class ${type.name}<#if type.isDiscriminatedParentTypeDefinition()></#if>(<#if ty
${helper.camelCaseToSnakeCase(discriminatorName)}: ${helper.getLanguageTypeNameForTypeReference(discriminatorType)} = <@compress single_line=true>
<#if discriminatorValue?? && !helper.isWildcard(discriminatorValue)>
<#if discriminatorType.isEnumTypeReference()>
- ${helper.getLanguageTypeNameForTypeReference(discriminatorType)}.${helper.toParseExpression(null, discriminatorType, discriminatorValue, parserArguments)}
+ ${helper.getLanguageTypeNameForTypeReference(discriminatorType)}.${discriminatorValue.name}
<#else>
${helper.toParseExpression(null, discriminatorType, discriminatorValue, parserArguments)}
</#if>
@@ -199,7 +199,7 @@ class ${type.name}<#if type.isDiscriminatedParentTypeDefinition()></#if>(<#if ty
<#if type.isDiscriminatedParentTypeDefinition()>
<@emitImport import="from abc import abstractmethod" />
@abstractmethod
- def serialize_${helper.camelCaseToSnakeCase(type.name)}_child(write_buffer: WriteBuffer) -> None:
+ def serialize_${helper.camelCaseToSnakeCase(type.name)}_child(self, write_buffer: WriteBuffer) -> None:
pass
</#if>
@@ -231,9 +231,10 @@ class ${type.name}<#if type.isDiscriminatedParentTypeDefinition()></#if>(<#if ty
<#assign checksumField = field.asChecksumField().orElseThrow()>
<#assign typedField = field.asTypedField().orElseThrow()>
<#assign namedField = field.asNamedField().orElseThrow()>
+ <@emitImport import="from plc4py.protocols.${protocolName} import StaticHelper" />
# Checksum Field (checksum) (Calculated)
- write_buffer.${helper.getDataWriterCall(typedField.type, namedField.name)}(${helper.getLanguageTypeNameForField(field)}(${helper.toParseExpression(checksumField, checksumField.type, checksumField.checksumExpression, parserArguments)}), logical_name="${namedField.name}")
+ write_buffer.${helper.getDataWriterCall(typedField.type, namedField.name)}(${helper.getLanguageTypeNameForField(field)}(StaticHelper.${helper.toParseExpression(checksumField, checksumField.type, checksumField.checksumExpression, parserArguments)}), logical_name="${namedField.name}")
<#break>
<#case "const">
<#assign constField = field.asConstField().orElseThrow()>
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/StaticHelper.py b/sandbox/plc4py/plc4py/protocols/modbus/StaticHelper.py
new file mode 100644
index 0000000000..eccf9f2e79
--- /dev/null
+++ b/sandbox/plc4py/plc4py/protocols/modbus/StaticHelper.py
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from ctypes import c_uint16, c_byte, c_uint8
+
+from plc4py.protocols.modbus.readwrite.ModbusPDU import ModbusPDU
+from plc4py.spi.generation.WriteBuffer import WriteBufferByteBased
+from plc4py.utils.GenericTypes import ByteOrder
+
+auch_crc_hi: bytearray = bytearray(
+ b"\x00\xC1\x81\x40\x01\xC0\x80\x41\x01\xC0\x80\x41\x00\xC1\x81 \
+ \x40\x01\xC0\x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01\xC0 \
+ \x80\x41\x01\xC0\x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01 \
+ \xC0\x80\x41\x00\xC1\x81\x40\x01\xC0\x80\x41\x01\xC0\x80\x41 \
+ \x00\xC1\x81\x40\x01\xC0\x80\x41\x00\xC1\x81\x40\x00\xC1\x81 \
+ \x40\x01\xC0\x80\x41\x00\xC1\x81\x40\x01\xC0\x80\x41\x01\xC0 \
+ \x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01\xC0\x80\x41\x01 \
+ \xC0\x80\x41\x00\xC1\x81\x40\x01\xC0\x80\x41\x00\xC1\x81\x40 \
+ \x00\xC1\x81\x40\x01\xC0\x80\x41\x01\xC0\x80\x41\x00\xC1\x81 \
+ \x40\x00\xC1\x81\x40\x01\xC0\x80\x41\x00\xC1\x81\x40\x01\xC0 \
+ \x80\x41\x01\xC0\x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01 \
+ \xC0\x80\x41\x01\xC0\x80\x41\x00\xC1\x81\x40\x01\xC0\x80\x41 \
+ \x00\xC1\x81\x40\x00\xC1\x81\x40\x01\xC0\x80\x41\x00\xC1\x81 \
+ \x40\x01\xC0\x80\x41\x01\xC0\x80\x41\x00\xC1\x81\x40\x01\xC0 \
+ \x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01\xC0\x80\x41\x01 \
+ \xC0\x80\x41\x00\xC1\x81\x40\x00\xC1\x81\x40\x01\xC0\x80\x41 \
+ \x00\xC1\x81\x40\x01\xC0\x80\x41\x01\xC0\x80\x41\x00\xC1\x81 \
+ \x40"
+)
+
+auch_crc_lo: bytearray = bytearray(
+ b"\x00\xC0\xC1\x01\xC3\x03\x02\xC2\xC6\x06\x07\xC7\x05\xC5\xC4 \
+ \x04\xCC\x0C\x0D\xCD\x0F\xCF\xCE\x0E\x0A\xCA\xCB\x0B\xC9\x09 \
+ \x08\xC8\xD8\x18\x19\xD9\x1B\xDB\xDA\x1A\x1E\xDE\xDF\x1F\xDD \
+ \x1D\x1C\xDC\x14\xD4\xD5\x15\xD7\x17\x16\xD6\xD2\x12\x13\xD3 \
+ \x11\xD1\xD0\x10\xF0\x30\x31\xF1\x33\xF3\xF2\x32\x36\xF6\xF7 \
+ \x37\xF5\x35\x34\xF4\x3C\xFC\xFD\x3D\xFF\x3F\x3E\xFE\xFA\x3A \
+ \x3B\xFB\x39\xF9\xF8\x38\x28\xE8\xE9\x29\xEB\x2B\x2A\xEA\xEE \
+ \x2E\x2F\xEF\x2D\xED\xEC\x2C\xE4\x24\x25\xE5\x27\xE7\xE6\x26 \
+ \x22\xE2\xE3\x23\xE1\x21\x20\xE0\xA0\x60\x61\xA1\x63\xA3\xA2 \
+ \x62\x66\xA6\xA7\x67\xA5\x65\x64\xA4\x6C\xAC\xAD\x6D\xAF\x6F \
+ \x6E\xAE\xAA\x6A\x6B\xAB\x69\xA9\xA8\x68\x78\xB8\xB9\x79\xBB \
+ \x7B\x7A\xBA\xBE\x7E\x7F\xBF\x7D\xBD\xBC\x7C\xB4\x74\x75\xB5 \
+ \x77\xB7\xB6\x76\x72\xB2\xB3\x73\xB1\x71\x70\xB0\x50\x90\x91 \
+ \x51\x93\x53\x52\x92\x96\x56\x57\x97\x55\x95\x94\x54\x9C\x5C \
+ \x5D\x9D\x5F\x9F\x9E\x5E\x5A\x9A\x9B\x5B\x99\x59\x58\x98\x88 \
+ \x48\x49\x89\x4B\x8B\x8A\x4A\x4E\x8E\x8F\x4F\x8D\x4D\x4C\x8C \
+ \x44\x84\x85\x45\x87\x47\x46\x86\x82\x42\x43\x83\x41\x81\x80 \
+ \x40"
+)
+
+
+def rtu_crc_check(address: c_uint16, pdu: ModbusPDU) -> int:
+ # Using the algorithm from PI_MBUS_300.pdf page 121
+ write_buffer: WriteBufferByteBased = WriteBufferByteBased(
+ pdu.length_in_bytes() + 2, byte_order=ByteOrder.LITTLE_ENDIAN
+ )
+ write_buffer.write_unsigned_short(address, 8)
+ pdu.serialize(write_buffer)
+ m_view: memoryview = write_buffer.get_bytes()
+ uch_crc_hi: c_byte = c_byte(0xFF)
+ uch_crc_lo: c_byte = c_byte(0xFF)
+ u_index: int = 0
+ for b in m_view:
+ u_index = (int(uch_crc_hi.value) ^ b) & 0xFF
+ uch_crc_hi = c_byte(int(uch_crc_lo.value) ^ auch_crc_hi[u_index])
+ uch_crc_lo = c_byte(auch_crc_lo[u_index])
+ return ((int(uch_crc_hi.value) << 8) & 0xFFFF) | (int(uch_crc_lo.value) & 0x00FF)
+
+
+# 8 Bit checksum, (byte) transported as 2 characters
+def ascii_lrc_check(address: c_uint8, pdu: ModbusPDU) -> int:
+ write_buffer: WriteBufferByteBased = WriteBufferByteBased(
+ pdu.length_in_bytes() + 2, byte_order=ByteOrder.LITTLE_ENDIAN
+ )
+ write_buffer.write_unsigned_byte(address, 8)
+ pdu.serialize(write_buffer)
+ m_view: memoryview = write_buffer.get_bytes()
+
+ # A procedure for generating an LRC is:
+ # 1. Add all bytes in the message, (byte) excluding the starting ‘colon’ and ending
+ # CRLF. Add them into an 8–bit tag, (byte) so that carries will be discarded.
+ # 2. Subtract the final tag value from FF hex (all 1’s), (byte) to produce the
+ # ones–complement.
+ # 3. Add 1 to produce the twos–complement
+ # 4. Convert the 8 bit checksum into it's 16 bit (2 char) hex representation.
+ # (Handled in the transport layer)
+ lrc: int = 0
+ for b in m_view:
+ lrc = lrc + b
+
+ lrc = -lrc
+ return lrc & 0xFF
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py
index 58f87c19d6..84c761aa36 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py
@@ -40,9 +40,9 @@ class DataItem:
read_buffer: ReadBuffer, data_type: ModbusDataType, number_of_values: c_uint16
):
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_bool()
+ data_type66, ModbusDataType.get_bool()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # BOOL
# Reserved Field (Compartmentalized so the "reserved" variable can't leak)
reserved: c_uint16 = read_buffer.readUnsignedInt("", 15)
@@ -59,27 +59,27 @@ class DataItem:
value: c_bool = read_buffer.readBit("")
return PlcBOOL(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_bool()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_bool()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcBOOL(c_bool(read_buffer.readBit(""))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_byte()
+ data_type66, ModbusDataType.get_byte()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # BYTE
# Reserved Field (Compartmentalized so the "reserved" variable can't leak)
reserved: c_uint8 = read_buffer.readUnsignedShort("", 8)
@@ -96,42 +96,42 @@ class DataItem:
value: c_uint8 = read_buffer.readUnsignedShort("", 8)
return PlcBYTE(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_byte()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_byte()): # List
# Array field (value)
# Count array
- if numberOfValues * c_int32(8) > Integer.MAX_VALUE:
+ if numberOfValues66 * c_int32(8) > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues * c_int32(8))
+ + (numberOfValues66 * c_int32(8))
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues * c_int32(8))
+ item_count: int = int(numberOfValues66 * c_int32(8))
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcBOOL(c_bool(read_buffer.readBit(""))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_word()): # WORD
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_word()): # WORD
# Simple Field (value)
value: c_uint16 = read_buffer.readUnsignedInt("", 16)
return PlcWORD(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_dword()): # DWORD
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_dword()): # DWORD
# Simple Field (value)
value: c_uint32 = read_buffer.readUnsignedLong("", 32)
return PlcDWORD(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_lword()): # LWORD
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_lword()): # LWORD
# Simple Field (value)
value: c_uint64 = read_buffer.readUnsignedBigInteger("", 64)
return PlcLWORD(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_sint()
+ data_type66, ModbusDataType.get_sint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # SINT
# Reserved Field (Compartmentalized so the "reserved" variable can't leak)
reserved: c_uint8 = read_buffer.readUnsignedShort("", 8)
@@ -148,105 +148,105 @@ class DataItem:
value: c_int8 = read_buffer.readSignedByte("", 8)
return PlcSINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_sint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_sint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSINT(c_int8(read_buffer.readSignedByte("", 8))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_int()
+ data_type66, ModbusDataType.get_int()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # INT
# Simple Field (value)
value: c_int16 = read_buffer.readShort("", 16)
return PlcINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_int()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_int()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcINT(c_int16(read_buffer.readShort("", 16))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_dint()
+ data_type66, ModbusDataType.get_dint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # DINT
# Simple Field (value)
value: c_int32 = read_buffer.readInt("", 32)
return PlcDINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_dint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_dint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcDINT(c_int32(read_buffer.readInt("", 32))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_lint()
+ data_type66, ModbusDataType.get_lint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # LINT
# Simple Field (value)
value: c_int64 = read_buffer.readLong("", 64)
return PlcLINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_lint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_lint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcLINT(c_int64(read_buffer.readLong("", 64))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_usint()
+ data_type66, ModbusDataType.get_usint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # USINT
# Reserved Field (Compartmentalized so the "reserved" variable can't leak)
reserved: c_uint8 = read_buffer.readUnsignedShort("", 8)
@@ -263,96 +263,96 @@ class DataItem:
value: c_uint8 = read_buffer.readUnsignedShort("", 8)
return PlcUSINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_usint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_usint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUINT(c_uint8(read_buffer.readUnsignedShort("", 8))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_uint()
+ data_type66, ModbusDataType.get_uint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # UINT
# Simple Field (value)
value: c_uint16 = read_buffer.readUnsignedInt("", 16)
return PlcUINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_uint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_uint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUDINT(c_uint16(read_buffer.readUnsignedInt("", 16))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_udint()
+ data_type66, ModbusDataType.get_udint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # UDINT
# Simple Field (value)
value: c_uint32 = read_buffer.readUnsignedLong("", 32)
return PlcUDINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_udint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_udint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcULINT(c_uint32(read_buffer.readUnsignedLong("", 32))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_ulint()
+ data_type66, ModbusDataType.get_ulint()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # ULINT
# Simple Field (value)
value: c_uint64 = read_buffer.readUnsignedBigInteger("", 64)
return PlcULINT(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_ulint()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_ulint()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(
@@ -361,104 +361,104 @@ class DataItem:
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_real()
+ data_type66, ModbusDataType.get_real()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # REAL
# Simple Field (value)
value: c_float = read_buffer.readFloat("", 32)
return PlcREAL(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_real()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_real()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcREAL(c_float(read_buffer.readFloat("", 32))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_lreal()
+ data_type66, ModbusDataType.get_lreal()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # LREAL
# Simple Field (value)
value: c_double = read_buffer.readDouble("", 64)
return PlcLREAL(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_lreal()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_lreal()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcLREAL(c_double(read_buffer.readDouble("", 64))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_char()
+ data_type66, ModbusDataType.get_char()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # CHAR
# Simple Field (value)
value: str = read_buffer.readString("", 8, "UTF-8")
return PlcCHAR(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_char()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_char()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSTRING(str(read_buffer.readString("", 8, "UTF-8"))))
return PlcList(value)
if EvaluationHelper.equals(
- data_type, ModbusDataType.get_wchar()
+ data_type66, ModbusDataType.get_wchar()
) and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ number_of_values66, c_uint16(1)
): # WCHAR
# Simple Field (value)
value: str = read_buffer.readString("", 16, "UTF-16")
return PlcWCHAR(value)
- if EvaluationHelper.equals(data_type, ModbusDataType.get_wchar()): # List
+ if EvaluationHelper.equals(data_type66, ModbusDataType.get_wchar()): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSTRING(str(read_buffer.readString("", 16, "UTF-16"))))
@@ -486,16 +486,16 @@ class DataItem:
byteOrder: ByteOrder,
) -> None:
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_bool()
+ dataType66, ModbusDataType.get_bool()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # BOOL
# Reserved Field
writeBuffer.WriteUint16("cuint160x0000", 15, c_uint16(0x0000))
# Simple Field (value)
value: c_bool = _value.getC_bool()
writeBuffer.WriteBit("value", (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_bool()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_bool()): # List
values: PlcList = _value
for val in values.getList():
@@ -503,45 +503,45 @@ class DataItem:
writeBuffer.WriteBit("value", (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_byte()
+ dataType66, ModbusDataType.get_byte()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # BYTE
# Reserved Field
writeBuffer.WriteUint8("cuint80x00", 8, c_uint8(0x00))
# Simple Field (value)
value: c_uint8 = _value.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_byte()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_byte()): # List
values: PlcList = _value
for val in values.getList():
value: c_bool = val.getC_bool()
writeBuffer.WriteBit("value", (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_word()): # WORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_word()): # WORD
# Simple Field (value)
value: c_uint16 = _value.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_dword()): # DWORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_dword()): # DWORD
# Simple Field (value)
value: c_uint32 = _value.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lword()): # LWORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lword()): # LWORD
# Simple Field (value)
value: c_uint64 = _value.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_sint()
+ dataType66, ModbusDataType.get_sint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # SINT
# Reserved Field
writeBuffer.WriteUint8("cuint80x00", 8, c_uint8(0x00))
# Simple Field (value)
value: c_int8 = _value.getC_int8()
writeBuffer.WriteInt8("value", 8, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_sint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_sint()): # List
values: PlcList = _value
for val in values.getList():
@@ -549,14 +549,14 @@ class DataItem:
writeBuffer.WriteInt8("value", 8, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_int()
+ dataType66, ModbusDataType.get_int()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # INT
# Simple Field (value)
value: c_int16 = _value.getC_int16()
writeBuffer.WriteInt16("value", 16, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_int()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_int()): # List
values: PlcList = _value
for val in values.getList():
@@ -564,14 +564,14 @@ class DataItem:
writeBuffer.WriteInt16("value", 16, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_dint()
+ dataType66, ModbusDataType.get_dint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # DINT
# Simple Field (value)
value: c_int32 = _value.getC_int32()
writeBuffer.WriteInt32("value", 32, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_dint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_dint()): # List
values: PlcList = _value
for val in values.getList():
@@ -579,14 +579,14 @@ class DataItem:
writeBuffer.WriteInt32("value", 32, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_lint()
+ dataType66, ModbusDataType.get_lint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # LINT
# Simple Field (value)
value: c_int64 = _value.getC_int64()
writeBuffer.WriteInt64("value", 64, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lint()): # List
values: PlcList = _value
for val in values.getList():
@@ -594,16 +594,16 @@ class DataItem:
writeBuffer.WriteInt64("value", 64, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_usint()
+ dataType66, ModbusDataType.get_usint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # USINT
# Reserved Field
writeBuffer.WriteUint8("cuint80x00", 8, c_uint8(0x00))
# Simple Field (value)
value: c_uint8 = _value.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_usint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_usint()): # List
values: PlcList = _value
for val in values.getList():
@@ -611,14 +611,14 @@ class DataItem:
writeBuffer.WriteUint8("value", 8, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_uint()
+ dataType66, ModbusDataType.get_uint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # UINT
# Simple Field (value)
value: c_uint16 = _value.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_uint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_uint()): # List
values: PlcList = _value
for val in values.getList():
@@ -626,14 +626,14 @@ class DataItem:
writeBuffer.WriteUint16("value", 16, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_udint()
+ dataType66, ModbusDataType.get_udint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # UDINT
# Simple Field (value)
value: c_uint32 = _value.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_udint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_udint()): # List
values: PlcList = _value
for val in values.getList():
@@ -641,14 +641,14 @@ class DataItem:
writeBuffer.WriteUint32("value", 32, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_ulint()
+ dataType66, ModbusDataType.get_ulint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # ULINT
# Simple Field (value)
value: c_uint64 = _value.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_ulint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_ulint()): # List
values: PlcList = _value
for val in values.getList():
@@ -656,14 +656,14 @@ class DataItem:
writeBuffer.WriteUint64("value", 64, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_real()
+ dataType66, ModbusDataType.get_real()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # REAL
# Simple Field (value)
value: c_float = _value.getC_float()
writeBuffer.WriteFloat32("value", 32, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_real()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_real()): # List
values: PlcList = _value
for val in values.getList():
@@ -671,14 +671,14 @@ class DataItem:
writeBuffer.WriteFloat32("value", 32, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_lreal()
+ dataType66, ModbusDataType.get_lreal()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # LREAL
# Simple Field (value)
value: c_double = _value.getC_double()
writeBuffer.WriteFloat64("value", 64, (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lreal()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lreal()): # List
values: PlcList = _value
for val in values.getList():
@@ -686,14 +686,14 @@ class DataItem:
writeBuffer.WriteFloat64("value", 64, (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_char()
+ dataType66, ModbusDataType.get_char()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # CHAR
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(8), "UTF-8", (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_char()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_char()): # List
values: PlcList = _value
for val in values.getList():
@@ -701,14 +701,14 @@ class DataItem:
writeBuffer.WriteString("value", uint32(8), "UTF-8", (value))
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_wchar()
+ dataType66, ModbusDataType.get_wchar()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # WCHAR
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(16), "UTF-16", (value))
- if EvaluationHelper.equals(dataType, ModbusDataType.get_wchar()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_wchar()): # List
values: PlcList = _value
for val in values.getList():
@@ -729,160 +729,160 @@ class DataItem:
) -> int:
sizeInBits: int = 0
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_bool()
+ dataType66, ModbusDataType.get_bool()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # BOOL
# Reserved Field
sizeInBits += 15
# Simple Field (value)
sizeInBits += 1
- if EvaluationHelper.equals(dataType, ModbusDataType.get_bool()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_bool()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 1
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_byte()
+ dataType66, ModbusDataType.get_byte()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # BYTE
# Reserved Field
sizeInBits += 8
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, ModbusDataType.get_byte()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_byte()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 1
- if EvaluationHelper.equals(dataType, ModbusDataType.get_word()): # WORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_word()): # WORD
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, ModbusDataType.get_dword()): # DWORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_dword()): # DWORD
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lword()): # LWORD
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lword()): # LWORD
# Simple Field (value)
sizeInBits += 64
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_sint()
+ dataType66, ModbusDataType.get_sint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # SINT
# Reserved Field
sizeInBits += 8
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, ModbusDataType.get_sint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_sint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_int()
+ dataType66, ModbusDataType.get_int()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # INT
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, ModbusDataType.get_int()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_int()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_dint()
+ dataType66, ModbusDataType.get_dint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # DINT
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, ModbusDataType.get_dint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_dint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_lint()
+ dataType66, ModbusDataType.get_lint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # LINT
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_usint()
+ dataType66, ModbusDataType.get_usint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # USINT
# Reserved Field
sizeInBits += 8
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, ModbusDataType.get_usint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_usint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_uint()
+ dataType66, ModbusDataType.get_uint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # UINT
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, ModbusDataType.get_uint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_uint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_udint()
+ dataType66, ModbusDataType.get_udint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # UDINT
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, ModbusDataType.get_udint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_udint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_ulint()
+ dataType66, ModbusDataType.get_ulint()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # ULINT
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, ModbusDataType.get_ulint()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_ulint()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_real()
+ dataType66, ModbusDataType.get_real()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # REAL
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, ModbusDataType.get_real()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_real()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_lreal()
+ dataType66, ModbusDataType.get_lreal()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # LREAL
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, ModbusDataType.get_lreal()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_lreal()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_char()
+ dataType66, ModbusDataType.get_char()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # CHAR
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, ModbusDataType.get_char()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_char()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
if EvaluationHelper.equals(
- dataType, ModbusDataType.get_wchar()
+ dataType66, ModbusDataType.get_wchar()
) and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ numberOfValues66, c_uint16(1)
): # WCHAR
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, ModbusDataType.get_wchar()): # List
+ if EvaluationHelper.equals(dataType66, ModbusDataType.get_wchar()): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
return sizeInBits
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py
index b8afde3aef..9ba726b3a1 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py
@@ -43,7 +43,7 @@ class ModbusADU(ABC, PlcMessage):
pass
@abstractmethod
- def serialize_modbus_adu_child(write_buffer: WriteBuffer) -> None:
+ def serialize_modbus_adu_child(self, write_buffer: WriteBuffer) -> None:
pass
def serialize(self, write_buffer: WriteBuffer):
@@ -106,11 +106,11 @@ class ModbusADU(ABC, PlcMessage):
# Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
builder: ModbusADUBuilder = None
- if EvaluationHelper.equals(driverType, DriverType.get_modbu_s__tcp()):
+ if EvaluationHelper.equals(driverType66, DriverType.get_modbu_s__tcp()):
builder = ModbusTcpADU.staticParseBuilder(read_buffer, driverType, response)
- if EvaluationHelper.equals(driverType, DriverType.get_modbu_s__rtu()):
+ if EvaluationHelper.equals(driverType66, DriverType.get_modbu_s__rtu()):
builder = ModbusRtuADU.staticParseBuilder(read_buffer, driverType, response)
- if EvaluationHelper.equals(driverType, DriverType.get_modbu_s__ascii()):
+ if EvaluationHelper.equals(driverType66, DriverType.get_modbu_s__ascii()):
builder = ModbusAsciiADU.staticParseBuilder(
read_buffer, driverType, response
)
@@ -119,7 +119,7 @@ class ModbusADU(ABC, PlcMessage):
"Unsupported case for discriminated type"
+ " parameters ["
+ "driverType="
- + driverType
+ + driverType66
+ "]"
)
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py
index 2a478ce666..1120a29c52 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py
@@ -22,6 +22,7 @@ from dataclasses import dataclass
from ctypes import c_bool
from ctypes import c_uint8
from plc4py.api.messages.PlcMessage import PlcMessage
+from plc4py.protocols.modbus import StaticHelper
from plc4py.protocols.modbus.readwrite.DriverType import DriverType
from plc4py.protocols.modbus.readwrite.ModbusADU import ModbusADU
from plc4py.protocols.modbus.readwrite.ModbusADU import ModbusADUBuilder
@@ -37,7 +38,7 @@ class ModbusAsciiADU(PlcMessage, ModbusADU):
# Arguments.
response: c_bool
# Accessors for discriminator values.
- driver_type: DriverType = DriverType.get_modbu_s__ascii()
+ driver_type: DriverType = DriverType.MODBUS_ASCII
def __post_init__(self):
super().__init__(self.response)
@@ -50,13 +51,12 @@ class ModbusAsciiADU(PlcMessage, ModbusADU):
write_buffer.write_unsigned_byte(self.address, logical_name="address")
# Simple Field (pdu)
- write_buffer.DataWriterComplexDefault(write_buffer)(
- self.pdu, logical_name="pdu"
- )
+ write_buffer.write_serializable(self.pdu, logical_name="pdu")
# Checksum Field (checksum) (Calculated)
write_buffer.write_unsigned_byte(
- c_uint8(ascii_lrc_check(address, pdu)), logical_name="crc"
+ c_uint8(StaticHelper.ascii_lrc_check(self.address, self.pdu)),
+ logical_name="crc",
)
write_buffer.pop_context("ModbusAsciiADU")
@@ -102,7 +102,7 @@ class ModbusAsciiADU(PlcMessage, ModbusADU):
crc: c_uint8 = read_checksum_field(
"crc",
read_unsigned_short,
- (c_uint8)(ascii_lrc_check(address, pdu)),
+ (c_uint8)(ascii_lrc_check(self.address, self.pdu)),
WithOption.WithByteOrder(get_bi_g__endian()),
)
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py
index 91d2cd9ddb..69ac6a20e3 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py
@@ -85,7 +85,7 @@ class ModbusDeviceInformationObject(PlcMessage):
"objectLength", read_unsigned_short
)
- data: List[c_byte] = read_buffer.read_byte_array("data", int(objectLength))
+ data: List[c_byte] = read_buffer.read_byte_array("data", int(object_length))
read_buffer.close_context("ModbusDeviceInformationObject")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py
index 37f45d9c28..cf08d93b09 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py
@@ -50,7 +50,7 @@ class ModbusPDU(ABC, PlcMessage):
pass
@abstractmethod
- def serialize_modbus_pdu_child(write_buffer: WriteBuffer) -> None:
+ def serialize_modbus_pdu_child(self, write_buffer: WriteBuffer) -> None:
pass
def serialize(self, write_buffer: WriteBuffer):
@@ -125,7 +125,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x02))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadDiscreteInputsRequest.staticParseBuilder(
read_buffer, response
@@ -133,7 +133,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x02))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadDiscreteInputsResponse.staticParseBuilder(
read_buffer, response
@@ -141,7 +141,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x01))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadCoilsRequest.staticParseBuilder(
read_buffer, response
@@ -149,7 +149,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x01))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadCoilsResponse.staticParseBuilder(
read_buffer, response
@@ -157,7 +157,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x05))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUWriteSingleCoilRequest.staticParseBuilder(
read_buffer, response
@@ -165,7 +165,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x05))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUWriteSingleCoilResponse.staticParseBuilder(
read_buffer, response
@@ -173,7 +173,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0F))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUWriteMultipleCoilsRequest.staticParseBuilder(
read_buffer, response
@@ -181,7 +181,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0F))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUWriteMultipleCoilsResponse.staticParseBuilder(
read_buffer, response
@@ -189,7 +189,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x04))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadInputRegistersRequest.staticParseBuilder(
read_buffer, response
@@ -197,7 +197,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x04))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadInputRegistersResponse.staticParseBuilder(
read_buffer, response
@@ -205,7 +205,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x03))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadHoldingRegistersRequest.staticParseBuilder(
read_buffer, response
@@ -213,7 +213,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x03))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadHoldingRegistersResponse.staticParseBuilder(
read_buffer, response
@@ -221,7 +221,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x06))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUWriteSingleRegisterRequest.staticParseBuilder(
read_buffer, response
@@ -229,7 +229,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x06))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUWriteSingleRegisterResponse.staticParseBuilder(
read_buffer, response
@@ -237,7 +237,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x10))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUWriteMultipleHoldingRegistersRequest.staticParseBuilder(
read_buffer, response
@@ -245,7 +245,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x10))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUWriteMultipleHoldingRegistersResponse.staticParseBuilder(
read_buffer, response
@@ -253,7 +253,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x17))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = (
ModbusPDUReadWriteMultipleHoldingRegistersRequest.staticParseBuilder(
@@ -263,7 +263,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x17))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = (
ModbusPDUReadWriteMultipleHoldingRegistersResponse.staticParseBuilder(
@@ -273,7 +273,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x16))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUMaskWriteHoldingRegisterRequest.staticParseBuilder(
read_buffer, response
@@ -281,7 +281,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x16))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUMaskWriteHoldingRegisterResponse.staticParseBuilder(
read_buffer, response
@@ -289,7 +289,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x18))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadFifoQueueRequest.staticParseBuilder(
read_buffer, response
@@ -297,7 +297,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x18))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadFifoQueueResponse.staticParseBuilder(
read_buffer, response
@@ -305,7 +305,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x14))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadFileRecordRequest.staticParseBuilder(
read_buffer, response
@@ -313,7 +313,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x14))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadFileRecordResponse.staticParseBuilder(
read_buffer, response
@@ -321,7 +321,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x15))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUWriteFileRecordRequest.staticParseBuilder(
read_buffer, response
@@ -329,7 +329,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x15))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUWriteFileRecordResponse.staticParseBuilder(
read_buffer, response
@@ -337,7 +337,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x07))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadExceptionStatusRequest.staticParseBuilder(
read_buffer, response
@@ -345,7 +345,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x07))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadExceptionStatusResponse.staticParseBuilder(
read_buffer, response
@@ -353,7 +353,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x08))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUDiagnosticRequest.staticParseBuilder(
read_buffer, response
@@ -361,7 +361,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x08))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUDiagnosticResponse.staticParseBuilder(
read_buffer, response
@@ -369,7 +369,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0B))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUGetComEventCounterRequest.staticParseBuilder(
read_buffer, response
@@ -377,7 +377,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0B))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUGetComEventCounterResponse.staticParseBuilder(
read_buffer, response
@@ -385,7 +385,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0C))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUGetComEventLogRequest.staticParseBuilder(
read_buffer, response
@@ -393,7 +393,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x0C))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUGetComEventLogResponse.staticParseBuilder(
read_buffer, response
@@ -401,7 +401,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x11))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReportServerIdRequest.staticParseBuilder(
read_buffer, response
@@ -409,7 +409,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x11))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReportServerIdResponse.staticParseBuilder(
read_buffer, response
@@ -417,7 +417,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x2B))
- and EvaluationHelper.equals(response, c_bool(False))
+ and EvaluationHelper.equals(response66, c_bool(False))
):
builder = ModbusPDUReadDeviceIdentificationRequest.staticParseBuilder(
read_buffer, response
@@ -425,7 +425,7 @@ class ModbusPDU(ABC, PlcMessage):
if (
EvaluationHelper.equals(errorFlag, c_bool(False))
and EvaluationHelper.equals(functionFlag, c_uint8(0x2B))
- and EvaluationHelper.equals(response, c_bool(True))
+ and EvaluationHelper.equals(response66, c_bool(True))
):
builder = ModbusPDUReadDeviceIdentificationResponse.staticParseBuilder(
read_buffer, response
@@ -441,7 +441,7 @@ class ModbusPDU(ABC, PlcMessage):
+ functionFlag
+ " "
+ "response="
- + response
+ + response66
+ "]"
)
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py
index ae854e58ef..333fb58230 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py
@@ -110,7 +110,7 @@ class ModbusPDUGetComEventLogResponse(PlcMessage, ModbusPDU):
message_count: c_uint16 = read_simple_field("messageCount", read_unsigned_int)
events: List[c_byte] = read_buffer.read_byte_array(
- "events", int(byteCount - c_int32(6))
+ "events", int(byte_count - c_int32(6))
)
read_buffer.close_context("ModbusPDUGetComEventLogResponse")
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py
index 5ce3b8fec7..b21ef46960 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReadCoilsResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadCoilsResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py
index fe3492ffdd..ced2e7edbf 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReadDiscreteInputsResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadDiscreteInputsResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py
index 7ac3ee9a0e..6654f125a4 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py
@@ -89,7 +89,7 @@ class ModbusPDUReadFileRecordResponseItem(PlcMessage):
)
data: List[c_byte] = read_buffer.read_byte_array(
- "data", int(dataLength - c_int32(1))
+ "data", int(data_length - c_int32(1))
)
read_buffer.close_context("ModbusPDUReadFileRecordResponseItem")
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py
index 97f4481caf..388a71efad 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReadHoldingRegistersResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadHoldingRegistersResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py
index dd58ee6093..41d5bd4f0b 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReadInputRegistersResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadInputRegistersResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py
index 5381ddd5a7..29400438a5 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py
@@ -127,7 +127,7 @@ class ModbusPDUReadWriteMultipleHoldingRegistersRequest(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadWriteMultipleHoldingRegistersRequest")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py
index 52e74ca916..7253a29cca 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReadWriteMultipleHoldingRegistersResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReadWriteMultipleHoldingRegistersResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py
index 447a3bbad2..776f8695a3 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py
@@ -78,7 +78,7 @@ class ModbusPDUReportServerIdResponse(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUReportServerIdResponse")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py
index b6d324a65f..d18447c81c 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py
@@ -110,7 +110,7 @@ class ModbusPDUWriteFileRecordRequestItem(PlcMessage):
record_length: c_uint16 = read_implicit_field("recordLength", read_unsigned_int)
record_data: List[c_byte] = read_buffer.read_byte_array(
- "recordData", int(recordLength * c_int32(2))
+ "recordData", int(record_length * c_int32(2))
)
read_buffer.close_context("ModbusPDUWriteFileRecordRequestItem")
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py
index 58ef6c91a1..175a70f0c0 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py
@@ -109,7 +109,7 @@ class ModbusPDUWriteFileRecordResponseItem(PlcMessage):
record_length: c_uint16 = read_implicit_field("recordLength", read_unsigned_int)
record_data: List[c_byte] = read_buffer.read_byte_array(
- "recordData", int(recordLength)
+ "recordData", int(record_length)
)
read_buffer.close_context("ModbusPDUWriteFileRecordResponseItem")
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py
index c3a3710d54..e9f9f669ad 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py
@@ -101,7 +101,7 @@ class ModbusPDUWriteMultipleCoilsRequest(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUWriteMultipleCoilsRequest")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py
index c4fd0147d3..71a7afa2e5 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py
@@ -101,7 +101,7 @@ class ModbusPDUWriteMultipleHoldingRegistersRequest(PlcMessage, ModbusPDU):
byte_count: c_uint8 = read_implicit_field("byteCount", read_unsigned_short)
- value: List[c_byte] = read_buffer.read_byte_array("value", int(byteCount))
+ value: List[c_byte] = read_buffer.read_byte_array("value", int(byte_count))
read_buffer.close_context("ModbusPDUWriteMultipleHoldingRegistersRequest")
# Create the instance
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py
index e69805d713..bff03c01b5 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py
@@ -23,6 +23,7 @@ from ctypes import c_bool
from ctypes import c_uint16
from ctypes import c_uint8
from plc4py.api.messages.PlcMessage import PlcMessage
+from plc4py.protocols.modbus import StaticHelper
from plc4py.protocols.modbus.readwrite.DriverType import DriverType
from plc4py.protocols.modbus.readwrite.ModbusADU import ModbusADU
from plc4py.protocols.modbus.readwrite.ModbusADU import ModbusADUBuilder
@@ -38,7 +39,7 @@ class ModbusRtuADU(PlcMessage, ModbusADU):
# Arguments.
response: c_bool
# Accessors for discriminator values.
- driver_type: DriverType = DriverType.get_modbu_s__rtu()
+ driver_type: DriverType = DriverType.MODBUS_RTU
def __post_init__(self):
super().__init__(self.response)
@@ -51,13 +52,12 @@ class ModbusRtuADU(PlcMessage, ModbusADU):
write_buffer.write_unsigned_byte(self.address, logical_name="address")
# Simple Field (pdu)
- write_buffer.DataWriterComplexDefault(write_buffer)(
- self.pdu, logical_name="pdu"
- )
+ write_buffer.write_serializable(self.pdu, logical_name="pdu")
# Checksum Field (checksum) (Calculated)
write_buffer.write_unsigned_short(
- c_uint16(rtu_crc_check(address, pdu)), logical_name="crc"
+ c_uint16(StaticHelper.rtu_crc_check(self.address, self.pdu)),
+ logical_name="crc",
)
write_buffer.pop_context("ModbusRtuADU")
@@ -103,7 +103,7 @@ class ModbusRtuADU(PlcMessage, ModbusADU):
crc: c_uint16 = read_checksum_field(
"crc",
read_unsigned_int,
- (c_uint16)(rtu_crc_check(address, pdu)),
+ (c_uint16)(rtu_crc_check(self.address, self.pdu)),
WithOption.WithByteOrder(get_bi_g__endian()),
)
diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py
index 9f32a57f28..cd8453f922 100644
--- a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py
+++ b/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py
@@ -40,7 +40,7 @@ class ModbusTcpADU(PlcMessage, ModbusADU):
response: c_bool
PROTOCOLIDENTIFIER: c_uint16 = 0x0000
# Accessors for discriminator values.
- driver_type: DriverType = DriverType.get_modbu_s__tcp()
+ driver_type: DriverType = DriverType.MODBUS_TCP
def __post_init__(self):
super().__init__(self.response)
@@ -69,9 +69,7 @@ class ModbusTcpADU(PlcMessage, ModbusADU):
)
# Simple Field (pdu)
- write_buffer.DataWriterComplexDefault(write_buffer)(
- self.pdu, logical_name="pdu"
- )
+ write_buffer.write_serializable(self.pdu, logical_name="pdu")
write_buffer.pop_context("ModbusTcpADU")
diff --git a/sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py b/sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py
index e64f50970e..3c7ea1cf8e 100644
--- a/sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py
+++ b/sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py
@@ -38,121 +38,121 @@ class DataItem:
def static_parse(
read_buffer: ReadBuffer, data_type: str, number_of_values: c_uint16
):
- if EvaluationHelper.equals(data_type, "_bool") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_bool") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # BOOL
# Simple Field (value)
value: c_bool = read_buffer.readBit("")
return PlcBOOL(value)
- if EvaluationHelper.equals(data_type, "_bool"): # List
+ if EvaluationHelper.equals(data_type66, "_bool"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcBOOL(c_bool(read_buffer.readBit(""))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_byte") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_byte") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # BYTE
# Simple Field (value)
value: c_uint8 = read_buffer.readUnsignedShort("", 8)
return PlcBYTE(value)
- if EvaluationHelper.equals(data_type, "_byte"): # List
+ if EvaluationHelper.equals(data_type66, "_byte"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUINT(c_uint8(read_buffer.readUnsignedShort("", 8))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_word") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_word") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # WORD
# Simple Field (value)
value: c_uint16 = read_buffer.readUnsignedInt("", 16)
return PlcWORD(value)
- if EvaluationHelper.equals(data_type, "_word"): # List
+ if EvaluationHelper.equals(data_type66, "_word"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUDINT(c_uint16(read_buffer.readUnsignedInt("", 16))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_dword") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_dword") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # DWORD
# Simple Field (value)
value: c_uint32 = read_buffer.readUnsignedLong("", 32)
return PlcDWORD(value)
- if EvaluationHelper.equals(data_type, "_dword"): # List
+ if EvaluationHelper.equals(data_type66, "_dword"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcULINT(c_uint32(read_buffer.readUnsignedLong("", 32))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_lword") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_lword") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # LWORD
# Simple Field (value)
value: c_uint64 = read_buffer.readUnsignedBigInteger("", 64)
return PlcLWORD(value)
- if EvaluationHelper.equals(data_type, "_lword"): # List
+ if EvaluationHelper.equals(data_type66, "_lword"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(
@@ -160,193 +160,193 @@ class DataItem:
)
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_sint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_sint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # SINT
# Simple Field (value)
value: c_int8 = read_buffer.readSignedByte("", 8)
return PlcSINT(value)
- if EvaluationHelper.equals(data_type, "_sint"): # List
+ if EvaluationHelper.equals(data_type66, "_sint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSINT(c_int8(read_buffer.readSignedByte("", 8))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_int") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_int") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # INT
# Simple Field (value)
value: c_int16 = read_buffer.readShort("", 16)
return PlcINT(value)
- if EvaluationHelper.equals(data_type, "_int"): # List
+ if EvaluationHelper.equals(data_type66, "_int"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcINT(c_int16(read_buffer.readShort("", 16))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_dint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_dint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # DINT
# Simple Field (value)
value: c_int32 = read_buffer.readInt("", 32)
return PlcDINT(value)
- if EvaluationHelper.equals(data_type, "_dint"): # List
+ if EvaluationHelper.equals(data_type66, "_dint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcDINT(c_int32(read_buffer.readInt("", 32))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_lint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_lint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # LINT
# Simple Field (value)
value: c_int64 = read_buffer.readLong("", 64)
return PlcLINT(value)
- if EvaluationHelper.equals(data_type, "_lint"): # List
+ if EvaluationHelper.equals(data_type66, "_lint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcLINT(c_int64(read_buffer.readLong("", 64))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_usint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_usint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # USINT
# Simple Field (value)
value: c_uint8 = read_buffer.readUnsignedShort("", 8)
return PlcUSINT(value)
- if EvaluationHelper.equals(data_type, "_usint"): # List
+ if EvaluationHelper.equals(data_type66, "_usint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUINT(c_uint8(read_buffer.readUnsignedShort("", 8))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_uint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_uint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # UINT
# Simple Field (value)
value: c_uint16 = read_buffer.readUnsignedInt("", 16)
return PlcUINT(value)
- if EvaluationHelper.equals(data_type, "_uint"): # List
+ if EvaluationHelper.equals(data_type66, "_uint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcUDINT(c_uint16(read_buffer.readUnsignedInt("", 16))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_udint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_udint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # UDINT
# Simple Field (value)
value: c_uint32 = read_buffer.readUnsignedLong("", 32)
return PlcUDINT(value)
- if EvaluationHelper.equals(data_type, "_udint"): # List
+ if EvaluationHelper.equals(data_type66, "_udint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcULINT(c_uint32(read_buffer.readUnsignedLong("", 32))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_ulint") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_ulint") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # ULINT
# Simple Field (value)
value: c_uint64 = read_buffer.readUnsignedBigInteger("", 64)
return PlcULINT(value)
- if EvaluationHelper.equals(data_type, "_ulint"): # List
+ if EvaluationHelper.equals(data_type66, "_ulint"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(
@@ -354,108 +354,108 @@ class DataItem:
)
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_real") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_real") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # REAL
# Simple Field (value)
value: c_float = read_buffer.readFloat("", 32)
return PlcREAL(value)
- if EvaluationHelper.equals(data_type, "_real"): # List
+ if EvaluationHelper.equals(data_type66, "_real"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcREAL(c_float(read_buffer.readFloat("", 32))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_lreal") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_lreal") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # LREAL
# Simple Field (value)
value: c_double = read_buffer.readDouble("", 64)
return PlcLREAL(value)
- if EvaluationHelper.equals(data_type, "_lreal"): # List
+ if EvaluationHelper.equals(data_type66, "_lreal"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcLREAL(c_double(read_buffer.readDouble("", 64))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_char") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_char") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # CHAR
# Simple Field (value)
value: str = read_buffer.readString("", 8, "UTF-8")
return PlcCHAR(value)
- if EvaluationHelper.equals(data_type, "_char"): # List
+ if EvaluationHelper.equals(data_type66, "_char"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSTRING(str(read_buffer.readString("", 8, "UTF-8"))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_wchar") and EvaluationHelper.equals(
- number_of_values, c_uint16(1)
+ if EvaluationHelper.equals(data_type66, "_wchar") and EvaluationHelper.equals(
+ number_of_values66, c_uint16(1)
): # WCHAR
# Simple Field (value)
value: str = read_buffer.readString("", 16, "UTF-16")
return PlcWCHAR(value)
- if EvaluationHelper.equals(data_type, "_wchar"): # List
+ if EvaluationHelper.equals(data_type66, "_wchar"): # List
# Array field (value)
# Count array
- if numberOfValues > Integer.MAX_VALUE:
+ if numberOfValues66 > Integer.MAX_VALUE:
raise ParseException(
"Array count of "
- + (numberOfValues)
+ + (numberOfValues66)
+ " exceeds the maximum allowed count of "
+ Integer.MAX_VALUE
)
- item_count: int = int(numberOfValues)
+ item_count: int = int(numberOfValues66)
value: List[PlcValue] = []
for cur_item in range(item_count):
value.append(PlcSTRING(str(read_buffer.readString("", 16, "UTF-16"))))
return PlcList(value)
- if EvaluationHelper.equals(data_type, "_string"): # STRING
+ if EvaluationHelper.equals(data_type66, "_string"): # STRING
# Simple Field (value)
value: str = read_buffer.readString("", 255, "UTF-8")
return PlcSTRING(value)
- if EvaluationHelper.equals(data_type, "_wstring"): # STRING
+ if EvaluationHelper.equals(data_type66, "_wstring"): # STRING
# Simple Field (value)
value: str = read_buffer.readString("", 255, "UTF-16")
@@ -481,232 +481,232 @@ class DataItem:
numberOfValues: c_uint16,
byteOrder: ByteOrder,
) -> None:
- if EvaluationHelper.equals(dataType, "BOOL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "BOOL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # BOOL
# Simple Field (value)
value: c_bool = _value.getC_bool()
writeBuffer.WriteBit("value", (value))
- if EvaluationHelper.equals(dataType, "BOOL"): # List
+ if EvaluationHelper.equals(dataType66, "BOOL"): # List
values: PlcList = _value
for val in values.getList():
value: c_bool = val.getC_bool()
writeBuffer.WriteBit("value", (value))
- if EvaluationHelper.equals(dataType, "BYTE") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "BYTE") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # BYTE
# Simple Field (value)
value: c_uint8 = _value.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "BYTE"): # List
+ if EvaluationHelper.equals(dataType66, "BYTE"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint8 = val.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "WORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "WORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # WORD
# Simple Field (value)
value: c_uint16 = _value.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "WORD"): # List
+ if EvaluationHelper.equals(dataType66, "WORD"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint16 = val.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "DWORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "DWORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # DWORD
# Simple Field (value)
value: c_uint32 = _value.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "DWORD"): # List
+ if EvaluationHelper.equals(dataType66, "DWORD"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint32 = val.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "LWORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LWORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LWORD
# Simple Field (value)
value: c_uint64 = _value.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "LWORD"): # List
+ if EvaluationHelper.equals(dataType66, "LWORD"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint64 = val.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "SINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "SINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # SINT
# Simple Field (value)
value: c_int8 = _value.getC_int8()
writeBuffer.WriteInt8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "SINT"): # List
+ if EvaluationHelper.equals(dataType66, "SINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_int8 = val.getC_int8()
writeBuffer.WriteInt8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "INT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "INT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # INT
# Simple Field (value)
value: c_int16 = _value.getC_int16()
writeBuffer.WriteInt16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "INT"): # List
+ if EvaluationHelper.equals(dataType66, "INT"): # List
values: PlcList = _value
for val in values.getList():
value: c_int16 = val.getC_int16()
writeBuffer.WriteInt16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "DINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "DINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # DINT
# Simple Field (value)
value: c_int32 = _value.getC_int32()
writeBuffer.WriteInt32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "DINT"): # List
+ if EvaluationHelper.equals(dataType66, "DINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_int32 = val.getC_int32()
writeBuffer.WriteInt32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "LINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LINT
# Simple Field (value)
value: c_int64 = _value.getC_int64()
writeBuffer.WriteInt64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "LINT"): # List
+ if EvaluationHelper.equals(dataType66, "LINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_int64 = val.getC_int64()
writeBuffer.WriteInt64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "USINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "USINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # USINT
# Simple Field (value)
value: c_uint8 = _value.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "USINT"): # List
+ if EvaluationHelper.equals(dataType66, "USINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint8 = val.getC_uint8()
writeBuffer.WriteUint8("value", 8, (value))
- if EvaluationHelper.equals(dataType, "UINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "UINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # UINT
# Simple Field (value)
value: c_uint16 = _value.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "UINT"): # List
+ if EvaluationHelper.equals(dataType66, "UINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint16 = val.getC_uint16()
writeBuffer.WriteUint16("value", 16, (value))
- if EvaluationHelper.equals(dataType, "UDINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "UDINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # UDINT
# Simple Field (value)
value: c_uint32 = _value.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "UDINT"): # List
+ if EvaluationHelper.equals(dataType66, "UDINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint32 = val.getC_uint32()
writeBuffer.WriteUint32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "ULINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "ULINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # ULINT
# Simple Field (value)
value: c_uint64 = _value.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "ULINT"): # List
+ if EvaluationHelper.equals(dataType66, "ULINT"): # List
values: PlcList = _value
for val in values.getList():
value: c_uint64 = val.getC_uint64()
writeBuffer.WriteUint64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "REAL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "REAL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # REAL
# Simple Field (value)
value: c_float = _value.getC_float()
writeBuffer.WriteFloat32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "REAL"): # List
+ if EvaluationHelper.equals(dataType66, "REAL"): # List
values: PlcList = _value
for val in values.getList():
value: c_float = val.getC_float()
writeBuffer.WriteFloat32("value", 32, (value))
- if EvaluationHelper.equals(dataType, "LREAL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LREAL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LREAL
# Simple Field (value)
value: c_double = _value.getC_double()
writeBuffer.WriteFloat64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "LREAL"): # List
+ if EvaluationHelper.equals(dataType66, "LREAL"): # List
values: PlcList = _value
for val in values.getList():
value: c_double = val.getC_double()
writeBuffer.WriteFloat64("value", 64, (value))
- if EvaluationHelper.equals(dataType, "CHAR") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "CHAR") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # CHAR
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(8), "UTF-8", (value))
- if EvaluationHelper.equals(dataType, "CHAR"): # List
+ if EvaluationHelper.equals(dataType66, "CHAR"): # List
values: PlcList = _value
for val in values.getList():
value: str = val.getStr()
writeBuffer.WriteString("value", uint32(8), "UTF-8", (value))
- if EvaluationHelper.equals(dataType, "WCHAR") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "WCHAR") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # WCHAR
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(16), "UTF-16", (value))
- if EvaluationHelper.equals(dataType, "WCHAR"): # List
+ if EvaluationHelper.equals(dataType66, "WCHAR"): # List
values: PlcList = _value
for val in values.getList():
value: str = val.getStr()
writeBuffer.WriteString("value", uint32(16), "UTF-16", (value))
- if EvaluationHelper.equals(dataType, "STRING"): # STRING
+ if EvaluationHelper.equals(dataType66, "STRING"): # STRING
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(255), "UTF-8", (value))
- if EvaluationHelper.equals(dataType, "WSTRING"): # STRING
+ if EvaluationHelper.equals(dataType66, "WSTRING"): # STRING
# Simple Field (value)
value: str = _value.getStr()
writeBuffer.WriteString("value", uint32(255), "UTF-16", (value))
@@ -724,146 +724,146 @@ class DataItem:
_value: PlcValue, dataType: str, numberOfValues: c_uint16
) -> int:
sizeInBits: int = 0
- if EvaluationHelper.equals(dataType, "BOOL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "BOOL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # BOOL
# Simple Field (value)
sizeInBits += 1
- if EvaluationHelper.equals(dataType, "BOOL"): # List
+ if EvaluationHelper.equals(dataType66, "BOOL"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 1
- if EvaluationHelper.equals(dataType, "BYTE") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "BYTE") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # BYTE
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, "BYTE"): # List
+ if EvaluationHelper.equals(dataType66, "BYTE"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
- if EvaluationHelper.equals(dataType, "WORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "WORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # WORD
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, "WORD"): # List
+ if EvaluationHelper.equals(dataType66, "WORD"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
- if EvaluationHelper.equals(dataType, "DWORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "DWORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # DWORD
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, "DWORD"): # List
+ if EvaluationHelper.equals(dataType66, "DWORD"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
- if EvaluationHelper.equals(dataType, "LWORD") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LWORD") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LWORD
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, "LWORD"): # List
+ if EvaluationHelper.equals(dataType66, "LWORD"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
- if EvaluationHelper.equals(dataType, "SINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "SINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # SINT
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, "SINT"): # List
+ if EvaluationHelper.equals(dataType66, "SINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
- if EvaluationHelper.equals(dataType, "INT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "INT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # INT
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, "INT"): # List
+ if EvaluationHelper.equals(dataType66, "INT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
- if EvaluationHelper.equals(dataType, "DINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "DINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # DINT
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, "DINT"): # List
+ if EvaluationHelper.equals(dataType66, "DINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
- if EvaluationHelper.equals(dataType, "LINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LINT
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, "LINT"): # List
+ if EvaluationHelper.equals(dataType66, "LINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
- if EvaluationHelper.equals(dataType, "USINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "USINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # USINT
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, "USINT"): # List
+ if EvaluationHelper.equals(dataType66, "USINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
- if EvaluationHelper.equals(dataType, "UINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "UINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # UINT
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, "UINT"): # List
+ if EvaluationHelper.equals(dataType66, "UINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
- if EvaluationHelper.equals(dataType, "UDINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "UDINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # UDINT
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, "UDINT"): # List
+ if EvaluationHelper.equals(dataType66, "UDINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
- if EvaluationHelper.equals(dataType, "ULINT") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "ULINT") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # ULINT
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, "ULINT"): # List
+ if EvaluationHelper.equals(dataType66, "ULINT"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
- if EvaluationHelper.equals(dataType, "REAL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "REAL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # REAL
# Simple Field (value)
sizeInBits += 32
- if EvaluationHelper.equals(dataType, "REAL"): # List
+ if EvaluationHelper.equals(dataType66, "REAL"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 32
- if EvaluationHelper.equals(dataType, "LREAL") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "LREAL") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # LREAL
# Simple Field (value)
sizeInBits += 64
- if EvaluationHelper.equals(dataType, "LREAL"): # List
+ if EvaluationHelper.equals(dataType66, "LREAL"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 64
- if EvaluationHelper.equals(dataType, "CHAR") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "CHAR") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # CHAR
# Simple Field (value)
sizeInBits += 8
- if EvaluationHelper.equals(dataType, "CHAR"): # List
+ if EvaluationHelper.equals(dataType66, "CHAR"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 8
- if EvaluationHelper.equals(dataType, "WCHAR") and EvaluationHelper.equals(
- numberOfValues, c_uint16(1)
+ if EvaluationHelper.equals(dataType66, "WCHAR") and EvaluationHelper.equals(
+ numberOfValues66, c_uint16(1)
): # WCHAR
# Simple Field (value)
sizeInBits += 16
- if EvaluationHelper.equals(dataType, "WCHAR"): # List
+ if EvaluationHelper.equals(dataType66, "WCHAR"): # List
values: PlcList = _value
sizeInBits += values.getList().size() * 16
- if EvaluationHelper.equals(dataType, "STRING"): # STRING
+ if EvaluationHelper.equals(dataType66, "STRING"): # STRING
# Simple Field (value)
sizeInBits += 255
- if EvaluationHelper.equals(dataType, "WSTRING"): # STRING
+ if EvaluationHelper.equals(dataType66, "WSTRING"): # STRING
# Simple Field (value)
sizeInBits += 255
return sizeInBits
diff --git a/sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py b/sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py
index a4eaaa0ad1..13dd782184 100644
--- a/sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py
+++ b/sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py
@@ -138,7 +138,7 @@ class WriteBuffer(ByteOrderAware, PositionAware):
# @param value the value to be serialized
# @throws SerializationException if something goes wrong
#
- def write_serializable(self, value) -> None:
+ def write_serializable(self, value, logical_name="") -> None:
value.serialize(self)
@@ -287,7 +287,7 @@ class WriteBufferByteBased(WriteBuffer):
) -> None:
for item in value:
self.push_context(logical_name, **kwargs)
- self.write_serializable(item)
+ self.write_serializable(item, logical_name="")
self.pop_context(logical_name, **kwargs)
def _handle_numeric_encoding(self, value: NUMERIC_UNION, bit_length: int, **kwargs):